Mercurial > public > ostc4
comparison Discovery/Src/tInfoSensor.c @ 786:19ab6f3ed52a
Cleanup sensor data interface:
In a very early implementation of the multiplexer the address of the mux was 0 followed by the sensors. As a resul the ID of the channels was shifted by one. To avoid confusion and because the mux address is meanwhile changed to the last address, it makes sense to return to the indexing where only the three visible sensor slots are used as reference (0,1,2).
author | Ideenmodellierer |
---|---|
date | Sun, 04 Jun 2023 21:54:24 +0200 |
parents | c31237d20491 |
children | a370741a743b |
comparison
equal
deleted
inserted
replaced
785:3c0b16473af4 | 786:19ab6f3ed52a |
---|---|
50 SSettings *pSettings = settingsGetPointer(); | 50 SSettings *pSettings = settingsGetPointer(); |
51 activeSensorId = sensorId; | 51 activeSensorId = sensorId; |
52 set_globalState(StISENINFO); | 52 set_globalState(StISENINFO); |
53 switch (activeSensorId) | 53 switch (activeSensorId) |
54 { | 54 { |
55 case 3: setBackMenu((uint32_t)openEdit_O2Sensors,0,3); | 55 case 2: setBackMenu((uint32_t)openEdit_O2Sensors,0,3); |
56 break; | 56 break; |
57 case 2: setBackMenu((uint32_t)openEdit_O2Sensors,0,2); | 57 case 1: setBackMenu((uint32_t)openEdit_O2Sensors,0,2); |
58 break; | 58 break; |
59 default: | 59 default: |
60 case 1: setBackMenu((uint32_t)openEdit_O2Sensors,0,1); | 60 case 0: setBackMenu((uint32_t)openEdit_O2Sensors,0,1); |
61 break; | 61 break; |
62 } | 62 } |
63 | 63 |
64 sensorActive = 1; | 64 sensorActive = 1; |
65 if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId - 1))) | 65 if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId))) |
66 { | 66 { |
67 sensorActive = 0; | 67 sensorActive = 0; |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 | 71 |
72 uint8_t OnAction_Sensor(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 72 uint8_t OnAction_Sensor(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
73 { | 73 { |
74 if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId - 1))) | 74 if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) |
75 { | 75 { |
76 settingsGetPointer()->ppo2sensors_deactivated &= ~(1 << (activeSensorId - 1)); | 76 settingsGetPointer()->ppo2sensors_deactivated &= ~(1 << (activeSensorId)); |
77 tMenuEdit_set_on_off(editId, 1); | 77 tMenuEdit_set_on_off(editId, 1); |
78 } | 78 } |
79 else | 79 else |
80 { | 80 { |
81 settingsGetPointer()->ppo2sensors_deactivated |= (1 << (activeSensorId - 1)); | 81 settingsGetPointer()->ppo2sensors_deactivated |= (1 << (activeSensorId)); |
82 tMenuEdit_set_on_off(editId, 0); | 82 tMenuEdit_set_on_off(editId, 0); |
83 } | 83 } |
84 return UPDATE_DIVESETTINGS; | 84 return UPDATE_DIVESETTINGS; |
85 } | 85 } |
86 | 86 |
153 text[0] = '\001'; | 153 text[0] = '\001'; |
154 text[1] = TXT_Sensor; | 154 text[1] = TXT_Sensor; |
155 text[2] = ' '; | 155 text[2] = ' '; |
156 text[3] = TXT_Information; | 156 text[3] = TXT_Information; |
157 text[4] = ' '; | 157 text[4] = ' '; |
158 text[5] = '0' + activeSensorId; | 158 text[5] = '1' + activeSensorId; |
159 text[6] = 0; | 159 text[6] = 0; |
160 tInfo_write_content_simple( 30, 340, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); | 160 tInfo_write_content_simple( 30, 340, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); |
161 | 161 |
162 pDiveO2Data = (SSensorDataDiveO2*)&stateRealGetPointer()->lifeData.extIf_sensor_data[activeSensorId-1]; | 162 pDiveO2Data = (SSensorDataDiveO2*)&stateRealGetPointer()->lifeData.extIf_sensor_data[activeSensorId]; |
163 | 163 |
164 strIndex = snprintf(text,32,"ID: "); | 164 strIndex = snprintf(text,32,"ID: "); |
165 if(pDiveO2Data->sensorId != 0) | 165 if(pDiveO2Data->sensorId != 0) |
166 { | 166 { |
167 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]); | 167 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]); |
199 *textPointer++ = TXT_2BYTE; | 199 *textPointer++ = TXT_2BYTE; |
200 *textPointer++ = TXT2BYTE_Sensor; | 200 *textPointer++ = TXT2BYTE_Sensor; |
201 *textPointer++ = ' '; | 201 *textPointer++ = ' '; |
202 *textPointer++ = TXT_2BYTE; | 202 *textPointer++ = TXT_2BYTE; |
203 *textPointer++ = TXT2BYTE_O2IFDigital; | 203 *textPointer++ = TXT2BYTE_O2IFDigital; |
204 *textPointer++ = '0' + activeSensorId; | 204 *textPointer++ = '1' + activeSensorId; |
205 | 205 |
206 snprintf(textPointer, 20,": %01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[activeSensorId - 1], pStateReal->lifeData.sensorVoltage_mV[activeSensorId - 1]); | 206 snprintf(textPointer, 20,": %01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[activeSensorId], pStateReal->lifeData.sensorVoltage_mV[activeSensorId]); |
207 | 207 |
208 tInfo_write_content_simple( 30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020); | 208 tInfo_write_content_simple( 30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020); |
209 | 209 |
210 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0); | 210 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0); |
211 } | 211 } |
216 { | 216 { |
217 case ACTION_BUTTON_BACK: | 217 case ACTION_BUTTON_BACK: |
218 exitMenuEdit_to_BackMenu(); | 218 exitMenuEdit_to_BackMenu(); |
219 break; | 219 break; |
220 | 220 |
221 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId - 1))) | 221 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) |
222 { | 222 { |
223 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId - 1)); | 223 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId)); |
224 sensorActive = 1; | 224 sensorActive = 1; |
225 } | 225 } |
226 else | 226 else |
227 { | 227 { |
228 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId - 1)); | 228 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId)); |
229 sensorActive = 0; | 229 sensorActive = 0; |
230 } | 230 } |
231 break; | 231 break; |
232 case ACTION_BUTTON_NEXT: | 232 case ACTION_BUTTON_NEXT: |
233 case ACTION_TIMEOUT: | 233 case ACTION_TIMEOUT: |