changeset 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 4a6bffaa38b3
children 6a35e2e97bfb
files Discovery/Inc/base.h Discovery/Inc/tHome.h Discovery/Inc/tStructure.h Discovery/Inc/text_multilanguage.h Discovery/Src/base.c Discovery/Src/settings.c Discovery/Src/t7.c Discovery/Src/tMenuEditHardware.c Discovery/Src/text_multilanguage.c
diffstat 9 files changed, 183 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/Discovery/Inc/base.h	Thu Feb 02 17:26:54 2023 +0100
+++ b/Discovery/Inc/base.h	Thu Feb 02 17:35:38 2023 +0100
@@ -91,6 +91,16 @@
 	ACTION_END
 } SAction;
 
+typedef enum
+{
+	LOCK_OFF = 0,
+	LOCK_FIRST_PRESS,
+	LOCK_1,
+	LOCK_2,
+	LOCK_3,
+	LOCK_UNLOCKED
+} SButtonLock;
+
 /* Exported macro ------------------------------------------------------------*/
 /* Exported functions ------------------------------------------------------- */
 
@@ -110,6 +120,7 @@
 uint8_t font_update_required(void);
 void set_Backlight_Boost(uint8_t level);
 void StoreButtonAction(uint8_t action);
+SButtonLock get_ButtonLock(void);
 
 #endif /* BASE_H */
 
--- a/Discovery/Inc/tHome.h	Thu Feb 02 17:26:54 2023 +0100
+++ b/Discovery/Inc/tHome.h	Thu Feb 02 17:35:38 2023 +0100
@@ -53,7 +53,10 @@
 {
 		EXTRADISPLAY_none = 0,
 		EXTRADISPLAY_BIGFONT,
+		EXTRADISPLAY_BFACTIVE,
+#ifdef HAVEDECOGAME
 		EXTRADISPLAY_DECOGAME,
+#endif
 		EXTRADISPLAY_END
 };
 
--- a/Discovery/Inc/tStructure.h	Thu Feb 02 17:26:54 2023 +0100
+++ b/Discovery/Inc/tStructure.h	Thu Feb 02 17:35:38 2023 +0100
@@ -284,6 +284,7 @@
 #define StMHARD5_ButtonBalance1	_MB(2,7,5,2,0)
 #define StMHARD5_ButtonBalance2	_MB(2,7,5,3,0)
 #define StMHARD5_ButtonBalance3	_MB(2,7,5,4,0)
+#define StMHARD5_ButtonLock		_MB(2,7,5,5,0)
 
 //#define StMHARD6_UpdateCPU2_No	_MB(2,7,6,1,0)
 //#define StMHARD6_UpdateCPU2_Yes	_MB(2,7,6,2,0)
--- a/Discovery/Inc/text_multilanguage.h	Thu Feb 02 17:26:54 2023 +0100
+++ b/Discovery/Inc/text_multilanguage.h	Thu Feb 02 17:35:38 2023 +0100
@@ -147,6 +147,7 @@
 		TXT_PSCRLungRatio,
 		TXT_SimPpo2,
 		TXT_CO2Sensor,
+		TXT_ButtonLock,
 		/* */
 		TXT_END,
 
@@ -299,6 +300,7 @@
 		TXT2BYTE_ExtraBigFontV2,
 		TXT2BYTE_ExtraDecoGame,
 		TXT2BYTE_ExtraNone,
+		TXT2BYTE_ExtraActive,
 		/* */
 		TXT2BYTE_MotionCtrl,
 		TXT2BYTE_MoCtrlNone,
--- a/Discovery/Src/base.c	Thu Feb 02 17:26:54 2023 +0100
+++ b/Discovery/Src/base.c	Thu Feb 02 17:35:38 2023 +0100
@@ -293,8 +293,10 @@
 static uint8_t returnFromCommCleanUpRequest = 0; ///< use this to exit bluetooth mode and call tComm_exit()
 uint32_t base_tempLightLevel = 0;
 static uint8_t	wasFirmwareUpdateCheckBattery = 0;
-static uint8_t DoDisplayRefresh = 0;	/* trigger to refresh display data */
-static uint8_t DoHousekeeping = 0;		/* trigger to cleanup the frame buffers */
+static uint8_t DoDisplayRefresh = 0;			/* trigger to refresh display data */
+static uint8_t DoHousekeeping = 0;				/* trigger to cleanup the frame buffers */
+static SButtonLock ButtonLockState = LOCK_OFF;  /* Used for button unlock sequence */
+
 
 /* Private function prototypes -----------------------------------------------*/
 static void SystemClock_Config(void);
@@ -309,6 +311,7 @@
 static void deco_loop(void);
 static void resetToFirmwareUpdate(void);
 static void TriggerButtonAction(void);
+static void TriggerButtonUnlock(void);
 static void EvaluateButton(void);
 static void RefreshDisplay(void);
 static void TimeoutControlRequestModechange(void);
@@ -468,6 +471,11 @@
 
     TIM_init();		/* start cylic 100ms task */
 
+    if( settingsGetPointer()->buttonLockActive )
+    {
+    	ButtonLockState = LOCK_FIRST_PRESS;
+    }
+
     /* @brief main LOOP
      *
      * this is executed while no IRQ interrupts it
@@ -499,7 +507,14 @@
         DataEX_merge_devicedata(); 	/* data is exchanged at startup and every 10 minutes => check if something changed */
 
         deco_loop();
-        TriggerButtonAction();
+        if((ButtonLockState) && (stateUsed->mode == MODE_SURFACE))
+        {
+        	TriggerButtonUnlock();
+        }
+        else
+        {
+        	TriggerButtonAction();
+        }
         if(DoHousekeeping)
         {
            	DoHousekeeping = housekeepingFrame();
@@ -711,6 +726,61 @@
 	}
 }
 
+static void TriggerButtonUnlock()
+{
+	static uint32_t lastInput = 0;
+	uint8_t action = ButtonAction;
+	SStateList status;
+	SSettings* pSettings;
+	pSettings = settingsGetPointer();
+
+	if(action != ACTION_END)
+	{
+		if(((time_elapsed_ms(lastInput, HAL_GetTick()) < 2000)) || (ButtonLockState == LOCK_FIRST_PRESS))
+		{
+			switch(ButtonLockState)
+			{
+				case LOCK_FIRST_PRESS:
+				case LOCK_1:	if(action == ACTION_BUTTON_ENTER)
+								{
+									ButtonLockState = LOCK_2;
+								}
+								else
+								{
+									ButtonLockState = LOCK_1;
+								}
+					break;
+				case LOCK_2:	if(action == ACTION_BUTTON_NEXT)
+								{
+									ButtonLockState = LOCK_3;
+								}
+								else
+								{
+									ButtonLockState = LOCK_1;
+								}
+					break;
+				case LOCK_3:	if(action == ACTION_BUTTON_BACK)
+								{
+									ButtonLockState = LOCK_OFF;
+								}
+								else
+								{
+									ButtonLockState = LOCK_1;
+								}
+					break;
+
+				default:	ButtonLockState = LOCK_OFF;
+					break;
+			}
+		}
+		else
+		{
+			ButtonLockState = LOCK_1;
+		}
+		lastInput = LastButtonPressedTick;
+		ButtonAction = ACTION_END;
+	}
+}
 
 static void TriggerButtonAction()
 {
@@ -772,7 +842,7 @@
 				{
 					if(get_globalState() == StDMENU)
 					{
-						if (pSettings->extraDisplay == EXTRADISPLAY_BIGFONT)
+						if ((pSettings->extraDisplay == EXTRADISPLAY_BIGFONT) || (pSettings->extraDisplay == EXTRADISPLAY_BFACTIVE))
 						{
 							pSettings->design = 3;
 							if(pSettings->MotionDetection == MOTION_DETECT_SECTOR)
@@ -781,8 +851,10 @@
 								MapCVToSector();
 							}
 						}
+#ifdef HAVEDECOGAME
 						else if (pSettings->extraDisplay	== EXTRADISPLAY_DECOGAME)
 							pSettings->design = 4;
+#endif
 					}
 					set_globalState(StD);
 				}
@@ -960,6 +1032,10 @@
     output->mode  = (uint8_t)((id     ) & 0xFF);
 }
 
+SButtonLock get_ButtonLock(void)
+{
+	return ButtonLockState;
+}
 
 void set_globalState_Menu_Page(uint8_t page)
 {
--- a/Discovery/Src/settings.c	Thu Feb 02 17:26:54 2023 +0100
+++ b/Discovery/Src/settings.c	Thu Feb 02 17:35:38 2023 +0100
@@ -87,7 +87,7 @@
  * There might even be entries with fixed values that have no range
  */
 const SSettings SettingsStandard = {
-    .header = 0xFFFF0024,
+    .header = 0xFFFF0025,
     .warning_blink_dsec = 8 * 2,
     .lastDiveLogId = 0,
     .logFlashNextSampleStartAddress = SAMPLESTART,
@@ -330,6 +330,7 @@
 	.ext_sensor_map[2] = SENSOR_OPTIC,
 	.ext_sensor_map[3] = SENSOR_NONE,
 	.ext_sensor_map[4] = SENSOR_NONE,
+	.buttonLockActive = 0
 };
 
 /* Private function prototypes -----------------------------------------------*/
@@ -529,6 +530,8 @@
     				 pSettings->ext_sensor_map[3] = SENSOR_NONE;
     				 pSettings->ext_sensor_map[4] = SENSOR_NONE;
     	// no break;
+    case 0xFFFF0024: pSettings->buttonLockActive = 0;
+    	// no break;
     default:
         pSettings->header = pStandard->header;
         break; // no break before!!
@@ -1547,6 +1550,12 @@
        	corrections++;
     }
 
+    if(Settings.buttonLockActive > 1)
+    {
+        Settings.buttonLockActive = 1;
+        corrections++;
+    }
+
     if(corrections)
     {
     	settingsWarning = 1;
--- a/Discovery/Src/t7.c	Thu Feb 02 17:26:54 2023 +0100
+++ b/Discovery/Src/t7.c	Thu Feb 02 17:35:38 2023 +0100
@@ -44,6 +44,7 @@
 #include "unit.h"
 #include "motion.h"
 #include "configuration.h"
+#include "base.h"
 
 /* Private function prototypes -----------------------------------------------*/
 
@@ -697,6 +698,7 @@
     uint8_t date[3], year,month,day;
     uint32_t color;
     uint8_t  customview_warnings = 0;
+    SButtonLock ButtonLockState;
 
     RTC_DateTypeDef Sdate;
     RTC_TimeTypeDef Stime;
@@ -721,23 +723,41 @@
         updateNecessary = 0;
 
     /* buttons */
-    text[0] = TXT_2BYTE;
-    text[1] = TXT2BYTE_ButtonLogbook;
-    text[2] = 0;
-    write_content_simple(&t7screen, 0, 799, 479-TOP_LINE_HIGHT, &FontT24,text,CLUT_ButtonSurfaceScreen);
-
-    text[0] = '\001';
-    text[1] = TXT_2BYTE;
-    text[2] = TXT2BYTE_ButtonView;
-    text[3] = 0;
-    write_content_simple(&t7screen, 0, 799, 479-TOP_LINE_HIGHT, &FontT24,text,CLUT_ButtonSurfaceScreen);
-
-    text[0] = '\002';
-    text[1] = TXT_2BYTE;
-    text[2] = TXT2BYTE_ButtonMenu;
-    text[3] = 0;
-    write_content_simple(&t7screen, 0, 799, 479-TOP_LINE_HIGHT, &FontT24,text,CLUT_ButtonSurfaceScreen);
-
+    ButtonLockState = get_ButtonLock();
+    if(ButtonLockState == LOCK_OFF)
+    {
+		text[0] = TXT_2BYTE;
+		text[1] = TXT2BYTE_ButtonLogbook;
+		text[2] = 0;
+		write_content_simple(&t7screen, 0, 799, 479-TOP_LINE_HIGHT, &FontT24,text,CLUT_ButtonSurfaceScreen);
+
+		text[0] = '\001';
+		text[1] = TXT_2BYTE;
+		text[2] = TXT2BYTE_ButtonView;
+		text[3] = 0;
+		write_content_simple(&t7screen, 0, 799, 479-TOP_LINE_HIGHT, &FontT24,text,CLUT_ButtonSurfaceScreen);
+
+		text[0] = '\002';
+		text[1] = TXT_2BYTE;
+		text[2] = TXT2BYTE_ButtonMenu;
+		text[3] = 0;
+		write_content_simple(&t7screen, 0, 799, 479-TOP_LINE_HIGHT, &FontT24,text,CLUT_ButtonSurfaceScreen);
+    }
+    else
+    {
+    	switch(ButtonLockState)
+    	{
+    		default:
+    		case LOCK_1:  	snprintf(text,255,"\a\001          ");
+    			break;
+    		case LOCK_2:  	snprintf(text,255,"\a\002          ");
+    			break;
+    		case LOCK_3:  	snprintf(text,255,"\a          ");
+    			break;
+    	}
+    	write_content_simple(&t7screen, 0, 799, 479-TOP_LINE_HIGHT, &FontT24,text,CLUT_ButtonSurfaceScreen);
+    	      //  GFX_write_string_color(&FontT48,&t7c2,TextR1,0,CLUT_WarningYellow);
+    }
     /* was power on reset */
 //.....
 /* removed hw 160802 in V1.1.1
--- a/Discovery/Src/tMenuEditHardware.c	Thu Feb 02 17:26:54 2023 +0100
+++ b/Discovery/Src/tMenuEditHardware.c	Thu Feb 02 17:35:38 2023 +0100
@@ -67,6 +67,7 @@
 uint8_t OnAction_Sensor_Detect	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_Button			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_ButtonBalance	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+uint8_t OnAction_ButtonLock		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 // not required uint8_t OnAction_Bluetooth				(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 
 /* Exported functions --------------------------------------------------------*/
@@ -872,6 +873,8 @@
         write_field_button(eventListButtonBalance[i],360,500,ME_Y_LINE4-(i*ME_Y_LINE_STEP),&FontT48,text);
     }
 
+    snprintf(text,32,"%c",TXT_ButtonLock);
+    write_field_on_off(StMHARD5_ButtonLock,	 30, 95, ME_Y_LINE5,  &FontT48, text, settingsGetPointer()->buttonLockActive);
 
     setEvent(StMHARD5_Button1, (uint32_t)OnAction_Button);
 
@@ -879,7 +882,7 @@
     {
         setEvent(eventListButtonBalance[i], (uint32_t)OnAction_ButtonBalance);
     }
-
+    setEvent(StMHARD5_ButtonLock, (uint32_t)OnAction_ButtonLock);
     write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
 }
 
@@ -897,12 +900,6 @@
 
     write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
 
-    text[0] = '\020'; // '\031';
-    text[1] = TXT_2BYTE;
-    text[2] = TXT2BYTE_LowerIsLess;
-    text[3] = 0;
-    write_label_var(  20, 780, ME_Y_LINE5, &FontT42, text);
-
     for(int i=0;i<3;i++)
     {
         text[0] = TXT_2BYTE;
@@ -915,13 +912,14 @@
     {
         sens[i] = settingsHelperButtonSens_translate_hwOS_values_to_percentage(stateRealGetPointer()->lifeData.buttonPICdata[i]);
     }
-    snprintf(text,64,"(%03u  %03u  %03u)",sens[2],sens[1],sens[0]);
+    snprintf(text,64,"\020\016\016%c%c \017 (%03u  %03u  %03u)",TXT_2BYTE,TXT2BYTE_LowerIsLess,sens[2],sens[1],sens[0]);
     write_label_var(  20, 340, ME_Y_LINE6, &FontT42, text);
 
     tMenuEdit_refresh_field(StMHARD5_Button1);
     tMenuEdit_refresh_field(StMHARD5_ButtonBalance1);
     tMenuEdit_refresh_field(StMHARD5_ButtonBalance2);
     tMenuEdit_refresh_field(StMHARD5_ButtonBalance3);
+    tMenuEdit_refresh_field(StMHARD5_ButtonLock);
 }
 
 
@@ -1007,3 +1005,21 @@
 
     return UNSPECIFIC_RETURN;
 }
+
+uint8_t OnAction_ButtonLock(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+{
+	SSettings *pSettings = settingsGetPointer();
+
+    if(pSettings->buttonLockActive)
+    {
+    	pSettings->buttonLockActive = 0;
+        tMenuEdit_set_on_off(editId, 0);
+    }
+    else
+    {
+    	pSettings->buttonLockActive = 1;
+        tMenuEdit_set_on_off(editId, 1);
+    }
+
+    return UNSPECIFIC_RETURN;
+}
--- a/Discovery/Src/text_multilanguage.c	Thu Feb 02 17:26:54 2023 +0100
+++ b/Discovery/Src/text_multilanguage.c	Thu Feb 02 17:35:38 2023 +0100
@@ -1340,12 +1340,18 @@
 static uint8_t text_ES_ExtraDisplay[] = "Letras grandes";
 
 // Menu SYS2
-static uint8_t text_EN_ExtraBigFont[] = "yes";
-static uint8_t text_DE_ExtraBigFont[] = "ja";
+static uint8_t text_EN_ExtraBigFont[] = "Optional";
+static uint8_t text_DE_ExtraBigFont[] = "Optional";
 static uint8_t text_FR_ExtraBigFont[] = "si";
 static uint8_t text_IT_ExtraBigFont[] = "si";
 static uint8_t text_ES_ExtraBigFont[] = "si";
 
+static uint8_t text_EN_ExtraBFActive[] = "Start screen";
+static uint8_t text_DE_ExtraBFActive[] = "Start Bildschirm";
+static uint8_t text_FR_ExtraBFActive[] = "";
+static uint8_t text_IT_ExtraBFActive[] = "";
+static uint8_t text_ES_ExtraBFActive[] = "";
+
 // Menu SYS2 (future feature)
 static uint8_t text_EN_ExtraDecoGame[] = "Deco game";
 static uint8_t text_DE_ExtraDecoGame[] = "Deko-Spiel";
@@ -1753,6 +1759,11 @@
 static uint8_t text_IT_CO2Sensor[] = "CO2 Sensor";
 static uint8_t text_ES_CO2Sensor[] = "CO2 Sensor";
 
+static uint8_t text_EN_KeyLock[] = "Key lock";
+static uint8_t text_DE_KeyLock[] = "Tastensperre";
+static uint8_t text_FR_KeyLock[] = "";
+static uint8_t text_IT_KeyLock[] = "";
+static uint8_t text_ES_KeyLock[] = "";
 
 /* Lookup Table -------------------------------------------------------------*/
 
@@ -1843,6 +1854,7 @@
 	{(uint8_t)TXT_PSCRLungRatio,	{text_EN_LungRatio, text_DE_LungRatio, text_FR_LungRatio, text_IT_LungRatio, text_ES_LungRatio}},
 	{(uint8_t)TXT_SimPpo2,			{text_EN_SimPpo2, text_DE_SimPpo2, text_FR_SimPpo2, text_IT_SimPpo2, text_ES_SimPpo2}},
 	{(uint8_t)TXT_CO2Sensor,		{text_EN_CO2Sensor, text_DE_CO2Sensor, text_FR_CO2Sensor, text_IT_CO2Sensor, text_ES_CO2Sensor}},
+	{(uint8_t)TXT_ButtonLock,			{text_EN_KeyLock, text_DE_KeyLock, text_FR_KeyLock, text_IT_KeyLock, text_ES_KeyLock}},
 };
 
 const tText text_array2[] =
@@ -1970,6 +1982,7 @@
     {(uint8_t)TXT2BYTE_ExtraBigFont,	{text_EN_ExtraBigFont, text_DE_ExtraBigFont, text_FR_ExtraBigFont, text_IT_ExtraBigFont, text_ES_ExtraBigFont}},
     {(uint8_t)TXT2BYTE_ExtraDecoGame,	{text_EN_ExtraDecoGame, text_DE_ExtraDecoGame, text_FR_ExtraDecoGame, text_IT_ExtraDecoGame, text_ES_ExtraDecoGame}},
     {(uint8_t)TXT2BYTE_ExtraNone,		{text_EN_ExtraNone, text_DE_ExtraNone, text_FR_ExtraNone, text_IT_ExtraNone, text_ES_ExtraNone}},
+	{(uint8_t)TXT2BYTE_ExtraActive,		{text_EN_ExtraBFActive, text_DE_ExtraBFActive, text_FR_ExtraBFActive, text_IT_ExtraBFActive, text_ES_ExtraBFActive}},
 	{(uint8_t)TXT2BYTE_MotionCtrl,		{text_EN_MotionCtrl, text_DE_MotionCtrl, text_FR_MotionCtrl, text_IT_MotionCtrl, text_ES_MotionCtrl}},
 	{(uint8_t)TXT2BYTE_MoCtrlNone,		{text_EN_MoCtrlNone, text_DE_MoCtrlNone, text_FR_MoCtrlNone, text_IT_MoCtrlNone, text_ES_MoCtrlNone}},
 	{(uint8_t)TXT2BYTE_MoCtrlPitch,		{text_EN_MoCtrlPitch, text_DE_MoCtrlPitch, text_FR_MoCtrlPitch, text_IT_MoCtrlPitch, text_ES_MoCtrlPitch}},