mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Add a sleep timeout setting for hall sensor (#1969)
Some checks are pending
Docs / deploy-docs (push) Waiting to run
CI / build (MHP30) (push) Waiting to run
CI / build (Pinecil) (push) Waiting to run
CI / build (Pinecilv2) (push) Waiting to run
CI / build (S60) (push) Waiting to run
CI / build (S60P) (push) Waiting to run
CI / build (T55) (push) Waiting to run
CI / build (TS100) (push) Waiting to run
CI / build (TS101) (push) Waiting to run
CI / build (TS80) (push) Waiting to run
CI / build (TS80P) (push) Waiting to run
CI / build_multi-lang (Pinecil) (push) Waiting to run
CI / build_multi-lang (Pinecilv2) (push) Waiting to run
CI / upload_metadata (push) Blocked by required conditions
CI / tests (push) Waiting to run
CI / check_c-cpp (push) Waiting to run
CI / check_python (push) Waiting to run
CI / check_shell (push) Waiting to run
CI / check_readme (push) Waiting to run
Some checks are pending
Docs / deploy-docs (push) Waiting to run
CI / build (MHP30) (push) Waiting to run
CI / build (Pinecil) (push) Waiting to run
CI / build (Pinecilv2) (push) Waiting to run
CI / build (S60) (push) Waiting to run
CI / build (S60P) (push) Waiting to run
CI / build (T55) (push) Waiting to run
CI / build (TS100) (push) Waiting to run
CI / build (TS101) (push) Waiting to run
CI / build (TS80) (push) Waiting to run
CI / build (TS80P) (push) Waiting to run
CI / build_multi-lang (Pinecil) (push) Waiting to run
CI / build_multi-lang (Pinecilv2) (push) Waiting to run
CI / upload_metadata (push) Blocked by required conditions
CI / tests (push) Waiting to run
CI / check_c-cpp (push) Waiting to run
CI / check_python (push) Waiting to run
CI / check_shell (push) Waiting to run
CI / check_readme (push) Waiting to run
* Add a sleep timeout setting for hall sensor * Update Settings.h to reorder HallEffectSleepTime to the end * Update Settings.cpp to reorder HallEffectSleepTime to the end * add HallEffSleepTimeout to rest of translations * mix misaligned number in Settings.cpp * fix clang-format issue in getHallEffectSleepTimeout
This commit is contained in:
@@ -73,8 +73,9 @@ enum SettingsOptions {
|
||||
ProfilePhase5Temp = 50, // Temperature to target for the end of phase 5
|
||||
ProfilePhase5Duration = 51, // Target duration for phase 5
|
||||
ProfileCooldownSpeed = 52, // Maximum allowed cooldown speed in degrees per second
|
||||
HallEffectSleepTime = 53, // Seconds (/5) timeout to sleep when hall effect over threshold
|
||||
//
|
||||
SettingsOptionsLength = 53, //
|
||||
SettingsOptionsLength = 54, //
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -84,6 +84,7 @@ enum class SettingsItemIndex : uint8_t {
|
||||
SleepTimeout,
|
||||
ShutdownTimeout,
|
||||
HallEffSensitivity,
|
||||
HallEffSleepTimeout,
|
||||
TemperatureUnit,
|
||||
DisplayRotation,
|
||||
CooldownBlink,
|
||||
|
||||
@@ -104,6 +104,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
|
||||
{ MIN_TEMP_C, MAX_TEMP_F, 5, 90}, // ProfilePhase5Temp
|
||||
{ 10, 180, 5, 30}, // ProfilePhase5Duration
|
||||
{ 1, 10, 1, 2}, // ProfileCooldownSpeed
|
||||
{ 0, 12, 1, 0}, // HallEffectSleepTime
|
||||
};
|
||||
static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength));
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ static void displayLogoTime(void);
|
||||
|
||||
#ifdef HALL_SENSOR
|
||||
static void displayHallEffect(void);
|
||||
static void displayHallEffectSleepTime(void);
|
||||
static bool showHallEffect(void);
|
||||
#endif /* HALL_SENSOR */
|
||||
|
||||
@@ -162,6 +163,7 @@ static void displayAdvancedMenu(void);
|
||||
* -Sleep Time
|
||||
* -Shutdown Time
|
||||
* Hall Sensor Sensitivity
|
||||
* Hall Sensor Sleep Time
|
||||
*
|
||||
* UI
|
||||
* Temperature Unit
|
||||
@@ -346,6 +348,8 @@ const menuitem PowerSavingMenu[] = {
|
||||
#ifdef HALL_SENSOR
|
||||
/* Hall Effect Sensitivity */
|
||||
{SETTINGS_DESC(SettingsItemIndex::HallEffSensitivity), nullptr, displayHallEffect, showHallEffect, SettingsOptions::HallEffectSensitivity, SettingsItemIndex::HallEffSensitivity, 7},
|
||||
/* Hall Effect Sleep Time */
|
||||
{SETTINGS_DESC(SettingsItemIndex::HallEffSleepTimeout), nullptr, displayHallEffectSleepTime, showHallEffect, SettingsOptions::HallEffectSleepTime, SettingsItemIndex::HallEffSleepTimeout, 5},
|
||||
#endif /* HALL_SENSOR */
|
||||
/* vvvv end of menu marker. DO NOT REMOVE vvvv */
|
||||
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength, SettingsItemIndex::NUM_ITEMS, 0}
|
||||
@@ -740,6 +744,16 @@ static void displayHallEffect(void) {
|
||||
}
|
||||
}
|
||||
static bool showHallEffect(void) { return getHallSensorFitted(); }
|
||||
static void displayHallEffectSleepTime(void) {
|
||||
if (getSettingValue(SettingsOptions::HallEffectSleepTime)) {
|
||||
OLED::printNumber(getSettingValue(SettingsOptions::HallEffectSleepTime) * 5, 2, FontStyle::LARGE, false);
|
||||
OLED::print(LargeSymbolSeconds, FontStyle::LARGE);
|
||||
} else {
|
||||
// When sleep time is set to zero, we sleep for 1 second anyways. This is the default.
|
||||
OLED::printNumber(1, 2, FontStyle::LARGE, false);
|
||||
OLED::print(LargeSymbolSeconds, FontStyle::LARGE);
|
||||
}
|
||||
}
|
||||
#endif /* HALL_SENSOR */
|
||||
|
||||
static void setTempF(const enum SettingsOptions option) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
void GUIDelay(); //
|
||||
bool checkForUnderVoltage(void); //
|
||||
uint32_t getSleepTimeout(void); //
|
||||
uint32_t getHallEffectSleepTimeout(void); //
|
||||
bool shouldBeSleeping(); //
|
||||
bool shouldShutdown(void); //
|
||||
void printVoltage(void); //
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "OperatingModeUtilities.h"
|
||||
|
||||
#ifndef NO_SLEEP_MODE
|
||||
#ifdef HALL_SENSOR
|
||||
uint32_t getHallEffectSleepTimeout(void) {
|
||||
if (getSettingValue(SettingsOptions::HallEffectSensitivity) && getSettingValue(SettingsOptions::HallEffectSleepTime)) {
|
||||
uint32_t sleepThres = getSettingValue(SettingsOptions::HallEffectSleepTime) * 5 * TICKS_SECOND;
|
||||
return sleepThres;
|
||||
}
|
||||
return TICKS_SECOND;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -32,7 +32,7 @@ bool shouldBeSleeping() {
|
||||
if (lastHallEffectSleepStart == 0) {
|
||||
lastHallEffectSleepStart = xTaskGetTickCount();
|
||||
}
|
||||
if ((xTaskGetTickCount() - lastHallEffectSleepStart) > TICKS_SECOND) {
|
||||
if ((xTaskGetTickCount() - lastHallEffectSleepStart) > getHallEffectSleepTimeout()) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user