feat: add 0.5 second option to power on/off delays (#5134)
This commit is contained in:
@@ -478,6 +478,18 @@ void GeneralSetupPanel::populateRotEncCB(int reCount)
|
|||||||
b->setCurrentIndex(generalSettings.reNavigation);
|
b->setCurrentIndex(generalSettings.reNavigation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pwrDelayFromYaml(int delay)
|
||||||
|
{
|
||||||
|
static int8_t vals[] = { 1, 4, 3, 2, 0 };
|
||||||
|
return vals[delay + 2];
|
||||||
|
}
|
||||||
|
|
||||||
|
int pwrDelayToYaml(int delay)
|
||||||
|
{
|
||||||
|
static int8_t vals[] = { 2, -2, 1, 0, -1 };
|
||||||
|
return vals[delay];
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralSetupPanel::setValues()
|
void GeneralSetupPanel::setValues()
|
||||||
{
|
{
|
||||||
ui->beeperCB->setCurrentIndex(generalSettings.beeperMode+2);
|
ui->beeperCB->setCurrentIndex(generalSettings.beeperMode+2);
|
||||||
@@ -509,8 +521,8 @@ void GeneralSetupPanel::setValues()
|
|||||||
ui->vBatMaxDSB->setValue((double)(generalSettings.vBatMax + 120) / 10);
|
ui->vBatMaxDSB->setValue((double)(generalSettings.vBatMax + 120) / 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->pwrOnDelay->setValue(2 - generalSettings.pwrOnSpeed);
|
ui->pwrOnDelay->setCurrentIndex(pwrDelayFromYaml(generalSettings.pwrOnSpeed));
|
||||||
ui->pwrOffDelay->setValue(2 - generalSettings.pwrOffSpeed);
|
ui->pwrOffDelay->setCurrentIndex(pwrDelayFromYaml(generalSettings.pwrOffSpeed));
|
||||||
|
|
||||||
ui->registrationId->setText(generalSettings.registrationId);
|
ui->registrationId->setText(generalSettings.registrationId);
|
||||||
|
|
||||||
@@ -632,15 +644,15 @@ void GeneralSetupPanel::on_splashScreenDuration_currentIndexChanged(int index)
|
|||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSetupPanel::on_pwrOnDelay_valueChanged(int)
|
void GeneralSetupPanel::on_pwrOnDelay_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
generalSettings.pwrOnSpeed = 2 - ui->pwrOnDelay->value();
|
generalSettings.pwrOnSpeed = pwrDelayToYaml(index);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSetupPanel::on_pwrOffDelay_valueChanged(int)
|
void GeneralSetupPanel::on_pwrOffDelay_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
generalSettings.pwrOffSpeed = 2 - ui->pwrOffDelay->value();
|
generalSettings.pwrOffSpeed = pwrDelayToYaml(index);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ class GeneralSetupPanel : public GeneralPanel
|
|||||||
void on_contrastSB_editingFinished();
|
void on_contrastSB_editingFinished();
|
||||||
void on_registrationId_editingFinished();
|
void on_registrationId_editingFinished();
|
||||||
|
|
||||||
void on_pwrOnDelay_valueChanged(int);
|
void on_pwrOnDelay_currentIndexChanged(int);
|
||||||
void on_pwrOffDelay_valueChanged(int);
|
void on_pwrOffDelay_currentIndexChanged(int);
|
||||||
void on_pwrOnOffHaptic_CB_stateChanged(int);
|
void on_pwrOnOffHaptic_CB_stateChanged(int);
|
||||||
|
|
||||||
void on_modelQuickSelect_CB_stateChanged(int);
|
void on_modelQuickSelect_CB_stateChanged(int);
|
||||||
|
|||||||
@@ -1368,13 +1368,32 @@ p, li { white-space: pre-wrap; }
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="12" column="1">
|
<item row="12" column="1">
|
||||||
<widget class="QSpinBox" name="pwrOnDelay">
|
<widget class="QComboBox" name="pwrOnDelay">
|
||||||
<property name="suffix">
|
<item>
|
||||||
<string> sec</string>
|
<property name="text">
|
||||||
</property>
|
<string>0s</string>
|
||||||
<property name="maximum">
|
</property>
|
||||||
<number>3</number>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>0.5s</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>1s</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>2s</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>3s</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
@@ -1548,13 +1567,32 @@ Acceptable values are 3v..12v</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="13" column="1">
|
<item row="13" column="1">
|
||||||
<widget class="QSpinBox" name="pwrOffDelay">
|
<widget class="QComboBox" name="pwrOffDelay">
|
||||||
<property name="suffix">
|
<item>
|
||||||
<string> sec</string>
|
<property name="text">
|
||||||
</property>
|
<string>0s</string>
|
||||||
<property name="maximum">
|
</property>
|
||||||
<number>3</number>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>0.5s</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>1s</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>2s</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>3s</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1" colspan="2">
|
<item row="3" column="1" colspan="2">
|
||||||
|
|||||||
@@ -585,17 +585,11 @@ void menuRadioSetup(event_t event)
|
|||||||
|
|
||||||
#if defined(PWR_BUTTON_PRESS)
|
#if defined(PWR_BUTTON_PRESS)
|
||||||
case ITEM_RADIO_SETUP_PWR_ON_SPEED:
|
case ITEM_RADIO_SETUP_PWR_ON_SPEED:
|
||||||
lcdDrawTextAlignedLeft(y, STR_PWR_ON_DELAY);
|
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));
|
||||||
lcdDrawNumber(LCD_W-7, y, 2 - g_eeGeneral.pwrOnSpeed, attr|RIGHT);
|
|
||||||
lcdDrawChar(lcdLastRightPos, y, 's');
|
|
||||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, -1, 2);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
|
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
|
||||||
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_DELAY);
|
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));
|
||||||
lcdDrawNumber(LCD_W-7, y, 2 - g_eeGeneral.pwrOffSpeed, attr|RIGHT);
|
|
||||||
lcdDrawChar(lcdLastRightPos, y, 's');
|
|
||||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, -1, 2);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -549,17 +549,11 @@ void menuRadioSetup(event_t event)
|
|||||||
|
|
||||||
#if defined(PWR_BUTTON_PRESS)
|
#if defined(PWR_BUTTON_PRESS)
|
||||||
case ITEM_RADIO_SETUP_PWR_ON_SPEED:
|
case ITEM_RADIO_SETUP_PWR_ON_SPEED:
|
||||||
lcdDrawTextAlignedLeft(y, STR_PWR_ON_DELAY);
|
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));
|
||||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 2 - g_eeGeneral.pwrOnSpeed, attr|LEFT);
|
|
||||||
lcdDrawChar(lcdLastRightPos, y, 's');
|
|
||||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, -1, 2);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
|
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
|
||||||
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_DELAY);
|
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));
|
||||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 2 - g_eeGeneral.pwrOffSpeed, attr|LEFT);
|
|
||||||
lcdDrawChar(lcdLastRightPos, y, 's');
|
|
||||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, -1, 2);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -760,10 +760,10 @@ static SetupLineDef setupLines[] = {
|
|||||||
STR_PWR_OFF_DELAY,
|
STR_PWR_OFF_DELAY,
|
||||||
[](Window* parent, coord_t x, coord_t y) {
|
[](Window* parent, coord_t x, coord_t y) {
|
||||||
new Choice(
|
new Choice(
|
||||||
parent, {x, y, 0, EdgeTxStyles::UI_ELEMENT_HEIGHT}, STR_PWR_OFF_DELAYS, 0, 3,
|
parent, {x, y, 0, EdgeTxStyles::UI_ELEMENT_HEIGHT}, STR_PWR_OFF_DELAYS, 0, 4,
|
||||||
[=]() -> int32_t { return 2 - g_eeGeneral.pwrOffSpeed; },
|
[=]() -> int32_t { return pwrDelayFromYaml(g_eeGeneral.pwrOffSpeed); },
|
||||||
[=](int32_t newValue) {
|
[=](int32_t newValue) {
|
||||||
g_eeGeneral.pwrOffSpeed = 2 - newValue;
|
g_eeGeneral.pwrOffSpeed = pwrDelayToYaml(newValue);
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int quarter = 3 - duration / (totalDuration / 5);
|
int quarter = 4 - (duration * 5) / totalDuration;
|
||||||
if (quarter < 0) quarter = 0;
|
if (quarter < 0) quarter = 0;
|
||||||
for (int i = 3; i >= quarter; i -= 1) shutdownAnim[i]->hide();
|
for (int i = 3; i >= quarter; i -= 1) shutdownAnim[i]->hide();
|
||||||
|
|
||||||
|
|||||||
+27
-7
@@ -1231,11 +1231,19 @@ void copyMinMaxToOutputs(uint8_t ch)
|
|||||||
storageDirty(EE_MODEL);
|
storageDirty(EE_MODEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PWR_BUTTON_PRESS) || defined(STARTUP_ANIMATION)
|
||||||
|
uint32_t pwrDelayTime(int delay)
|
||||||
|
{
|
||||||
|
static uint8_t vals[] = { 0, 5, 10, 20, 30 };
|
||||||
|
return vals[pwrDelayFromYaml(delay)] * 10;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(STARTUP_ANIMATION)
|
#if defined(STARTUP_ANIMATION)
|
||||||
|
|
||||||
inline uint32_t PWR_PRESS_DURATION_MIN()
|
inline uint32_t PWR_PRESS_DURATION_MIN()
|
||||||
{
|
{
|
||||||
return (2 - g_eeGeneral.pwrOnSpeed) * 100;
|
return pwrDelayTime(g_eeGeneral.pwrOnSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr uint32_t PWR_PRESS_DURATION_MAX = 500; // 5s
|
constexpr uint32_t PWR_PRESS_DURATION_MAX = 500; // 5s
|
||||||
@@ -1608,6 +1616,20 @@ int main()
|
|||||||
tasksStart();
|
tasksStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PWR_BUTTON_PRESS)
|
||||||
|
int pwrDelayFromYaml(int delay)
|
||||||
|
{
|
||||||
|
static int8_t vals[] = { 1, 4, 3, 2, 0 };
|
||||||
|
return vals[delay + 2];
|
||||||
|
}
|
||||||
|
|
||||||
|
int pwrDelayToYaml(int delay)
|
||||||
|
{
|
||||||
|
static int8_t vals[] = { 2, -2, 1, 0, -1 };
|
||||||
|
return vals[delay];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
#if defined(PWR_BUTTON_PRESS)
|
#if defined(PWR_BUTTON_PRESS)
|
||||||
|
|
||||||
@@ -1617,19 +1639,17 @@ inline uint32_t PWR_PRESS_SHUTDOWN_DELAY()
|
|||||||
if (pwrForcePressed())
|
if (pwrForcePressed())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (2 - g_eeGeneral.pwrOffSpeed) * 100;
|
return pwrDelayTime(g_eeGeneral.pwrOffSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pwr_press_time = 0;
|
uint32_t pwr_press_time = 0;
|
||||||
|
|
||||||
uint32_t pwrPressedDuration()
|
uint32_t pwrPressedDuration()
|
||||||
{
|
{
|
||||||
if (pwr_press_time == 0) {
|
if (pwr_press_time == 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
else {
|
return get_tmr10ms() - pwr_press_time;
|
||||||
return get_tmr10ms() - pwr_press_time;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(COLORLCD)
|
#if defined(COLORLCD)
|
||||||
|
|||||||
@@ -950,3 +950,6 @@ extern bool modelLSEnabled();
|
|||||||
extern bool modelSFEnabled();
|
extern bool modelSFEnabled();
|
||||||
extern bool modelCustomScriptsEnabled();
|
extern bool modelCustomScriptsEnabled();
|
||||||
extern bool modelTelemetryEnabled();
|
extern bool modelTelemetryEnabled();
|
||||||
|
|
||||||
|
int pwrDelayFromYaml(int delay);
|
||||||
|
int pwrDelayToYaml(int delay);
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
#define TR_FLYSKY_PULSE_PROTO "PWM","PPM"
|
#define TR_FLYSKY_PULSE_PROTO "PWM","PPM"
|
||||||
#define TR_FLYSKY_SERIAL_PROTO "iBUS","SBUS"
|
#define TR_FLYSKY_SERIAL_PROTO "iBUS","SBUS"
|
||||||
#define TR_PPM_POL "-","+"
|
#define TR_PPM_POL "-","+"
|
||||||
#define TR_PWR_OFF_DELAYS "0s","1s","2s","4s"
|
#define TR_PWR_OFF_DELAYS "0s","0.5s","1s","2s","3s"
|
||||||
#if defined(COLORLCD)
|
#if defined(COLORLCD)
|
||||||
#define TR_SPLASHSCREEN_DELAYS "1s","2s","3s","4s","6s","8s","10s","15s"
|
#define TR_SPLASHSCREEN_DELAYS "1s","2s","3s","4s","6s","8s","10s","15s"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user