Mercurial > public > ostc4
annotate Discovery/Src/t5_gauge.c @ 917:0d6c4b40fae4 Evo_2_23
Bugfix external interface power up after sleep:
The previous implementation did not consider if the external power was enabled of not before sleep (the power was later enabled by sensor handling). The power is now activated immediatly after leaving sleep in order to aoid delays in sensor startup.
author | Ideenmodellierer |
---|---|
date | Sun, 03 Nov 2024 15:37:00 +0100 |
parents | 18946846b95b |
children |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/t5_gauge.c | |
5 /// \brief dive screen for Gauge mode | |
6 /// \author Heinrichs Weikamp gmbh | |
7 /// \date 1-Feb-2017 | |
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 "t5_gauge.h" | |
31 | |
32 #include "data_exchange_main.h" | |
33 #include "decom.h" | |
34 #include "gfx_fonts.h" | |
35 #include "math.h" | |
36 #include "tHome.h" | |
37 #include "simulation.h" | |
38 #include "timer.h" | |
39 #include "unit.h" | |
40 | |
41 | |
42 /* Private variables ---------------------------------------------------------*/ | |
43 GFX_DrawCfgScreen t5screen; | |
44 GFX_DrawCfgWindow t5l1; | |
45 GFX_DrawCfgWindow t5r1; | |
46 GFX_DrawCfgWindow t5c1; | |
47 GFX_DrawCfgWindow t5c2; | |
48 GFX_DrawCfgWindow t5c3; // for menu text | |
49 | |
50 uint8_t t5_selection_customview = 0; | |
51 | |
52 /* Importend function prototypes ---------------------------------------------*/ | |
53 //extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium); | |
54 | |
55 /* Private types -------------------------------------------------------------*/ | |
56 | |
57 #define CUSTOMBOX_LINE_LEFT (250) | |
58 #define CUSTOMBOX_LINE_RIGHT (549) | |
59 #define CUSTOMBOX_INSIDE_OFFSET (2) | |
60 #define CUSTOMBOX_OUTSIDE_OFFSET (2) | |
61 | |
62 #define TEXTSIZE 16 | |
63 | |
64 const uint8_t t5_customviewsStandard[] = | |
65 { | |
837 | 66 CVIEW_T3_sensors, |
67 CVIEW_T3_Compass, | |
38 | 68 CVIEW_T3_MaxDepth, |
69 CVIEW_T3_StopWatch, | |
70 CVIEW_T3_Temperature, | |
71 CVIEW_T3_GasList, | |
72 CVIEW_T3_Decostop, | |
73 CVIEW_T3_END | |
74 }; | |
75 | |
76 | |
77 const uint8_t *t5_customviews = t5_customviewsStandard; | |
78 | |
79 /* Private function prototypes -----------------------------------------------*/ | |
80 void t5_refresh_divemode(void); | |
81 void t5_refresh_customview(float depth); | |
82 | |
83 uint8_t t5_test_customview_warnings(void); | |
84 //void t5_show_customview_warnings(void); | |
85 //void t5_compass(uint16_t ActualHeading, uint16_t UserSetHeading); | |
86 | |
87 /* Exported functions --------------------------------------------------------*/ | |
88 | |
89 // for tHomeDiveMenuControl() in tHome.c | |
90 uint8_t t5_getCustomView(void) | |
91 { | |
92 return t5_selection_customview; | |
93 } | |
94 | |
95 | |
96 void t5_init(void) | |
97 { | |
413 | 98 SSettings* pSettings; |
99 pSettings = settingsGetPointer(); | |
100 | |
38 | 101 t5_selection_customview = t5_customviewsStandard[0]; |
102 | |
103 t5screen.FBStartAdress = 0; | |
104 t5screen.ImageHeight = 480; | |
105 t5screen.ImageWidth = 800; | |
106 t5screen.LayerIndex = 1; | |
107 | |
108 t5l1.Image = &t5screen; | |
109 t5l1.WindowNumberOfTextLines = 2; | |
110 t5l1.WindowLineSpacing = 19; // Abstand von Y0 | |
413 | 111 t5l1.WindowTab = 100; |
112 if(!pSettings->FlipDisplay) | |
113 { | |
114 t5l1.WindowX0 = 0; | |
115 t5l1.WindowX1 = BigFontSeperationLeftRight - 5; | |
116 t5l1.WindowY0 = BigFontSeperationTopBottom + 5; | |
117 t5l1.WindowY1 = 479; | |
118 } | |
119 else | |
120 { | |
121 t5l1.WindowX0 = 800 - BigFontSeperationLeftRight + 5; | |
122 t5l1.WindowX1 = 799; | |
123 t5l1.WindowY0 = 0; | |
124 t5l1.WindowY1 = 479 - BigFontSeperationTopBottom + 5 ; | |
125 } | |
38 | 126 |
127 t5r1.Image = &t5screen; | |
128 t5r1.WindowNumberOfTextLines = t5l1.WindowNumberOfTextLines; | |
129 t5r1.WindowLineSpacing = t5l1.WindowLineSpacing; | |
130 t5r1.WindowTab = t5l1.WindowTab; | |
413 | 131 if(!pSettings->FlipDisplay) |
132 { | |
133 t5r1.WindowX0 = BigFontSeperationLeftRight + 5; | |
134 t5r1.WindowX1 = 799; | |
135 } | |
136 else | |
137 { | |
138 t5r1.WindowX0 = 0; | |
139 t5r1.WindowX1 = BigFontSeperationLeftRight - 5; | |
140 } | |
38 | 141 t5r1.WindowY0 = t5l1.WindowY0; |
142 t5r1.WindowY1 = t5l1.WindowY1; | |
143 | |
144 t5c1.Image = &t5screen; | |
145 t5c1.WindowNumberOfTextLines = 2; | |
518 | 146 t5c1.WindowLineSpacing = 84 + 5; |
38 | 147 t5c1.WindowX0 = 0; |
148 t5c1.WindowX1 = 799; | |
413 | 149 if(!pSettings->FlipDisplay) |
150 { | |
151 t5c1.WindowY0 = 0; | |
152 t5c1.WindowY1 = BigFontSeperationTopBottom - 5; | |
153 } | |
154 else | |
155 { | |
156 t5c1.WindowY0 = 480 - BigFontSeperationTopBottom + 5; | |
157 t5c1.WindowY1 = 479; | |
158 } | |
38 | 159 |
160 t5c2.Image = &t5screen; | |
161 t5c2.WindowNumberOfTextLines = 3; | |
162 t5c2.WindowLineSpacing = 58; | |
163 t5c2.WindowX0 = 370; | |
164 t5c2.WindowX1 = 799; | |
165 t5c2.WindowY0 = 0; | |
166 t5c2.WindowY1 = BigFontSeperationTopBottom - 5; | |
167 t5c2.WindowTab = 600; | |
168 | |
169 t5c3.Image = &t5screen; | |
170 t5c3.WindowNumberOfTextLines = 1; | |
171 t5c3.WindowLineSpacing = 0; // Abstand von Y0 | |
172 t5c3.WindowTab = 100; | |
173 t5c3.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
174 t5c3.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
413 | 175 if(!pSettings->FlipDisplay) |
176 { | |
177 t5c3.WindowY0 = 0; | |
178 t5c3.WindowY1 = 69; | |
179 } | |
180 else | |
181 { | |
182 t5c3.WindowY0 = 480 - 69; | |
183 t5c3.WindowY1 = 479; | |
184 } | |
38 | 185 } |
186 | |
187 | |
188 void t5_refresh(void) | |
189 { | |
190 static uint8_t last_mode = MODE_SURFACE; | |
191 | |
192 SStateList status; | |
193 get_globalStateList(&status); | |
194 | |
195 if(stateUsed->mode != MODE_DIVE) | |
196 { | |
197 last_mode = MODE_SURFACE; | |
198 settingsGetPointer()->design = 7; | |
199 if(t5screen.FBStartAdress) | |
200 { | |
201 releaseFrame(24,t5screen.FBStartAdress); | |
202 t5screen.FBStartAdress = 0; | |
203 } | |
204 return; | |
205 } | |
206 | |
207 if(status.base != BaseHome) | |
208 return; | |
209 | |
210 t5screen.FBStartAdress = getFrame(24); | |
211 | |
212 if(last_mode != MODE_DIVE) | |
213 { | |
214 last_mode = MODE_DIVE; | |
215 t5_selection_customview = *t5_customviews; | |
216 } | |
217 | |
218 if(status.page == PageSurface) | |
219 set_globalState(StD); | |
220 | |
221 t5_refresh_divemode(); | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
222 GFX_SetFramesTopBottom(t5screen.FBStartAdress, 0,480); |
38 | 223 releaseAllFramesExcept(24,t5screen.FBStartAdress); |
224 } | |
225 | |
226 | |
227 /* Private functions ---------------------------------------------------------*/ | |
228 | |
229 void t5_refresh_divemode(void) | |
230 { | |
231 char text[512]; | |
232 uint8_t customview_warnings = 0; | |
233 float depth_meter = 0.0; | |
234 | |
235 // everything like lines, depth, ascent graph and divetime | |
236 depth_meter = t3_basics_lines_depth_and_divetime(&t5screen, &t5l1, &t5r1, DIVEMODE_Gauge); | |
237 | |
238 // customview | |
239 if(stateUsed->warnings.numWarnings) | |
240 customview_warnings = t5_test_customview_warnings(); | |
241 | |
242 if(customview_warnings && warning_count_high_time) | |
243 t3_basics_show_customview_warnings(&t5c1); | |
244 else | |
245 t5_refresh_customview(depth_meter); | |
246 | |
247 if(stateUsed->warnings.lowBattery) | |
248 t3_basics_battery_low_customview_extra(&t5c1); | |
249 | |
250 | |
251 /* Menu Selection (and gas mix) */ | |
252 if(get_globalState() == StDBEAR) | |
253 { | |
254 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveBearingQ); | |
255 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
256 } | |
257 else | |
258 if(get_globalState() == StDRAVG) | |
259 { | |
260 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveResetAvgQ); | |
261 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
262 } | |
263 // else | |
264 // if(get_globalState() == StDMENU) | |
265 // { | |
266 // snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveMenuQ); | |
267 // GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
268 // } | |
269 else | |
270 if(get_globalState() == StDSIM1) | |
271 { | |
272 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ); | |
273 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
274 } | |
275 else | |
276 if(get_globalState() == StDSIM2) | |
277 { | |
278 if(settingsGetPointer()->nonMetricalSystem) | |
279 snprintf(text,TEXTSIZE,"\a\001" " Sim:-3.33ft "); | |
280 else | |
281 snprintf(text,TEXTSIZE,"\a\001" " Sim:-1m "); | |
282 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
283 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
284 , unit_depth_integer(simulation_get_aim_depth()) | |
285 , unit_depth_char1() | |
286 , unit_depth_char2() | |
287 ); | |
288 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow); | |
289 | |
290 } | |
291 else | |
292 if(get_globalState() == StDSIM3) | |
293 { | |
294 if(settingsGetPointer()->nonMetricalSystem) | |
295 snprintf(text,TEXTSIZE,"\a\001" " Sim:+3.33ft "); | |
296 else | |
297 snprintf(text,TEXTSIZE,"\a\001" " Sim:+1m "); | |
298 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
299 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
300 , unit_depth_integer(simulation_get_aim_depth()) | |
301 , unit_depth_char1() | |
302 , unit_depth_char2() | |
303 ); | |
304 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow); | |
305 } | |
306 else | |
307 if(get_globalState() == StDSIM4) | |
308 { | |
309 snprintf(text,TEXTSIZE,"\a\001" " Sim:+5' "); | |
310 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
311 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
312 , unit_depth_integer(simulation_get_aim_depth()) | |
313 , unit_depth_char1() | |
314 , unit_depth_char2() | |
315 ); | |
316 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow); | |
317 } | |
318 else | |
319 { | |
320 // keep empty | |
321 } | |
322 } | |
323 | |
324 | |
386
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
175
diff
changeset
|
325 void t5_change_customview(uint8_t action) |
38 | 326 { |
386
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
175
diff
changeset
|
327 t3_basics_change_customview(&t5_selection_customview, t5_customviews, action); |
38 | 328 } |
329 | |
330 | |
331 void t5_refresh_customview(float depth) | |
332 { | |
386
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
175
diff
changeset
|
333 // if((t5_selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) |
39c147e47c1c
Added key direction awarness to t3, t5 and t6 views:
ideenmodellierer
parents:
175
diff
changeset
|
334 // t5_change_customview(); |
38 | 335 |
336 t3_basics_refresh_customview(depth, t5_selection_customview, &t5screen, &t5c1, &t5c2, DIVEMODE_Gauge); | |
337 } | |
338 | |
339 | |
340 uint8_t t5_test_customview_warnings(void) | |
341 { | |
342 uint8_t count = 0; | |
343 | |
344 count = 0; | |
345 return count; | |
346 } | |
347 | |
348 |