comparison Discovery/Src/tInfoSensor.c @ 783:c31237d20491

Update digital O2 sensor information: In the previous version only one digital O2 sensor was supported and the additional data could be accessed via a separate menu item. Because of the intraduction of the multiplexer there are three datasets available not. Because of the existing menu structure it was not possible to add additional menu items. To solve the problem the sensor information has been moved beghind the sensor On/Off functionality. When selecting a sensor the sensor data will be shown and the de-/activation of a sensor may be done in scope of the sensor information dialog.
author Ideenmodellierer
date Mon, 29 May 2023 20:26:38 +0200
parents e33d661d1743
children 19ab6f3ed52a
comparison
equal deleted inserted replaced
782:9a1bb9e7cb61 783:c31237d20491
37 37
38 #include <string.h> 38 #include <string.h>
39 #include <inttypes.h> 39 #include <inttypes.h>
40 40
41 extern void openEdit_O2Sensors(void); 41 extern void openEdit_O2Sensors(void);
42 uint8_t OnAction_Sensor (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
42 43
43 /* Private variables ---------------------------------------------------------*/ 44 /* Private variables ---------------------------------------------------------*/
44 45 static uint8_t activeSensorId = 0;
46 static uint8_t sensorActive = 0;
45 /* Exported functions --------------------------------------------------------*/ 47 /* Exported functions --------------------------------------------------------*/
46 void openInfo_Sensor(void) 48 void openInfo_Sensor(uint8_t sensorId)
47 { 49 {
50 SSettings *pSettings = settingsGetPointer();
51 activeSensorId = sensorId;
48 set_globalState(StISENINFO); 52 set_globalState(StISENINFO);
49 setBackMenu((uint32_t)openEdit_O2Sensors,0,6); 53 switch (activeSensorId)
54 {
55 case 3: setBackMenu((uint32_t)openEdit_O2Sensors,0,3);
56 break;
57 case 2: setBackMenu((uint32_t)openEdit_O2Sensors,0,2);
58 break;
59 default:
60 case 1: setBackMenu((uint32_t)openEdit_O2Sensors,0,1);
61 break;
62 }
63
64 sensorActive = 1;
65 if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId - 1)))
66 {
67 sensorActive = 0;
68 }
69 }
70
71
72 uint8_t OnAction_Sensor(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
73 {
74 if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId - 1)))
75 {
76 settingsGetPointer()->ppo2sensors_deactivated &= ~(1 << (activeSensorId - 1));
77 tMenuEdit_set_on_off(editId, 1);
78 }
79 else
80 {
81 settingsGetPointer()->ppo2sensors_deactivated |= (1 << (activeSensorId - 1));
82 tMenuEdit_set_on_off(editId, 0);
83 }
84 return UPDATE_DIVESETTINGS;
50 } 85 }
51 86
52 87
53 88
54 uint64_t mod64(uint64_t a, uint64_t b) 89 uint64_t mod64(uint64_t a, uint64_t b)
71 value /= 10; 106 value /= 10;
72 } 107 }
73 strcpy(pbuf,&tmpBuf[index+1]); 108 strcpy(pbuf,&tmpBuf[index+1]);
74 } 109 }
75 110
76 // =============================================================================== 111 void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode)
77 // refreshInfo_Compass 112 {
78 /// @brief there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode 113 char localtext[32];
79 /// the accel is not called during this process 114
115 if(left2ByteCode)
116 {
117 localtext[0] = TXT_2BYTE;
118 localtext[1] = left2ByteCode;
119 localtext[2] = 0;
120 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
121 }
122
123 if(middle2ByteCode)
124 {
125 localtext[0] = '\001';
126 localtext[1] = TXT_2BYTE;
127 localtext[2] = middle2ByteCode;
128 localtext[3] = 0;
129 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
130 }
131
132 if(right2ByteCode)
133 {
134 localtext[0] = '\002';
135 localtext[1] = TXT_2BYTE;
136 localtext[2] = right2ByteCode;
137 localtext[3] = 0;
138 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
139 }
140 }
141
80 // =============================================================================== 142 // ===============================================================================
81 void refreshInfo_Sensor(GFX_DrawCfgScreen s) 143 void refreshInfo_Sensor(GFX_DrawCfgScreen s)
82 { 144 {
145 const SDiveState *pStateReal = stateRealGetPointer();
83 SSensorDataDiveO2* pDiveO2Data; 146 SSensorDataDiveO2* pDiveO2Data;
84 char text[31]; 147 char text[31];
85 uint8_t strIndex = 0; 148 uint8_t strIndex = 0;
149 char *textPointer = text;
86 150
87 float pressure = 0.0; 151 float pressure = 0.0;
88 152
89 text[0] = '\001'; 153 text[0] = '\001';
90 text[1] = TXT_Sensor; 154 text[1] = TXT_Sensor;
91 text[2] = ' '; 155 text[2] = ' ';
92 text[3] = TXT_Information; 156 text[3] = TXT_Information;
93 text[4] = 0; 157 text[4] = ' ';
158 text[5] = '0' + activeSensorId;
159 text[6] = 0;
94 tInfo_write_content_simple( 30, 340, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); 160 tInfo_write_content_simple( 30, 340, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware);
95 161
96 162 pDiveO2Data = (SSensorDataDiveO2*)&stateRealGetPointer()->lifeData.extIf_sensor_data[activeSensorId-1];
97 pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data;
98 163
99 strIndex = snprintf(text,32,"ID: "); 164 strIndex = snprintf(text,32,"ID: ");
100 if(pDiveO2Data->sensorId != 0) 165 if(pDiveO2Data->sensorId != 0)
101 { 166 {
102 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]); 167 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]);
119 tInfo_write_content_simple( 30, 340, ME_Y_LINE5, &FontT48, text, CLUT_Font020); 184 tInfo_write_content_simple( 30, 340, ME_Y_LINE5, &FontT48, text, CLUT_Font020);
120 #ifdef ENABLE_EXTERNAL_PRESSURE 185 #ifdef ENABLE_EXTERNAL_PRESSURE
121 snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0])); 186 snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0]));
122 tInfo_write_content_simple( 30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020); 187 tInfo_write_content_simple( 30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
123 #endif 188 #endif
189
190 if(sensorActive)
191 {
192 *textPointer++ = '\005';
193 }
194 else
195 {
196 *textPointer++ = '\006';
197 }
198 *textPointer++ = ' ';
199 *textPointer++ = TXT_2BYTE;
200 *textPointer++ = TXT2BYTE_Sensor;
201 *textPointer++ = ' ';
202 *textPointer++ = TXT_2BYTE;
203 *textPointer++ = TXT2BYTE_O2IFDigital;
204 *textPointer++ = '0' + activeSensorId;
205
206 snprintf(textPointer, 20,": %01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[activeSensorId - 1], pStateReal->lifeData.sensorVoltage_mV[activeSensorId - 1]);
207
208 tInfo_write_content_simple( 30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
209
210 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0);
124 } 211 }
125 212
126 void sendActionToInfoSensor(uint8_t sendAction) 213 void sendActionToInfoSensor(uint8_t sendAction)
127 { 214 {
128
129 switch(sendAction) 215 switch(sendAction)
130 { 216 {
131
132 case ACTION_BUTTON_BACK: 217 case ACTION_BUTTON_BACK:
133 exitMenuEdit_to_BackMenu(); 218 exitMenuEdit_to_BackMenu();
134 break; 219 break;
135 220
136 case ACTION_BUTTON_ENTER: 221 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId - 1)))
222 {
223 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId - 1));
224 sensorActive = 1;
225 }
226 else
227 {
228 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId - 1));
229 sensorActive = 0;
230 }
231 break;
137 case ACTION_BUTTON_NEXT: 232 case ACTION_BUTTON_NEXT:
138 case ACTION_TIMEOUT: 233 case ACTION_TIMEOUT:
139 case ACTION_MODE_CHANGE: 234 case ACTION_MODE_CHANGE:
140 case ACTION_IDLE_TICK: 235 case ACTION_IDLE_TICK:
141 case ACTION_IDLE_SECOND: 236 case ACTION_IDLE_SECOND: