Mercurial > public > ostc4
comparison Discovery/Src/tInfoSensor.c @ 827:ffb1036c27c2 Evo_2_23
Moved CO2 Menu from Xtra to Hardware:
The first CO2 sensor menu implementation was placed within the Xtra menu. In the new version the CO2 options may be accessed using the sensor overview menu of the Hardware page. With this change it is no longer necessary to take care for compile switches in the menus because the menu will only be shown if a CO2 sensor is detected.
author | Ideenmodellierer |
---|---|
date | Sun, 05 Nov 2023 20:19:08 +0100 |
parents | a370741a743b |
children | 17d9d6eddd8d |
comparison
equal
deleted
inserted
replaced
826:a370741a743b | 827:ffb1036c27c2 |
---|---|
32 #include "gfx_fonts.h" | 32 #include "gfx_fonts.h" |
33 #include "tHome.h" | 33 #include "tHome.h" |
34 #include "tInfo.h" | 34 #include "tInfo.h" |
35 #include "tInfoSensor.h" | 35 #include "tInfoSensor.h" |
36 #include "tMenuEdit.h" | 36 #include "tMenuEdit.h" |
37 #include "data_exchange_main.h" | |
37 | 38 |
38 #include <string.h> | 39 #include <string.h> |
39 #include <inttypes.h> | 40 #include <inttypes.h> |
40 | 41 |
41 extern void openEdit_O2Sensors(void); | 42 extern void openEdit_O2Sensors(void); |
137 localtext[3] = 0; | 138 localtext[3] = 0; |
138 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | 139 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); |
139 } | 140 } |
140 } | 141 } |
141 | 142 |
142 // =============================================================================== | 143 static void refreshInfo_SensorO2(GFX_DrawCfgScreen s) |
143 void refreshInfo_Sensor(GFX_DrawCfgScreen s) | |
144 { | 144 { |
145 const SDiveState *pStateReal = stateRealGetPointer(); | 145 const SDiveState *pStateReal = stateRealGetPointer(); |
146 SSensorDataDiveO2* pDiveO2Data; | 146 SSensorDataDiveO2* pDiveO2Data; |
147 char text[31]; | 147 char text[31]; |
148 uint8_t strIndex = 0; | 148 uint8_t strIndex = 0; |
149 char *textPointer = text; | 149 char *textPointer = text; |
150 | 150 |
151 float pressure = 0.0; | 151 float pressure = 0.0; |
152 | |
153 pDiveO2Data = (SSensorDataDiveO2*)pStateReal->lifeData.extIf_sensor_data[activeSensorId]; | |
154 strIndex = snprintf(text,32,"ID: "); | |
155 if(pDiveO2Data->sensorId != 0) | |
156 { | |
157 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]); | |
158 } | |
159 tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020); | |
160 snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0); | |
161 tInfo_write_content_simple( 30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020); | |
162 | |
163 #ifdef ENABLE_EXTERNAL_PRESSURE | |
164 pressure = (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[2]); | |
165 #else | |
166 pressure = (float)pDiveO2Data->pressure / 1000.0; | |
167 #endif | |
168 snprintf(text,32,"Druck: %02.1f (%02.1f)", (float)pDiveO2Data->pressure / 1000.0, pressure *1000.0); | |
169 | |
170 tInfo_write_content_simple( 30, 770, ME_Y_LINE3, &FontT48, text, CLUT_Font020); | |
171 snprintf(text,32,"Feuchtigkeit: %02.1f", (float)pDiveO2Data->humidity / 1000.0); | |
172 tInfo_write_content_simple( 30, 770, ME_Y_LINE4, &FontT48, text, CLUT_Font020); | |
173 snprintf(text,32,"Status: 0x%lx", pDiveO2Data->status); | |
174 tInfo_write_content_simple( 30, 770, ME_Y_LINE5, &FontT48, text, CLUT_Font020); | |
175 #ifdef ENABLE_EXTERNAL_PRESSURE | |
176 snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0])); | |
177 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020); | |
178 #endif | |
179 | |
180 if(sensorActive) | |
181 { | |
182 *textPointer++ = '\005'; | |
183 } | |
184 else | |
185 { | |
186 *textPointer++ = '\006'; | |
187 } | |
188 *textPointer++ = ' '; | |
189 *textPointer++ = TXT_2BYTE; | |
190 *textPointer++ = TXT2BYTE_Sensor; | |
191 *textPointer++ = ' '; | |
192 *textPointer++ = TXT_2BYTE; | |
193 *textPointer++ = TXT2BYTE_O2IFDigital; | |
194 *textPointer++ = '1' + activeSensorId; | |
195 | |
196 snprintf(textPointer, 20,": %01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[activeSensorId], pStateReal->lifeData.sensorVoltage_mV[activeSensorId]); | |
197 | |
198 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020); | |
199 | |
200 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0); | |
201 } | |
202 | |
203 static void refreshInfo_SensorCo2(GFX_DrawCfgScreen s) | |
204 { | |
205 const SDiveState *pStateReal = stateRealGetPointer(); | |
206 char text[31]; | |
207 char *textPointer = text; | |
208 | |
209 snprintf(text,32,"CO2: %ld ppm",pStateReal->lifeData.CO2_data.CO2_ppm); | |
210 tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020); | |
211 | |
212 | |
213 snprintf(text,32,"Signal: %d",pStateReal->lifeData.CO2_data.signalStrength); | |
214 tInfo_write_content_simple( 30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020); | |
215 | |
216 if(sensorActive) | |
217 { | |
218 *textPointer++ = '\005'; | |
219 } | |
220 else | |
221 { | |
222 *textPointer++ = '\006'; | |
223 } | |
224 *textPointer++ = ' '; | |
225 *textPointer++ = TXT_2BYTE; | |
226 *textPointer++ = TXT2BYTE_Sensor; | |
227 *textPointer++ = ' '; | |
228 *textPointer++ = 'C'; | |
229 *textPointer++ = 'o'; | |
230 *textPointer++ = '1' + activeSensorId; | |
231 | |
232 snprintf(textPointer, 20,": %ld ppm", pStateReal->lifeData.CO2_data.CO2_ppm); | |
233 | |
234 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020); | |
235 | |
236 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_O2Calib); | |
237 } | |
238 // =============================================================================== | |
239 void refreshInfo_Sensor(GFX_DrawCfgScreen s) | |
240 { | |
241 const SDiveState *pStateReal = stateRealGetPointer(); | |
242 | |
243 char text[31]; | |
152 | 244 |
153 text[0] = '\001'; | 245 text[0] = '\001'; |
154 text[1] = TXT_Sensor; | 246 text[1] = TXT_Sensor; |
155 text[2] = ' '; | 247 text[2] = ' '; |
156 text[3] = TXT_Information; | 248 text[3] = TXT_Information; |
157 text[4] = ' '; | 249 text[4] = ' '; |
158 text[5] = '1' + activeSensorId; | 250 text[5] = '1' + activeSensorId; |
159 text[6] = 0; | 251 text[6] = 0; |
160 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); | 252 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); |
161 | 253 |
162 pDiveO2Data = (SSensorDataDiveO2*)&stateRealGetPointer()->lifeData.extIf_sensor_data[activeSensorId]; | 254 switch(pStateReal->lifeData.extIf_sensor_map[activeSensorId]) |
163 | 255 { |
164 strIndex = snprintf(text,32,"ID: "); | 256 default: |
165 if(pDiveO2Data->sensorId != 0) | 257 case SENSOR_DIGO2M: refreshInfo_SensorO2(s); |
166 { | 258 break; |
167 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]); | 259 case SENSOR_CO2M: refreshInfo_SensorCo2(s); |
168 } | 260 break; |
169 tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020); | 261 } |
170 snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0); | |
171 tInfo_write_content_simple( 30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020); | |
172 | |
173 #ifdef ENABLE_EXTERNAL_PRESSURE | |
174 pressure = (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[2]); | |
175 #else | |
176 pressure = (float)pDiveO2Data->pressure / 1000.0; | |
177 #endif | |
178 snprintf(text,32,"Druck: %02.1f (%02.1f)", (float)pDiveO2Data->pressure / 1000.0, pressure *1000.0); | |
179 | |
180 tInfo_write_content_simple( 30, 770, ME_Y_LINE3, &FontT48, text, CLUT_Font020); | |
181 snprintf(text,32,"Feuchtigkeit: %02.1f", (float)pDiveO2Data->humidity / 1000.0); | |
182 tInfo_write_content_simple( 30, 770, ME_Y_LINE4, &FontT48, text, CLUT_Font020); | |
183 snprintf(text,32,"Status: 0x%lx", pDiveO2Data->status); | |
184 tInfo_write_content_simple( 30, 770, ME_Y_LINE5, &FontT48, text, CLUT_Font020); | |
185 #ifdef ENABLE_EXTERNAL_PRESSURE | |
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])); | |
187 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020); | |
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++ = '1' + activeSensorId; | |
205 | |
206 snprintf(textPointer, 20,": %01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[activeSensorId], pStateReal->lifeData.sensorVoltage_mV[activeSensorId]); | |
207 | |
208 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020); | |
209 | |
210 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0); | |
211 } | 262 } |
212 | 263 |
213 void sendActionToInfoSensor(uint8_t sendAction) | 264 void sendActionToInfoSensor(uint8_t sendAction) |
214 { | 265 { |
215 switch(sendAction) | 266 switch(sendAction) |
218 exitMenuEdit_to_BackMenu(); | 269 exitMenuEdit_to_BackMenu(); |
219 break; | 270 break; |
220 | 271 |
221 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) | 272 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) |
222 { | 273 { |
274 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) | |
275 { | |
276 settingsGetPointer()->co2_sensor_active = 1; | |
277 } | |
223 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId)); | 278 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId)); |
224 sensorActive = 1; | 279 sensorActive = 1; |
225 } | 280 } |
226 else | 281 else |
227 { | 282 { |
283 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) | |
284 { | |
285 settingsGetPointer()->co2_sensor_active = 0; | |
286 } | |
228 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId)); | 287 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId)); |
229 sensorActive = 0; | 288 sensorActive = 0; |
230 } | 289 } |
231 break; | 290 break; |
232 case ACTION_BUTTON_NEXT: | 291 case ACTION_BUTTON_NEXT: if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) |
292 { | |
293 DataEX_setExtInterface_Cmd(EXT_INTERFACE_CO2_CALIB); | |
294 } | |
295 break; | |
233 case ACTION_TIMEOUT: | 296 case ACTION_TIMEOUT: |
234 case ACTION_MODE_CHANGE: | 297 case ACTION_MODE_CHANGE: |
235 case ACTION_IDLE_TICK: | 298 case ACTION_IDLE_TICK: |
236 case ACTION_IDLE_SECOND: | 299 case ACTION_IDLE_SECOND: |
237 default: | 300 default: |