Mercurial > public > ostc4
annotate Discovery/Src/tHome.c @ 500:0d2449e9d659
Added possibility to switch between "classic" bigfont views and a selection with a new information combination
New strings for the selection have been added and the menu handling has been updated to enable the selection.
author | Ideenmodellierer |
---|---|
date | Mon, 24 Aug 2020 19:36:18 +0200 |
parents | 39c147e47c1c |
children | 06b21f1e47a5 |
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; | |
59 | |
379 | 60 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}; |
500
0d2449e9d659
Added possibility to switch between "classic" bigfont views and a selection with a new information combination
Ideenmodellierer
parents:
386
diff
changeset
|
61 const uint8_t cv_changelist_BS[] = {CVIEW_T3_Decostop, CVIEW_sensors, CVIEW_Compass, CVIEW_T3_MaxDepth,CVIEW_T3_StopWatch, CVIEW_T3_TTS, CVIEW_T3_ppO2andGas, CVIEW_noneOrDebug, CVIEW_T3_END}; |
0d2449e9d659
Added possibility to switch between "classic" bigfont views and a selection with a new information combination
Ideenmodellierer
parents:
386
diff
changeset
|
62 |
0d2449e9d659
Added possibility to switch between "classic" bigfont views and a selection with a new information combination
Ideenmodellierer
parents:
386
diff
changeset
|
63 #ifdef ENABLE_BIGFONT_VX |
0d2449e9d659
Added possibility to switch between "classic" bigfont views and a selection with a new information combination
Ideenmodellierer
parents:
386
diff
changeset
|
64 const uint8_t cv_changelist_BSV2[] = {CVIEW_T3_Decostop, CVIEW_sensors, CVIEW_T3_Navigation, CVIEW_T3_DepthData, CVIEW_T3_TTS, CVIEW_T3_ppO2andGas, CVIEW_noneOrDebug, CVIEW_T3_END}; |
0d2449e9d659
Added possibility to switch between "classic" bigfont views and a selection with a new information combination
Ideenmodellierer
parents:
386
diff
changeset
|
65 #endif |
38 | 66 |
67 /* Private function prototypes -----------------------------------------------*/ | |
68 | |
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 if(settingsGetPointer()->design == 3) | |
384
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
156 { |
38 | 157 settingsGetPointer()->design = 7; |
384
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
158 if(settingsGetPointer()->MotionDetection == MOTION_DETECT_SECTOR) |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
159 { |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
160 DefinePitchSectors(stateRealGetPointer()->lifeData.compass_pitch,CUSTOMER_DEFINED_VIEWS); |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
161 } |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
162 } |
38 | 163 switch(get_globalState()) |
164 { | |
165 case StD: | |
166 if(settingsGetPointer()->design == 6) | |
167 { | |
168 if(is_stateUsedSetToSim()) | |
169 set_globalState(StDSIM1); | |
170 else | |
171 set_globalState(StDQUIT); | |
172 break; | |
173 } | |
174 | |
175 if(settingsGetPointer()->design == 5) | |
176 { | |
177 if(t5_getCustomView() == CVIEW_Compass) | |
178 set_globalState(StDBEAR); | |
179 else | |
180 set_globalState(StDRAVG); | |
181 break; | |
182 } | |
183 | |
184 if(stateUsed->warnings.betterGas) | |
185 set_globalState(StDMGAS); | |
186 else | |
187 if(stateUsed->warnings.betterSetpoint) | |
188 set_globalState(StDMSPT); | |
189 else | |
190 set_globalState(StDMENU); | |
191 break; | |
192 | |
193 case StDMGAS: | |
194 if(stateUsed->warnings.betterSetpoint) | |
195 set_globalState(StDMSPT); | |
196 else | |
197 set_globalState(StDMENU); | |
198 break; | |
199 | |
200 case StDMSPT: | |
201 set_globalState(StDMENU); | |
202 break; | |
203 | |
204 case StDMENU: | |
205 if(is_stateUsedSetToSim()) | |
206 set_globalState(StDSIM1); | |
207 else | |
208 set_globalState(StD); | |
209 break; | |
210 | |
211 case StDSIM1: | |
212 set_globalState(StDSIM2); | |
213 break; | |
214 | |
215 case StDSIM2: | |
216 set_globalState(StDSIM3); | |
217 break; | |
218 | |
219 case StDSIM3: | |
220 set_globalState(StDSIM4); | |
221 break; | |
222 | |
223 case StDSIM4: | |
224 set_globalState(StD); | |
225 break; | |
226 | |
227 case StDBEAR: // t5_gauge | |
228 set_globalState(StDRAVG); | |
229 break; | |
230 | |
231 case StDRAVG: // t5_gauge | |
232 if(is_stateUsedSetToSim()) | |
233 set_globalState(StDSIM1); | |
234 else | |
235 set_globalState(StD); | |
236 break; | |
237 | |
238 case StDQUIT: // t6_apnea | |
239 set_globalState(StD); | |
240 break; | |
241 | |
242 default: | |
243 set_globalState(StD); | |
244 } | |
245 } | |
246 | |
247 if(sendAction == ACTION_BUTTON_ENTER) | |
248 { | |
249 if(settingsGetPointer()->design == 4) | |
250 return; | |
251 | |
384
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
252 if(settingsGetPointer()->design == 3) /* switch back to t7 (standard) view */ |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
253 { |
38 | 254 settingsGetPointer()->design = 7; |
384
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
255 if(settingsGetPointer()->MotionDetection == MOTION_DETECT_SECTOR) |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
256 { |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
257 DefinePitchSectors(stateRealGetPointer()->lifeData.compass_pitch,CUSTOMER_DEFINED_VIEWS); |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
258 } |
427ae9f8e28e
Consider number of available t3 views in sector handling:
ideenmodellierer
parents:
379
diff
changeset
|
259 } |
38 | 260 |
261 switch(get_globalState()) | |
262 { | |
263 case StDMGAS: | |
264 openEdit_DiveSelectBetterGas(); | |
265 set_globalState(StD); | |
266 break; | |
267 case StDMSPT: | |
268 openEdit_DiveSelectBetterSetpoint(); | |
269 set_globalState(StD); | |
270 break; | |
271 | |
272 case StDMENU: | |
273 openMenu_first_page_with_OC_gas_update(); | |
274 break; | |
275 | |
276 case StDSIM1: | |
277 Sim_Quit(); | |
278 break; | |
279 | |
280 case StDSIM2: | |
281 Sim_Ascend(); | |
282 break; | |
283 | |
284 case StDSIM3: | |
285 Sim_Descend(); | |
286 break; | |
287 | |
288 case StDSIM4: | |
289 Sim_Divetime(); | |
290 break; | |
291 | |
292 case StDBEAR: // t5_gauge | |
272
74a8296a2318
cleanup: simplify stateUsed usage
Jan Mulder <jlmulder@xs4all.nl>
parents:
210
diff
changeset
|
293 stateUsedWrite->diveSettings.compassHeading = (uint16_t)stateUsed->lifeData.compass_heading; |
38 | 294 set_globalState(StD); |
295 break; | |
296 | |
297 case StDRAVG: // t5_gauge | |
298 timer_Stopwatch_Restart(); | |
299 set_globalState(StD); | |
300 break; | |
301 | |
302 case StDQUIT: // t6_apnea | |
303 set_globalState(StD); // used to end StDQUIT, is called before everything else because changes are made in the next lines | |
304 if(is_stateUsedSetToSim()) | |
305 Sim_Quit(); | |
306 else | |
307 dataOutGetPointer()->setEndDive = 1; | |
308 break; | |
309 | |
310 default: | |
311 break; | |
312 } | |
313 } | |
314 } | |
315 | |
316 | |
317 void tHome_findNextStop(const uint16_t *list, uint8_t *depthOutMeter, uint16_t *lengthOutSeconds) | |
318 { | |
319 uint8_t ptr = DECOINFO_STRUCT_MAX_STOPS - 1; | |
320 | |
321 while(ptr && !list[ptr]) | |
322 ptr--; | |
323 | |
324 *lengthOutSeconds = list[ptr]; | |
325 if(!(*lengthOutSeconds)) | |
326 { | |
327 *depthOutMeter = 0; | |
328 } | |
329 else | |
330 if(ptr == 0) | |
331 { | |
332 *depthOutMeter = (uint8_t)((stateUsed->diveSettings.last_stop_depth_bar*10.0f) + 0.1f); | |
333 } | |
334 else | |
335 { | |
336 ptr -= 1; | |
337 *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); | |
338 } | |
339 } | |
340 | |
341 | |
342 void tHome_change_field_button_pressed(void) | |
343 { | |
344 tHome_tick_count_field = 0; | |
345 if(settingsGetPointer()->design == 7) | |
346 t7_change_field(); | |
347 } | |
348 | |
349 | |
361
b111fc4250e9
Pass action to customer vie update function.
Ideenmodellierer
parents:
289
diff
changeset
|
350 void tHome_change_customview_button_pressed(uint8_t action) |
38 | 351 { |
352 tHome_tick_count_cview = 0; | |
353 if(settingsGetPointer()->design == 7) | |
361
b111fc4250e9
Pass action to customer vie update function.
Ideenmodellierer
parents:
289
diff
changeset
|
354 t7_change_customview(action); |
38 | 355 else |
356 if(settingsGetPointer()->design == 3) | |
386
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
384
diff
changeset
|
357 t3_change_customview(action); |
38 | 358 else |
359 if(settingsGetPointer()->design == 5) | |
386
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
384
diff
changeset
|
360 t5_change_customview(action); |
38 | 361 else |
362 if(settingsGetPointer()->design == 6) | |
386
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
384
diff
changeset
|
363 t6_change_customview(action); |
38 | 364 } |
365 | |
366 | |
367 void tHome_tick(void) | |
368 { | |
369 uint16_t field = settingsGetPointer()->tX_userselectedLeftLowerCornerTimeout; | |
370 uint16_t cview = settingsGetPointer()->tX_customViewTimeout; | |
371 | |
372 if(field) | |
373 { | |
374 tHome_tick_count_field++; | |
375 if(tHome_tick_count_field > (field * 10)) | |
376 { | |
377 tHome_tick_count_field = 0; | |
378 if(settingsGetPointer()->design == 7) | |
379 { | |
380 t7_set_field_to_primary(); | |
381 } | |
382 } | |
383 } | |
384 | |
385 if(cview) | |
386 { | |
387 tHome_tick_count_cview++; | |
388 if(tHome_tick_count_cview > (cview *10)) | |
389 { | |
390 tHome_tick_count_cview = 0; | |
391 if(settingsGetPointer()->design == 7) | |
392 { | |
393 t7_set_customview_to_primary(); | |
394 } | |
395 } | |
396 } | |
397 } | |
398 | |
399 | |
400 uint32_t tHome_DateCode(RTC_DateTypeDef *dateInput) | |
401 { | |
402 uint32_t answer = 0; | |
403 | |
404 answer = 0; | |
405 answer += (dateInput->Year & 0x7F)<< 9; | |
406 answer += (dateInput->Month & 0x0F)<< 5; | |
407 answer += (dateInput->Date & 0x1F); | |
408 | |
409 return answer; | |
410 } | |
411 | |
412 | |
413 uint8_t tHome_gas_writer(uint8_t oxygen_percentage, uint8_t helium_percentage, char *text) | |
414 { | |
415 if(oxygen_percentage == 100) | |
416 return (uint8_t) snprintf(text,10,"Oxy"); | |
417 else if((oxygen_percentage == 21) && (!helium_percentage)) | |
418 return (uint8_t) snprintf(text,10,"Air"); | |
419 else if(!helium_percentage) | |
420 return (uint8_t) snprintf(text,10,"NX%02i",oxygen_percentage); | |
421 else if((oxygen_percentage + helium_percentage) == 100) | |
422 return (uint8_t) snprintf(text,10,"HX%02i",oxygen_percentage); | |
423 else | |
424 return (uint8_t) snprintf(text,10,"%02i/%02i",oxygen_percentage,helium_percentage); | |
425 } | |
426 | |
427 uint8_t tHome_show_lost_connection_count(GFX_DrawCfgScreen *ScreenToWriteOn) | |
428 { | |
208 | 429 static uint8_t LastKnowRTEState = SPI_RX_STATE_INVALID; |
430 | |
99 | 431 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
|
432 if(DataEX_lost_connection_count()>=SPI_MIN_ERROR_SHOW && SPI_SHOW_SYNC_STATS){ |
38 | 433 |
99 | 434 char text[64]; |
38 | 435 |
82 | 436 SDataExchangeSlaveToMaster* dataIn=get_dataInPointer(); |
208 | 437 SDataReceiveFromMaster* pDataOut = dataOutGetPointer(); |
82 | 438 |
500
0d2449e9d659
Added possibility to switch between "classic" bigfont views and a selection with a new information combination
Ideenmodellierer
parents:
386
diff
changeset
|
439 snprintf(text,32,"spi err:\002 %ld/%ld",DataEX_lost_connection_count(),get_num_SPI_CALLBACKS()); |
99 | 440 Gfx_write_label_var(ScreenToWriteOn, 100,300, 0,&FontT24,CLUT_ButtonSymbols,text); |
82 | 441 |
104 | 442 // 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]); |
443 // Gfx_write_label_var(ScreenToWriteOn, 350,550, 0,&FontT24,CLUT_ButtonSymbols,text); | |
82 | 444 |
208 | 445 //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]); |
446 | |
447 /* data shifted => ignore received data */ | |
448 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)) | |
449 { | |
450 dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE] = LastKnowRTEState; | |
451 } | |
452 else | |
453 { | |
454 LastKnowRTEState =dataIn->header.checkCode[SPI_HEADER_INDEX_RX_STATE]; | |
455 } | |
456 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 | 457 Gfx_write_label_var(ScreenToWriteOn, 600,800, 0,&FontT24,CLUT_ButtonSymbols,text); |
458 } | |
82 | 459 |
99 | 460 |
461 | |
462 // snprintf(text,32,"cpt:\002%i",get_num_SPI_CALLBACKS()); | |
463 // Gfx_write_label_var(ScreenToWriteOn, 600,800, 90,&FontT24,CLUT_ButtonSymbols,text); | |
82 | 464 |
465 // snprintf(text,10,"i2c:\002%i",get_DataEX_Error_place()); | |
466 // Gfx_write_label_var(ScreenToWriteOn, 600,800, 90,&FontT24,CLUT_ButtonSymbols,text); | |
38 | 467 |
468 return DataEX_lost_connection_count(); | |
469 } |