Mercurial > public > ostc4
annotate Discovery/Src/t4_tetris.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 | ecb71521d004 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/t4_tetris.c | |
5 /// \brief Main Template file for dive mode special screen t4_tetris | |
6 /// \author Heinrichs Weikamp gmbh | |
7 /// \date 17-Feb-2016 | |
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 "t4_tetris.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 "timer.h" | |
38 #include "unit.h" | |
39 | |
40 /* Exported variables --------------------------------------------------------*/ | |
41 | |
42 /* Private variables ---------------------------------------------------------*/ | |
43 GFX_DrawCfgScreen t4screen; | |
44 GFX_DrawCfgWindow t4l1; | |
45 GFX_DrawCfgWindow t4l2; | |
46 GFX_DrawCfgWindow t4l3; | |
47 | |
48 extern float depthLastCall[9]; | |
49 extern uint8_t idDepthLastCall; | |
50 extern float temperatureLastCall[3]; | |
51 extern uint8_t idTemperatureLastCall; | |
52 | |
53 | |
54 /* Private types -------------------------------------------------------------*/ | |
55 #define TEXTSIZE 16 | |
56 | |
57 const uint16_t t4SeperationLeftRight = 250; | |
58 const uint16_t t4SeperationTopMid = 315; | |
59 const uint16_t t4SeperationMidBottom = 139; | |
60 | |
61 /* Private function prototypes -----------------------------------------------*/ | |
62 void t4_refresh_divemode(void); | |
63 void t4_refresh_customview(float depth); | |
64 | |
65 uint8_t t4_test_customview_warnings(void); | |
66 void t4_show_customview_warnings(void); | |
67 void t4_battery_low_customview_extra(void); | |
68 | |
69 /* Exported functions --------------------------------------------------------*/ | |
70 | |
71 void t4_init(void) | |
72 { | |
73 t4screen.FBStartAdress = 0; | |
74 t4screen.ImageHeight = 480; | |
75 t4screen.ImageWidth = 800; | |
76 t4screen.LayerIndex = 1; | |
77 | |
78 t4l1.Image = &t4screen; | |
79 t4l1.WindowNumberOfTextLines = 2; | |
80 t4l1.WindowLineSpacing = 19; // Abstand von Y0 | |
81 t4l1.WindowTab = 100; | |
82 t4l1.WindowX0 = 0; | |
83 t4l1.WindowX1 = t4SeperationLeftRight - 2; | |
84 t4l1.WindowY1 = 479; | |
85 t4l1.WindowY0 = t4SeperationTopMid + 3; | |
86 | |
87 t4l2.Image = t4l1.Image; | |
88 t4l2.WindowNumberOfTextLines = t4l1.WindowNumberOfTextLines; | |
89 t4l2.WindowLineSpacing = t4l1.WindowLineSpacing; | |
90 t4l2.WindowTab = t4l1.WindowTab; | |
91 t4l2.WindowX0 = t4l1.WindowX0; | |
92 t4l2.WindowX1 = t4l1.WindowX1; | |
93 t4l2.WindowY1 = t4SeperationTopMid - 2; | |
94 t4l2.WindowY0 = t4SeperationMidBottom + 3; | |
95 | |
96 t4l3.Image = t4l1.Image; | |
97 t4l3.WindowNumberOfTextLines = t4l1.WindowNumberOfTextLines; | |
98 t4l3.WindowLineSpacing = t4l1.WindowLineSpacing; | |
99 t4l3.WindowTab = t4l1.WindowTab; | |
100 t4l3.WindowX0 = t4l1.WindowX0; | |
101 t4l3.WindowX1 = t4l1.WindowX1; | |
102 t4l3.WindowY1 = t4SeperationMidBottom - 2; | |
103 t4l3.WindowY0 = 0; | |
104 } | |
105 | |
106 | |
107 void t4_refresh(void) | |
108 { | |
109 SStateList status; | |
110 get_globalStateList(&status); | |
111 | |
112 if(stateUsed->mode != MODE_DIVE) | |
113 { | |
114 settingsGetPointer()->design = 7; | |
115 return; | |
116 } | |
117 | |
118 if(status.base != BaseHome) | |
119 return; | |
120 | |
121 t4screen.FBStartAdress = getFrame(25); | |
122 t4_refresh_divemode(); | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
123 GFX_SetFramesTopBottom(t4screen.FBStartAdress, 0,480); |
38 | 124 releaseAllFramesExcept(25,t4screen.FBStartAdress); |
125 } | |
126 | |
127 | |
128 /* Private functions ---------------------------------------------------------*/ | |
129 | |
130 void t4_refresh_divemode(void) | |
131 { | |
132 char text[512]; | |
133 // uint8_t textpointer = 0; | |
134 // uint8_t customview_warnings = 0; | |
135 | |
136 point_t start, stop; | |
137 | |
138 start.x = 0; | |
139 stop.x = t4SeperationLeftRight; | |
140 stop.y = start.y = t4SeperationTopMid; | |
141 GFX_draw_line(&t4screen, start, stop, CLUT_Font020); | |
142 | |
143 stop.y = start.y = t4SeperationMidBottom; | |
144 GFX_draw_line(&t4screen, start, stop, CLUT_Font020); | |
145 | |
146 start.y = 0; | |
147 stop.y = 479; | |
148 stop.x = start.x = t4SeperationLeftRight; | |
149 GFX_draw_line(&t4screen, start, stop, CLUT_Font020); | |
150 | |
151 | |
152 // depth | |
153 float depth = 0; | |
154 float depthThisCall = unit_depth_float(stateUsed->lifeData.depth_meter); | |
155 if(is_stateUsedSetToSim()) | |
156 { | |
157 depth = (depthThisCall + depthLastCall[0] + depthLastCall[1] + depthLastCall[2] + depthLastCall[3] + depthLastCall[4] + depthLastCall[5] + depthLastCall[6] + depthLastCall[7] + depthLastCall[8]) / 10.0f; | |
158 | |
159 idDepthLastCall++; | |
160 if(idDepthLastCall >= 9) | |
161 idDepthLastCall = 0; | |
162 depthLastCall[idDepthLastCall] = depthThisCall; | |
163 } | |
164 else | |
165 { | |
166 depth = (depthThisCall + depthLastCall[0] + depthLastCall[1] + depthLastCall[2]) / 4.0f; | |
167 | |
168 idDepthLastCall++; | |
169 if(idDepthLastCall >= 3) | |
170 idDepthLastCall = 0; | |
171 depthLastCall[idDepthLastCall] = depthThisCall; | |
172 } | |
173 | |
174 if(depth <= 0.3f) | |
175 depth = 0; | |
176 | |
177 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth); | |
178 GFX_write_string(&FontT24,&t4l1,text,0); | |
179 | |
180 if( depth < 100) | |
181 snprintf(text,TEXTSIZE,"\020%01.1f",depth); | |
182 else | |
183 snprintf(text,TEXTSIZE,"\020%01.0f",depth); | |
184 | |
185 t3_basics_colorscheme_mod(text); | |
186 GFX_write_string(&FontT144,&t4l1,text,1); | |
187 | |
188 // divetime | |
189 SDivetime Divetime = {0,0,0, 0}; | |
190 | |
191 Divetime.Total = stateUsed->lifeData.dive_time_seconds_without_surface_time; | |
192 Divetime.Minutes = Divetime.Total / 60; | |
193 Divetime.Seconds = Divetime.Total - ( Divetime.Minutes * 60 ); | |
194 | |
195 SDivetime TimeoutTime = {0,0,0,0}; | |
196 TimeoutTime.Total = settingsGetPointer()->timeoutDiveReachedZeroDepth - stateUsed->lifeData.counterSecondsShallowDepth; | |
197 if(TimeoutTime.Total > settingsGetPointer()->timeoutDiveReachedZeroDepth) | |
198 { | |
199 TimeoutTime.Total = 0; | |
200 } | |
201 TimeoutTime.Minutes = TimeoutTime.Total / 60; | |
202 TimeoutTime.Seconds = TimeoutTime.Total - (TimeoutTime.Minutes * 60); | |
203 | |
204 if(stateUsed->lifeData.counterSecondsShallowDepth) | |
205 { | |
206 snprintf(text,TEXTSIZE,"\f\136 %u:%02u",TimeoutTime.Minutes, TimeoutTime.Seconds); | |
207 GFX_write_string(&FontT42,&t4l2,text,0); | |
208 } | |
209 else | |
210 { | |
211 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Divetime); | |
212 GFX_write_string(&FontT42,&t4l2,text,0); | |
213 } | |
214 | |
215 if(Divetime.Minutes < 1000) | |
216 snprintf(text,TEXTSIZE,"\020\016%u:%02u",Divetime.Minutes, Divetime.Seconds); | |
217 else | |
218 snprintf(text,TEXTSIZE,"\020\016%u'",Divetime.Minutes); | |
219 t3_basics_colorscheme_mod(text); | |
220 GFX_write_string(&FontT105,&t4l2,text,1); | |
221 } | |
222 | |
223 | |
224 | |
225 |