Mercurial > public > ostc4
annotate Discovery/Src/tInfoSensor.c @ 843:2cab242c9a4a Evo_2_23
Update version number and set beta state
author | Ideenmodellierer |
---|---|
date | Sat, 20 Jan 2024 19:38:52 +0100 |
parents | ffb1036c27c2 |
children | 17d9d6eddd8d |
rev | line source |
---|---|
717 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tInfoCompass.c | |
5 /// \brief there is only compass_DX_f, compass_DY_f, compass_DZ_f output during this mode | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 23-Feb-2015 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 /* Includes ------------------------------------------------------------------*/ | |
30 | |
31 #include "gfx_engine.h" | |
32 #include "gfx_fonts.h" | |
33 #include "tHome.h" | |
34 #include "tInfo.h" | |
35 #include "tInfoSensor.h" | |
36 #include "tMenuEdit.h" | |
827 | 37 #include "data_exchange_main.h" |
717 | 38 |
39 #include <string.h> | |
40 #include <inttypes.h> | |
41 | |
42 extern void openEdit_O2Sensors(void); | |
783 | 43 uint8_t OnAction_Sensor (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
717 | 44 |
45 /* Private variables ---------------------------------------------------------*/ | |
783 | 46 static uint8_t activeSensorId = 0; |
47 static uint8_t sensorActive = 0; | |
717 | 48 /* Exported functions --------------------------------------------------------*/ |
783 | 49 void openInfo_Sensor(uint8_t sensorId) |
717 | 50 { |
783 | 51 SSettings *pSettings = settingsGetPointer(); |
52 activeSensorId = sensorId; | |
717 | 53 set_globalState(StISENINFO); |
783 | 54 switch (activeSensorId) |
55 { | |
786 | 56 case 2: setBackMenu((uint32_t)openEdit_O2Sensors,0,3); |
783 | 57 break; |
786 | 58 case 1: setBackMenu((uint32_t)openEdit_O2Sensors,0,2); |
783 | 59 break; |
60 default: | |
786 | 61 case 0: setBackMenu((uint32_t)openEdit_O2Sensors,0,1); |
783 | 62 break; |
63 } | |
64 | |
65 sensorActive = 1; | |
786 | 66 if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId))) |
783 | 67 { |
68 sensorActive = 0; | |
69 } | |
70 } | |
71 | |
72 | |
73 uint8_t OnAction_Sensor(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
74 { | |
786 | 75 if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) |
783 | 76 { |
786 | 77 settingsGetPointer()->ppo2sensors_deactivated &= ~(1 << (activeSensorId)); |
783 | 78 tMenuEdit_set_on_off(editId, 1); |
79 } | |
80 else | |
81 { | |
786 | 82 settingsGetPointer()->ppo2sensors_deactivated |= (1 << (activeSensorId)); |
783 | 83 tMenuEdit_set_on_off(editId, 0); |
84 } | |
85 return UPDATE_DIVESETTINGS; | |
717 | 86 } |
87 | |
88 | |
89 | |
90 uint64_t mod64(uint64_t a, uint64_t b) | |
91 { | |
92 uint64_t div; | |
93 div=(a/10); | |
94 b=(10*div); | |
95 return (a-b); | |
96 } | |
97 | |
98 void uint64ToString(uint64_t value, char* pbuf) | |
99 { | |
100 char tmpBuf[32]; | |
101 uint8_t index = 31; | |
102 | |
103 tmpBuf[index--] = 0; /* zero termination */ | |
104 while((index != 0) && (value != 0)) | |
105 { | |
106 tmpBuf[index--] = '0' + (value % 10);// mod64(worker64,10); | |
107 value /= 10; | |
108 } | |
109 strcpy(pbuf,&tmpBuf[index+1]); | |
110 } | |
111 | |
783 | 112 void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) |
113 { | |
114 char localtext[32]; | |
115 | |
116 if(left2ByteCode) | |
117 { | |
118 localtext[0] = TXT_2BYTE; | |
119 localtext[1] = left2ByteCode; | |
120 localtext[2] = 0; | |
121 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
122 } | |
123 | |
124 if(middle2ByteCode) | |
125 { | |
126 localtext[0] = '\001'; | |
127 localtext[1] = TXT_2BYTE; | |
128 localtext[2] = middle2ByteCode; | |
129 localtext[3] = 0; | |
130 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
131 } | |
132 | |
133 if(right2ByteCode) | |
134 { | |
135 localtext[0] = '\002'; | |
136 localtext[1] = TXT_2BYTE; | |
137 localtext[2] = right2ByteCode; | |
138 localtext[3] = 0; | |
139 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
140 } | |
141 } | |
142 | |
827 | 143 static void refreshInfo_SensorO2(GFX_DrawCfgScreen s) |
717 | 144 { |
783 | 145 const SDiveState *pStateReal = stateRealGetPointer(); |
717 | 146 SSensorDataDiveO2* pDiveO2Data; |
147 char text[31]; | |
148 uint8_t strIndex = 0; | |
783 | 149 char *textPointer = text; |
717 | 150 |
724
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
151 float pressure = 0.0; |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
152 |
827 | 153 pDiveO2Data = (SSensorDataDiveO2*)pStateReal->lifeData.extIf_sensor_data[activeSensorId]; |
154 strIndex = snprintf(text,32,"ID: "); | |
155 if(pDiveO2Data->sensorId != 0) | |
156 { | |
157 uint64ToString(pDiveO2Data->sensorId,&text[strIndex]); | |
158 } | |
159 tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020); | |
160 snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0); | |
161 tInfo_write_content_simple( 30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020); | |
162 | |
163 #ifdef ENABLE_EXTERNAL_PRESSURE | |
164 pressure = (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[2]); | |
165 #else | |
166 pressure = (float)pDiveO2Data->pressure / 1000.0; | |
167 #endif | |
168 snprintf(text,32,"Druck: %02.1f (%02.1f)", (float)pDiveO2Data->pressure / 1000.0, pressure *1000.0); | |
169 | |
170 tInfo_write_content_simple( 30, 770, ME_Y_LINE3, &FontT48, text, CLUT_Font020); | |
171 snprintf(text,32,"Feuchtigkeit: %02.1f", (float)pDiveO2Data->humidity / 1000.0); | |
172 tInfo_write_content_simple( 30, 770, ME_Y_LINE4, &FontT48, text, CLUT_Font020); | |
173 snprintf(text,32,"Status: 0x%lx", pDiveO2Data->status); | |
174 tInfo_write_content_simple( 30, 770, ME_Y_LINE5, &FontT48, text, CLUT_Font020); | |
175 #ifdef ENABLE_EXTERNAL_PRESSURE | |
176 snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0])); | |
177 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020); | |
178 #endif | |
179 | |
180 if(sensorActive) | |
181 { | |
182 *textPointer++ = '\005'; | |
183 } | |
184 else | |
185 { | |
186 *textPointer++ = '\006'; | |
187 } | |
188 *textPointer++ = ' '; | |
189 *textPointer++ = TXT_2BYTE; | |
190 *textPointer++ = TXT2BYTE_Sensor; | |
191 *textPointer++ = ' '; | |
192 *textPointer++ = TXT_2BYTE; | |
193 *textPointer++ = TXT2BYTE_O2IFDigital; | |
194 *textPointer++ = '1' + activeSensorId; | |
195 | |
196 snprintf(textPointer, 20,": %01.2f, %01.1f mV", pStateReal->lifeData.ppO2Sensor_bar[activeSensorId], pStateReal->lifeData.sensorVoltage_mV[activeSensorId]); | |
197 | |
198 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020); | |
199 | |
200 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0); | |
201 } | |
202 | |
203 static void refreshInfo_SensorCo2(GFX_DrawCfgScreen s) | |
204 { | |
205 const SDiveState *pStateReal = stateRealGetPointer(); | |
206 char text[31]; | |
207 char *textPointer = text; | |
208 | |
209 snprintf(text,32,"CO2: %ld ppm",pStateReal->lifeData.CO2_data.CO2_ppm); | |
210 tInfo_write_content_simple( 30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020); | |
211 | |
212 | |
213 snprintf(text,32,"Signal: %d",pStateReal->lifeData.CO2_data.signalStrength); | |
214 tInfo_write_content_simple( 30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020); | |
215 | |
216 if(sensorActive) | |
217 { | |
218 *textPointer++ = '\005'; | |
219 } | |
220 else | |
221 { | |
222 *textPointer++ = '\006'; | |
223 } | |
224 *textPointer++ = ' '; | |
225 *textPointer++ = TXT_2BYTE; | |
226 *textPointer++ = TXT2BYTE_Sensor; | |
227 *textPointer++ = ' '; | |
228 *textPointer++ = 'C'; | |
229 *textPointer++ = 'o'; | |
230 *textPointer++ = '1' + activeSensorId; | |
231 | |
232 snprintf(textPointer, 20,": %ld ppm", pStateReal->lifeData.CO2_data.CO2_ppm); | |
233 | |
234 tInfo_write_content_simple( 30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020); | |
235 | |
236 tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_O2Calib); | |
237 } | |
238 // =============================================================================== | |
239 void refreshInfo_Sensor(GFX_DrawCfgScreen s) | |
240 { | |
241 const SDiveState *pStateReal = stateRealGetPointer(); | |
242 | |
243 char text[31]; | |
244 | |
717 | 245 text[0] = '\001'; |
246 text[1] = TXT_Sensor; | |
247 text[2] = ' '; | |
248 text[3] = TXT_Information; | |
783 | 249 text[4] = ' '; |
786 | 250 text[5] = '1' + activeSensorId; |
783 | 251 text[6] = 0; |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
786
diff
changeset
|
252 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); |
717 | 253 |
827 | 254 switch(pStateReal->lifeData.extIf_sensor_map[activeSensorId]) |
255 { | |
256 default: | |
257 case SENSOR_DIGO2M: refreshInfo_SensorO2(s); | |
258 break; | |
259 case SENSOR_CO2M: refreshInfo_SensorCo2(s); | |
260 break; | |
261 } | |
717 | 262 } |
263 | |
264 void sendActionToInfoSensor(uint8_t sendAction) | |
265 { | |
266 switch(sendAction) | |
267 { | |
268 case ACTION_BUTTON_BACK: | |
269 exitMenuEdit_to_BackMenu(); | |
270 break; | |
271 | |
786 | 272 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) |
783 | 273 { |
827 | 274 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) |
275 { | |
276 settingsGetPointer()->co2_sensor_active = 1; | |
277 } | |
786 | 278 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId)); |
783 | 279 sensorActive = 1; |
280 } | |
281 else | |
282 { | |
827 | 283 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) |
284 { | |
285 settingsGetPointer()->co2_sensor_active = 0; | |
286 } | |
786 | 287 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId)); |
783 | 288 sensorActive = 0; |
289 } | |
290 break; | |
827 | 291 case ACTION_BUTTON_NEXT: if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) |
292 { | |
293 DataEX_setExtInterface_Cmd(EXT_INTERFACE_CO2_CALIB); | |
294 } | |
295 break; | |
717 | 296 case ACTION_TIMEOUT: |
297 case ACTION_MODE_CHANGE: | |
298 case ACTION_IDLE_TICK: | |
299 case ACTION_IDLE_SECOND: | |
300 default: | |
301 break; | |
302 } | |
303 } | |
304 |