comparison Discovery/Src/tInfoSensor.c @ 981:c6c781a2e85b default tip

Merge into default
author heinrichsweikamp
date Tue, 11 Feb 2025 18:12:00 +0100 (9 days ago)
parents 3420e3ba698d
children
comparison
equal deleted inserted replaced
871:f7318457df4d 981:c6c781a2e85b
32 #include "gfx_fonts.h" 32 #include "gfx_fonts.h"
33 #include "tHome.h" 33 #include "tHome.h"
34 #include "tInfo.h" 34 #include "tInfo.h"
35 #include "tInfoSensor.h" 35 #include "tInfoSensor.h"
36 #include "tMenuEdit.h" 36 #include "tMenuEdit.h"
37 #include "data_exchange_main.h"
37 38
38 #include <string.h> 39 #include <string.h>
39 #include <inttypes.h> 40 #include <inttypes.h>
40 41
41 extern void openEdit_O2Sensors(void); 42 extern void openEdit_O2Sensors(void);
58 break; 59 break;
59 default: 60 default:
60 case 0: setBackMenu((uint32_t)openEdit_O2Sensors,0,1); 61 case 0: setBackMenu((uint32_t)openEdit_O2Sensors,0,1);
61 break; 62 break;
62 } 63 }
63
64 sensorActive = 1; 64 sensorActive = 1;
65 if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId))) 65 if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId)))
66 { 66 {
67 sensorActive = 0; 67 sensorActive = 0;
68 } 68 }
69 DataEX_setExtInterface_Cmd(EXT_INTERFACE_O2_INDICATE, activeSensorId);
69 } 70 }
70 71
71 72
72 uint8_t OnAction_Sensor(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 73 uint8_t OnAction_Sensor(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
73 { 74 {
106 value /= 10; 107 value /= 10;
107 } 108 }
108 strcpy(pbuf,&tmpBuf[index+1]); 109 strcpy(pbuf,&tmpBuf[index+1]);
109 } 110 }
110 111
111 void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) 112
112 { 113 static void refreshInfo_SensorO2(GFX_DrawCfgScreen s)
113 char localtext[32];
114
115 if(left2ByteCode)
116 {
117 localtext[0] = TXT_2BYTE;
118 localtext[1] = left2ByteCode;
119 localtext[2] = 0;
120 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
121 }
122
123 if(middle2ByteCode)
124 {
125 localtext[0] = '\001';
126 localtext[1] = TXT_2BYTE;
127 localtext[2] = middle2ByteCode;
128 localtext[3] = 0;
129 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
130 }
131
132 if(right2ByteCode)
133 {
134 localtext[0] = '\002';
135 localtext[1] = TXT_2BYTE;
136 localtext[2] = right2ByteCode;
137 localtext[3] = 0;
138 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
139 }
140 }
141
142 // ===============================================================================
143 void refreshInfo_Sensor(GFX_DrawCfgScreen s)
144 { 114 {
145 const SDiveState *pStateReal = stateRealGetPointer(); 115 const SDiveState *pStateReal = stateRealGetPointer();
146 SSensorDataDiveO2* pDiveO2Data; 116 SSensorDataDiveO2* pDiveO2Data;
147 char text[31]; 117 char text[31];
148 uint8_t strIndex = 0; 118 uint8_t strIndex = 0;
149 char *textPointer = text; 119 char *textPointer = text;
150 120
151 float pressure = 0.0; 121 float pressure = 0.0;
122
123 pDiveO2Data = (SSensorDataDiveO2*)pStateReal->lifeData.extIf_sensor_data[activeSensorId];
124 strIndex = snprintf(text,32,"ID: ");
125 if(pDiveO2Data->sensorId != 0)
126 {
127 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]);
128 }
129 tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020);
130 snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0);
131 tInfo_write_content_simple( 30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020);
132
133 #ifdef ENABLE_EXTERNAL_PRESSURE
134 pressure = (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[2]);
135 #else
136 pressure = (float)pDiveO2Data->pressure / 1000.0;
137 #endif
138 snprintf(text,32,"Druck: %02.1f (%02.1f)", (float)pDiveO2Data->pressure / 1000.0, pressure *1000.0);
139
140 tInfo_write_content_simple( 30, 770, ME_Y_LINE3, &FontT48, text, CLUT_Font020);
141 snprintf(text,32,"Feuchtigkeit: %02.1f", (float)pDiveO2Data->humidity / 1000.0);
142 tInfo_write_content_simple( 30, 770, ME_Y_LINE4, &FontT48, text, CLUT_Font020);
143 snprintf(text,32,"Status: 0x%lx", pDiveO2Data->status);
144 tInfo_write_content_simple( 30, 770, ME_Y_LINE5, &FontT48, text, CLUT_Font020);
145 #ifdef ENABLE_EXTERNAL_PRESSURE
146 snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0]));
147 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
148 #endif
149
150 if(sensorActive)
151 {
152 *textPointer++ = '\005';
153 }
154 else
155 {
156 *textPointer++ = '\006';
157 }
158 *textPointer++ = ' ';
159 *textPointer++ = TXT_2BYTE;
160 *textPointer++ = TXT2BYTE_Sensor;
161 *textPointer++ = ' ';
162 *textPointer++ = TXT_2BYTE;
163 *textPointer++ = TXT2BYTE_O2IFDigital;
164 *textPointer++ = '1' + activeSensorId;
165
166 snprintf(textPointer, 20,": %01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[activeSensorId], pStateReal->lifeData.sensorVoltage_mV[activeSensorId]);
167
168 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
169
170 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0);
171 }
172
173 static void refreshInfo_SensorCo2(GFX_DrawCfgScreen s)
174 {
175 const SDiveState *pStateReal = stateRealGetPointer();
176 char text[31];
177 char *textPointer = text;
178
179 snprintf(text,32,"CO2: %ld ppm",pStateReal->lifeData.CO2_data.CO2_ppm);
180 tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020);
181
182
183 snprintf(text,32,"Signal: %d",pStateReal->lifeData.CO2_data.signalStrength);
184 tInfo_write_content_simple( 30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020);
185
186 if(sensorActive)
187 {
188 *textPointer++ = '\005';
189 }
190 else
191 {
192 *textPointer++ = '\006';
193 }
194 *textPointer++ = ' ';
195 *textPointer++ = TXT_2BYTE;
196 *textPointer++ = TXT2BYTE_Sensor;
197 *textPointer++ = ' ';
198 *textPointer++ = 'C';
199 *textPointer++ = 'o';
200 *textPointer++ = '1' + activeSensorId;
201
202 snprintf(textPointer, 20,": %ld ppm", pStateReal->lifeData.CO2_data.CO2_ppm);
203
204 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
205
206 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_O2Calib);
207 }
208 // ===============================================================================
209 void refreshInfo_Sensor(GFX_DrawCfgScreen s)
210 {
211 const SDiveState *pStateReal = stateRealGetPointer();
212
213 char text[31];
152 214
153 text[0] = '\001'; 215 text[0] = '\001';
154 text[1] = TXT_Sensor; 216 text[1] = TXT_Sensor;
155 text[2] = ' '; 217 text[2] = ' ';
156 text[3] = TXT_Information; 218 text[3] = TXT_Information;
157 text[4] = ' '; 219 text[4] = ' ';
158 text[5] = '1' + activeSensorId; 220 text[5] = '1' + activeSensorId;
159 text[6] = 0; 221 text[6] = 0;
160 tInfo_write_content_simple( 30, 340, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); 222 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware);
161 223
162 pDiveO2Data = (SSensorDataDiveO2*)&stateRealGetPointer()->lifeData.extIf_sensor_data[activeSensorId]; 224 switch(pStateReal->lifeData.extIf_sensor_map[activeSensorId])
163 225 {
164 strIndex = snprintf(text,32,"ID: "); 226 default:
165 if(pDiveO2Data->sensorId != 0) 227 case SENSOR_DIGO2M: refreshInfo_SensorO2(s);
166 { 228 break;
167 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]); 229 case SENSOR_CO2M: refreshInfo_SensorCo2(s);
168 } 230 break;
169 tInfo_write_content_simple( 30, 340, ME_Y_LINE1, &FontT48, text, CLUT_Font020); 231 }
170 snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0);
171 tInfo_write_content_simple( 30, 340, ME_Y_LINE2, &FontT48, text, CLUT_Font020);
172
173 #ifdef ENABLE_EXTERNAL_PRESSURE
174 pressure = (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[2]);
175 #else
176 pressure = (float)pDiveO2Data->pressure / 1000.0;
177 #endif
178 snprintf(text,32,"Druck: %02.1f (%02.1f)", (float)pDiveO2Data->pressure / 1000.0, pressure *1000.0);
179
180 tInfo_write_content_simple( 30, 340, ME_Y_LINE3, &FontT48, text, CLUT_Font020);
181 snprintf(text,32,"Feuchtigkeit: %02.1f", (float)pDiveO2Data->humidity / 1000.0);
182 tInfo_write_content_simple( 30, 340, ME_Y_LINE4, &FontT48, text, CLUT_Font020);
183 snprintf(text,32,"Status: 0x%lx", pDiveO2Data->status);
184 tInfo_write_content_simple( 30, 340, ME_Y_LINE5, &FontT48, text, CLUT_Font020);
185 #ifdef ENABLE_EXTERNAL_PRESSURE
186 snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0]));
187 tInfo_write_content_simple( 30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
188 #endif
189
190 if(sensorActive)
191 {
192 *textPointer++ = '\005';
193 }
194 else
195 {
196 *textPointer++ = '\006';
197 }
198 *textPointer++ = ' ';
199 *textPointer++ = TXT_2BYTE;
200 *textPointer++ = TXT2BYTE_Sensor;
201 *textPointer++ = ' ';
202 *textPointer++ = TXT_2BYTE;
203 *textPointer++ = TXT2BYTE_O2IFDigital;
204 *textPointer++ = '1' + activeSensorId;
205
206 snprintf(textPointer, 20,": %01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[activeSensorId], pStateReal->lifeData.sensorVoltage_mV[activeSensorId]);
207
208 tInfo_write_content_simple( 30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
209
210 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0);
211 } 232 }
212 233
213 void sendActionToInfoSensor(uint8_t sendAction) 234 void sendActionToInfoSensor(uint8_t sendAction)
214 { 235 {
215 switch(sendAction) 236 switch(sendAction)
218 exitMenuEdit_to_BackMenu(); 239 exitMenuEdit_to_BackMenu();
219 break; 240 break;
220 241
221 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) 242 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId)))
222 { 243 {
244 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M)
245 {
246 settingsGetPointer()->co2_sensor_active = 1;
247 }
223 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId)); 248 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId));
224 sensorActive = 1; 249 sensorActive = 1;
225 } 250 }
226 else 251 else
227 { 252 {
253 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M)
254 {
255 settingsGetPointer()->co2_sensor_active = 0;
256 }
228 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId)); 257 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId));
229 sensorActive = 0; 258 sensorActive = 0;
230 } 259 }
231 break; 260 break;
232 case ACTION_BUTTON_NEXT: 261 case ACTION_BUTTON_NEXT: if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M)
262 {
263 DataEX_setExtInterface_Cmd(EXT_INTERFACE_CO2_CALIB, activeSensorId);
264 }
265 break;
233 case ACTION_TIMEOUT: 266 case ACTION_TIMEOUT:
234 case ACTION_MODE_CHANGE: 267 case ACTION_MODE_CHANGE:
235 case ACTION_IDLE_TICK: 268 case ACTION_IDLE_TICK:
236 case ACTION_IDLE_SECOND: 269 case ACTION_IDLE_SECOND:
237 default: 270 default: