Mercurial > public > ostc4
annotate Discovery/Src/t4_tetris.c @ 625:028d8f3a9410
Switch Sector / Scroll detection to vector implementation:
The vector implementation is mor robust against influences of roll and yaw to the pitch angle. To improve the performance the old sector based implementation has been replaced. In addition after entering focus state the roll angle is ignored.
To improve readability and due to removal of some no longer needed function codes, function names have been updated
author | Ideenmodellierer |
---|---|
date | Mon, 08 Feb 2021 21:35:46 +0100 |
parents | ecb71521d004 |
children | db92692c014f |
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 /* Private types -------------------------------------------------------------*/ | |
49 #define TEXTSIZE 16 | |
50 | |
51 const uint16_t t4SeperationLeftRight = 250; | |
52 const uint16_t t4SeperationTopMid = 315; | |
53 const uint16_t t4SeperationMidBottom = 139; | |
54 | |
55 /* Private function prototypes -----------------------------------------------*/ | |
56 void t4_refresh_divemode(void); | |
57 | |
58 /* Exported functions --------------------------------------------------------*/ | |
59 | |
60 void t4_init(void) | |
61 { | |
62 t4screen.FBStartAdress = 0; | |
63 t4screen.ImageHeight = 480; | |
64 t4screen.ImageWidth = 800; | |
65 t4screen.LayerIndex = 1; | |
66 | |
67 t4l1.Image = &t4screen; | |
68 t4l1.WindowNumberOfTextLines = 2; | |
69 t4l1.WindowLineSpacing = 19; // Abstand von Y0 | |
70 t4l1.WindowTab = 100; | |
71 t4l1.WindowX0 = 0; | |
72 t4l1.WindowX1 = t4SeperationLeftRight - 2; | |
73 t4l1.WindowY1 = 479; | |
74 t4l1.WindowY0 = t4SeperationTopMid + 3; | |
75 | |
76 t4l2.Image = t4l1.Image; | |
77 t4l2.WindowNumberOfTextLines = t4l1.WindowNumberOfTextLines; | |
78 t4l2.WindowLineSpacing = t4l1.WindowLineSpacing; | |
79 t4l2.WindowTab = t4l1.WindowTab; | |
80 t4l2.WindowX0 = t4l1.WindowX0; | |
81 t4l2.WindowX1 = t4l1.WindowX1; | |
82 t4l2.WindowY1 = t4SeperationTopMid - 2; | |
83 t4l2.WindowY0 = t4SeperationMidBottom + 3; | |
84 | |
85 t4l3.Image = t4l1.Image; | |
86 t4l3.WindowNumberOfTextLines = t4l1.WindowNumberOfTextLines; | |
87 t4l3.WindowLineSpacing = t4l1.WindowLineSpacing; | |
88 t4l3.WindowTab = t4l1.WindowTab; | |
89 t4l3.WindowX0 = t4l1.WindowX0; | |
90 t4l3.WindowX1 = t4l1.WindowX1; | |
91 t4l3.WindowY1 = t4SeperationMidBottom - 2; | |
92 t4l3.WindowY0 = 0; | |
93 } | |
94 | |
95 | |
96 void t4_refresh(void) | |
97 { | |
98 SStateList status; | |
99 get_globalStateList(&status); | |
100 | |
101 if(stateUsed->mode != MODE_DIVE) | |
102 { | |
103 settingsGetPointer()->design = 7; | |
104 return; | |
105 } | |
106 | |
107 if(status.base != BaseHome) | |
108 return; | |
109 | |
110 t4screen.FBStartAdress = getFrame(25); | |
111 t4_refresh_divemode(); | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
38
diff
changeset
|
112 GFX_SetFramesTopBottom(t4screen.FBStartAdress, 0,480); |
38 | 113 releaseAllFramesExcept(25,t4screen.FBStartAdress); |
114 } | |
115 | |
116 | |
117 /* Private functions ---------------------------------------------------------*/ | |
118 | |
119 void t4_refresh_divemode(void) | |
120 { | |
121 char text[512]; | |
122 // uint8_t textpointer = 0; | |
123 // uint8_t customview_warnings = 0; | |
124 | |
125 point_t start, stop; | |
126 | |
127 start.x = 0; | |
128 stop.x = t4SeperationLeftRight; | |
129 stop.y = start.y = t4SeperationTopMid; | |
130 GFX_draw_line(&t4screen, start, stop, CLUT_Font020); | |
131 | |
132 stop.y = start.y = t4SeperationMidBottom; | |
133 GFX_draw_line(&t4screen, start, stop, CLUT_Font020); | |
134 | |
135 start.y = 0; | |
136 stop.y = 479; | |
137 stop.x = start.x = t4SeperationLeftRight; | |
138 GFX_draw_line(&t4screen, start, stop, CLUT_Font020); | |
139 | |
140 | |
141 // depth | |
174
ecb71521d004
Bugfix: make max depth move with current depth (part 2)
Jan Mulder <jlmulder@xs4all.nl>
parents:
166
diff
changeset
|
142 float depth = unit_depth_float(stateUsed->lifeData.depth_meter); |
38 | 143 |
144 if(depth <= 0.3f) | |
145 depth = 0; | |
146 | |
147 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth); | |
148 GFX_write_string(&FontT24,&t4l1,text,0); | |
149 | |
150 if( depth < 100) | |
151 snprintf(text,TEXTSIZE,"\020%01.1f",depth); | |
152 else | |
153 snprintf(text,TEXTSIZE,"\020%01.0f",depth); | |
154 | |
155 t3_basics_colorscheme_mod(text); | |
156 GFX_write_string(&FontT144,&t4l1,text,1); | |
157 | |
158 // divetime | |
159 SDivetime Divetime = {0,0,0, 0}; | |
160 | |
161 Divetime.Total = stateUsed->lifeData.dive_time_seconds_without_surface_time; | |
162 Divetime.Minutes = Divetime.Total / 60; | |
163 Divetime.Seconds = Divetime.Total - ( Divetime.Minutes * 60 ); | |
164 | |
165 SDivetime TimeoutTime = {0,0,0,0}; | |
166 TimeoutTime.Total = settingsGetPointer()->timeoutDiveReachedZeroDepth - stateUsed->lifeData.counterSecondsShallowDepth; | |
167 if(TimeoutTime.Total > settingsGetPointer()->timeoutDiveReachedZeroDepth) | |
168 { | |
169 TimeoutTime.Total = 0; | |
170 } | |
171 TimeoutTime.Minutes = TimeoutTime.Total / 60; | |
172 TimeoutTime.Seconds = TimeoutTime.Total - (TimeoutTime.Minutes * 60); | |
173 | |
174 if(stateUsed->lifeData.counterSecondsShallowDepth) | |
175 { | |
176 snprintf(text,TEXTSIZE,"\f\136 %u:%02u",TimeoutTime.Minutes, TimeoutTime.Seconds); | |
177 GFX_write_string(&FontT42,&t4l2,text,0); | |
178 } | |
179 else | |
180 { | |
181 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Divetime); | |
182 GFX_write_string(&FontT42,&t4l2,text,0); | |
183 } | |
184 | |
185 if(Divetime.Minutes < 1000) | |
186 snprintf(text,TEXTSIZE,"\020\016%u:%02u",Divetime.Minutes, Divetime.Seconds); | |
187 else | |
188 snprintf(text,TEXTSIZE,"\020\016%u'",Divetime.Minutes); | |
189 t3_basics_colorscheme_mod(text); | |
190 GFX_write_string(&FontT105,&t4l2,text,1); | |
191 } | |
192 | |
193 | |
194 | |
195 |