Mercurial > public > ostc4
annotate Discovery/Src/tHome.c @ 589:8d95bab5bf6a
Minor: Update the documentation for building the code
author | heinrichsweikamp |
---|---|
date | Thu, 17 Dec 2020 10:58:28 +0100 |
parents | 1105cf7bbf6f |
children | 280c11153080 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tHome.c | |
5 /// \brief Control for Surface and Dive Templates | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 10-November-2014 | |
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 #include "tHome.h" | |
31 | |
32 #include "data_exchange_main.h" // for dataOutGetPointer() | |
33 #include "gfx_fonts.h" | |
34 #include "t3.h" | |
35 #include "t4_tetris.h" | |
36 #include "t5_gauge.h" | |
37 #include "t6_apnea.h" | |
38 #include "t7.h" | |
39 #include "tDebug.h" | |
40 #include "timer.h" // for timer_Stopwatch_Restart | |
41 #include "tMenu.h" | |
42 #include "tMenuEditGasOC.h" // for openEdit_DiveSelectBetterGas() | |
43 #include "tMenuEditSetpoint.h" // for openEdit_DiveSelectBetterSetpoint() | |
44 #include "simulation.h" | |
361
b111fc4250e9
Pass action to customer vie update function.
Ideenmodellierer
parents:
289
diff
changeset
|
45 #include "motion.h" |
38 | 46 |
47 /* Private types -------------------------------------------------------------*/ | |
48 | |
49 /* Exported variables --------------------------------------------------------*/ | |
50 _Bool warning_count_high_time = 0; | |
51 _Bool display_count_high_time = 0; | |
52 | |
53 uint8_t errorsInSettings = 0; | |
54 /* Private variables ---------------------------------------------------------*/ | |
55 static uint8_t warning_toogle_count; | |
56 static uint16_t display_toogle_count; | |
57 static uint16_t tHome_tick_count_cview; | |
58 static uint16_t tHome_tick_count_field; | |
576 | 59 static uint16_t tHome_tick_count_o2sens; |
38 | 60 |
379 | 61 const uint8_t cv_changelist[] = {CVIEW_Compass, CVIEW_SummaryOfLeftCorner, CVIEW_Tissues, CVIEW_Profile, CVIEW_EADTime, CVIEW_Gaslist, CVIEW_noneOrDebug, CVIEW_Decolist,CVIEW_sensors,CVIEW_sensors_mV, CVIEW_END}; |
542
6960df7ddb09
Added new t3 view showing first deco stop and tts in parallel:
Ideenmodellierer
parents:
541
diff
changeset
|
62 const uint8_t cv_changelist_BS[] = {CVIEW_T3_Decostop, CVIEW_sensors, CVIEW_Compass, CVIEW_T3_MaxDepth,CVIEW_T3_StopWatch, CVIEW_T3_TTS, CVIEW_T3_GasList, CVIEW_T3_ppO2andGas, CVIEW_noneOrDebug, CVIEW_T3_Navigation, CVIEW_T3_DepthData, CVIEW_T3_DecoTTS, CVIEW_T3_END}; |
38 | 63 |
64 /* Private function prototypes -----------------------------------------------*/ | |
65 | |
576 | 66 #define AUTORETURN_O2SENS (200u) /* return to sensor view after 20 seconds in case sensor is connected */ |
67 | |
68 | |
38 | 69 /* Exported functions --------------------------------------------------------*/ |
70 | |
71 void set_globalState_tHome(void) | |
72 { | |
73 if(stateUsed->mode == MODE_DIVE) | |
74 set_globalState(StD); | |
75 else | |
76 set_globalState(StS); | |
77 } | |
78 | |
79 | |
80 void tHome_init(void) | |
81 { | |
82 t7_init(); // standard + surface | |
83 t3_init(); // big font | |
84 t4_init(); // game | |
85 t5_init(); // gauge | |
86 t6_init(); // apnea | |
87 } | |
88 | |
89 | |
90 void tHome_init_compass(void) | |
91 { | |
92 init_t7_compass(); | |
93 } | |
94 | |
95 | |
96 void tHome_refresh(void) | |
97 { | |
98 SSettings* pSettings = settingsGetPointer(); | |
99 | |
100 warning_toogle_count++; | |
101 if(warning_toogle_count >= 2* pSettings->warning_blink_dsec) | |
102 warning_toogle_count = 0; | |
103 | |
104 if(warning_toogle_count >= pSettings->warning_blink_dsec) | |
105 warning_count_high_time = 1; | |
106 else | |
107 warning_count_high_time = 0; | |
108 | |
109 | |
110 display_toogle_count++; | |
111 if(display_toogle_count >= 2* pSettings->display_toogle_desc) | |
112 display_toogle_count = 0; | |
113 | |
114 if(display_toogle_count >= pSettings->display_toogle_desc) | |
115 display_count_high_time = 1; | |
116 else | |
117 display_count_high_time = 0; | |
118 | |
119 | |
120 if(pSettings->design == 6) | |
121 t6_refresh(); | |
122 else | |
123 if(pSettings->design == 5) | |
124 t5_refresh(); | |
125 else | |
126 if(pSettings->design == 4) | |
127 t4_refresh(); | |
128 else | |
129 if(pSettings->design == 3) | |
130 t3_refresh(); | |
131 else | |
132 if(pSettings->design == 7) | |
133 t7_refresh(); | |
134 else | |
135 { | |
136 pSettings->design = 7; | |
137 t7_refresh(); | |
138 } | |
139 } | |
140 | |
141 | |
142 void tHome_sleepmode_fun(void) | |
143 { | |
144 t7_refresh_sleepmode_fun(); | |
145 } | |
146 | |
147 | |
148 void tHomeDiveMenuControl(uint8_t sendAction) | |
149 { | |
150 if(sendAction == ACTION_BUTTON_NEXT) | |
151 { | |
152 if(settingsGetPointer()->design == 4) | |
153 return; | |
154 | |
155 switch(get_globalState()) | |
156 { | |
516
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
157 case StD: |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
158 if(settingsGetPointer()->design == 6) |
38 | 159 { |
160 if(is_stateUsedSetToSim()) | |
161 set_globalState(StDSIM1); | |
162 else | |
163 set_globalState(StDQUIT); | |
164 break; | |
165 } | |
166 | |
167 if(settingsGetPointer()->design == 5) | |
168 { | |
169 if(t5_getCustomView() == CVIEW_Compass) | |
170 set_globalState(StDBEAR); | |
171 else | |
172 set_globalState(StDRAVG); | |
173 break; | |
174 } | |
175 | |
516
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
176 if(settingsGetPointer()->design == 3) |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
177 { |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
178 switch(t3_getCustomView()) |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
179 { |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
180 case CVIEW_T3_Navigation: |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
181 case CVIEW_Compass: set_globalState(StDBEAR); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
182 break; |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
183 case CVIEW_T3_StopWatch: set_globalState(StDRAVG); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
184 break; |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
185 case CVIEW_T3_GasList: if(stateUsed->warnings.betterGas) |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
186 { |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
187 set_globalState(StDMGAS); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
188 } |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
189 break; |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
190 default: |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
191 break; |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
192 } |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
193 break; |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
194 } |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
195 |
38 | 196 if(stateUsed->warnings.betterGas) |
197 set_globalState(StDMGAS); | |
198 else | |
199 if(stateUsed->warnings.betterSetpoint) | |
200 set_globalState(StDMSPT); | |
201 else | |
202 set_globalState(StDMENU); | |
203 break; | |
204 | |
205 case StDMGAS: | |
516
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
206 if(settingsGetPointer()->design == 3) |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
207 { |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
208 set_globalState(StD); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
209 } |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
210 else |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
211 { |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
212 if(stateUsed->warnings.betterSetpoint) |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
213 set_globalState(StDMSPT); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
214 else |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
215 set_globalState(StDMENU); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
216 } |
38 | 217 break; |
218 | |
219 case StDMSPT: | |
220 set_globalState(StDMENU); | |
221 break; | |
222 | |
223 case StDMENU: | |
224 if(is_stateUsedSetToSim()) | |
225 set_globalState(StDSIM1); | |
226 else | |
227 set_globalState(StD); | |
228 break; | |
229 | |
230 case StDSIM1: | |
231 set_globalState(StDSIM2); | |
232 break; | |
233 | |
234 case StDSIM2: | |
235 set_globalState(StDSIM3); | |
236 break; | |
237 | |
238 case StDSIM3: | |
239 set_globalState(StDSIM4); | |
240 break; | |
241 | |
242 case StDSIM4: | |
243 set_globalState(StD); | |
244 break; | |
245 | |
516
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
246 case StDBEAR: |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
247 if(settingsGetPointer()->design == 5) |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
248 { |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
249 set_globalState(StDRAVG); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
250 } |
38 | 251 |
516
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
252 if(settingsGetPointer()->design == 3) |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
253 { |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
254 if(t3_getCustomView() == CVIEW_T3_Navigation) |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
255 { |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
256 set_globalState(StDRAVG); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
257 } |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
258 else |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
259 { |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
260 set_globalState(StD); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
261 } |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
262 } |
38 | 263 break; |
516
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
264 case StDRAVG: |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
265 if(settingsGetPointer()->design == 5) |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
266 { |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
267 if(is_stateUsedSetToSim()) |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
268 set_globalState(StDSIM1); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
269 else |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
270 set_globalState(StD); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
271 break; |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
272 } |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
273 else |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
274 { |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
275 set_globalState(StD); |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
276 } |
bd66f4910993
Added quick menu function to big font view:
Ideenmodellierer
parents:
505
diff
changeset
|
277 break; |
38 | 278 case StDQUIT: // t6_apnea |
279 set_globalState(StD); | |
280 break; | |
281 | |
282 default: | |
283 set_globalState(StD); | |
284 } | |
285 } | |
286 | |
287 if(sendAction == ACTION_BUTTON_ENTER) | |
288 { | |
289 if(settingsGetPointer()->design == 4) | |
290 return; | |
291 | |
292 switch(get_globalState()) | |
293 { | |
294 case StDMGAS: | |
295 openEdit_DiveSelectBetterGas(); | |
296 set_globalState(StD); | |
297 break; | |
298 case StDMSPT: | |
299 openEdit_DiveSelectBetterSetpoint(); | |
300 set_globalState(StD); | |
301 break; | |
302 | |
303 case StDMENU: | |
304 openMenu_first_page_with_OC_gas_update(); | |
305 break; | |
306 | |
307 case StDSIM1: | |
308 Sim_Quit(); | |
309 break; | |
310 | |
311 case StDSIM2: | |
312 Sim_Ascend(); | |
313 break; | |
314 | |
315 case StDSIM3: | |
316 Sim_Descend(); | |
317 break; | |
318 | |
319 case StDSIM4: | |
320 Sim_Divetime(); | |
321 break; | |
322 | |
323 case StDBEAR: // t5_gauge | |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
210
diff
changeset
|
324 stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; |
38 | 325 set_globalState(StD); |
326 break; | |
327 | |
328 case StDRAVG: // t5_gauge | |
329 timer_Stopwatch_Restart(); | |
330 set_globalState(StD); | |
331 break; | |
332 | |
333 case StDQUIT: // t6_apnea | |
334 set_globalState(StD); // used to end StDQUIT, is called before everything else because changes are made in the next lines | |
335 if(is_stateUsedSetToSim()) | |
336 Sim_Quit(); | |
337 else | |
338 dataOutGetPointer()->setEndDive = 1; | |
339 break; | |
340 | |
341 default: | |
342 break; | |
343 } | |
344 } | |
345 } | |
346 | |
347 | |
348 void tHome_findNextStop(const uint16_t *list, uint8_t *depthOutMeter, uint16_t *lengthOutSeconds) | |
349 { | |
350 uint8_t ptr = DECOINFO_STRUCT_MAX_STOPS - 1; | |
351 | |
352 while(ptr && !list[ptr]) | |
353 ptr--; | |
354 | |
355 *lengthOutSeconds = list[ptr]; | |
356 if(!(*lengthOutSeconds)) | |
357 { | |
358 *depthOutMeter = 0; | |
359 } | |
360 else | |
361 if(ptr == 0) | |
362 { | |
363 *depthOutMeter = (uint8_t)((stateUsed->diveSettings.last_stop_depth_bar*10.0f) + 0.1f); | |
364 } | |
365 else | |
366 { | |
367 ptr -= 1; | |
368 *depthOutMeter = (uint8_t)(((stateUsed->diveSettings.input_second_to_last_stop_depth_bar + (stateUsed->diveSettings.input_next_stop_increment_depth_bar * ptr))*10.0f) + 0.1f); | |
369 } | |
370 } | |
371 | |
372 | |
373 void tHome_change_field_button_pressed(void) | |
374 { | |
375 tHome_tick_count_field = 0; | |
576 | 376 tHome_tick_count_o2sens = 0; |
38 | 377 if(settingsGetPointer()->design == 7) |
378 t7_change_field(); | |
379 } | |
380 | |
381 | |
361
b111fc4250e9
Pass action to customer vie update function.
Ideenmodellierer
parents:
289
diff
changeset
|
382 void tHome_change_customview_button_pressed(uint8_t action) |
38 | 383 { |
384 tHome_tick_count_cview = 0; | |
576 | 385 tHome_tick_count_o2sens = 0; |
386 | |
38 | 387 if(settingsGetPointer()->design == 7) |
361
b111fc4250e9
Pass action to customer vie update function.
Ideenmodellierer
parents:
289
diff
changeset
|
388 t7_change_customview(action); |
38 | 389 else |
390 if(settingsGetPointer()->design == 3) | |
386
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
384
diff
changeset
|
391 t3_change_customview(action); |
38 | 392 else |
393 if(settingsGetPointer()->design == 5) | |
386
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
384
diff
changeset
|
394 t5_change_customview(action); |
38 | 395 else |
396 if(settingsGetPointer()->design == 6) | |
386
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
384
diff
changeset
|
397 t6_change_customview(action); |
38 | 398 } |
399 | |
505 | 400 uint8_t tHome_getNumberOfAvailableCVs(const uint8_t* pcv_list) |
401 { | |
402 uint8_t cnt = 0; | |
403 | |
404 while((pcv_list[cnt] != CVIEW_END) && (pcv_list[cnt] != CVIEW_T3_END)) | |
405 { | |
406 cnt++; | |
407 if (cnt > 100) /* just in case an invalid list has been provided... */ | |
408 { | |
409 break; | |
410 } | |
411 } | |
412 cnt--; /* do not count end token */ | |
413 return cnt; | |
414 } | |
38 | 415 |
416 void tHome_tick(void) | |
417 { | |
418 uint16_t field = settingsGetPointer()->tX_userselectedLeftLowerCornerTimeout; | |
419 uint16_t cview = settingsGetPointer()->tX_customViewTimeout; | |
420 | |
421 if(field) | |
422 { | |
423 tHome_tick_count_field++; | |
424 if(tHome_tick_count_field > (field * 10)) | |
425 { | |
426 tHome_tick_count_field = 0; | |
427 if(settingsGetPointer()->design == 7) | |
428 { | |
429 t7_set_field_to_primary(); | |
430 } | |
431 } | |
432 } | |
433 | |
434 if(cview) | |
435 { | |
436 tHome_tick_count_cview++; | |
437 if(tHome_tick_count_cview > (cview *10)) | |
438 { | |
439 tHome_tick_count_cview = 0; | |
440 if(settingsGetPointer()->design == 7) | |
441 { | |
442 t7_set_customview_to_primary(); | |
443 } | |
541
6fbf7cd391cb
Added default view selection and auto return to view to t3 visualization:
Ideenmodellierer
parents:
516
diff
changeset
|
444 if(settingsGetPointer()->design == 3) |
6fbf7cd391cb
Added default view selection and auto return to view to t3 visualization:
Ideenmodellierer
parents:
516
diff
changeset
|
445 { |
6fbf7cd391cb
Added default view selection and auto return to view to t3 visualization:
Ideenmodellierer
parents:
516
diff
changeset
|
446 t3_set_customview_to_primary(); |
6fbf7cd391cb
Added default view selection and auto return to view to t3 visualization:
Ideenmodellierer
parents:
516
diff
changeset
|
447 } |
38 | 448 } |
449 } | |
576 | 450 |
451 if((stateUsed->mode == MODE_SURFACE) && (stateUsed->diveSettings.ppo2sensors_deactivated != 0x07) && (stateUsed->diveSettings.ccrOption != 0)) | |
452 { | |
453 tHome_tick_count_o2sens++; | |
454 if(tHome_tick_count_o2sens > AUTORETURN_O2SENS) | |
455 { | |
456 tHome_tick_count_o2sens = 0; | |
457 t7_select_customview(CVIEW_sensors); | |
458 } | |
459 } | |
38 | 460 } |
461 | |
462 | |
463 uint32_t tHome_DateCode(RTC_DateTypeDef *dateInput) | |
464 { | |
465 uint32_t answer = 0; | |
466 | |
467 answer = 0; | |
468 answer += (dateInput->Year & 0x7F)<< 9; | |
469 answer += (dateInput->Month & 0x0F)<< 5; | |
470 answer += (dateInput->Date & 0x1F); | |
471 | |
472 return answer; | |
473 } | |
474 | |
475 | |
476 uint8_t tHome_gas_writer(uint8_t oxygen_percentage, uint8_t helium_percentage, char *text) | |
477 { | |
478 if(oxygen_percentage == 100) | |
479 return (uint8_t) snprintf(text,10,"Oxy"); | |
480 else if((oxygen_percentage == 21) && (!helium_percentage)) | |
481 return (uint8_t) snprintf(text,10,"Air"); | |
482 else if(!helium_percentage) | |
483 return (uint8_t) snprintf(text,10,"NX%02i",oxygen_percentage); | |
484 else if((oxygen_percentage + helium_percentage) == 100) | |
485 return (uint8_t) snprintf(text,10,"HX%02i",oxygen_percentage); | |
486 else | |
487 return (uint8_t) snprintf(text,10,"%02i/%02i",oxygen_percentage,helium_percentage); | |
488 } | |
489 | |
490 uint8_t tHome_show_lost_connection_count(GFX_DrawCfgScreen *ScreenToWriteOn) | |
491 { | |
208 | 492 static uint8_t LastKnowRTEState = SPI_RX_STATE_INVALID; |
493 | |
99 | 494 if(!SPI_MIN_ERROR_SHOW) return 0; |
172
c659fda83e44
Minor: Button defaults, release date adjusted, use SPI_SHOW_SYNC_STATS
heinrichsweikamp
parents:
138
diff
changeset
|
495 if(DataEX_lost_connection_count()>=SPI_MIN_ERROR_SHOW && SPI_SHOW_SYNC_STATS){ |
38 | 496 |
99 | 497 char text[64]; |
38 | 498 |
82 | 499 SDataExchangeSlaveToMaster* dataIn=get_dataInPointer(); |
208 | 500 SDataReceiveFromMaster* pDataOut = dataOutGetPointer(); |
82 | 501 |
493
b560e474e319
Added possibility to switch between "classic" bigfont views and a selection with a new information combination
Ideenmodellierer
parents:
386
diff
changeset
|
502 snprintf(text,32,"spi err:\002 %ld/%ld",DataEX_lost_connection_count(),get_num_SPI_CALLBACKS()); |
99 | 503 Gfx_write_label_var(ScreenToWriteOn, 100,300, 0,&FontT24,CLUT_ButtonSymbols,text); |
82 | 504 |
104 | 505 // snprintf(text,32,"header:\002%X%X%X%X",dataIn->header.checkCode[0],dataIn->header.checkCode[1],dataIn->header.checkCode[2],dataIn->header.checkCode[3]); |
506 // Gfx_write_label_var(ScreenToWriteOn, 350,550, 0,&FontT24,CLUT_ButtonSymbols,text); | |
82 | 507 |
208 | 508 //snprintf(text,32,"footer:\002%X%X%X%X",dataIn->footer.checkCode[0],dataIn->footer.checkCode[1],dataIn->footer.checkCode[2],dataIn->footer.checkCode[3]); |
509 | |
510 /* data shifted => ignore received data */ | |
511 if((pDataOut->header.checkCode[SPI_HEADER_INDEX_RX_STATE] == SPI_RX_STATE_SHIFTED) || (pDataOut->header.checkCode[SPI_HEADER_INDEX_RX_STATE] == SPI_RX_STATE_OFFLINE)) | |
512 { | |
513 dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE] = LastKnowRTEState; | |
514 } | |
515 else | |
516 { | |
517 LastKnowRTEState =dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE]; | |
518 } | |
519 snprintf(text,32,"RX State M|R:\002%X|%X",pDataOut->header.checkCode[SPI_HEADER_INDEX_RX_STATE], dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE] ); | |
99 | 520 Gfx_write_label_var(ScreenToWriteOn, 600,800, 0,&FontT24,CLUT_ButtonSymbols,text); |
521 } | |
82 | 522 |
99 | 523 |
524 | |
525 // snprintf(text,32,"cpt:\002%i",get_num_SPI_CALLBACKS()); | |
526 // Gfx_write_label_var(ScreenToWriteOn, 600,800, 90,&FontT24,CLUT_ButtonSymbols,text); | |
82 | 527 |
528 // snprintf(text,10,"i2c:\002%i",get_DataEX_Error_place()); | |
529 // Gfx_write_label_var(ScreenToWriteOn, 600,800, 90,&FontT24,CLUT_ButtonSymbols,text); | |
38 | 530 |
531 return DataEX_lost_connection_count(); | |
532 } |