# HG changeset patch # User Ideenmodellierer # Date 1664132958 -7200 # Node ID d55817a11f4c5ae23c21ae253832711ecd0a677c # Parent cc542448fb28987f0b7390233af46dedf2ca1b9d Improvment key event detection: In previous version the evaluation of a button event was called in the 100ms callback. Assuming an event is signaled at the in line for 100ms there is a potential risk to loose a button event. To avoid this scenarion the evaluation function was moved into the extint callback (called ~50+xms) and the line readback tim was reduced to 40ms. Reminder: This function is not called in the main loop because the main loop is not executed in UART mode => movement would cause key events to not beeing detected diff -r cc542448fb28 -r d55817a11f4c Discovery/Src/base.c --- a/Discovery/Src/base.c Fri Aug 19 11:30:24 2022 +0200 +++ b/Discovery/Src/base.c Sun Sep 25 21:09:18 2022 +0200 @@ -271,8 +271,8 @@ static uint8_t blBoost = 0; static uint8_t RequestModeChange = 0; -static uint8_t LastButtonPressed; -static uint32_t LastButtonPressedTick; +static uint8_t LastButtonPressed = INVALID_BUTTON; +static uint32_t LastButtonPressedTick = 0; static uint32_t BaseTick100ms; /* Tick at last 100ms cycle */ /* SDRAM handler declaration */ @@ -516,7 +516,6 @@ updateMiniLiveLogbook(1); RefreshDisplay(); - DoHousekeeping = 0; /* make sure frames are not cleared before they are transferred */ TimeoutControl(); /* exit menus if needed */ #ifdef ENABLE_MOTION_CONTROL @@ -574,8 +573,6 @@ BaseTick100ms = HAL_GetTick(); /* store start of 100ms cycle */ - EvaluateButton(); - if(returnFromCommCleanUpRequest) { tComm_exit(); @@ -667,11 +664,15 @@ else #endif */ - return; + } - - LastButtonPressed = GPIO_Pin; - LastButtonPressedTick = HAL_GetTick(); + if((GPIO_Pin == BUTTON_ENTER_PIN) || (GPIO_Pin == BUTTON_NEXT_PIN) || (GPIO_Pin == BUTTON_BACK_PIN)) + { + LastButtonPressed = GPIO_Pin; + LastButtonPressedTick = HAL_GetTick(); + } + + EvaluateButton(); #ifdef DEMOMODE uint8_t demoMachineCall = 0; @@ -718,7 +719,7 @@ pSettings = settingsGetPointer(); - if(ButtonAction != ACTION_END) + if(action != ACTION_END) { get_globalStateList(&status); @@ -842,7 +843,7 @@ if (GFX_logoStatus() != 0) return; - if ((LastButtonPressed != INVALID_BUTTON) && (time_elapsed_ms(LastButtonPressedTick, HAL_GetTick())) > 50) + if ((LastButtonPressed != INVALID_BUTTON) && (time_elapsed_ms(LastButtonPressedTick, HAL_GetTick()) > 40)) { if (LastButtonPressed == BUTTON_BACK_PIN) { // links if (HAL_GPIO_ReadPin(BUTTON_BACK_GPIO_PORT, BUTTON_BACK_PIN) == 1) {