Mercurial > public > ostc4
comparison Discovery/Src/tInfoSensor.c @ 1073:734f84b72b30 Icon_Integration tip
CV Option Menu added sub menus for O2 and CO2 sensors:
In the previous implementation by the external sensor menu the problem exists that only three sensor could be displayed. If three o2 sensors were active then the CO2 sensor was not accessible. With the new dynamic view the CO2 sensor is a standalone menu element. The three sensor view was reused from the external sensor menu by introducing a filter (sensor type) functionality. O" and CO2 sensors may now be calibrated using the cv option sub menus.
| author | Ideenmodellierer |
|---|---|
| date | Fri, 20 Feb 2026 17:26:46 +0100 |
| parents | 3420e3ba698d |
| children |
comparison
equal
deleted
inserted
replaced
| 1072:8b97003dbb60 | 1073:734f84b72b30 |
|---|---|
| 37 #include "data_exchange_main.h" | 37 #include "data_exchange_main.h" |
| 38 | 38 |
| 39 #include <string.h> | 39 #include <string.h> |
| 40 #include <inttypes.h> | 40 #include <inttypes.h> |
| 41 | 41 |
| 42 extern void openEdit_O2Sensors(void); | 42 extern void openEdit_Sensors(uint8_t filter); |
| 43 uint8_t OnAction_Sensor (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 43 uint8_t OnAction_Sensor (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
| 44 | 44 |
| 45 /* Private variables ---------------------------------------------------------*/ | 45 /* Private variables ---------------------------------------------------------*/ |
| 46 static uint8_t activeSensorId = 0; | 46 static uint8_t activeSensorId = 0; |
| 47 static uint8_t sensorActive = 0; | 47 static uint8_t sensorActive = 0; |
| 48 static externalInterfaceSensorType sensorType = SENSOR_NONE; | |
| 48 /* Exported functions --------------------------------------------------------*/ | 49 /* Exported functions --------------------------------------------------------*/ |
| 49 void openInfo_Sensor(uint8_t sensorId) | 50 void openInfo_Sensor(uint8_t sensorId) |
| 50 { | 51 { |
| 51 SSettings *pSettings = settingsGetPointer(); | 52 SSettings *pSettings = settingsGetPointer(); |
| 52 activeSensorId = sensorId; | 53 activeSensorId = sensorId; |
| 53 set_globalState(StISENINFO); | 54 set_globalState(StISENINFO); |
| 54 switch (activeSensorId) | 55 switch (activeSensorId) |
| 55 { | 56 { |
| 56 case 2: setBackMenu((uint32_t)openEdit_O2Sensors,0,3); | 57 case 2: setBackMenu((uint32_t)openEdit_Sensors,SENSOR_END,3); |
| 57 break; | 58 break; |
| 58 case 1: setBackMenu((uint32_t)openEdit_O2Sensors,0,2); | 59 case 1: setBackMenu((uint32_t)openEdit_Sensors,SENSOR_END,2); |
| 59 break; | 60 break; |
| 60 default: | 61 default: |
| 61 case 0: setBackMenu((uint32_t)openEdit_O2Sensors,0,1); | 62 case 0: setBackMenu((uint32_t)openEdit_Sensors,SENSOR_END,1); |
| 62 break; | 63 break; |
| 63 } | 64 } |
| 64 sensorActive = 1; | 65 sensorActive = 1; |
| 65 if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId))) | 66 switch(sensorType) /* type has to be set using the set function before info dialog is used */ |
| 66 { | 67 { |
| 67 sensorActive = 0; | 68 case SENSOR_CO2: |
| 69 case SENSOR_CO2M: sensorActive = pSettings->co2_sensor_active; | |
| 70 break; | |
| 71 case SENSOR_DIGO2: DataEX_setExtInterface_Cmd(EXT_INTERFACE_O2_INDICATE, activeSensorId); | |
| 72 /*no break*/ | |
| 73 default: if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId))) | |
| 74 { | |
| 75 sensorActive = 0; | |
| 76 } | |
| 77 break; | |
| 68 } | 78 } |
| 69 DataEX_setExtInterface_Cmd(EXT_INTERFACE_O2_INDICATE, activeSensorId); | 79 |
| 70 } | 80 |
| 71 | 81 } |
| 72 | 82 |
| 73 uint8_t OnAction_Sensor(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 83 void openInfo_SetSensorType(externalInterfaceSensorType Type) |
| 74 { | 84 { |
| 75 if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) | 85 sensorType = Type; |
| 76 { | 86 } |
| 77 settingsGetPointer()->ppo2sensors_deactivated &= ~(1 << (activeSensorId)); | |
| 78 tMenuEdit_set_on_off(editId, 1); | |
| 79 } | |
| 80 else | |
| 81 { | |
| 82 settingsGetPointer()->ppo2sensors_deactivated |= (1 << (activeSensorId)); | |
| 83 tMenuEdit_set_on_off(editId, 0); | |
| 84 } | |
| 85 return UPDATE_DIVESETTINGS; | |
| 86 } | |
| 87 | |
| 88 | |
| 89 | 87 |
| 90 uint64_t mod64(uint64_t a, uint64_t b) | 88 uint64_t mod64(uint64_t a, uint64_t b) |
| 91 { | 89 { |
| 92 uint64_t div; | 90 uint64_t div; |
| 93 div=(a/10); | 91 div=(a/10); |
| 219 text[4] = ' '; | 217 text[4] = ' '; |
| 220 text[5] = '1' + activeSensorId; | 218 text[5] = '1' + activeSensorId; |
| 221 text[6] = 0; | 219 text[6] = 0; |
| 222 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); | 220 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); |
| 223 | 221 |
| 224 switch(pStateReal->lifeData.extIf_sensor_map[activeSensorId]) | 222 switch(sensorType) |
| 225 { | 223 { |
| 226 default: | 224 default: |
| 227 case SENSOR_DIGO2M: refreshInfo_SensorO2(s); | 225 case SENSOR_DIGO2M: refreshInfo_SensorO2(s); |
| 228 break; | 226 break; |
| 227 case SENSOR_CO2: | |
| 229 case SENSOR_CO2M: refreshInfo_SensorCo2(s); | 228 case SENSOR_CO2M: refreshInfo_SensorCo2(s); |
| 230 break; | 229 break; |
| 231 } | 230 } |
| 232 } | 231 } |
| 233 | 232 |
| 234 void sendActionToInfoSensor(uint8_t sendAction) | 233 void sendActionToInfoSensor(uint8_t sendAction) |
| 235 { | 234 { |
| 235 SSettings *pSettings = settingsGetPointer(); | |
| 236 | |
| 236 switch(sendAction) | 237 switch(sendAction) |
| 237 { | 238 { |
| 238 case ACTION_BUTTON_BACK: | 239 case ACTION_BUTTON_BACK: |
| 239 exitMenuEdit_to_BackMenu(); | 240 exitMenuEdit_to_BackMenu(); |
| 240 break; | 241 break; |
| 241 | 242 |
| 242 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) | 243 case ACTION_BUTTON_ENTER: switch(sensorType) |
| 243 { | 244 { |
| 244 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) | 245 case SENSOR_CO2: |
| 245 { | 246 case SENSOR_CO2M: if(pSettings->co2_sensor_active) |
| 246 settingsGetPointer()->co2_sensor_active = 1; | 247 { |
| 247 } | 248 pSettings->co2_sensor_active = 0; |
| 248 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId)); | 249 sensorActive = 0; |
| 249 sensorActive = 1; | 250 } |
| 250 } | 251 else |
| 251 else | 252 { |
| 252 { | 253 pSettings->co2_sensor_active = 1; |
| 253 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) | 254 sensorActive = 1; |
| 254 { | 255 } |
| 255 settingsGetPointer()->co2_sensor_active = 0; | 256 break; |
| 256 } | 257 default: if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId))) |
| 257 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId)); | 258 { |
| 258 sensorActive = 0; | 259 pSettings->ppo2sensors_deactivated &= ~(1 << (activeSensorId)); |
| 259 } | 260 sensorActive = 1; |
| 260 break; | 261 } |
| 261 case ACTION_BUTTON_NEXT: if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) | 262 else |
| 263 { | |
| 264 pSettings->ppo2sensors_deactivated |= (1 << (activeSensorId)); | |
| 265 sensorActive = 0; | |
| 266 } | |
| 267 break; | |
| 268 } | |
| 269 break; | |
| 270 case ACTION_BUTTON_NEXT: if((sensorType == SENSOR_CO2M) || (sensorType == SENSOR_CO2)) | |
| 262 { | 271 { |
| 263 DataEX_setExtInterface_Cmd(EXT_INTERFACE_CO2_CALIB, activeSensorId); | 272 DataEX_setExtInterface_Cmd(EXT_INTERFACE_CO2_CALIB, activeSensorId); |
| 264 } | 273 } |
| 265 break; | 274 break; |
| 266 case ACTION_TIMEOUT: | 275 case ACTION_TIMEOUT: |
