Add support for pwr-on and power-off speed
This commit is contained in:
+18
-6
@@ -1728,8 +1728,17 @@ void copyTrimsToOffset(uint8_t ch)
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
|
||||
|
||||
const uint8_t _pwrOnOffDuration_lookup[] = {
|
||||
200, // 2s
|
||||
100, // 1s
|
||||
50, // 0.5s
|
||||
0, // none
|
||||
};
|
||||
|
||||
#if defined(STARTUP_ANIMATION)
|
||||
#define PWR_PRESS_DURATION_MIN 100 // 1s
|
||||
|
||||
#define PWR_PRESS_DURATION_MIN() (_pwrOnOffDuration_lookup[g_eeGeneral.pwrOnSpeed & 3])
|
||||
#define PWR_PRESS_DURATION_MAX 500 // 5s
|
||||
|
||||
void runStartupAnimation()
|
||||
@@ -1740,8 +1749,8 @@ void runStartupAnimation()
|
||||
|
||||
while (pwrPressed()) {
|
||||
duration = get_tmr10ms() - start;
|
||||
if (duration < PWR_PRESS_DURATION_MIN) {
|
||||
drawStartupAnimation(duration);
|
||||
if (duration < PWR_PRESS_DURATION_MIN()) {
|
||||
drawStartupAnimation(duration, PWR_PRESS_DURATION_MIN());
|
||||
}
|
||||
else if (duration >= PWR_PRESS_DURATION_MAX) {
|
||||
drawSleepBitmap();
|
||||
@@ -1754,7 +1763,7 @@ void runStartupAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
if (duration < PWR_PRESS_DURATION_MIN || duration >= PWR_PRESS_DURATION_MAX) {
|
||||
if (duration < PWR_PRESS_DURATION_MIN() || duration >= PWR_PRESS_DURATION_MAX) {
|
||||
boardOff();
|
||||
}
|
||||
}
|
||||
@@ -2025,6 +2034,9 @@ int main()
|
||||
|
||||
#if !defined(SIMU)
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
|
||||
#define PWR_PRESS_SHUTDOWN_DELAY() (_pwrOnOffDuration_lookup[g_eeGeneral.pwrOffSpeed & 3])
|
||||
|
||||
uint32_t pwr_press_time = 0;
|
||||
|
||||
uint32_t pwrPressedDuration()
|
||||
@@ -2070,7 +2082,7 @@ uint32_t pwrCheck()
|
||||
if (g_eeGeneral.backlightMode != e_backlight_mode_off) {
|
||||
BACKLIGHT_ENABLE();
|
||||
}
|
||||
if (get_tmr10ms() - pwr_press_time > PWR_PRESS_SHUTDOWN_DELAY) {
|
||||
if (get_tmr10ms() - pwr_press_time > (uint32_t)PWR_PRESS_SHUTDOWN_DELAY()) {
|
||||
#if defined(SHUTDOWN_CONFIRMATION)
|
||||
while (1) {
|
||||
#else
|
||||
@@ -2100,7 +2112,7 @@ uint32_t pwrCheck()
|
||||
return e_power_off;
|
||||
}
|
||||
else {
|
||||
drawShutdownAnimation(pwrPressedDuration(), message);
|
||||
drawShutdownAnimation(pwrPressedDuration(), PWR_PRESS_SHUTDOWN_DELAY(), message);
|
||||
return e_power_press;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user