Moved settings.lockscreen
This commit is contained in:
@@ -216,10 +216,10 @@ struct BatteryWHperKMAccessor : public NewSettingsAccessor<uint16_t> { ConfigWra
|
|||||||
struct BatteryApplyCalibrationAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.battery.applyCalibration; } };
|
struct BatteryApplyCalibrationAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.battery.applyCalibration; } };
|
||||||
|
|
||||||
// Lockscreen
|
// Lockscreen
|
||||||
struct LockscreenAllowPresetSwitchAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.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 RefAccessorSaveSettings<int8_t> { int8_t &getRef() const override { return settings.lockscreen.pin[index]; } };
|
struct LockscreenPinDigitAccessor : public NewSettingsAccessor<int8_t> { ConfigWrapper<int8_t> &getConfig() const override { return configs.lockscreen.pin[index].digit; } };
|
||||||
struct LockscreenKeepLockedAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.lockscreen.keepLockedAfterReboot; } };
|
struct LockscreenKeepLockedAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.lockscreen.keepLockedAfterReboot; } };
|
||||||
|
|
||||||
// Handbremse
|
// Handbremse
|
||||||
struct HandbremsEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.handbremse.enable; } };
|
struct HandbremsEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.handbremse.enable; } };
|
||||||
|
@@ -14,6 +14,18 @@
|
|||||||
#include "ledstripdefines.h"
|
#include "ledstripdefines.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
void Lockscreen::start()
|
void Lockscreen::start()
|
||||||
{
|
{
|
||||||
Base::start();
|
Base::start();
|
||||||
@@ -27,10 +39,9 @@ void Lockscreen::start()
|
|||||||
currentMode = &m_mode;
|
currentMode = &m_mode;
|
||||||
|
|
||||||
isLocked = true;
|
isLocked = true;
|
||||||
if (settings.lockscreen.keepLockedAfterReboot && !settings.lockscreen.locked)
|
if (configs.lockscreen.keepLockedAfterReboot.value && !configs.lockscreen.locked.value)
|
||||||
{
|
{
|
||||||
settings.lockscreen.locked = true;
|
configs.write_config(configs.lockscreen.locked, true);
|
||||||
saveSettings();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +96,7 @@ void Lockscreen::redraw()
|
|||||||
|
|
||||||
if (!m_back_pressed && ++m_currentIndex>=4)
|
if (!m_back_pressed && ++m_currentIndex>=4)
|
||||||
{
|
{
|
||||||
if (m_numbers == settings.lockscreen.pin)
|
if (isValidPin(m_numbers))
|
||||||
{
|
{
|
||||||
if (!gas || !brems || *gas > 200.f || *brems > 200.f)
|
if (!gas || !brems || *gas > 200.f || *brems > 200.f)
|
||||||
espgui::switchScreen<PotisCalibrateDisplay>(true);
|
espgui::switchScreen<PotisCalibrateDisplay>(true);
|
||||||
@@ -148,17 +159,16 @@ void Lockscreen::stop()
|
|||||||
isLocked = false;
|
isLocked = false;
|
||||||
if (!(!gas || !brems || *gas > 200.f || *brems > 200.f))
|
if (!(!gas || !brems || *gas > 200.f || *brems > 200.f))
|
||||||
{
|
{
|
||||||
if (settings.lockscreen.keepLockedAfterReboot && settings.lockscreen.locked)
|
if (configs.lockscreen.keepLockedAfterReboot.value && configs.lockscreen.locked.value)
|
||||||
{
|
{
|
||||||
settings.lockscreen.locked = false;
|
configs.write_config(configs.lockscreen.locked, false);
|
||||||
saveSettings();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lockscreen::buttonPressed(espgui::Button button)
|
void Lockscreen::buttonPressed(espgui::Button button)
|
||||||
{
|
{
|
||||||
if (settings.lockscreen.allowPresetSwitch ||
|
if (configs.lockscreen.allowPresetSwitch.value ||
|
||||||
!cpputils::is_in(button, BobbyButton::Profile0, BobbyButton::Profile1, BobbyButton::Profile2, BobbyButton::Profile3))
|
!cpputils::is_in(button, BobbyButton::Profile0, BobbyButton::Profile1, BobbyButton::Profile2, BobbyButton::Profile3))
|
||||||
Base::buttonPressed(button);
|
Base::buttonPressed(button);
|
||||||
|
|
||||||
|
@@ -198,11 +198,10 @@ void PotisCalibrateDisplay::buttonPressed(espgui::Button button)
|
|||||||
case Status::Begin:
|
case Status::Begin:
|
||||||
if (m_bootup)
|
if (m_bootup)
|
||||||
espgui::switchScreen<StatusDisplay>();
|
espgui::switchScreen<StatusDisplay>();
|
||||||
else if (settings.lockscreen.keepLockedAfterReboot && settings.lockscreen.locked)
|
else if (configs.lockscreen.keepLockedAfterReboot.value && configs.lockscreen.locked.value)
|
||||||
{
|
{
|
||||||
espgui::switchScreen<MainMenu>();
|
espgui::switchScreen<MainMenu>();
|
||||||
settings.lockscreen.locked = false;
|
configs.write_config(configs.lockscreen.locked, false);
|
||||||
saveSettings();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
espgui::switchScreen<BoardcomputerHardwareSettingsMenu>();
|
espgui::switchScreen<BoardcomputerHardwareSettingsMenu>();
|
||||||
|
@@ -79,7 +79,7 @@ extern "C" void app_main()
|
|||||||
{
|
{
|
||||||
espgui::switchScreen<ButtonCalibrateDisplay>(true);
|
espgui::switchScreen<ButtonCalibrateDisplay>(true);
|
||||||
}
|
}
|
||||||
else if (settings.lockscreen.keepLockedAfterReboot && settings.lockscreen.locked)
|
else if (configs.lockscreen.keepLockedAfterReboot.value && configs.lockscreen.locked.value)
|
||||||
{
|
{
|
||||||
espgui::switchScreen<Lockscreen>();
|
espgui::switchScreen<Lockscreen>();
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "ledstrip.h"
|
#include "ledstrip.h"
|
||||||
|
#include "unifiedmodelmode.h"
|
||||||
|
#include "displays/lockscreen.h"
|
||||||
|
|
||||||
using namespace espconfig;
|
using namespace espconfig;
|
||||||
|
|
||||||
@@ -83,6 +85,15 @@ 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;
|
||||||
@@ -248,7 +259,18 @@ public:
|
|||||||
ConfigWrapper<int16_t> back50VoltCalibration {5000, DoReset, {}, "batB50VCal" };
|
ConfigWrapper<int16_t> back50VoltCalibration {5000, DoReset, {}, "batB50VCal" };
|
||||||
ConfigWrapper<bool> applyCalibration {true, DoReset, {}, "applyBatCal" };
|
ConfigWrapper<bool> applyCalibration {true, DoReset, {}, "applyBatCal" };
|
||||||
} battery;
|
} battery;
|
||||||
// end old settings
|
|
||||||
|
struct {
|
||||||
|
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"}
|
||||||
|
};
|
||||||
|
} lockscreen;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
ConfigWrapper<bool> bleEnabled {true, DoReset, {}, "bleEnabled" };
|
ConfigWrapper<bool> bleEnabled {true, DoReset, {}, "bleEnabled" };
|
||||||
@@ -496,7 +518,15 @@ public:
|
|||||||
x(battery.back30VoltCalibration) \
|
x(battery.back30VoltCalibration) \
|
||||||
x(battery.front50VoltCalibration) \
|
x(battery.front50VoltCalibration) \
|
||||||
x(battery.back50VoltCalibration) \
|
x(battery.back50VoltCalibration) \
|
||||||
x(battery.applyCalibration)
|
x(battery.applyCalibration) \
|
||||||
|
\
|
||||||
|
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(bleSettings.bleEnabled)
|
//x(bleSettings.bleEnabled)
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@@ -130,13 +130,6 @@ constexpr Settings::Handbremse defaultHandbremse {
|
|||||||
.visualize = true,
|
.visualize = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Settings::LockscreenSettings defaultLockscreen {
|
|
||||||
.allowPresetSwitch = true,
|
|
||||||
.keepLockedAfterReboot = false,
|
|
||||||
.locked = false,
|
|
||||||
.pin = { 1, 2, 3, 4 }
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr Settings::Hybrid defaultHybrid {
|
constexpr Settings::Hybrid defaultHybrid {
|
||||||
.hybridMode = UnifiedModelMode::FocTorque,
|
.hybridMode = UnifiedModelMode::FocTorque,
|
||||||
.enable = false,
|
.enable = false,
|
||||||
@@ -169,7 +162,6 @@ constexpr Settings defaultSettings {
|
|||||||
.larsmMode = defaultLarsmMode,
|
.larsmMode = defaultLarsmMode,
|
||||||
.motortestMode = defaultMotortestMode,
|
.motortestMode = defaultMotortestMode,
|
||||||
.hybrid = defaultHybrid,
|
.hybrid = defaultHybrid,
|
||||||
.lockscreen = defaultLockscreen,
|
|
||||||
.savedStatistics = defaultSavedStatistics,
|
.savedStatistics = defaultSavedStatistics,
|
||||||
.handbremse = defaultHandbremse,
|
.handbremse = defaultHandbremse,
|
||||||
#ifdef FEATURE_ESPNOW
|
#ifdef FEATURE_ESPNOW
|
||||||
|
@@ -71,20 +71,13 @@ struct Settings
|
|||||||
uint16_t maxPwm; // profileSetting
|
uint16_t maxPwm; // profileSetting
|
||||||
} motortestMode;
|
} motortestMode;
|
||||||
|
|
||||||
struct Hybrid {
|
struct Hybrid { // wont convert
|
||||||
UnifiedModelMode hybridMode;
|
UnifiedModelMode hybridMode;
|
||||||
bool enable;
|
bool enable;
|
||||||
int16_t activationLimit;
|
int16_t activationLimit;
|
||||||
int16_t deactivationLimit;
|
int16_t deactivationLimit;
|
||||||
} hybrid;
|
} hybrid;
|
||||||
|
|
||||||
struct LockscreenSettings {
|
|
||||||
bool allowPresetSwitch;
|
|
||||||
bool keepLockedAfterReboot;
|
|
||||||
bool locked;
|
|
||||||
std::array<int8_t, 4> pin;
|
|
||||||
} lockscreen;
|
|
||||||
|
|
||||||
struct SavedStatistics {
|
struct SavedStatistics {
|
||||||
uint32_t totalCentimeters;
|
uint32_t totalCentimeters;
|
||||||
} savedStatistics;
|
} savedStatistics;
|
||||||
@@ -119,11 +112,6 @@ void Settings::executeForEveryCommonSetting(T &&callable)
|
|||||||
callable("hybridAcL", hybrid.activationLimit);
|
callable("hybridAcL", hybrid.activationLimit);
|
||||||
callable("hybridDeacL", hybrid.deactivationLimit);
|
callable("hybridDeacL", hybrid.deactivationLimit);
|
||||||
|
|
||||||
callable("lockAlwPresetSw", lockscreen.allowPresetSwitch);
|
|
||||||
callable("keepLocked", lockscreen.keepLockedAfterReboot);
|
|
||||||
callable("currentlyLocked", lockscreen.locked);
|
|
||||||
callable("lockscreenPin", lockscreen.pin);
|
|
||||||
|
|
||||||
callable("totalCentimeter", savedStatistics.totalCentimeters);
|
callable("totalCentimeter", savedStatistics.totalCentimeters);
|
||||||
|
|
||||||
callable("handBremsE", handbremse.enable);
|
callable("handBremsE", handbremse.enable);
|
||||||
|
Reference in New Issue
Block a user