Mercurial > public > ostc4
annotate Discovery/Src/tInfoSensor.c @ 927:908d9a8e8c84 Evo_2_23
Cleanup Internal Uart:
The internal UART was using the wrong UART RX channel. In addition the compile switches have been updated to allow GNSS data flow if new GPIO config is available or if GNSS is enabled for the external UART.
author | Ideenmodellierer |
---|---|
date | Tue, 26 Nov 2024 21:01:13 +0100 |
parents | 17d9d6eddd8d |
children |
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 |
827 | 113 static void refreshInfo_SensorO2(GFX_DrawCfgScreen s) |
717 | 114 { |
783 | 115 const SDiveState *pStateReal = stateRealGetPointer(); |
717 | 116 SSensorDataDiveO2* pDiveO2Data; |
117 char text[31]; | |
118 uint8_t strIndex = 0; | |
783 | 119 char *textPointer = text; |
717 | 120 |
724
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
121 float pressure = 0.0; |
f285424f04d9
Development feature: external pressure sensor
Ideenmodellierer
parents:
717
diff
changeset
|
122 |
827 | 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]; | |
214 | |
717 | 215 text[0] = '\001'; |
216 text[1] = TXT_Sensor; | |
217 text[2] = ' '; | |
218 text[3] = TXT_Information; | |
783 | 219 text[4] = ' '; |
786 | 220 text[5] = '1' + activeSensorId; |
783 | 221 text[6] = 0; |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
786
diff
changeset
|
222 tInfo_write_content_simple( 30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware); |
717 | 223 |
827 | 224 switch(pStateReal->lifeData.extIf_sensor_map[activeSensorId]) |
225 { | |
226 default: | |
227 case SENSOR_DIGO2M: refreshInfo_SensorO2(s); | |
228 break; | |
229 case SENSOR_CO2M: refreshInfo_SensorCo2(s); | |
230 break; | |
231 } | |
717 | 232 } |
233 | |
234 void sendActionToInfoSensor(uint8_t sendAction) | |
235 { | |
236 switch(sendAction) | |
237 { | |
238 case ACTION_BUTTON_BACK: | |
239 exitMenuEdit_to_BackMenu(); | |
240 break; | |
241 | |
786 | 242 case ACTION_BUTTON_ENTER: if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId))) |
783 | 243 { |
827 | 244 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) |
245 { | |
246 settingsGetPointer()->co2_sensor_active = 1; | |
247 } | |
786 | 248 settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId)); |
783 | 249 sensorActive = 1; |
250 } | |
251 else | |
252 { | |
827 | 253 if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) |
254 { | |
255 settingsGetPointer()->co2_sensor_active = 0; | |
256 } | |
786 | 257 settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId)); |
783 | 258 sensorActive = 0; |
259 } | |
260 break; | |
827 | 261 case ACTION_BUTTON_NEXT: if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M) |
262 { | |
263 DataEX_setExtInterface_Cmd(EXT_INTERFACE_CO2_CALIB); | |
264 } | |
265 break; | |
717 | 266 case ACTION_TIMEOUT: |
267 case ACTION_MODE_CHANGE: | |
268 case ACTION_IDLE_TICK: | |
269 case ACTION_IDLE_SECOND: | |
270 default: | |
271 break; | |
272 } | |
273 } | |
274 |