feat: option to automatically power off radio after inactivity (#3414)
This commit is contained in:
@@ -93,6 +93,7 @@ enum {
|
||||
ITEM_RADIO_SETUP_START_SOUND,
|
||||
CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_ON_SPEED)
|
||||
CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_OFF_SPEED)
|
||||
CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_AUTO_OFF)
|
||||
CASE_HAPTIC(ITEM_RADIO_SETUP_PWR_ON_OFF_HAPTIC)
|
||||
CASE_PXX2(ITEM_RADIO_SETUP_OWNER_ID)
|
||||
CASE_GPS(ITEM_RADIO_SETUP_LABEL_GPS)
|
||||
@@ -191,6 +192,7 @@ void menuRadioSetup(event_t event)
|
||||
0,
|
||||
CASE_PWR_BUTTON_PRESS(0)
|
||||
CASE_PWR_BUTTON_PRESS(0)
|
||||
CASE_PWR_BUTTON_PRESS(0)
|
||||
CASE_HAPTIC(0) // power on/off haptic
|
||||
CASE_PXX2(0) /* owner registration ID */
|
||||
|
||||
@@ -590,6 +592,13 @@ void menuRadioSetup(event_t event)
|
||||
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
|
||||
g_eeGeneral.pwrOffSpeed = pwrDelayToYaml(editChoice(LCD_W-2, y, STR_PWR_OFF_DELAY, STR_PWR_OFF_DELAYS, pwrDelayFromYaml(g_eeGeneral.pwrOffSpeed), 0, 4, attr|RIGHT, event));
|
||||
break;
|
||||
|
||||
case ITEM_RADIO_SETUP_PWR_AUTO_OFF:
|
||||
lcdDrawTextAlignedLeft(y, STR_PWR_AUTO_OFF);
|
||||
lcdDrawNumber(LCD_W-7, y, g_eeGeneral.pwrOffIfInactive, attr|RIGHT);
|
||||
lcdDrawChar(lcdLastRightPos, y, 'm');
|
||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffIfInactive, 0, 255);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(HAPTIC)
|
||||
|
||||
@@ -82,6 +82,7 @@ enum MenuRadioSetupItems {
|
||||
ITEM_RADIO_SETUP_START_SOUND,
|
||||
CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_ON_SPEED)
|
||||
CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_OFF_SPEED)
|
||||
CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_AUTO_OFF)
|
||||
CASE_HAPTIC(ITEM_RADIO_SETUP_PWR_ON_OFF_HAPTIC)
|
||||
#if defined(PXX2)
|
||||
ITEM_RADIO_SETUP_OWNER_ID,
|
||||
@@ -195,6 +196,7 @@ void menuRadioSetup(event_t event)
|
||||
0,
|
||||
CASE_PWR_BUTTON_PRESS(0) // pwr on speed
|
||||
CASE_PWR_BUTTON_PRESS(0) // pwr off speed
|
||||
CASE_PWR_BUTTON_PRESS(0) // pwr auto off
|
||||
CASE_HAPTIC(0) // power on/off haptic
|
||||
CASE_PXX2(0) // owner registration ID
|
||||
CASE_GPS(LABEL(GPS))
|
||||
@@ -549,11 +551,18 @@ void menuRadioSetup(event_t event)
|
||||
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
case ITEM_RADIO_SETUP_PWR_ON_SPEED:
|
||||
g_eeGeneral.pwrOnSpeed = pwrDelayToYaml(editChoice(LCD_W-2, y, STR_PWR_ON_DELAY, STR_PWR_OFF_DELAYS, pwrDelayFromYaml(g_eeGeneral.pwrOnSpeed), 0, 4, attr|RIGHT, event));
|
||||
g_eeGeneral.pwrOnSpeed = pwrDelayToYaml(editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_PWR_ON_DELAY, STR_PWR_OFF_DELAYS, pwrDelayFromYaml(g_eeGeneral.pwrOnSpeed), 0, 4, attr|LEFT, event));
|
||||
break;
|
||||
|
||||
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
|
||||
g_eeGeneral.pwrOffSpeed = pwrDelayToYaml(editChoice(LCD_W-2, y, STR_PWR_OFF_DELAY, STR_PWR_OFF_DELAYS, pwrDelayFromYaml(g_eeGeneral.pwrOffSpeed), 0, 4, attr|RIGHT, event));
|
||||
g_eeGeneral.pwrOffSpeed = pwrDelayToYaml(editChoice(RADIO_SETUP_2ND_COLUMN, y, STR_PWR_OFF_DELAY, STR_PWR_OFF_DELAYS, pwrDelayFromYaml(g_eeGeneral.pwrOffSpeed), 0, 4, attr|LEFT, event));
|
||||
break;
|
||||
|
||||
case ITEM_RADIO_SETUP_PWR_AUTO_OFF:
|
||||
lcdDrawTextAlignedLeft(y, STR_PWR_AUTO_OFF);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffIfInactive, attr|LEFT);
|
||||
lcdDrawChar(lcdLastRightPos, y, 'm');
|
||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffIfInactive, 0, 255);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -770,6 +770,16 @@ static SetupLineDef setupLines[] = {
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Pwr Off If Inactive
|
||||
{
|
||||
STR_PWR_AUTO_OFF,
|
||||
[](Window* parent, coord_t x, coord_t y) {
|
||||
auto edit = new NumberEdit(parent,{x, y, RadioSetupPage::NUM_W, EdgeTxStyles::UI_ELEMENT_HEIGHT}, 0,
|
||||
255, GET_SET_DEFAULT(g_eeGeneral.pwrOffIfInactive));
|
||||
edit->setSuffix(" min");
|
||||
}
|
||||
},
|
||||
#endif
|
||||
#if defined(HAPTIC)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user