Mercurial > public > ostc4
annotate Discovery/Src/t5_gauge.c @ 169:842f57bbaaad cleanup-1
Bugfix: highlight the menu underline correctly on selected state
This fixes an optical bug. In dive and simulation mode, the
underline in the top menu was not highlighted correctly for the
DECO ans SYS submenu's. The check when to highlight simply was not
correct. And, yes, this part of the code is rather obfuscated, and
deserves some attention later on.
Reported-by: Matthias Heinrichs <matthias.heinrichs@heinrichsweikamp.com>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Sun, 10 Mar 2019 10:09:58 +0100 |
parents | 255eedad4155 |
children | 9da7dd50e2ec |
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 extern float depthLastCall[9]; | |
51 extern uint8_t idDepthLastCall; | |
52 extern float temperatureLastCall[3]; | |
53 extern uint8_t idTemperatureLastCall; | |
54 | |
55 uint8_t t5_selection_customview = 0; | |
56 | |
57 /* Importend function prototypes ---------------------------------------------*/ | |
58 //extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium); | |
59 | |
60 /* Private types -------------------------------------------------------------*/ | |
61 | |
62 #define CUSTOMBOX_LINE_LEFT (250) | |
63 #define CUSTOMBOX_LINE_RIGHT (549) | |
64 #define CUSTOMBOX_INSIDE_OFFSET (2) | |
65 #define CUSTOMBOX_OUTSIDE_OFFSET (2) | |
66 | |
67 #define TEXTSIZE 16 | |
68 | |
69 const uint8_t t5_customviewsStandard[] = | |
70 { | |
71 CVIEW_sensors, | |
72 CVIEW_Compass, | |
73 CVIEW_T3_MaxDepth, | |
74 CVIEW_T3_StopWatch, | |
75 CVIEW_T3_Temperature, | |
76 CVIEW_T3_GasList, | |
77 CVIEW_T3_Decostop, | |
78 CVIEW_T3_END | |
79 }; | |
80 | |
81 | |
82 const uint8_t *t5_customviews = t5_customviewsStandard; | |
83 | |
84 /* Private function prototypes -----------------------------------------------*/ | |
85 void t5_refresh_divemode(void); | |
86 void t5_refresh_customview(float depth); | |
87 | |
88 uint8_t t5_test_customview_warnings(void); | |
89 //void t5_show_customview_warnings(void); | |
90 //void t5_compass(uint16_t ActualHeading, uint16_t UserSetHeading); | |
91 | |
92 /* Exported functions --------------------------------------------------------*/ | |
93 | |
94 // for tHomeDiveMenuControl() in tHome.c | |
95 uint8_t t5_getCustomView(void) | |
96 { | |
97 return t5_selection_customview; | |
98 } | |
99 | |
100 | |
101 void t5_init(void) | |
102 { | |
103 t5_selection_customview = t5_customviewsStandard[0]; | |
104 | |
105 t5screen.FBStartAdress = 0; | |
106 t5screen.ImageHeight = 480; | |
107 t5screen.ImageWidth = 800; | |
108 t5screen.LayerIndex = 1; | |
109 | |
110 t5l1.Image = &t5screen; | |
111 t5l1.WindowNumberOfTextLines = 2; | |
112 t5l1.WindowLineSpacing = 19; // Abstand von Y0 | |
113 t5l1.WindowTab = 100; | |
114 t5l1.WindowX0 = 0; | |
115 t5l1.WindowX1 = BigFontSeperationLeftRight - 5; | |
116 t5l1.WindowY0 = BigFontSeperationTopBottom + 5; | |
117 t5l1.WindowY1 = 479; | |
118 | |
119 t5r1.Image = &t5screen; | |
120 t5r1.WindowNumberOfTextLines = t5l1.WindowNumberOfTextLines; | |
121 t5r1.WindowLineSpacing = t5l1.WindowLineSpacing; | |
122 t5r1.WindowTab = t5l1.WindowTab; | |
123 t5r1.WindowX0 = BigFontSeperationLeftRight + 5; | |
124 t5r1.WindowX1 = 799; | |
125 t5r1.WindowY0 = t5l1.WindowY0; | |
126 t5r1.WindowY1 = t5l1.WindowY1; | |
127 | |
128 t5c1.Image = &t5screen; | |
129 t5c1.WindowNumberOfTextLines = 2; | |
130 t5c1.WindowLineSpacing = t5l1.WindowLineSpacing; | |
131 t5c1.WindowX0 = 0; | |
132 t5c1.WindowX1 = 799; | |
133 t5c1.WindowY0 = 0; | |
134 t5c1.WindowY1 = BigFontSeperationTopBottom - 5; | |
135 | |
136 t5c2.Image = &t5screen; | |
137 t5c2.WindowNumberOfTextLines = 3; | |
138 t5c2.WindowLineSpacing = 58; | |
139 t5c2.WindowX0 = 370; | |
140 t5c2.WindowX1 = 799; | |
141 t5c2.WindowY0 = 0; | |
142 t5c2.WindowY1 = BigFontSeperationTopBottom - 5; | |
143 t5c2.WindowTab = 600; | |
144 | |
145 t5c3.Image = &t5screen; | |
146 t5c3.WindowNumberOfTextLines = 1; | |
147 t5c3.WindowLineSpacing = 0; // Abstand von Y0 | |
148 t5c3.WindowTab = 100; | |
149 t5c3.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
150 t5c3.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
151 t5c3.WindowY0 = 0; | |
152 t5c3.WindowY1 = 69; | |
153 } | |
154 | |
155 | |
156 void t5_refresh(void) | |
157 { | |
158 static uint8_t last_mode = MODE_SURFACE; | |
159 | |
160 SStateList status; | |
161 get_globalStateList(&status); | |
162 | |
163 if(stateUsed->mode != MODE_DIVE) | |
164 { | |
165 last_mode = MODE_SURFACE; | |
166 settingsGetPointer()->design = 7; | |
167 if(t5screen.FBStartAdress) | |
168 { | |
169 releaseFrame(24,t5screen.FBStartAdress); | |
170 t5screen.FBStartAdress = 0; | |
171 } | |
172 return; | |
173 } | |
174 | |
175 if(status.base != BaseHome) | |
176 return; | |
177 | |
178 t5screen.FBStartAdress = getFrame(24); | |
179 | |
180 if(last_mode != MODE_DIVE) | |
181 { | |
182 last_mode = MODE_DIVE; | |
183 t5_selection_customview = *t5_customviews; | |
184 } | |
185 | |
186 if(status.page == PageSurface) | |
187 set_globalState(StD); | |
188 | |
189 t5_refresh_divemode(); | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
190 GFX_SetFramesTopBottom(t5screen.FBStartAdress, 0,480); |
38 | 191 releaseAllFramesExcept(24,t5screen.FBStartAdress); |
192 } | |
193 | |
194 | |
195 /* Private functions ---------------------------------------------------------*/ | |
196 | |
197 void t5_refresh_divemode(void) | |
198 { | |
199 char text[512]; | |
200 uint8_t customview_warnings = 0; | |
201 float depth_meter = 0.0; | |
202 | |
203 // everything like lines, depth, ascent graph and divetime | |
204 depth_meter = t3_basics_lines_depth_and_divetime(&t5screen, &t5l1, &t5r1, DIVEMODE_Gauge); | |
205 | |
206 // customview | |
207 if(stateUsed->warnings.numWarnings) | |
208 customview_warnings = t5_test_customview_warnings(); | |
209 | |
210 if(customview_warnings && warning_count_high_time) | |
211 t3_basics_show_customview_warnings(&t5c1); | |
212 else | |
213 t5_refresh_customview(depth_meter); | |
214 | |
215 if(stateUsed->warnings.lowBattery) | |
216 t3_basics_battery_low_customview_extra(&t5c1); | |
217 | |
218 | |
219 /* Menu Selection (and gas mix) */ | |
220 if(get_globalState() == StDBEAR) | |
221 { | |
222 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveBearingQ); | |
223 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
224 } | |
225 else | |
226 if(get_globalState() == StDRAVG) | |
227 { | |
228 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveResetAvgQ); | |
229 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
230 } | |
231 // else | |
232 // if(get_globalState() == StDMENU) | |
233 // { | |
234 // snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveMenuQ); | |
235 // GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
236 // } | |
237 else | |
238 if(get_globalState() == StDSIM1) | |
239 { | |
240 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ); | |
241 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
242 } | |
243 else | |
244 if(get_globalState() == StDSIM2) | |
245 { | |
246 if(settingsGetPointer()->nonMetricalSystem) | |
247 snprintf(text,TEXTSIZE,"\a\001" " Sim:-3.33ft "); | |
248 else | |
249 snprintf(text,TEXTSIZE,"\a\001" " Sim:-1m "); | |
250 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
251 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
252 , unit_depth_integer(simulation_get_aim_depth()) | |
253 , unit_depth_char1() | |
254 , unit_depth_char2() | |
255 ); | |
256 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow); | |
257 | |
258 } | |
259 else | |
260 if(get_globalState() == StDSIM3) | |
261 { | |
262 if(settingsGetPointer()->nonMetricalSystem) | |
263 snprintf(text,TEXTSIZE,"\a\001" " Sim:+3.33ft "); | |
264 else | |
265 snprintf(text,TEXTSIZE,"\a\001" " Sim:+1m "); | |
266 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
267 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
268 , unit_depth_integer(simulation_get_aim_depth()) | |
269 , unit_depth_char1() | |
270 , unit_depth_char2() | |
271 ); | |
272 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow); | |
273 } | |
274 else | |
275 if(get_globalState() == StDSIM4) | |
276 { | |
277 snprintf(text,TEXTSIZE,"\a\001" " Sim:+5' "); | |
278 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
279 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
280 , unit_depth_integer(simulation_get_aim_depth()) | |
281 , unit_depth_char1() | |
282 , unit_depth_char2() | |
283 ); | |
284 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow); | |
285 } | |
286 else | |
287 { | |
288 // keep empty | |
289 } | |
290 } | |
291 | |
292 | |
293 void t5_change_customview(void) | |
294 { | |
295 t3_basics_change_customview(&t5_selection_customview, t5_customviews); | |
296 } | |
297 | |
298 | |
299 void t5_refresh_customview(float depth) | |
300 { | |
301 if((t5_selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) | |
302 t5_change_customview(); | |
303 | |
304 t3_basics_refresh_customview(depth, t5_selection_customview, &t5screen, &t5c1, &t5c2, DIVEMODE_Gauge); | |
305 } | |
306 | |
307 | |
308 uint8_t t5_test_customview_warnings(void) | |
309 { | |
310 uint8_t count = 0; | |
311 | |
312 count = 0; | |
313 return count; | |
314 } | |
315 | |
316 |