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