comparison Discovery/Src/base.c @ 740:5078da3845c0

Added button lock after wakeup in surface mode: During setup of diveequipment the OSTC4 is sometimes operated unintended (e.g. while equipping the jaket). To avoid this it is now possible to activate a button lock in the button lock sensitivity menu. The OSTC4 will then wakeup as usuall but if the diver wants to oerate the menus he has to press the buttons in a certain order. The button to be pressed is indicated by a blue bar. The button lock is deactivated in dive mode.
author Ideenmodellierer
date Thu, 02 Feb 2023 17:35:38 +0100
parents b9f699d2e3d0
children b392524753fb
comparison
equal deleted inserted replaced
739:4a6bffaa38b3 740:5078da3845c0
291 static uint32_t time_without_button_pressed_deciseconds = 0; /**< langbeschreibung (eigenes Feld) warum diese variable verwendet wird um den sleepmode zu aktivieren */ 291 static uint32_t time_without_button_pressed_deciseconds = 0; /**< langbeschreibung (eigenes Feld) warum diese variable verwendet wird um den sleepmode zu aktivieren */
292 uint8_t bootToBootloader = 0; ///< set in tComm.c to install firmware updates, calls resetToFirmwareUpdate() 292 uint8_t bootToBootloader = 0; ///< set in tComm.c to install firmware updates, calls resetToFirmwareUpdate()
293 static uint8_t returnFromCommCleanUpRequest = 0; ///< use this to exit bluetooth mode and call tComm_exit() 293 static uint8_t returnFromCommCleanUpRequest = 0; ///< use this to exit bluetooth mode and call tComm_exit()
294 uint32_t base_tempLightLevel = 0; 294 uint32_t base_tempLightLevel = 0;
295 static uint8_t wasFirmwareUpdateCheckBattery = 0; 295 static uint8_t wasFirmwareUpdateCheckBattery = 0;
296 static uint8_t DoDisplayRefresh = 0; /* trigger to refresh display data */ 296 static uint8_t DoDisplayRefresh = 0; /* trigger to refresh display data */
297 static uint8_t DoHousekeeping = 0; /* trigger to cleanup the frame buffers */ 297 static uint8_t DoHousekeeping = 0; /* trigger to cleanup the frame buffers */
298 static SButtonLock ButtonLockState = LOCK_OFF; /* Used for button unlock sequence */
299
298 300
299 /* Private function prototypes -----------------------------------------------*/ 301 /* Private function prototypes -----------------------------------------------*/
300 static void SystemClock_Config(void); 302 static void SystemClock_Config(void);
301 static void Error_Handler(void); 303 static void Error_Handler(void);
302 static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command); 304 static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command);
307 static uint32_t TIM_BACKLIGHT_adjust(void); 309 static uint32_t TIM_BACKLIGHT_adjust(void);
308 static void gotoSleep(void); 310 static void gotoSleep(void);
309 static void deco_loop(void); 311 static void deco_loop(void);
310 static void resetToFirmwareUpdate(void); 312 static void resetToFirmwareUpdate(void);
311 static void TriggerButtonAction(void); 313 static void TriggerButtonAction(void);
314 static void TriggerButtonUnlock(void);
312 static void EvaluateButton(void); 315 static void EvaluateButton(void);
313 static void RefreshDisplay(void); 316 static void RefreshDisplay(void);
314 static void TimeoutControlRequestModechange(void); 317 static void TimeoutControlRequestModechange(void);
315 static void TimeoutControl(void); 318 static void TimeoutControl(void);
316 319
466 } 469 }
467 InitMotionDetection(); 470 InitMotionDetection();
468 471
469 TIM_init(); /* start cylic 100ms task */ 472 TIM_init(); /* start cylic 100ms task */
470 473
474 if( settingsGetPointer()->buttonLockActive )
475 {
476 ButtonLockState = LOCK_FIRST_PRESS;
477 }
478
471 /* @brief main LOOP 479 /* @brief main LOOP
472 * 480 *
473 * this is executed while no IRQ interrupts it 481 * this is executed while no IRQ interrupts it
474 * - deco calculation 482 * - deco calculation
475 * - bluetooth 483 * - bluetooth
497 } 505 }
498 506
499 DataEX_merge_devicedata(); /* data is exchanged at startup and every 10 minutes => check if something changed */ 507 DataEX_merge_devicedata(); /* data is exchanged at startup and every 10 minutes => check if something changed */
500 508
501 deco_loop(); 509 deco_loop();
502 TriggerButtonAction(); 510 if((ButtonLockState) && (stateUsed->mode == MODE_SURFACE))
511 {
512 TriggerButtonUnlock();
513 }
514 else
515 {
516 TriggerButtonAction();
517 }
503 if(DoHousekeeping) 518 if(DoHousekeeping)
504 { 519 {
505 DoHousekeeping = housekeepingFrame(); 520 DoHousekeeping = housekeepingFrame();
506 } 521 }
507 if(DoDisplayRefresh) /* set every 100ms by timer interrupt */ 522 if(DoDisplayRefresh) /* set every 100ms by timer interrupt */
709 tHome_sleepmode_fun(); 724 tHome_sleepmode_fun();
710 break; 725 break;
711 } 726 }
712 } 727 }
713 728
729 static void TriggerButtonUnlock()
730 {
731 static uint32_t lastInput = 0;
732 uint8_t action = ButtonAction;
733 SStateList status;
734 SSettings* pSettings;
735 pSettings = settingsGetPointer();
736
737 if(action != ACTION_END)
738 {
739 if(((time_elapsed_ms(lastInput, HAL_GetTick()) < 2000)) || (ButtonLockState == LOCK_FIRST_PRESS))
740 {
741 switch(ButtonLockState)
742 {
743 case LOCK_FIRST_PRESS:
744 case LOCK_1: if(action == ACTION_BUTTON_ENTER)
745 {
746 ButtonLockState = LOCK_2;
747 }
748 else
749 {
750 ButtonLockState = LOCK_1;
751 }
752 break;
753 case LOCK_2: if(action == ACTION_BUTTON_NEXT)
754 {
755 ButtonLockState = LOCK_3;
756 }
757 else
758 {
759 ButtonLockState = LOCK_1;
760 }
761 break;
762 case LOCK_3: if(action == ACTION_BUTTON_BACK)
763 {
764 ButtonLockState = LOCK_OFF;
765 }
766 else
767 {
768 ButtonLockState = LOCK_1;
769 }
770 break;
771
772 default: ButtonLockState = LOCK_OFF;
773 break;
774 }
775 }
776 else
777 {
778 ButtonLockState = LOCK_1;
779 }
780 lastInput = LastButtonPressedTick;
781 ButtonAction = ACTION_END;
782 }
783 }
714 784
715 static void TriggerButtonAction() 785 static void TriggerButtonAction()
716 { 786 {
717 uint8_t action = ButtonAction; 787 uint8_t action = ButtonAction;
718 SStateList status; 788 SStateList status;
770 } 840 }
771 } else if ((status.page == PageDive) && (status.line != 0)) 841 } else if ((status.page == PageDive) && (status.line != 0))
772 { 842 {
773 if(get_globalState() == StDMENU) 843 if(get_globalState() == StDMENU)
774 { 844 {
775 if (pSettings->extraDisplay == EXTRADISPLAY_BIGFONT) 845 if ((pSettings->extraDisplay == EXTRADISPLAY_BIGFONT) || (pSettings->extraDisplay == EXTRADISPLAY_BFACTIVE))
776 { 846 {
777 pSettings->design = 3; 847 pSettings->design = 3;
778 if(pSettings->MotionDetection == MOTION_DETECT_SECTOR) 848 if(pSettings->MotionDetection == MOTION_DETECT_SECTOR)
779 { 849 {
780 DefineSectorCount(CUSTOMER_DEFINED_VIEWS); 850 DefineSectorCount(CUSTOMER_DEFINED_VIEWS);
781 MapCVToSector(); 851 MapCVToSector();
782 } 852 }
783 } 853 }
854 #ifdef HAVEDECOGAME
784 else if (pSettings->extraDisplay == EXTRADISPLAY_DECOGAME) 855 else if (pSettings->extraDisplay == EXTRADISPLAY_DECOGAME)
785 pSettings->design = 4; 856 pSettings->design = 4;
857 #endif
786 } 858 }
787 set_globalState(StD); 859 set_globalState(StD);
788 } 860 }
789 else 861 else
790 { 862 {
958 output->line = (uint8_t)((id >> 16) & 0xFF); 1030 output->line = (uint8_t)((id >> 16) & 0xFF);
959 output->field = (uint8_t)((id >> 8) & 0xFF); 1031 output->field = (uint8_t)((id >> 8) & 0xFF);
960 output->mode = (uint8_t)((id ) & 0xFF); 1032 output->mode = (uint8_t)((id ) & 0xFF);
961 } 1033 }
962 1034
1035 SButtonLock get_ButtonLock(void)
1036 {
1037 return ButtonLockState;
1038 }
963 1039
964 void set_globalState_Menu_Page(uint8_t page) 1040 void set_globalState_Menu_Page(uint8_t page)
965 { 1041 {
966 globalStateID = ((BaseMenu << 28) + (page << 24)); 1042 globalStateID = ((BaseMenu << 28) + (page << 24));
967 } 1043 }