Skip to content

Commit

Permalink
BUG FIX: power save never activated
Browse files Browse the repository at this point in the history
  • Loading branch information
egzumer committed Oct 10, 2023
1 parent a6ef758 commit d087a25
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,8 +1189,7 @@ void APP_Update(void)
{
gBatterySaveCountdown_10ms = battery_save_count_10ms;
}
else
if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
else if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode)
{
//if (gCurrentFunction != FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_POWER_SAVE);
Expand Down Expand Up @@ -1288,8 +1287,6 @@ void APP_Update(void)
// called every 10ms
void APP_CheckKeys(void)
{
KEY_Code_t Key;

#ifdef ENABLE_AIRCOPY
if (gSetting_KILLED || (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY))
return;
Expand Down Expand Up @@ -1327,16 +1324,16 @@ void APP_CheckKeys(void)
else
gPttDebounceCounter = 0;

// *****************
// --------------------- OTHER KEYS ----------------------------

// scan the hardware keys
Key = KEYBOARD_Poll();
KEY_Code_t Key = KEYBOARD_Poll();

if (Key != KEY_INVALID)
if (Key != KEY_INVALID) // any key pressed
boot_counter_10ms = 0; // cancel boot screen/beeps if any key pressed

if (gKeyReading0 != Key)
{ // new key pressed
if (gKeyReading0 != Key) // new key pressed
{

if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID)
APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key
Expand All @@ -1346,18 +1343,19 @@ void APP_CheckKeys(void)
return;
}

if (++gDebounceCounter == key_debounce_10ms)
{ // debounced new key pressed
gDebounceCounter++;

if (Key == KEY_INVALID)
if (gDebounceCounter == key_debounce_10ms) // debounced new key pressed
{
if (Key == KEY_INVALID) //all PTT keys released
{
if (gKeyReading1 != KEY_INVALID)
if (gKeyReading1 != KEY_INVALID) // some button was pressed before
{
APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld);
APP_ProcessKey(gKeyReading1, false, gKeyBeingHeld); // process last button released event
gKeyReading1 = KEY_INVALID;
}
}
else
else // process new key pressed
{
gKeyReading1 = Key;
APP_ProcessKey(Key, true, false);
Expand All @@ -1367,21 +1365,19 @@ void APP_CheckKeys(void)
return;
}

if (gDebounceCounter < key_repeat_delay_10ms)
if (gDebounceCounter < key_repeat_delay_10ms || Key == KEY_INVALID) // the button is not held long enough for repeat yet, or not really pressed
return;

// key is being held pressed

if (gDebounceCounter == key_repeat_delay_10ms)
{ // initial key repeat delay after pressed
if (gDebounceCounter == key_repeat_delay_10ms) //initial key repeat with longer delay
{
if (Key != KEY_PTT)
{
gKeyBeingHeld = true;
APP_ProcessKey(Key, true, true);
}
}
else
{ // key repeat
else //subsequent fast key repeats
{
if (Key == KEY_UP || Key == KEY_DOWN)
{
gKeyBeingHeld = true;
Expand All @@ -1392,7 +1388,7 @@ void APP_CheckKeys(void)
if (gDebounceCounter < 0xFFFF)
return;

gDebounceCounter = key_repeat_delay_10ms;
gDebounceCounter = key_repeat_delay_10ms+1;
}
}

Expand Down

0 comments on commit d087a25

Please sign in to comment.