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