Made UI fsm skip low battery check when TX is enabled to avoid spurious triggers of low battery alert caused by the high current absorption from RF PA

replace/2cf5098dc98640cc2474b558b3504c3f97133938
Silvano Seva 2021-02-24 21:00:30 +01:00
rodzic 6b24895ef3
commit 056c53b35d
2 zmienionych plików z 22 dodań i 20 usunięć

Wyświetl plik

@ -251,11 +251,6 @@ static void dev_task(void *arg)
(void) arg; (void) arg;
OS_ERR os_err; OS_ERR os_err;
// Initialise battery voltage, to avoid filter settling transient
OSMutexPend(&state_mutex, 0u, OS_OPT_PEND_BLOCKING, 0u, &os_err);
state.v_bat = platform_getVbat();
OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err);
while(1) while(1)
{ {
// Lock mutex and update internal state // Lock mutex and update internal state

Wyświetl plik

@ -572,10 +572,10 @@ void _ui_fsm_insertVFONumber(kbd_msg_t msg, bool *sync_rtx) {
void _ui_changeBrightness(int variation) void _ui_changeBrightness(int variation)
{ {
if(variation >= 0) if(variation >= 0)
state.settings.brightness = state.settings.brightness =
(255 - state.settings.brightness < variation) ? 255 : state.settings.brightness + variation; (255 - state.settings.brightness < variation) ? 255 : state.settings.brightness + variation;
else else
state.settings.brightness = state.settings.brightness =
(state.settings.brightness < -variation) ? 0 : state.settings.brightness + variation; (state.settings.brightness < -variation) ? 0 : state.settings.brightness + variation;
platform_setBacklightLevel(state.settings.brightness); platform_setBacklightLevel(state.settings.brightness);
} }
@ -583,10 +583,10 @@ void _ui_changeBrightness(int variation)
void _ui_changeContrast(int variation) void _ui_changeContrast(int variation)
{ {
if(variation >= 0) if(variation >= 0)
state.settings.contrast = state.settings.contrast =
(255 - state.settings.contrast < variation) ? 255 : state.settings.contrast + variation; (255 - state.settings.contrast < variation) ? 255 : state.settings.contrast + variation;
else else
state.settings.contrast = state.settings.contrast =
(state.settings.contrast < -variation) ? 0 : state.settings.contrast + variation; (state.settings.contrast < -variation) ? 0 : state.settings.contrast + variation;
display_setContrast(state.settings.contrast); display_setContrast(state.settings.contrast);
} }
@ -703,12 +703,17 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
platform_terminate(); platform_terminate();
return; return;
} }
// Check if battery has enough charge to operate
float charge = battery_getCharge(state.v_bat); // Check if battery has enough charge to operate.
if (!state.emergency && charge <= 0) // Check is skipped if there is an ongoing transmission, since the voltage
// drop caused by the RF PA power absorption causes spurious triggers of
// the low battery alert.
bool txOngoing = platform_getPttStatus();
if ((!state.emergency) && (!txOngoing) && (state.charge <= 0))
{ {
state.ui_screen = LOW_BAT; state.ui_screen = LOW_BAT;
if(event.type == EVENT_KBD && event.payload) { if(event.type == EVENT_KBD && event.payload)
{
state.ui_screen = MAIN_VFO; state.ui_screen = MAIN_VFO;
state.emergency = true; state.emergency = true;
} }
@ -726,7 +731,9 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
macro_menu = true; macro_menu = true;
_ui_fsm_menuMacro(msg, sync_rtx); _ui_fsm_menuMacro(msg, sync_rtx);
return; return;
} else { }
else
{
macro_menu = false; macro_menu = false;
} }
switch(state.ui_screen) switch(state.ui_screen)
@ -1030,11 +1037,11 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
break; break;
// Return to Time&Date menu, saving values // Return to Time&Date menu, saving values
// NOTE: The user inserted a local time, we save an UTC time to the RTC // NOTE: The user inserted a local time, we save an UTC time to the RTC
if(ui_state.new_timedate.hour - state.settings.utc_timezone >= 24) if(ui_state.new_timedate.hour - state.settings.utc_timezone >= 24)
ui_state.new_timedate.hour = ui_state.new_timedate.hour - 24 - ui_state.new_timedate.hour = ui_state.new_timedate.hour - 24 -
state.settings.utc_timezone; state.settings.utc_timezone;
else if(ui_state.new_timedate.hour - state.settings.utc_timezone < 0) else if(ui_state.new_timedate.hour - state.settings.utc_timezone < 0)
ui_state.new_timedate.hour = ui_state.new_timedate.hour + 24 - ui_state.new_timedate.hour = ui_state.new_timedate.hour + 24 -
state.settings.utc_timezone; state.settings.utc_timezone;
else else
ui_state.new_timedate.hour += state.settings.utc_timezone; ui_state.new_timedate.hour += state.settings.utc_timezone;
@ -1050,7 +1057,7 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
break; break;
ui_state.input_position += 1; ui_state.input_position += 1;
ui_state.input_number = input_getPressedNumber(msg); ui_state.input_number = input_getPressedNumber(msg);
_ui_timedate_add_digit(&ui_state.new_timedate, ui_state.input_position, _ui_timedate_add_digit(&ui_state.new_timedate, ui_state.input_position,
ui_state.input_number); ui_state.input_number);
} }
break; break;
@ -1099,7 +1106,7 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
break; break;
#ifdef HAS_GPS #ifdef HAS_GPS
case SETTINGS_GPS: case SETTINGS_GPS:
if(msg.keys & KEY_LEFT || msg.keys & KEY_RIGHT || if(msg.keys & KEY_LEFT || msg.keys & KEY_RIGHT ||
((msg.keys & KEY_UP || msg.keys & KEY_DOWN) && ui_state.edit_mode)) ((msg.keys & KEY_UP || msg.keys & KEY_DOWN) && ui_state.edit_mode))
{ {
switch(ui_state.menu_selected) switch(ui_state.menu_selected)