Unify switch warnings

This commit is contained in:
Raphael Coeffic
2021-12-09 09:48:28 +01:00
parent 416084b9e0
commit 571cae732c
3 changed files with 44 additions and 128 deletions
+1 -28
View File
@@ -23,34 +23,7 @@
bool SwitchWarnDialog::warningInactive()
{
GET_ADC_IF_MIXER_NOT_RUNNING();
getMovedSwitch();
bool warn = false;
for (int i = 0; i < NUM_SWITCHES; i++) {
if (SWITCH_WARNING_ALLOWED(i)) {
unsigned int state = ((states >> (3 * i)) & 0x07);
if (state && state - 1 != ((switches_states >> (i * 2)) & 0x03)) {
warn = true;
}
}
}
if (g_model.potsWarnMode) {
evalFlightModeMixes(e_perout_mode_normal, 0);
bad_pots = 0;
for (int i = 0; i < NUM_POTS + NUM_SLIDERS; i++) {
if (!IS_POT_SLIDER_AVAILABLE(POT1 + i)) {
continue;
}
if ( (g_model.potsWarnEnabled & (1 << i)) && (abs(g_model.potsWarnPosition[i] - GET_LOWRES_POT_POSITION(i)) > 1)) {
warn = true;
bad_pots |= (1 << i);
}
}
}
if (!warn)
if (!isSwitchWarningRequired(bad_pots))
return true;
if (last_bad_switches != switches_states || last_bad_pots != bad_pots) {
+2 -3
View File
@@ -50,9 +50,8 @@ class SwitchWarnDialog: public FullScreenDialog {
protected:
swarnstate_t last_bad_switches;
swarnstate_t states;
uint8_t bad_pots;
uint8_t last_bad_pots;
uint8_t bad_pots;
uint8_t last_bad_pots;
bool warningInactive();
};