1
0
forked from me/IronOS

Add a sleep timeout setting for hall sensor (#1969)

* 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:
ave
2024-08-21 07:23:34 +02:00
committed by GitHub
parent adfc521122
commit 02b21a620b
42 changed files with 110 additions and 2 deletions

View File

@@ -233,6 +233,8 @@
"displayText": "Эфект Хола\nадчувальнасць",
"description": "Узровень адчувальнасці датчыка хола ў рэжыме сну (1=Мін. | ... | 9=Макс.)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Адзінкі\nтэмпературы",
"description": "Адзінкі вымярэння тэмпературы (C=Цэльcія | F=Фарэнгейта)"

View File

@@ -233,6 +233,8 @@
"displayText": "Датчик\nна Хол",
"description": "Чувствителност на сензора към магнитно поле (1=Слабо | ... | 9=Силно)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Единици за\nтемпературата",
"description": "Единици за температурата (C=Целзии | F=Фаренхайт)"

View File

@@ -233,6 +233,8 @@
"displayText": "Citlivost\nHall. čidla",
"description": "Citlivost Hallova čidla pro detekci spánku (1=nejméně citlivé | ... | 9=nejvíce citlivé)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Jednotka\nteploty",
"description": "C=Celsius | F=Fahrenheit"

View File

@@ -233,6 +233,8 @@
"displayText": "Hall sensor\nfølsomhed",
"description": "følsomhed overfor magneten (1=Mindst følsom | ... | 9=Mest følsom)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Temperatur\nEnhed",
"description": "Temperatur Enhed (C=Celsius | F=Fahrenheit)"

View File

@@ -233,6 +233,8 @@
"displayText": "Empfindlichkeit\nder Hall-Sonde",
"description": "Empfindlichkeit der Hall-Sonde um den Ruhemodus auszulösen (1=minimal | ... | 9=maximal)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Temperatur-\neinheit",
"description": "C=°Celsius | F=°Fahrenheit"

View File

@@ -233,6 +233,8 @@
"displayText": "Ευαισθ. αισθ. \nφαιν. Hall",
"description": "Ευαισθησία του αισθητήρα φαινομένου Hall για εντοπισμό αδράνειας (1=λιγότερο ευαίσθητο | ... | 9=περισσότερο ευαίσθητο)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Μονάδες\nθερμοκρασίας",
"description": "C=Κελσίου | F=Φαρενάιτ"

View File

@@ -233,6 +233,10 @@
"displayText": "Hall sensor\nsensitivity",
"description": "Sensitivity to magnets (1=least sensitive | ... | 9=most sensitive)"
},
"HallEffSleepTimeout": {
"displayText": "HallSensor\nSleepTime",
"description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Temperature\nunit",
"description": "C=°Celsius | F=°Fahrenheit"

View File

@@ -233,6 +233,8 @@
"displayText": "Hall Eff\nSensibilidad",
"description": "Sensibilidad del sensor de efecto Hall en la detección de reposo (1=menos sensible | ... | 9=más sensible)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Unidad de\ntemperatura",
"description": "Unidad de temperatura (C=entígrados | F=Fahrenheit)"

View File

@@ -233,6 +233,8 @@
"displayText": "Halli anduri\ntundlikkus",
"description": "Tundlikkus magnetite suhtes (1=vähetundlikum | ... | 9=kõige tundlikum)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Temperatuuri\nühik",
"description": "C=°Celsius | F=°Fahrenheit"

View File

@@ -233,6 +233,8 @@
"displayText": "Hall-\nherk.",
"description": "Hall-efektianturin herkkyys lepotilan tunnistuksessa (1=vähäinen herkkyys | ... | 9=suurin herkkyys)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Lämpötilan\nyksikkö",
"description": "C=celsius, F=fahrenheit"

View File

@@ -233,6 +233,8 @@
"displayText": "Sensibilité\ncapteur effet hall",
"description": "Sensibilité du capteur à effet Hall pour la mise en veille (1=peu sensible | ... | 9=très sensible)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Unité de\ntempérature",
"description": "C=Celsius | F=Fahrenheit"

View File

@@ -233,6 +233,8 @@
"displayText": "Osjetljivost\nHall senzora",
"description": "Osjetljivost senzora magnetskog polja za detekciju spavanja (N=Najmanja | S=Srednja | V=Visoka)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Jedinica\ntemperature",
"description": "Jedinica temperature (C=Celzij | F=Fahrenheit)"

View File

@@ -233,6 +233,8 @@
"displayText": "Alvásérzékelő\nérzékenység",
"description": "Alvásérzékelő gyorsulásmérő érzékenysége (1=legkevésbé érzékeny | ... | 9=legérzékenyebb)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Hőmérséklet\nmértékegysége",
"description": "Hőmérséklet mértékegysége (C=Celsius | F=Fahrenheit)"

View File

@@ -233,6 +233,8 @@
"displayText": "Sensore\nHall",
"description": "Regola la sensibilità del sensore ad effetto Hall per entrare in modalità riposo [1: minima; 9: massima]"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Unità di\ntemperatura",
"description": "Scegli l'unità di misura per la temperatura [C: grado Celsius; F: grado Farenheit]"

View File

@@ -233,6 +233,8 @@
"displayText": "磁界感度",
"description": "スタンバイモードに入るのに使用される磁場センサーの感度 <1=最低感度 | ... | 9=最高感度>"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "温度単位",
"description": "C=摂氏 | F=華氏"

View File

@@ -233,6 +233,8 @@
"displayText": "Holo\njutiklis",
"description": "Holo jutiklio jautrumas nustatant miegą (1=Mažiausias | ... | 9=Didžiausias)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Temperatūros\nvienetai",
"description": "Temperatūros vienetai (C=Celsijus | F=Farenheitas)"

View File

@@ -233,6 +233,8 @@
"displayText": "Hall-sensor\nfølsomhet",
"description": "Sensitiviteten til Hall-effekt-sensoren for å detektere inaktivitet (1=Minst følsom | ... | 9=Mest følsom)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "TmpEnh\n",
"description": "Temperaturskala (C=Celsius | F=Fahrenheit)"

View File

@@ -233,6 +233,8 @@
"displayText": "Hall sensor\ngevoeligheid",
"description": "Gevoeligheid naar de magneten (1=minst gevoelig | ... | 9=meest gevoelig)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Temperatuur\neenheid",
"description": "C=°Celsius | F=°Fahrenheit"

View File

@@ -233,6 +233,8 @@
"displayText": "Hall sensor\ngevoeligheid",
"description": "Gevoeligheid naar de magneten (1=minst gevoelig | ... | 9=meest gevoelig)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Temperatuur\nschaal",
"description": "Temperatuurschaal (°C=Celsius | °F=Fahrenheit)"

View File

@@ -233,6 +233,8 @@
"displayText": "Czułość\ncz. Halla",
"description": "Czułość czujnika Halla, używanego do przechodznia w tryb uśpienia (1: Minimalna | ... | 9: Maksymalna)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Jednostka\ntemperatury",
"description": "Jednostka temperatury (C: Celciusz | F: Fahrenheit)"

View File

@@ -233,6 +233,8 @@
"displayText": "Sensibilidade de\nmagnetismo",
"description": "Sensibilidade de magnetismo (1=Menor | ... | 9=Maior)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Unidade\ntemperatura",
"description": "Unidade de temperatura (C=Celsius | F=Fahrenheit)"

View File

@@ -233,6 +233,8 @@
"displayText": "Sensibilitate\nsenzor Hall",
"description": "Sensibilitate senzor cu efect Hall pentru a detecta repausul (1=putin sensibil | ... | 9=cel mai sensibil)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Unitate de\ntemperatură",
"description": "C=Celsius | F=Fahrenheit"

View File

@@ -233,6 +233,8 @@
"displayText": "Датчик\nХолла",
"description": "Чувствительность датчика Холла к магнитному полю (1=мин. | ... | 9=макс.)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Единицы\nизмерения",
"description": "Единицы измерения температуры (C=°Цельcия | F=°Фаренгейта)"

View File

@@ -233,6 +233,8 @@
"displayText": "Citliv.\nHall",
"description": "Citlivosť Hallovho senzora pre detekciu spánku (1=Min | ... | 9=Max)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Jednotka\nteploty",
"description": "Jednotky merania teploty (C=stupne Celzia | F=stupne Fahrenheita)"

View File

@@ -233,6 +233,8 @@
"displayText": "Občut.\nHall son",
"description": "Občutljivost Hallove sonde za zaznavanje spanja (1=najmanjša | ... | 9=največja)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Enota za\ntemperaturo",
"description": "Enota za temperaturo (C=celzij | F=fahrenheit)"

View File

@@ -233,6 +233,8 @@
"displayText": "Hall sensor\nsensitivity",
"description": "Sensitivity to magnets (1=најмање осетљиво | ... | 9=најосетљивије)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Јединица\nтемпературе",
"description": "Јединице у којима се приказује температура. (C=целзијус | F=фаренхајт)"

View File

@@ -233,6 +233,8 @@
"displayText": "Hall sensor\nsensitivity",
"description": "Sensitivity to magnets (1=najmanje osetljivo | ... | 9=najosetljivije)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Jedinica\ntemperature",
"description": "Jedinice u kojima se prikazuje temperatura. (C=celzijus | F=farenhajt)"

View File

@@ -233,6 +233,8 @@
"displayText": "Sensor-\nkänslght",
"description": "Känslighet för halleffekt-sensorn för viloläges-detektering (1=minst känslig | ... | 9=mest känslig)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Temperatur-\nenheter",
"description": "Temperaturenhet (C=Celsius | F=Fahrenheit)"

View File

@@ -233,6 +233,8 @@
"displayText": "Hall Sensör\nHassasiyeti",
"description": "Mıknatıslara duyarlılık (1=En az duyarlı | ... | 9=En duyarlı)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "SCKBRM\n",
"description": "Sıcaklık Birimi (C=Celsius | F=Fahrenheit)"

View File

@@ -233,6 +233,8 @@
"displayText": "Чутливість\nЕфекту Холла",
"description": "Чутливість датчика ефекту Холла при виявленні сну (1=мін. чутливості | ... | 9=макс. чутливості)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Формат темпе-\nратури(C°/F°)",
"description": "Одиниця виміру температури (C=Цельсій | F=Фаренгейт)"

View File

@@ -233,6 +233,8 @@
"displayText": "Hall\nđo nhay",
"description": "Đo nhay cam bien Hall đe phát hien che đo ngu (1=ít nhay nhat |...| 9=nhay nhat)"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "Đon vi\nnhiet đo",
"description": "C= Đo C | F= Đo F"

View File

@@ -233,6 +233,8 @@
"displayText": "磁場敏感度",
"description": "磁場感應器用嚟啓動待機模式嘅敏感度 <1=最低敏感度 | ... | 9=最高敏感度>"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "温度單位",
"description": "C=攝氏 | F=華氏"

View File

@@ -233,6 +233,8 @@
"displayText": "磁场灵敏度",
"description": "霍尔效应传感器用作启动待机模式的灵敏度 <1=最低灵敏度 | ... | 9=最高灵敏度>"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "温度单位",
"description": "C=摄氏 | F=华氏"

View File

@@ -233,6 +233,8 @@
"displayText": "磁場敏感度",
"description": "磁場感應器用作啟動待機模式的敏感度 <1=最低敏感度 | ... | 9=最高敏感度>"
},
"HallEffSleepTimeout": { "displayText": "HallSensor\nSleepTime", "description": "Interval before \"sleep mode\" starts when hall effect is above threshold"
},
"TemperatureUnit": {
"displayText": "溫標",
"description": "C=攝氏 | F=華氏"

View File

@@ -411,6 +411,13 @@
"include": ["HALL_SENSOR"],
"description": "If the unit has a hall effect sensor (Pinecil), this adjusts how sensitive it is at detecting a magnet to put the device into sleep mode."
},
{
"id": "HallEffSleepTimeout",
"maxLen": 10,
"maxLen2": 10,
"include": ["HALL_SENSOR"],
"description": "If the unit has a hall effect sensor (Pinecil), this adjusts how long the device takes before it drops down to the sleep temperature when hall sensor is over threshold."
},
{
"id": "TemperatureUnit",
"maxLen": 6,

View File

@@ -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 {

View File

@@ -84,6 +84,7 @@ enum class SettingsItemIndex : uint8_t {
SleepTimeout,
ShutdownTimeout,
HallEffSensitivity,
HallEffSleepTimeout,
TemperatureUnit,
DisplayRotation,
CooldownBlink,

View File

@@ -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));

View File

@@ -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) {

View File

@@ -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); //

View File

@@ -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

View File

@@ -32,7 +32,7 @@ bool shouldBeSleeping() {
if (lastHallEffectSleepStart == 0) {
lastHallEffectSleepStart = xTaskGetTickCount();
}
if ((xTaskGetTickCount() - lastHallEffectSleepStart) > TICKS_SECOND) {
if ((xTaskGetTickCount() - lastHallEffectSleepStart) > getHallEffectSleepTimeout()) {
return true;
}
} else {