Mercurial > public > ostc4
annotate Discovery/Src/t5_gauge.c @ 277:580822b5d3d1 IPC_Sync_Improvment_3
Rework SPI error handling.
SPI_Start_single_TxRx_with_Master evaluated the incoming data for a condition to send device instead of life data. In case of invalid input data this may cause unintended transmission of device data => now lifedata is send if incoming data is expected to be invalid
The SPI timeout monitoring was done at the beginning of the mode loop. A timeout may have been detected even if meanwhile valid data was received (this is evaluated at x20ms) => Moved the timeout monitoring after the handling of incoming data
author | ideenmodellierer |
---|---|
date | Sun, 28 Apr 2019 10:16:38 +0200 |
parents | 9da7dd50e2ec |
children | 39c147e47c1c |
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 { | |
66 CVIEW_sensors, | |
67 CVIEW_Compass, | |
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 { | |
98 t5_selection_customview = t5_customviewsStandard[0]; | |
99 | |
100 t5screen.FBStartAdress = 0; | |
101 t5screen.ImageHeight = 480; | |
102 t5screen.ImageWidth = 800; | |
103 t5screen.LayerIndex = 1; | |
104 | |
105 t5l1.Image = &t5screen; | |
106 t5l1.WindowNumberOfTextLines = 2; | |
107 t5l1.WindowLineSpacing = 19; // Abstand von Y0 | |
108 t5l1.WindowTab = 100; | |
109 t5l1.WindowX0 = 0; | |
110 t5l1.WindowX1 = BigFontSeperationLeftRight - 5; | |
111 t5l1.WindowY0 = BigFontSeperationTopBottom + 5; | |
112 t5l1.WindowY1 = 479; | |
113 | |
114 t5r1.Image = &t5screen; | |
115 t5r1.WindowNumberOfTextLines = t5l1.WindowNumberOfTextLines; | |
116 t5r1.WindowLineSpacing = t5l1.WindowLineSpacing; | |
117 t5r1.WindowTab = t5l1.WindowTab; | |
118 t5r1.WindowX0 = BigFontSeperationLeftRight + 5; | |
119 t5r1.WindowX1 = 799; | |
120 t5r1.WindowY0 = t5l1.WindowY0; | |
121 t5r1.WindowY1 = t5l1.WindowY1; | |
122 | |
123 t5c1.Image = &t5screen; | |
124 t5c1.WindowNumberOfTextLines = 2; | |
125 t5c1.WindowLineSpacing = t5l1.WindowLineSpacing; | |
126 t5c1.WindowX0 = 0; | |
127 t5c1.WindowX1 = 799; | |
128 t5c1.WindowY0 = 0; | |
129 t5c1.WindowY1 = BigFontSeperationTopBottom - 5; | |
130 | |
131 t5c2.Image = &t5screen; | |
132 t5c2.WindowNumberOfTextLines = 3; | |
133 t5c2.WindowLineSpacing = 58; | |
134 t5c2.WindowX0 = 370; | |
135 t5c2.WindowX1 = 799; | |
136 t5c2.WindowY0 = 0; | |
137 t5c2.WindowY1 = BigFontSeperationTopBottom - 5; | |
138 t5c2.WindowTab = 600; | |
139 | |
140 t5c3.Image = &t5screen; | |
141 t5c3.WindowNumberOfTextLines = 1; | |
142 t5c3.WindowLineSpacing = 0; // Abstand von Y0 | |
143 t5c3.WindowTab = 100; | |
144 t5c3.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; | |
145 t5c3.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; | |
146 t5c3.WindowY0 = 0; | |
147 t5c3.WindowY1 = 69; | |
148 } | |
149 | |
150 | |
151 void t5_refresh(void) | |
152 { | |
153 static uint8_t last_mode = MODE_SURFACE; | |
154 | |
155 SStateList status; | |
156 get_globalStateList(&status); | |
157 | |
158 if(stateUsed->mode != MODE_DIVE) | |
159 { | |
160 last_mode = MODE_SURFACE; | |
161 settingsGetPointer()->design = 7; | |
162 if(t5screen.FBStartAdress) | |
163 { | |
164 releaseFrame(24,t5screen.FBStartAdress); | |
165 t5screen.FBStartAdress = 0; | |
166 } | |
167 return; | |
168 } | |
169 | |
170 if(status.base != BaseHome) | |
171 return; | |
172 | |
173 t5screen.FBStartAdress = getFrame(24); | |
174 | |
175 if(last_mode != MODE_DIVE) | |
176 { | |
177 last_mode = MODE_DIVE; | |
178 t5_selection_customview = *t5_customviews; | |
179 } | |
180 | |
181 if(status.page == PageSurface) | |
182 set_globalState(StD); | |
183 | |
184 t5_refresh_divemode(); | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
185 GFX_SetFramesTopBottom(t5screen.FBStartAdress, 0,480); |
38 | 186 releaseAllFramesExcept(24,t5screen.FBStartAdress); |
187 } | |
188 | |
189 | |
190 /* Private functions ---------------------------------------------------------*/ | |
191 | |
192 void t5_refresh_divemode(void) | |
193 { | |
194 char text[512]; | |
195 uint8_t customview_warnings = 0; | |
196 float depth_meter = 0.0; | |
197 | |
198 // everything like lines, depth, ascent graph and divetime | |
199 depth_meter = t3_basics_lines_depth_and_divetime(&t5screen, &t5l1, &t5r1, DIVEMODE_Gauge); | |
200 | |
201 // customview | |
202 if(stateUsed->warnings.numWarnings) | |
203 customview_warnings = t5_test_customview_warnings(); | |
204 | |
205 if(customview_warnings && warning_count_high_time) | |
206 t3_basics_show_customview_warnings(&t5c1); | |
207 else | |
208 t5_refresh_customview(depth_meter); | |
209 | |
210 if(stateUsed->warnings.lowBattery) | |
211 t3_basics_battery_low_customview_extra(&t5c1); | |
212 | |
213 | |
214 /* Menu Selection (and gas mix) */ | |
215 if(get_globalState() == StDBEAR) | |
216 { | |
217 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveBearingQ); | |
218 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
219 } | |
220 else | |
221 if(get_globalState() == StDRAVG) | |
222 { | |
223 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveResetAvgQ); | |
224 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
225 } | |
226 // else | |
227 // if(get_globalState() == StDMENU) | |
228 // { | |
229 // snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveMenuQ); | |
230 // GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
231 // } | |
232 else | |
233 if(get_globalState() == StDSIM1) | |
234 { | |
235 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ); | |
236 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
237 } | |
238 else | |
239 if(get_globalState() == StDSIM2) | |
240 { | |
241 if(settingsGetPointer()->nonMetricalSystem) | |
242 snprintf(text,TEXTSIZE,"\a\001" " Sim:-3.33ft "); | |
243 else | |
244 snprintf(text,TEXTSIZE,"\a\001" " Sim:-1m "); | |
245 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
246 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
247 , unit_depth_integer(simulation_get_aim_depth()) | |
248 , unit_depth_char1() | |
249 , unit_depth_char2() | |
250 ); | |
251 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow); | |
252 | |
253 } | |
254 else | |
255 if(get_globalState() == StDSIM3) | |
256 { | |
257 if(settingsGetPointer()->nonMetricalSystem) | |
258 snprintf(text,TEXTSIZE,"\a\001" " Sim:+3.33ft "); | |
259 else | |
260 snprintf(text,TEXTSIZE,"\a\001" " Sim:+1m "); | |
261 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
262 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
263 , unit_depth_integer(simulation_get_aim_depth()) | |
264 , unit_depth_char1() | |
265 , unit_depth_char2() | |
266 ); | |
267 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow); | |
268 } | |
269 else | |
270 if(get_globalState() == StDSIM4) | |
271 { | |
272 snprintf(text,TEXTSIZE,"\a\001" " Sim:+5' "); | |
273 GFX_write_string_color(&FontT48,&t5c3,text,0,CLUT_WarningYellow); | |
274 snprintf(text,TEXTSIZE,"\a\f %u %c%c" | |
275 , unit_depth_integer(simulation_get_aim_depth()) | |
276 , unit_depth_char1() | |
277 , unit_depth_char2() | |
278 ); | |
279 GFX_write_string_color(&FontT42,&t5l1,text,0,CLUT_WarningYellow); | |
280 } | |
281 else | |
282 { | |
283 // keep empty | |
284 } | |
285 } | |
286 | |
287 | |
288 void t5_change_customview(void) | |
289 { | |
290 t3_basics_change_customview(&t5_selection_customview, t5_customviews); | |
291 } | |
292 | |
293 | |
294 void t5_refresh_customview(float depth) | |
295 { | |
296 if((t5_selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0)) | |
297 t5_change_customview(); | |
298 | |
299 t3_basics_refresh_customview(depth, t5_selection_customview, &t5screen, &t5c1, &t5c2, DIVEMODE_Gauge); | |
300 } | |
301 | |
302 | |
303 uint8_t t5_test_customview_warnings(void) | |
304 { | |
305 uint8_t count = 0; | |
306 | |
307 count = 0; | |
308 return count; | |
309 } | |
310 | |
311 |