Cleanups
This commit is contained in:
@ -213,7 +213,7 @@ struct BatteryApplyCalibrationAccessor : public NewSettingsAccessor<bool> { Conf
|
||||
// Lockscreen
|
||||
struct LockscreenAllowPresetSwitchAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.lockscreen.allowPresetSwitch; } };
|
||||
template<uint8_t index>
|
||||
struct LockscreenPinDigitAccessor : public NewSettingsAccessor<int8_t> { ConfigWrapper<int8_t> &getConfig() const override { return configs.lockscreen.pin[index].digit; } };
|
||||
struct LockscreenPinDigitAccessor : public NewSettingsAccessor<int8_t> { ConfigWrapper<int8_t> &getConfig() const override { return configs.lockscreen.pin[index]; } };
|
||||
struct LockscreenKeepLockedAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.lockscreen.keepLockedAfterReboot; } };
|
||||
|
||||
// Handbremse
|
||||
|
18
main/can.cpp
18
main/can.cpp
@ -272,21 +272,25 @@ void sendCanCommands()
|
||||
|
||||
const auto timestamp_before = espchrono::millis_clock::now();
|
||||
const auto result = twai_transmit(&message, timeout);
|
||||
const auto timestamp_after = espchrono::millis_clock::now();
|
||||
|
||||
if (result != ESP_OK && result != ESP_ERR_TIMEOUT)
|
||||
{
|
||||
ESP_LOGE(TAG, "ERROR: twai_transmit() failed with %s", esp_err_to_name(result));
|
||||
}
|
||||
else if (result == ESP_ERR_TIMEOUT)
|
||||
if (result == ESP_ERR_TIMEOUT)
|
||||
{
|
||||
++can_sequential_error_cnt;
|
||||
++can_total_error_cnt;
|
||||
|
||||
ESP_LOGW(TAG, "twai_transmit() took %lld ms, seq err: %d, total err: %d",
|
||||
espchrono::ago(timestamp_before).count(),
|
||||
ESP_LOGW(TAG, "twai_transmit() failed after %lldms with %s, seq err: %d, total err: %d",
|
||||
(timestamp_after - timestamp_before).count(),
|
||||
esp_err_to_name(result),
|
||||
can_sequential_error_cnt,
|
||||
can_total_error_cnt);
|
||||
}
|
||||
else if (result != ESP_OK)
|
||||
{
|
||||
ESP_LOGE(TAG, "ERROR: twai_transmit() failed after %lldms with %s",
|
||||
(timestamp_after - timestamp_before).count(),
|
||||
esp_err_to_name(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
can_sequential_error_cnt = 0;
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "lockscreen.h"
|
||||
|
||||
// system includes
|
||||
#include <algorithm>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tftinstance.h>
|
||||
#include <screenmanager.h>
|
||||
@ -11,17 +14,16 @@
|
||||
#include "displays/potiscalibratedisplay.h"
|
||||
#include "bobbybuttons.h"
|
||||
|
||||
bool isValidPin(std::array<int8_t,4> enteredPin)
|
||||
namespace {
|
||||
bool isValidPin(std::array<int8_t, 4> enteredPin)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (enteredPin[i] != configs.lockscreen.pin[i].digit.value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return std::equal(std::cbegin(enteredPin), std::cend(enteredPin),
|
||||
std::cbegin(configs.lockscreen.pin), std::cend(configs.lockscreen.pin),
|
||||
[](const int8_t digit, const auto &configuredDigit){
|
||||
return digit == configuredDigit.value;
|
||||
});
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void Lockscreen::start()
|
||||
{
|
||||
|
@ -86,15 +86,6 @@ public:
|
||||
ConfigWrapper<std::string> url;
|
||||
};
|
||||
|
||||
class ConfiguredLockscreenDigit
|
||||
{
|
||||
public:
|
||||
ConfiguredLockscreenDigit(const char *digitKey) :
|
||||
digit{0, DoReset, MinMaxOrZeroValue<int8_t, 1,9>, digitKey }
|
||||
{}
|
||||
ConfigWrapper<int8_t> digit;
|
||||
};
|
||||
|
||||
class ConfigContainer
|
||||
{
|
||||
using mac_t = wifi_stack::mac_t;
|
||||
@ -265,11 +256,11 @@ public:
|
||||
ConfigWrapper<bool> allowPresetSwitch {true, DoReset, {}, "lockAlwPresetSw" };
|
||||
ConfigWrapper<bool> keepLockedAfterReboot {false, DoReset, {}, "keepLocked" };
|
||||
ConfigWrapper<bool> locked {false, DoReset, {}, "currentlyLocked" };
|
||||
std::array<ConfiguredLockscreenDigit, 4> pin {
|
||||
ConfiguredLockscreenDigit {"lockscreenPin0"},
|
||||
ConfiguredLockscreenDigit {"lockscreenPin1"},
|
||||
ConfiguredLockscreenDigit {"lockscreenPin2"},
|
||||
ConfiguredLockscreenDigit {"lockscreenPin3"}
|
||||
std::array<ConfigWrapper<int8_t>, 4> pin {
|
||||
ConfigWrapper<int8_t> {1, DoReset, MinMaxValue<int8_t, 0, 9>, "lockscreenPin0" },
|
||||
ConfigWrapper<int8_t> {2, DoReset, MinMaxValue<int8_t, 0, 9>, "lockscreenPin1" },
|
||||
ConfigWrapper<int8_t> {3, DoReset, MinMaxValue<int8_t, 0, 9>, "lockscreenPin2" },
|
||||
ConfigWrapper<int8_t> {4, DoReset, MinMaxValue<int8_t, 0, 9>, "lockscreenPin3" },
|
||||
};
|
||||
} lockscreen;
|
||||
|
||||
@ -542,10 +533,10 @@ public:
|
||||
x(lockscreen.allowPresetSwitch) \
|
||||
x(lockscreen.keepLockedAfterReboot) \
|
||||
x(lockscreen.locked) \
|
||||
x(lockscreen.pin[0].digit) \
|
||||
x(lockscreen.pin[1].digit) \
|
||||
x(lockscreen.pin[2].digit) \
|
||||
x(lockscreen.pin[3].digit) \
|
||||
x(lockscreen.pin[0]) \
|
||||
x(lockscreen.pin[1]) \
|
||||
x(lockscreen.pin[2]) \
|
||||
x(lockscreen.pin[3]) \
|
||||
\
|
||||
x(savedStatistics.totalCentimeters) \
|
||||
\
|
||||
|
Reference in New Issue
Block a user