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"
|
868
|
39 #include "gfx_engine.h"
|
38
|
40
|
|
41 /* Exported variables --------------------------------------------------------*/
|
|
42
|
|
43 /* Private variables ---------------------------------------------------------*/
|
|
44 GFX_DrawCfgScreen t4screen;
|
|
45 GFX_DrawCfgWindow t4l1;
|
|
46 GFX_DrawCfgWindow t4l2;
|
|
47 GFX_DrawCfgWindow t4l3;
|
|
48
|
|
49 /* Private types -------------------------------------------------------------*/
|
|
50 #define TEXTSIZE 16
|
|
51
|
|
52 const uint16_t t4SeperationLeftRight = 250;
|
|
53 const uint16_t t4SeperationTopMid = 315;
|
|
54 const uint16_t t4SeperationMidBottom = 139;
|
|
55
|
|
56 /* Private function prototypes -----------------------------------------------*/
|
|
57 void t4_refresh_divemode(void);
|
|
58
|
|
59 /* Exported functions --------------------------------------------------------*/
|
|
60
|
|
61 void t4_init(void)
|
|
62 {
|
|
63 t4screen.FBStartAdress = 0;
|
|
64 t4screen.ImageHeight = 480;
|
|
65 t4screen.ImageWidth = 800;
|
|
66 t4screen.LayerIndex = 1;
|
|
67
|
|
68 t4l1.Image = &t4screen;
|
|
69 t4l1.WindowNumberOfTextLines = 2;
|
|
70 t4l1.WindowLineSpacing = 19; // Abstand von Y0
|
|
71 t4l1.WindowTab = 100;
|
|
72 t4l1.WindowX0 = 0;
|
|
73 t4l1.WindowX1 = t4SeperationLeftRight - 2;
|
|
74 t4l1.WindowY1 = 479;
|
|
75 t4l1.WindowY0 = t4SeperationTopMid + 3;
|
|
76
|
|
77 t4l2.Image = t4l1.Image;
|
|
78 t4l2.WindowNumberOfTextLines = t4l1.WindowNumberOfTextLines;
|
|
79 t4l2.WindowLineSpacing = t4l1.WindowLineSpacing;
|
|
80 t4l2.WindowTab = t4l1.WindowTab;
|
|
81 t4l2.WindowX0 = t4l1.WindowX0;
|
|
82 t4l2.WindowX1 = t4l1.WindowX1;
|
|
83 t4l2.WindowY1 = t4SeperationTopMid - 2;
|
|
84 t4l2.WindowY0 = t4SeperationMidBottom + 3;
|
|
85
|
|
86 t4l3.Image = t4l1.Image;
|
|
87 t4l3.WindowNumberOfTextLines = t4l1.WindowNumberOfTextLines;
|
|
88 t4l3.WindowLineSpacing = t4l1.WindowLineSpacing;
|
|
89 t4l3.WindowTab = t4l1.WindowTab;
|
|
90 t4l3.WindowX0 = t4l1.WindowX0;
|
|
91 t4l3.WindowX1 = t4l1.WindowX1;
|
|
92 t4l3.WindowY1 = t4SeperationMidBottom - 2;
|
|
93 t4l3.WindowY0 = 0;
|
|
94 }
|
|
95
|
|
96
|
|
97 void t4_refresh(void)
|
|
98 {
|
|
99 SStateList status;
|
|
100 get_globalStateList(&status);
|
|
101
|
|
102 if(stateUsed->mode != MODE_DIVE)
|
|
103 {
|
|
104 settingsGetPointer()->design = 7;
|
|
105 return;
|
|
106 }
|
|
107
|
|
108 if(status.base != BaseHome)
|
|
109 return;
|
|
110
|
|
111 t4screen.FBStartAdress = getFrame(25);
|
|
112 t4_refresh_divemode();
|
166
|
113 GFX_SetFramesTopBottom(t4screen.FBStartAdress, 0,480);
|
38
|
114 releaseAllFramesExcept(25,t4screen.FBStartAdress);
|
|
115 }
|
|
116
|
|
117
|
|
118 /* Private functions ---------------------------------------------------------*/
|
|
119
|
|
120 void t4_refresh_divemode(void)
|
|
121 {
|
|
122 char text[512];
|
|
123 // uint8_t textpointer = 0;
|
|
124 // uint8_t customview_warnings = 0;
|
|
125
|
|
126 point_t start, stop;
|
|
127
|
|
128 start.x = 0;
|
|
129 stop.x = t4SeperationLeftRight;
|
|
130 stop.y = start.y = t4SeperationTopMid;
|
|
131 GFX_draw_line(&t4screen, start, stop, CLUT_Font020);
|
|
132
|
|
133 stop.y = start.y = t4SeperationMidBottom;
|
|
134 GFX_draw_line(&t4screen, start, stop, CLUT_Font020);
|
|
135
|
|
136 start.y = 0;
|
|
137 stop.y = 479;
|
|
138 stop.x = start.x = t4SeperationLeftRight;
|
|
139 GFX_draw_line(&t4screen, start, stop, CLUT_Font020);
|
|
140
|
|
141
|
|
142 // depth
|
174
|
143 float depth = unit_depth_float(stateUsed->lifeData.depth_meter);
|
38
|
144
|
|
145 if(depth <= 0.3f)
|
|
146 depth = 0;
|
|
147
|
|
148 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth);
|
|
149 GFX_write_string(&FontT24,&t4l1,text,0);
|
|
150
|
|
151 if( depth < 100)
|
|
152 snprintf(text,TEXTSIZE,"\020%01.1f",depth);
|
|
153 else
|
|
154 snprintf(text,TEXTSIZE,"\020%01.0f",depth);
|
|
155
|
868
|
156 Gfx_colorsscheme_mod(text,0);
|
38
|
157 GFX_write_string(&FontT144,&t4l1,text,1);
|
|
158
|
|
159 // divetime
|
|
160 SDivetime Divetime = {0,0,0, 0};
|
|
161
|
|
162 Divetime.Total = stateUsed->lifeData.dive_time_seconds_without_surface_time;
|
|
163 Divetime.Minutes = Divetime.Total / 60;
|
|
164 Divetime.Seconds = Divetime.Total - ( Divetime.Minutes * 60 );
|
|
165
|
|
166 SDivetime TimeoutTime = {0,0,0,0};
|
|
167 TimeoutTime.Total = settingsGetPointer()->timeoutDiveReachedZeroDepth - stateUsed->lifeData.counterSecondsShallowDepth;
|
|
168 if(TimeoutTime.Total > settingsGetPointer()->timeoutDiveReachedZeroDepth)
|
|
169 {
|
|
170 TimeoutTime.Total = 0;
|
|
171 }
|
|
172 TimeoutTime.Minutes = TimeoutTime.Total / 60;
|
|
173 TimeoutTime.Seconds = TimeoutTime.Total - (TimeoutTime.Minutes * 60);
|
|
174
|
|
175 if(stateUsed->lifeData.counterSecondsShallowDepth)
|
|
176 {
|
|
177 snprintf(text,TEXTSIZE,"\f\136 %u:%02u",TimeoutTime.Minutes, TimeoutTime.Seconds);
|
|
178 GFX_write_string(&FontT42,&t4l2,text,0);
|
|
179 }
|
|
180 else
|
|
181 {
|
|
182 snprintf(text,TEXTSIZE,"\032\f%c",TXT_Divetime);
|
|
183 GFX_write_string(&FontT42,&t4l2,text,0);
|
|
184 }
|
|
185
|
|
186 if(Divetime.Minutes < 1000)
|
|
187 snprintf(text,TEXTSIZE,"\020\016%u:%02u",Divetime.Minutes, Divetime.Seconds);
|
|
188 else
|
|
189 snprintf(text,TEXTSIZE,"\020\016%u'",Divetime.Minutes);
|
868
|
190 Gfx_colorsscheme_mod(text,0);
|
38
|
191 GFX_write_string(&FontT105,&t4l2,text,1);
|
|
192 }
|
|
193
|
|
194
|
|
195
|
|
196
|