comparison Discovery/Src/t5_gauge.c @ 38:5f11787b4f42

include in ostc4 repository
author heinrichsweikamp
date Sat, 28 Apr 2018 11:52:34 +0200
parents
children cc9c18075e00
comparison
equal deleted inserted replaced
37:ccc45c0e1ea2 38:5f11787b4f42
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 const uint8_t t5_customviewsScooter[] =
82 {
83 CVIEW_Scooter,
84 CVIEW_Compass,
85 CVIEW_T3_MaxDepth,
86 CVIEW_T3_StopWatch,
87 CVIEW_T3_END
88 };
89
90 const uint8_t *t5_customviews = t5_customviewsStandard;
91
92 /* Private function prototypes -----------------------------------------------*/
93 void t5_refresh_divemode(void);
94 void t5_refresh_customview(float depth);
95
96 uint8_t t5_test_customview_warnings(void);
97 //void t5_show_customview_warnings(void);
98 //void t5_compass(uint16_t ActualHeading, uint16_t UserSetHeading);
99
100 /* Exported functions --------------------------------------------------------*/
101
102 // for tHomeDiveMenuControl() in tHome.c
103 uint8_t t5_getCustomView(void)
104 {
105 return t5_selection_customview;
106 }
107
108
109 void t5_init(void)
110 {
111 t5_selection_customview = t5_customviewsStandard[0];
112
113 t5screen.FBStartAdress = 0;
114 t5screen.ImageHeight = 480;
115 t5screen.ImageWidth = 800;
116 t5screen.LayerIndex = 1;
117
118 t5l1.Image = &t5screen;
119 t5l1.WindowNumberOfTextLines = 2;
120 t5l1.WindowLineSpacing = 19; // Abstand von Y0
121 t5l1.WindowTab = 100;
122 t5l1.WindowX0 = 0;
123 t5l1.WindowX1 = BigFontSeperationLeftRight - 5;
124 t5l1.WindowY0 = BigFontSeperationTopBottom + 5;
125 t5l1.WindowY1 = 479;
126
127 t5r1.Image = &t5screen;
128 t5r1.WindowNumberOfTextLines = t5l1.WindowNumberOfTextLines;
129 t5r1.WindowLineSpacing = t5l1.WindowLineSpacing;
130 t5r1.WindowTab = t5l1.WindowTab;
131 t5r1.WindowX0 = BigFontSeperationLeftRight + 5;
132 t5r1.WindowX1 = 799;
133 t5r1.WindowY0 = t5l1.WindowY0;
134 t5r1.WindowY1 = t5l1.WindowY1;
135
136 t5c1.Image = &t5screen;
137 t5c1.WindowNumberOfTextLines = 2;
138 t5c1.WindowLineSpacing = t5l1.WindowLineSpacing;
139 t5c1.WindowX0 = 0;
140 t5c1.WindowX1 = 799;
141 t5c1.WindowY0 = 0;
142 t5c1.WindowY1 = BigFontSeperationTopBottom - 5;
143
144 t5c2.Image = &t5screen;
145 t5c2.WindowNumberOfTextLines = 3;
146 t5c2.WindowLineSpacing = 58;
147 t5c2.WindowX0 = 370;
148 t5c2.WindowX1 = 799;
149 t5c2.WindowY0 = 0;
150 t5c2.WindowY1 = BigFontSeperationTopBottom - 5;
151 t5c2.WindowTab = 600;
152
153 t5c3.Image = &t5screen;
154 t5c3.WindowNumberOfTextLines = 1;
155 t5c3.WindowLineSpacing = 0; // Abstand von Y0
156 t5c3.WindowTab = 100;
157 t5c3.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET;
158 t5c3.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET;
159 t5c3.WindowY0 = 0;
160 t5c3.WindowY1 = 69;
161 }
162
163
164 void t5_refresh(void)
165 {
166 static uint8_t last_mode = MODE_SURFACE;
167
168 SStateList status;
169 get_globalStateList(&status);
170
171 if(stateUsed->mode != MODE_DIVE)
172 {
173 last_mode = MODE_SURFACE;
174 settingsGetPointer()->design = 7;
175 if(t5screen.FBStartAdress)
176 {
177 releaseFrame(24,t5screen.FBStartAdress);
178 t5screen.FBStartAdress = 0;
179 }
180 return;
181 }
182
183 if(status.base != BaseHome)
184 return;
185
186 t5screen.FBStartAdress = getFrame(24);
187
188 if(last_mode != MODE_DIVE)
189 {
190 last_mode = MODE_DIVE;
191 t5_selection_customview = *t5_customviews;
192 }
193
194 if(status.page == PageSurface)
195 set_globalState(StD);
196
197 t5_refresh_divemode();
198 GFX_SetFramesTopBottom(t5screen.FBStartAdress, NULL,480);
199 releaseAllFramesExcept(24,t5screen.FBStartAdress);
200 }
201
202
203 /* Private functions ---------------------------------------------------------*/
204
205 void t5_refresh_divemode(void)
206 {
207 char text[512];
208 uint8_t customview_warnings = 0;
209 float depth_meter = 0.0;
210
211 // everything like lines, depth, ascent graph and divetime
212 depth_meter = t3_basics_lines_depth_and_divetime(&t5screen, &t5l1, &t5r1, DIVEMODE_Gauge);
213
214 // customview
215 if(stateUsed->warnings.numWarnings)
216 customview_warnings = t5_test_customview_warnings();
217
218 if(customview_warnings && warning_count_high_time)
219 t3_basics_show_customview_warnings(&t5c1);
220 else
221 t5_refresh_customview(depth_meter);
222
223 if(stateUsed->warnings.lowBattery)
224 t3_basics_battery_low_customview_extra(&t5c1);
225
226
227 /* Menu Selection (and gas mix) */
228 if(get_globalState() == StDBEAR)
229 {
230 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveBearingQ);
231 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow);
232 }
233 else
234 if(get_globalState() == StDRAVG)
235 {
236 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveResetAvgQ);
237 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow);
238 }
239 // else
240 // if(get_globalState() == StDMENU)
241 // {
242 // snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveMenuQ);
243 // GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow);
244 // }
245 else
246 if(get_globalState() == StDSIM1)
247 {
248 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ);
249 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow);
250 }
251 else
252 if(get_globalState() == StDSIM2)
253 {
254 if(settingsGetPointer()->nonMetricalSystem)
255 snprintf(text,TEXTSIZE,"\a\001" " Sim:-3.33ft ");
256 else
257 snprintf(text,TEXTSIZE,"\a\001" " Sim:-1m ");
258 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow);
259 snprintf(text,TEXTSIZE,"\a\f %u %c%c"
260 , unit_depth_integer(simulation_get_aim_depth())
261 , unit_depth_char1()
262 , unit_depth_char2()
263 );
264 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow);
265
266 }
267 else
268 if(get_globalState() == StDSIM3)
269 {
270 if(settingsGetPointer()->nonMetricalSystem)
271 snprintf(text,TEXTSIZE,"\a\001" " Sim:+3.33ft ");
272 else
273 snprintf(text,TEXTSIZE,"\a\001" " Sim:+1m ");
274 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow);
275 snprintf(text,TEXTSIZE,"\a\f %u %c%c"
276 , unit_depth_integer(simulation_get_aim_depth())
277 , unit_depth_char1()
278 , unit_depth_char2()
279 );
280 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow);
281 }
282 else
283 if(get_globalState() == StDSIM4)
284 {
285 snprintf(text,TEXTSIZE,"\a\001" " Sim:+5' ");
286 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow);
287 snprintf(text,TEXTSIZE,"\a\f %u %c%c"
288 , unit_depth_integer(simulation_get_aim_depth())
289 , unit_depth_char1()
290 , unit_depth_char2()
291 );
292 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow);
293 }
294 else
295 {
296 // keep empty
297 }
298 }
299
300
301 void t5_change_customview(void)
302 {
303 t3_basics_change_customview(&t5_selection_customview, t5_customviews);
304 }
305
306
307 void t5_refresh_customview(float depth)
308 {
309 if((t5_selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0))
310 t5_change_customview();
311
312 t3_basics_refresh_customview(depth, t5_selection_customview, &t5screen, &t5c1, &t5c2, DIVEMODE_Gauge);
313 }
314
315
316 uint8_t t5_test_customview_warnings(void)
317 {
318 uint8_t count = 0;
319
320 count = 0;
321 return count;
322 }
323
324