Mercurial > public > ostc4
comparison Discovery/Src/tMenuEditHardware.c @ 718:b9f699d2e3d0
Updated menu structure to support new sensor information page:
The sensor information page has been added to the sensor submenu of the hardware menu. It will be shown dynamically in case a smart sensor is detected. In order to have this dynamic visualization some new functions had to be added to the general menu file. The information page returns to the sensor menu, for this behavior also a new function had to be added.
author | Ideenmodellierer |
---|---|
date | Sun, 20 Nov 2022 20:49:41 +0100 |
parents | c799151670d5 |
children | f285424f04d9 |
comparison
equal
deleted
inserted
replaced
717:88f73b05d45c | 718:b9f699d2e3d0 |
---|---|
35 #include "tCCR.h" | 35 #include "tCCR.h" |
36 #include "tMenuEdit.h" | 36 #include "tMenuEdit.h" |
37 #include "tHome.h" | 37 #include "tHome.h" |
38 #include "tInfo.h" | 38 #include "tInfo.h" |
39 #include "tInfoLog.h" | 39 #include "tInfoLog.h" |
40 #include "tInfoSensor.h" | |
40 #include "tComm.h" | 41 #include "tComm.h" |
41 #include "data_exchange_main.h" | 42 #include "data_exchange_main.h" |
42 | 43 |
43 extern void tM_build_pages(void); | 44 extern void tM_build_pages(void); |
44 | 45 |
60 uint8_t OnAction_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 61 uint8_t OnAction_Sensor1 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
61 uint8_t OnAction_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 62 uint8_t OnAction_Sensor2 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
62 uint8_t OnAction_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 63 uint8_t OnAction_Sensor3 (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
63 uint8_t OnAction_O2_Calibrate (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 64 uint8_t OnAction_O2_Calibrate (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
64 uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 65 uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
66 uint8_t OnAction_Sensor_Info (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
65 uint8_t OnAction_Button (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 67 uint8_t OnAction_Button (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
66 uint8_t OnAction_ButtonBalance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 68 uint8_t OnAction_ButtonBalance (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
67 // not required uint8_t OnAction_Bluetooth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 69 // not required uint8_t OnAction_Bluetooth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
68 | 70 |
69 /* Exported functions --------------------------------------------------------*/ | 71 /* Exported functions --------------------------------------------------------*/ |
71 | 73 |
72 #define O2_CALIB_FRACTION_AIR (0.209F) | 74 #define O2_CALIB_FRACTION_AIR (0.209F) |
73 #define O2_CALIB_FRACTION_O2 (0.98F) | 75 #define O2_CALIB_FRACTION_O2 (0.98F) |
74 | 76 |
75 static uint8_t O2_calib_gas = 21; | 77 static uint8_t O2_calib_gas = 21; |
78 static uint8_t haveSensorInfo = 0; | |
76 | 79 |
77 void openEdit_Hardware(uint8_t line) | 80 void openEdit_Hardware(uint8_t line) |
78 { | 81 { |
79 set_globalState_Menu_Line(line); | 82 set_globalState_Menu_Line(line); |
80 | 83 |
87 case 2: | 90 case 2: |
88 resetMenuEdit(CLUT_MenuPageHardware); | 91 resetMenuEdit(CLUT_MenuPageHardware); |
89 openEdit_Compass(); | 92 openEdit_Compass(); |
90 break; | 93 break; |
91 case 3: | 94 case 3: |
92 resetMenuEdit(CLUT_MenuPageHardware); | |
93 openEdit_O2Sensors(); | 95 openEdit_O2Sensors(); |
94 break; | 96 break; |
95 case 4: | 97 case 4: |
96 openEdit_Brightness(); | 98 openEdit_Brightness(); |
97 break; | 99 break; |
288 char text[32]; | 290 char text[32]; |
289 uint16_t y_line; | 291 uint16_t y_line; |
290 | 292 |
291 const SDiveState *pStateReal = stateRealGetPointer(); | 293 const SDiveState *pStateReal = stateRealGetPointer(); |
292 | 294 |
293 text[0] = '\001'; | 295 |
294 text[1] = TXT_o2Sensors; | 296 |
295 text[2] = 0; | 297 if((pStateReal->lifeData.extIf_sensor_Id != 0) && (haveSensorInfo == 0)) /* the sensor is detected after the interface has been selected => add button if info become available */ |
296 write_topline(text); | 298 { |
297 | 299 if(get_globalState() == StMHARD3_O2_Source) |
298 | 300 { |
299 text[0] = TXT_2BYTE; | 301 y_line = 5; |
300 text[1] = TXT2BYTE_Sensor; | 302 } |
301 text[2] = ' '; | 303 haveSensorInfo = 1; |
302 text[3] = '1'; | 304 openEdit_O2Sensors(); |
303 text[4] = 0; | 305 if(y_line == 5) |
304 write_label_var( 96, 340, ME_Y_LINE1, &FontT48, text); | 306 { |
305 text[3] = '2'; | 307 tMenuEdit_select(StMHARD3_O2_Source); |
306 write_label_var( 96, 340, ME_Y_LINE2, &FontT48, text); | 308 } |
307 text[3] = '3'; | 309 } |
308 write_label_var( 96, 340, ME_Y_LINE3, &FontT48, text); | 310 else |
309 | 311 { |
310 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) | 312 if(pStateReal->lifeData.extIf_sensor_Id == 0) |
311 { | 313 { |
314 haveSensorInfo = 0; | |
315 } | |
316 | |
317 text[0] = '\001'; | |
318 text[1] = TXT_o2Sensors; | |
319 text[2] = 0; | |
320 write_topline(text); | |
321 | |
322 | |
312 text[0] = TXT_2BYTE; | 323 text[0] = TXT_2BYTE; |
313 text[1] = TXT2BYTE_HUDbattery; | 324 text[1] = TXT2BYTE_Sensor; |
314 text[2] = 0; | 325 text[2] = ' '; |
315 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); | 326 text[3] = '1'; |
316 | 327 text[4] = 0; |
317 | 328 write_label_var( 96, 340, ME_Y_LINE1, &FontT48, text); |
318 snprintf(text, 20,"%01.3fV", get_HUD_battery_voltage_V()); | 329 text[3] = '2'; |
319 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); | 330 write_label_var( 96, 340, ME_Y_LINE2, &FontT48, text); |
331 text[3] = '3'; | |
332 write_label_var( 96, 340, ME_Y_LINE3, &FontT48, text); | |
333 | |
334 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) | |
335 { | |
336 text[0] = TXT_2BYTE; | |
337 text[1] = TXT2BYTE_HUDbattery; | |
338 text[2] = 0; | |
339 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); | |
340 | |
341 | |
342 snprintf(text, 20,"%01.3fV", get_HUD_battery_voltage_V()); | |
343 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); | |
344 } | |
345 else | |
346 { | |
347 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)) | |
348 { | |
349 text[0] = TXT_2BYTE; | |
350 text[1] = TXT2BYTE_O2Calib; | |
351 text[2] = 0; | |
352 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); | |
353 snprintf(text, 20,"%d%%", O2_calib_gas); | |
354 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); | |
355 } | |
356 } | |
357 | |
358 for(int i=0;i<3;i++) | |
359 { | |
360 snprintf(text, 20,"%01.2f, %01.1fmV", pStateReal->lifeData.ppO2Sensor_bar[i], pStateReal->lifeData.sensorVoltage_mV[i]); | |
361 y_line = ME_Y_LINE1 + (i * ME_Y_LINE_STEP); | |
362 write_label_var( 400, 800, y_line, &FontT48, text); | |
363 } | |
364 | |
365 if(DataEX_external_ADC_Present()) | |
366 { | |
367 text[0] = TXT_2BYTE; | |
368 text[1] = TXT2BYTE_O2Interface; | |
369 text[2] = 0; | |
370 write_label_var( 30, 340, ME_Y_LINE5, &FontT48, text); | |
371 text[0] = TXT_2BYTE; | |
372 switch(settingsGetPointer()->ppo2sensors_source) | |
373 { | |
374 default: | |
375 case O2_SENSOR_SOURCE_OPTIC: text[1] = TXT2BYTE_O2IFOptic; | |
376 text[2] = 0; | |
377 break; | |
378 case O2_SENSOR_SOURCE_ANALOG: text[1] = TXT2BYTE_O2IFAnalog; | |
379 text[2] = 0; | |
380 break; | |
381 case O2_SENSOR_SOURCE_DIGITAL: text[1] = TXT2BYTE_O2IFDigital; | |
382 text[2] = 0; | |
383 break; | |
384 case O2_SENSOR_SOURCE_ANADIG: text[1] = TXT2BYTE_O2IFAnalog; | |
385 text[2] = ' '; | |
386 text[3] = '+'; | |
387 text[4] = ' '; | |
388 text[5] = TXT_2BYTE; | |
389 text[6] = TXT2BYTE_O2IFDigital; | |
390 text[7] = 0; | |
391 break; | |
392 #ifdef ENABLE_SENTINEL_MODE | |
393 case O2_SENSOR_SOURCE_SENTINEL: snprintf(text, 10,"Sentinel"); | |
394 break; | |
395 #endif | |
396 } | |
397 write_label_var( 400, 800, ME_Y_LINE5, &FontT48, text); | |
398 | |
399 if(haveSensorInfo == 1) | |
400 { | |
401 text[0] = TXT_Sensor; | |
402 text[1] = ' '; | |
403 text[2] = TXT_Information; | |
404 text[3] = 0; | |
405 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, text); | |
406 } | |
407 } | |
408 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); | |
409 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); | |
410 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); | |
411 } | |
412 | |
413 if(get_globalState() == StMHARD3_O2_Calibrate) | |
414 { | |
415 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_O2Calib,TXT2BYTE_ButtonPlus); | |
320 } | 416 } |
321 else | 417 else |
322 { | 418 { |
323 text[0] = TXT_2BYTE; | |
324 text[1] = TXT2BYTE_O2Calib; | |
325 text[2] = 0; | |
326 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); | |
327 snprintf(text, 20,"%d%%", O2_calib_gas); | |
328 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); | |
329 } | |
330 | |
331 for(int i=0;i<3;i++) | |
332 { | |
333 snprintf(text, 20,"%01.2f, %01.1fmV", pStateReal->lifeData.ppO2Sensor_bar[i], pStateReal->lifeData.sensorVoltage_mV[i]); | |
334 y_line = ME_Y_LINE1 + (i * ME_Y_LINE_STEP); | |
335 write_label_var( 400, 800, y_line, &FontT48, text); | |
336 } | |
337 | |
338 if(DataEX_external_ADC_Present()) | |
339 { | |
340 text[0] = TXT_2BYTE; | |
341 text[1] = TXT2BYTE_O2Interface; | |
342 text[2] = 0; | |
343 write_label_var( 30, 340, ME_Y_LINE5, &FontT48, text); | |
344 text[0] = TXT_2BYTE; | |
345 switch(settingsGetPointer()->ppo2sensors_source) | |
346 { | |
347 default: | |
348 case O2_SENSOR_SOURCE_OPTIC: text[1] = TXT2BYTE_O2IFOptic; | |
349 text[2] = 0; | |
350 break; | |
351 case O2_SENSOR_SOURCE_ANALOG: text[1] = TXT2BYTE_O2IFAnalog; | |
352 text[2] = 0; | |
353 break; | |
354 case O2_SENSOR_SOURCE_DIGITAL: text[1] = TXT2BYTE_O2IFDigital; | |
355 text[2] = 0; | |
356 break; | |
357 case O2_SENSOR_SOURCE_ANADIG: text[1] = TXT2BYTE_O2IFAnalog; | |
358 text[2] = ' '; | |
359 text[3] = '+'; | |
360 text[4] = ' '; | |
361 text[5] = TXT_2BYTE; | |
362 text[6] = TXT2BYTE_O2IFDigital; | |
363 text[7] = 0; | |
364 break; | |
365 #ifdef ENABLE_SENTINEL_MODE | |
366 case O2_SENSOR_SOURCE_SENTINEL: snprintf(text, 10,"Sentinel"); | |
367 break; | |
368 #endif | |
369 } | |
370 | |
371 write_label_var( 400, 800, ME_Y_LINE5, &FontT48, text); | |
372 } | |
373 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); | |
374 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); | |
375 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); | |
376 | |
377 if(get_globalState() == StMHARD3_O2_Calibrate) | |
378 { | |
379 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_O2Calib,TXT2BYTE_ButtonPlus); | |
380 } | |
381 else | |
382 { | |
383 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | 419 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); |
384 } | 420 } |
385 } | 421 } |
386 | 422 |
387 | 423 |
388 void openEdit_O2Sensors(void) | 424 void openEdit_O2Sensors(void) |
389 { | 425 { |
390 uint8_t sensorActive[3]; | 426 uint8_t sensorActive[3]; |
427 | |
428 set_globalState(StMHARD3_Sensors); | |
429 resetMenuEdit(CLUT_MenuPageHardware); | |
391 | 430 |
392 sensorActive[0] = 1; | 431 sensorActive[0] = 1; |
393 sensorActive[1] = 1; | 432 sensorActive[1] = 1; |
394 sensorActive[2] = 1; | 433 sensorActive[2] = 1; |
395 if(settingsGetPointer()->ppo2sensors_deactivated & 1) | 434 if(settingsGetPointer()->ppo2sensors_deactivated & 1) |
401 | 440 |
402 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); | 441 write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); |
403 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); | 442 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); |
404 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); | 443 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); |
405 | 444 |
445 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) | |
446 { | |
447 haveSensorInfo = 0; /* as long as we do not move the HUD battery into the information page... */ | |
448 } | |
449 | |
406 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) | 450 if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) |
407 #ifdef ENABLE_SENTINEL_MODE | 451 #ifdef ENABLE_SENTINEL_MODE |
408 || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL) | 452 || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL) |
409 #endif | 453 #endif |
410 ) | 454 ) |
416 } | 460 } |
417 | 461 |
418 if(DataEX_external_ADC_Present()) | 462 if(DataEX_external_ADC_Present()) |
419 { | 463 { |
420 write_field_button(StMHARD3_O2_Source, 30, 800, ME_Y_LINE5, &FontT48, ""); | 464 write_field_button(StMHARD3_O2_Source, 30, 800, ME_Y_LINE5, &FontT48, ""); |
465 if(haveSensorInfo != 0) | |
466 { | |
467 write_field_button(StMHARD3_Sensor_Info, 30, 800, ME_Y_LINE6, &FontT48, ""); | |
468 } | |
421 } | 469 } |
422 | 470 |
423 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); | 471 setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1); |
424 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2); | 472 setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2); |
425 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3); | 473 setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3); |
433 } | 481 } |
434 | 482 |
435 if(DataEX_external_ADC_Present()) | 483 if(DataEX_external_ADC_Present()) |
436 { | 484 { |
437 setEvent(StMHARD3_O2_Source, (uint32_t)OnAction_O2_Source); | 485 setEvent(StMHARD3_O2_Source, (uint32_t)OnAction_O2_Source); |
486 if(haveSensorInfo != 0) | |
487 { | |
488 setEvent(StMHARD3_Sensor_Info, (uint32_t)OnAction_Sensor_Info); | |
489 } | |
438 } | 490 } |
439 | 491 |
440 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | 492 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); |
441 } | 493 } |
442 | 494 |
558 source = O2_SENSOR_SOURCE_OPTIC; | 610 source = O2_SENSOR_SOURCE_OPTIC; |
559 } | 611 } |
560 | 612 |
561 settingsGetPointer()->ppo2sensors_source = source; | 613 settingsGetPointer()->ppo2sensors_source = source; |
562 | 614 |
563 resetMenuEdit(CLUT_MenuPageHardware); /* rebuild menu structure (Hide HUD <=> Show Calibrate) */ | 615 openEdit_O2Sensors(); /* rebuild menu structure (Hide HUD <=> Show Calibrate) */ |
564 openEdit_O2Sensors(); | |
565 tMenuEdit_select(StMHARD3_O2_Source); | 616 tMenuEdit_select(StMHARD3_O2_Source); |
566 return UPDATE_DIVESETTINGS; | 617 return UPDATE_DIVESETTINGS; |
567 } | 618 } |
619 | |
620 uint8_t OnAction_Sensor_Info(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
621 { | |
622 return EXIT_TO_INFO_SENSOR; | |
623 } | |
624 | |
568 | 625 |
569 void openEdit_Brightness(void) | 626 void openEdit_Brightness(void) |
570 { | 627 { |
571 uint8_t actualBrightness; | 628 uint8_t actualBrightness; |
572 SSettings *pSettings = settingsGetPointer(); | 629 SSettings *pSettings = settingsGetPointer(); |