comparison Discovery/Src/data_exchange_main.c @ 1070:4499227a2db8 Icon_Integration

Added compile option for o2/diluent pressure display: Some external devices (like the RedBare rebreather) provide pressure sensor information o2 and diluent bottles. A data channel from RTE to main CPU has been defined and a visualization has been added to the lower left corner (llc). Pressure will be displayed in the gas list as well => for o2 display the definition of a 100% o2 gas is needed. Diluent will be assigned to the first gas. The ADVANCED_GAS compile switch needs to be activated for this feature
author Ideenmodellierer
date Thu, 19 Feb 2026 13:17:25 +0100
parents 3c73180fde1d
children
comparison
equal deleted inserted replaced
1069:e0ba2b29dc1f 1070:4499227a2db8
630 } 630 }
631 return retval; 631 return retval;
632 } 632 }
633 633
634 634
635 void DataEX_helper_Get_ID_Of_O2_Diluent(uint8_t* pIdO2, uint8_t* pIdDiluent)
636 {
637 const SDiveState *pStateReal = stateRealGetPointer();
638 uint8_t index = 0;
639
640 *pIdO2 = 0xff;
641 *pIdDiluent = 0xff;
642
643 for (index = NUM_GASES; index <= NUM_GASES*2; index++) /* search for o2 and start gas in diluent table */
644 {
645 if(pStateReal->diveSettings.gas[index].note.ub.first)
646 {
647 *pIdDiluent = index;
648 }
649 if(pStateReal->diveSettings.gas[index].oxygen_percentage >= 99)
650 {
651 *pIdO2 = index;
652 }
653 }
654 }
655
635 static uint8_t DataEX_helper_Check_And_Correct_Value_deviceData(SDeviceLine *lineWrite, int32_t from, int32_t to, uint8_t defaulttofrom) 656 static uint8_t DataEX_helper_Check_And_Correct_Value_deviceData(SDeviceLine *lineWrite, int32_t from, int32_t to, uint8_t defaulttofrom)
636 { 657 {
637 uint8_t retval = 0; 658 uint8_t retval = 0;
638 RTC_DateTypeDef sdatestructure; 659 RTC_DateTypeDef sdatestructure;
639 660
844 865
845 void DataEX_copy_to_LifeData(_Bool *modeChangeFlag) 866 void DataEX_copy_to_LifeData(_Bool *modeChangeFlag)
846 { 867 {
847 static uint16_t getDeviceDataAfterStartOfMainCPU = 20; 868 static uint16_t getDeviceDataAfterStartOfMainCPU = 20;
848 static uint16_t lastcounterSecondsShallowDepth = 0; 869 static uint16_t lastcounterSecondsShallowDepth = 0;
870
871 static uint8_t pressureIdO2 = 0xFF;
872 static uint8_t pressureIdDiluent = 0xFF;
849 873
850 SDiveState *pStateReal = stateRealGetPointerWrite(); 874 SDiveState *pStateReal = stateRealGetPointerWrite();
851 uint8_t idx; 875 uint8_t idx;
852 float meter = 0; 876 float meter = 0;
853 877
1005 } 1029 }
1006 } 1030 }
1007 1031
1008 if(pStateReal->data_old__lost_connection_to_slave == 0) 1032 if(pStateReal->data_old__lost_connection_to_slave == 0)
1009 { 1033 {
1010
1011 pStateReal->lifeData.extIf_sensor_Id = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].externalInterface_SensorID; 1034 pStateReal->lifeData.extIf_sensor_Id = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].externalInterface_SensorID;
1012 if(pStateReal->lifeData.extIf_sensor_Id < 3) 1035 if(pStateReal->lifeData.extIf_sensor_Id < 3)
1013 { 1036 {
1014 1037
1015 memcpy(pStateReal->lifeData.extIf_sensor_data[pStateReal->lifeData.extIf_sensor_Id], dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_data, 32); 1038 memcpy(pStateReal->lifeData.extIf_sensor_data[pStateReal->lifeData.extIf_sensor_Id], dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_data, 32);
1016 } 1039 }
1017 memcpy(pStateReal->lifeData.extIf_sensor_map, dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_map, EXT_INTERFACE_SENSOR_CNT); 1040 memcpy(pStateReal->lifeData.extIf_sensor_map, dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_ADC)].sensor_map, EXT_INTERFACE_SENSOR_CNT);
1018
1019 1041
1020 meter = getSampleDepth(&dataIn, pStateReal); 1042 meter = getSampleDepth(&dataIn, pStateReal);
1021 1043
1022 pStateReal->pressure_uTick_old = pStateReal->pressure_uTick_new; 1044 pStateReal->pressure_uTick_old = pStateReal->pressure_uTick_new;
1023 pStateReal->pressure_uTick_new = dataIn.data[dataIn.boolPressureData].pressure_uTick; 1045 pStateReal->pressure_uTick_new = dataIn.data[dataIn.boolPressureData].pressure_uTick;
1025 1047
1026 pStateReal->lifeData.dateBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_dr; 1048 pStateReal->lifeData.dateBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_dr;
1027 pStateReal->lifeData.timeBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_tr; 1049 pStateReal->lifeData.timeBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_tr;
1028 1050
1029 memcpy(&pStateReal->lifeData.gnssData, &dataIn.data[0].gnssInfo, sizeof(dataIn.data[0].gnssInfo)); 1051 memcpy(&pStateReal->lifeData.gnssData, &dataIn.data[0].gnssInfo, sizeof(dataIn.data[0].gnssInfo));
1052
1053 if((dataIn.data[dataIn.boolPressureData].pressure_bottle[0] != 0) || (dataIn.data[dataIn.boolPressureData].pressure_bottle[1] != 0))
1054 {
1055 if((pressureIdO2 == 0xFF) || (pressureIdDiluent == 0xFF))
1056 {
1057 DataEX_helper_Get_ID_Of_O2_Diluent(&pressureIdO2, &pressureIdDiluent);
1058 }
1059 if(pressureIdO2 != 0xFF)
1060 {
1061 pStateReal->lifeData.bottle_bar[pressureIdO2] = dataIn.data[dataIn.boolPressureData].pressure_bottle[0];
1062 }
1063 if(pressureIdDiluent != 0xFF)
1064 {
1065 pStateReal->lifeData.bottle_bar[pressureIdDiluent] = dataIn.data[dataIn.boolPressureData].pressure_bottle[1];
1066 }
1067 }
1030 } 1068 }
1031 1069
1032 if(pStateReal->data_old__lost_connection_to_slave == 0) 1070 if(pStateReal->data_old__lost_connection_to_slave == 0)
1033 { 1071 {
1034 //Start of diveMode? 1072 //Start of diveMode?