diff Discovery/Src/tMenuEditHardware.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 190e5814b2f5
children b392524753fb
line wrap: on
line diff
--- 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;
+}