comparison Discovery/Src/base.c @ 697:d55817a11f4c

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
author Ideenmodellierer
date Sun, 25 Sep 2022 21:09:18 +0200
parents 7a352b449055
children b9f699d2e3d0
comparison
equal deleted inserted replaced
696:cc542448fb28 697:d55817a11f4c
269 269
270 270
271 static uint8_t blBoost = 0; 271 static uint8_t blBoost = 0;
272 static uint8_t RequestModeChange = 0; 272 static uint8_t RequestModeChange = 0;
273 273
274 static uint8_t LastButtonPressed; 274 static uint8_t LastButtonPressed = INVALID_BUTTON;
275 static uint32_t LastButtonPressedTick; 275 static uint32_t LastButtonPressedTick = 0;
276 static uint32_t BaseTick100ms; /* Tick at last 100ms cycle */ 276 static uint32_t BaseTick100ms; /* Tick at last 100ms cycle */
277 277
278 /* SDRAM handler declaration */ 278 /* SDRAM handler declaration */
279 static SDRAM_HandleTypeDef hsdram; 279 static SDRAM_HandleTypeDef hsdram;
280 static FMC_SDRAM_TimingTypeDef SDRAM_Timing; 280 static FMC_SDRAM_TimingTypeDef SDRAM_Timing;
514 } 514 }
515 check_warning(); 515 check_warning();
516 updateMiniLiveLogbook(1); 516 updateMiniLiveLogbook(1);
517 517
518 RefreshDisplay(); 518 RefreshDisplay();
519 DoHousekeeping = 0; /* make sure frames are not cleared before they are transferred */
520 TimeoutControl(); /* exit menus if needed */ 519 TimeoutControl(); /* exit menus if needed */
521 520
522 #ifdef ENABLE_MOTION_CONTROL 521 #ifdef ENABLE_MOTION_CONTROL
523 if((stateUsed->mode == MODE_DIVE) && (settingsGetPointer()->MotionDetection != MOTION_DETECT_OFF)) /* handle motion events in divemode only */ 522 if((stateUsed->mode == MODE_DIVE) && (settingsGetPointer()->MotionDetection != MOTION_DETECT_OFF)) /* handle motion events in divemode only */
524 { 523 {
571 #endif 570 #endif
572 SStateList status; 571 SStateList status;
573 _Bool modeChange = 0; 572 _Bool modeChange = 0;
574 573
575 BaseTick100ms = HAL_GetTick(); /* store start of 100ms cycle */ 574 BaseTick100ms = HAL_GetTick(); /* store start of 100ms cycle */
576
577 EvaluateButton();
578 575
579 if(returnFromCommCleanUpRequest) 576 if(returnFromCommCleanUpRequest)
580 { 577 {
581 tComm_exit(); 578 tComm_exit();
582 returnFromCommCleanUpRequest = 0; 579 returnFromCommCleanUpRequest = 0;
665 if(buttonAction) 662 if(buttonAction)
666 GPIO_Pin = buttonAction; 663 GPIO_Pin = buttonAction;
667 else 664 else
668 #endif 665 #endif
669 */ 666 */
670 return; 667
671 } 668 }
672 669 if((GPIO_Pin == BUTTON_ENTER_PIN) || (GPIO_Pin == BUTTON_NEXT_PIN) || (GPIO_Pin == BUTTON_BACK_PIN))
673 LastButtonPressed = GPIO_Pin; 670 {
674 LastButtonPressedTick = HAL_GetTick(); 671 LastButtonPressed = GPIO_Pin;
672 LastButtonPressedTick = HAL_GetTick();
673 }
674
675 EvaluateButton();
675 676
676 #ifdef DEMOMODE 677 #ifdef DEMOMODE
677 uint8_t demoMachineCall = 0; 678 uint8_t demoMachineCall = 0;
678 if(GPIO_Pin & 0x80) 679 if(GPIO_Pin & 0x80)
679 { 680 {
716 SStateList status; 717 SStateList status;
717 SSettings* pSettings; 718 SSettings* pSettings;
718 pSettings = settingsGetPointer(); 719 pSettings = settingsGetPointer();
719 720
720 721
721 if(ButtonAction != ACTION_END) 722 if(action != ACTION_END)
722 { 723 {
723 get_globalStateList(&status); 724 get_globalStateList(&status);
724 725
725 if (action == ACTION_BUTTON_CUSTOM) { 726 if (action == ACTION_BUTTON_CUSTOM) {
726 GFX_screenshot(); 727 GFX_screenshot();
840 pSettings = settingsGetPointer(); 841 pSettings = settingsGetPointer();
841 842
842 if (GFX_logoStatus() != 0) 843 if (GFX_logoStatus() != 0)
843 return; 844 return;
844 845
845 if ((LastButtonPressed != INVALID_BUTTON) && (time_elapsed_ms(LastButtonPressedTick, HAL_GetTick())) > 50) 846 if ((LastButtonPressed != INVALID_BUTTON) && (time_elapsed_ms(LastButtonPressedTick, HAL_GetTick()) > 40))
846 { 847 {
847 if (LastButtonPressed == BUTTON_BACK_PIN) { // links 848 if (LastButtonPressed == BUTTON_BACK_PIN) { // links
848 if (HAL_GPIO_ReadPin(BUTTON_BACK_GPIO_PORT, BUTTON_BACK_PIN) == 1) { 849 if (HAL_GPIO_ReadPin(BUTTON_BACK_GPIO_PORT, BUTTON_BACK_PIN) == 1) {
849 action = ACTION_BUTTON_BACK; 850 action = ACTION_BUTTON_BACK;
850 } 851 }