comparison Discovery/Src/tMenuEditHardware.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 45b8f3c2acce
children acf6614dc396
comparison
equal deleted inserted replaced
782:9a1bb9e7cb61 783:c31237d20491
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
27 ////////////////////////////////////////////////////////////////////////////// 27 //////////////////////////////////////////////////////////////////////////////
28 28
29 /* Includes ------------------------------------------------------------------*/ 29 /* Includes ------------------------------------------------------------------*/
30 #include "tMenuEditHardware.h" 30 #include "tMenuEditHardware.h"
31 #include "tMenuEdit.h"
31 32
32 #include "externCPU2bootloader.h" 33 #include "externCPU2bootloader.h"
33 #include "gfx_fonts.h" 34 #include "gfx_fonts.h"
34 #include "ostc.h" 35 #include "ostc.h"
35 #include "tCCR.h" 36 #include "tCCR.h"
76 77
77 #define O2_CALIB_FRACTION_AIR (0.209F) 78 #define O2_CALIB_FRACTION_AIR (0.209F)
78 #define O2_CALIB_FRACTION_O2 (0.98F) 79 #define O2_CALIB_FRACTION_O2 (0.98F)
79 80
80 static uint8_t O2_calib_gas = 21; 81 static uint8_t O2_calib_gas = 21;
81 static uint8_t haveSensorInfo = 0;
82 82
83 void openEdit_Hardware(uint8_t line) 83 void openEdit_Hardware(uint8_t line)
84 { 84 {
85 set_globalState_Menu_Line(line); 85 set_globalState_Menu_Line(line);
86 86
424 } 424 }
425 } 425 }
426 openEdit_O2Sensors(); 426 openEdit_O2Sensors();
427 } 427 }
428 428
429 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 */ 429 strSensorId[0] = '\001';
430 { 430 strSensorId[1] = TXT_o2Sensors;
431 haveSensorInfo = 1; 431 strSensorId[2] = 0;
432 openEdit_O2Sensors(); 432 write_topline(strSensorId);
433 } 433
434 else 434 strSensorId[0] = TXT_2BYTE;
435 { 435 strSensorId[1] = TXT2BYTE_Sensor;
436 if(pStateReal->lifeData.extIf_sensor_Id == 0) 436 strSensorId[2] = ' ';
437 { 437 strSensorId[3] = TXT_2BYTE;
438 haveSensorInfo = 0; 438 strSensorId[4] = 'X';
439 } 439 strSensorId[5] = '1';
440 440 strSensorId[6] = 0;
441 strSensorId[0] = '\001'; 441
442 strSensorId[1] = TXT_o2Sensors; 442 for(index = 0; index < 3; index++)
443 strSensorId[2] = 0; 443 {
444 write_topline(strSensorId);
445
446
447 strSensorId[0] = TXT_2BYTE;
448 strSensorId[1] = TXT2BYTE_Sensor;
449 strSensorId[2] = ' ';
450 strSensorId[3] = TXT_2BYTE;
451 strSensorId[4] = 'X'; 444 strSensorId[4] = 'X';
452 strSensorId[5] = '1'; 445 strSensorId[5] = '1' + index;
453 strSensorId[6] = 0; 446
454 447 switch(pSettings->ext_sensor_map[index])
455 for(index = 0; index < 3; index++) 448 {
456 {
457 strSensorId[4] = 'X';
458 strSensorId[5] = '1' + index;
459
460 switch(pSettings->ext_sensor_map[index])
461 {
462 case SENSOR_SEARCH: strSensorId[1] = TXT2BYTE_SensorDetect; 449 case SENSOR_SEARCH: strSensorId[1] = TXT2BYTE_SensorDetect;
463 strSensorId[2] = 0; 450 strSensorId[2] = 0;
464 strSensorId[4] = 0; 451 strSensorId[4] = 0;
465 break; 452 break;
466 case SENSOR_OPTIC: strSensorId[4] = TXT2BYTE_O2IFOptic; 453 case SENSOR_OPTIC: strSensorId[4] = TXT2BYTE_O2IFOptic;
476 strSensorId[4] = 'e'; 463 strSensorId[4] = 'e';
477 break; 464 break;
478 default: 465 default:
479 strSensorId[5] = 0; 466 strSensorId[5] = 0;
480 break; 467 break;
481 } 468 }
482 if(strSensorId[4] != 'X') 469 if(strSensorId[4] != 'X')
483 { 470 {
484 write_label_var( 96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, strSensorId); 471 write_label_var( 96, 340, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, strSensorId);
485 } 472 }
486 strSensorValue[0] = 0; 473 strSensorValue[0] = 0;
487 if((pSettings->ext_sensor_map[index] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[index] < SENSOR_TYPE_O2_END)) 474 if((pSettings->ext_sensor_map[index] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[index] < SENSOR_TYPE_O2_END))
488 { 475 {
489 snprintf(strSensorValue, 20,"%01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[index], pStateReal->lifeData.sensorVoltage_mV[index]); 476 snprintf(strSensorValue, 20,"%01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[index], pStateReal->lifeData.sensorVoltage_mV[index]);
490 } 477 }
491 else if(pSettings->ext_sensor_map[index] == SENSOR_CO2) 478 else if(pSettings->ext_sensor_map[index] == SENSOR_CO2)
492 { 479 {
493 snprintf(strSensorValue, 20,"%ld ppm", pStateReal->lifeData.CO2_data.CO2_ppm); 480 snprintf(strSensorValue, 20,"%ld ppm", pStateReal->lifeData.CO2_data.CO2_ppm);
494 } 481 }
495 y_line = ME_Y_LINE1 + (index * ME_Y_LINE_STEP); 482 y_line = ME_Y_LINE1 + (index * ME_Y_LINE_STEP);
496 if(strSensorValue[0] != 0) 483 if(strSensorValue[0] != 0)
497 { 484 {
498 write_label_var( 480, 800, y_line, &FontT48, strSensorValue); 485 write_label_var( 480, 800, y_line, &FontT48, strSensorValue);
499 } 486 }
500 } 487 }
501 488
502 if(pSettings->ext_sensor_map[0] == SENSOR_OPTIC) 489 if(pSettings->ext_sensor_map[0] == SENSOR_OPTIC)
503 { 490 {
504 strSensorId[0] = TXT_2BYTE; 491 strSensorId[0] = TXT_2BYTE;
505 strSensorId[1] = TXT2BYTE_HUDbattery; 492 strSensorId[1] = TXT2BYTE_HUDbattery;
506 strSensorId[2] = 0; 493 strSensorId[2] = 0;
507 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, strSensorId); 494 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, strSensorId);
508 495
509 snprintf(strSensorId, 20,"%01.3fV", get_HUD_battery_voltage_V()); 496 snprintf(strSensorId, 20,"%01.3fV", get_HUD_battery_voltage_V());
510 write_label_var( 480, 800, ME_Y_LINE4, &FontT48, strSensorId); 497 write_label_var( 480, 800, ME_Y_LINE4, &FontT48, strSensorId);
511 } 498 }
512 else 499 else
513 { 500 {
514 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) 501 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
515 #ifdef ENABLE_SENTINEL_MODE 502 #ifdef ENABLE_SENTINEL_MODE
516 || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL) 503 || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)
517 #endif 504 #endif
518 ) 505 )
519 { 506 {
520 strSensorId[0] = TXT_2BYTE;
521 strSensorId[1] = TXT2BYTE_O2Calib;
522 strSensorId[2] = 0;
523 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, strSensorId);
524 snprintf(strSensorId, 20,"%d%%", O2_calib_gas);
525 write_label_var( 480, 800, ME_Y_LINE4, &FontT48, strSensorId);
526 }
527 }
528
529 if(DataEX_external_ADC_Present())
530 {
531 strSensorId[0] = TXT_2BYTE; 507 strSensorId[0] = TXT_2BYTE;
532 strSensorId[1] = TXT2BYTE_SensorDetect; 508 strSensorId[1] = TXT2BYTE_O2Calib;
533 strSensorId[2] = 0; 509 strSensorId[2] = 0;
534 510 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, strSensorId);
535 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, strSensorId); 511 snprintf(strSensorId, 20,"%d%%", O2_calib_gas);
536 } 512 write_label_var( 480, 800, ME_Y_LINE4, &FontT48, strSensorId);
537 513 }
538 if(haveSensorInfo == 1) 514 }
539 { 515 if(DataEX_external_ADC_Present())
540 strSensorId[0] = TXT_Sensor; 516 {
541 strSensorId[1] = ' '; 517 strSensorId[0] = TXT_2BYTE;
542 strSensorId[2] = TXT_Information; 518 strSensorId[1] = TXT2BYTE_SensorDetect;
543 strSensorId[3] = 0; 519 strSensorId[2] = 0;
544 write_label_var( 30, 340, ME_Y_LINE5, &FontT48, strSensorId); 520
545 } 521 write_label_var( 30, 340, ME_Y_LINE6, &FontT48, strSensorId);
546 522 }
547 if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_TYPE_O2_END)) 523
548 { 524 if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_TYPE_O2_END))
549 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); 525 {
550 } 526 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1);
551 if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_TYPE_O2_END)) 527 }
552 { 528 if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_TYPE_O2_END))
553 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); 529 {
554 } 530 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2);
555 if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_TYPE_O2_END)) 531 }
556 { 532 if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_TYPE_O2_END))
557 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); 533 {
558 } 534 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3);
559 } 535 }
560 536
561 if(get_globalState() == StMHARD3_O2_Calibrate) 537 if(get_globalState() == StMHARD3_O2_Calibrate)
562 { 538 {
563 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_O2Calib,TXT2BYTE_ButtonPlus); 539 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_O2Calib,TXT2BYTE_ButtonPlus);
571 547
572 void openEdit_O2Sensors(void) 548 void openEdit_O2Sensors(void)
573 { 549 {
574 SSettings *pSettings = settingsGetPointer(); 550 SSettings *pSettings = settingsGetPointer();
575 uint8_t sensorActive[3]; 551 uint8_t sensorActive[3];
552 uint8_t index = 0;
576 char text[3]; 553 char text[3];
577 554
578 set_globalState(StMHARD3_Sensors); 555 set_globalState(StMHARD3_Sensors);
579 resetMenuEdit(CLUT_MenuPageHardware); 556 resetMenuEdit(CLUT_MenuPageHardware);
580 557
581 sensorActive[0] = 1; 558 for(index = 0; index < 3; index++ )
582 sensorActive[1] = 1; 559 {
583 sensorActive[2] = 1; 560 if(pSettings->ppo2sensors_deactivated & (0x01 << index))
561 {
562 sensorActive[index] = 0;
563 }
564 else
565 {
566 sensorActive[index] = 1;
567 }
568 }
584 569
585 if(((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] >= SENSOR_TYPE_O2_END))) 570 if(((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] >= SENSOR_TYPE_O2_END)))
586 { 571 {
587 pSettings->ppo2sensors_deactivated |= 1; 572 pSettings->ppo2sensors_deactivated |= 1;
588 } 573 }
611 if(settingsGetPointer()->ppo2sensors_deactivated & 2) 596 if(settingsGetPointer()->ppo2sensors_deactivated & 2)
612 sensorActive[1] = 0; 597 sensorActive[1] = 0;
613 if(settingsGetPointer()->ppo2sensors_deactivated & 4) 598 if(settingsGetPointer()->ppo2sensors_deactivated & 4)
614 sensorActive[2] = 0; 599 sensorActive[2] = 0;
615 600
616 if(pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC)
617 {
618 haveSensorInfo = 0; /* as long as we do not move the HUD battery into the information page... */
619 }
620
621 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) 601 if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG)
622 #ifdef ENABLE_SENTINEL_MODE 602 #ifdef ENABLE_SENTINEL_MODE
623 || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL) 603 || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL)
624 #endif 604 #endif
625 ) 605 )
628 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, "\016\016 %\017"); 608 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, "\016\016 %\017");
629 609
630 write_field_toggle(StMHARD3_O2_Calibrate, 400, 800, ME_Y_LINE4, &FontT48, "", 21, 98); 610 write_field_toggle(StMHARD3_O2_Calibrate, 400, 800, ME_Y_LINE4, &FontT48, "", 21, 98);
631 } 611 }
632 612
633 if(haveSensorInfo != 0)
634 {
635 write_field_button(StMHARD3_Sensor_Info, 30, 800, ME_Y_LINE5, &FontT48, "");
636 }
637
638 if(DataEX_external_ADC_Present()) 613 if(DataEX_external_ADC_Present())
639 { 614 {
640 text[0] = TXT_2BYTE; 615 text[0] = TXT_2BYTE;
641 text[1] = TXT2BYTE_SensorDetect; 616 text[1] = TXT2BYTE_SensorDetect;
642 text[2] = 0; 617 text[2] = 0;
666 ) 641 )
667 { 642 {
668 setEvent(StMHARD3_O2_Calibrate, (uint32_t)OnAction_O2_Calibrate); 643 setEvent(StMHARD3_O2_Calibrate, (uint32_t)OnAction_O2_Calibrate);
669 } 644 }
670 645
671 if(haveSensorInfo != 0)
672 {
673 setEvent(StMHARD3_Sensor_Info, (uint32_t)OnAction_Sensor_Info);
674 }
675
676 if(DataEX_external_ADC_Present()) 646 if(DataEX_external_ADC_Present())
677 { 647 {
678 setEvent(StMHARD3_Sensor_Detect, (uint32_t)OnAction_Sensor_Detect); 648 setEvent(StMHARD3_Sensor_Detect, (uint32_t)OnAction_Sensor_Detect);
679 } 649 }
680 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 650 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
681 } 651 }
682 652
683 653
684 uint8_t OnAction_Sensor1(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 654 uint8_t OnAction_Sensor1(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
685 { 655 {
686 if(settingsGetPointer()->ppo2sensors_deactivated & 1) 656 const SDiveState *pStateReal = stateRealGetPointer();
687 { 657
688 settingsGetPointer()->ppo2sensors_deactivated &= 4+2; 658 if(pStateReal->lifeData.extIf_sensor_map[0] == SENSOR_DIGO2)
689 tMenuEdit_set_on_off(editId, 1); 659 {
690 } 660 return EXIT_TO_INFO_SENSOR;
691 else 661 }
692 { 662 else
693 settingsGetPointer()->ppo2sensors_deactivated |= 1; 663 {
694 tMenuEdit_set_on_off(editId, 0); 664 if(settingsGetPointer()->ppo2sensors_deactivated & 1)
695 } 665 {
666 settingsGetPointer()->ppo2sensors_deactivated &= 4+2;
667 tMenuEdit_set_on_off(editId, 1);
668 }
669 else
670 {
671 settingsGetPointer()->ppo2sensors_deactivated |= 1;
672 tMenuEdit_set_on_off(editId, 0);
673 }
674 }
696 675
697 return UPDATE_DIVESETTINGS; 676 return UPDATE_DIVESETTINGS;
698 } 677 }
699 678
700 679
701 uint8_t OnAction_Sensor2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 680 uint8_t OnAction_Sensor2(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
702 { 681 {
703 if(settingsGetPointer()->ppo2sensors_deactivated & 2) 682 const SDiveState *pStateReal = stateRealGetPointer();
704 { 683
705 settingsGetPointer()->ppo2sensors_deactivated &= 4+1; 684 if(pStateReal->lifeData.extIf_sensor_map[1] == SENSOR_DIGO2)
706 tMenuEdit_set_on_off(editId, 1); 685 {
707 } 686 return EXIT_TO_INFO_SENSOR;
708 else 687 }
709 { 688 else
710 settingsGetPointer()->ppo2sensors_deactivated |= 2; 689 {
711 tMenuEdit_set_on_off(editId, 0); 690 if(settingsGetPointer()->ppo2sensors_deactivated & 2)
712 } 691 {
713 692 settingsGetPointer()->ppo2sensors_deactivated &= 4+1;
693 tMenuEdit_set_on_off(editId, 1);
694 }
695 else
696 {
697 settingsGetPointer()->ppo2sensors_deactivated |= 2;
698 tMenuEdit_set_on_off(editId, 0);
699 }
700 }
714 return UPDATE_DIVESETTINGS; 701 return UPDATE_DIVESETTINGS;
715 } 702 }
716 703
717 704
718 uint8_t OnAction_Sensor3(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 705 uint8_t OnAction_Sensor3(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
719 { 706 {
720 if(settingsGetPointer()->ppo2sensors_deactivated & 4) 707 const SDiveState *pStateReal = stateRealGetPointer();
721 { 708
722 settingsGetPointer()->ppo2sensors_deactivated &= 2+1; 709 if(pStateReal->lifeData.extIf_sensor_map[2] == SENSOR_DIGO2)
723 tMenuEdit_set_on_off(editId, 1); 710 {
724 } 711 return EXIT_TO_INFO_SENSOR;
725 else 712 }
726 { 713 else
727 settingsGetPointer()->ppo2sensors_deactivated |= 4; 714 {
728 tMenuEdit_set_on_off(editId, 0); 715
729 } 716 if(settingsGetPointer()->ppo2sensors_deactivated & 4)
730 717 {
718 settingsGetPointer()->ppo2sensors_deactivated &= 2+1;
719 tMenuEdit_set_on_off(editId, 1);
720 }
721 else
722 {
723 settingsGetPointer()->ppo2sensors_deactivated |= 4;
724 tMenuEdit_set_on_off(editId, 0);
725 }
726 }
731 return UPDATE_DIVESETTINGS; 727 return UPDATE_DIVESETTINGS;
732 } 728 }
733 729
734 730
735 uint8_t OnAction_O2_Calibrate (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 731 uint8_t OnAction_O2_Calibrate (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)