annotate Discovery/Src/t6_apnea.c @ 196:2885628ab3ba div-fixes-cleaup-2

Bugfix, minor: color the overview customview correctly When using a custom color (from the SYS2 menu, layout), the overview customview was the only one presented in the wrong color. While the fix for this is rather simple (in hindsight), it was a non trivial search trough rather obfuscated code. There is a specific function to set the text color index on this page, but this only worked for a single line text string, that has the color index byte as the very first character. The original author already recognized that this function "could be extended", but left this extension as an exercise to the reader. So, the coloring is fixed by extending the function, and actually using it for the overview customview. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Wed, 20 Mar 2019 16:24:10 +0100
parents 8b8074080d7b
children 2bb1db22b5f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 /// -*- coding: UTF-8 -*-
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 /// \file Discovery/Src/t6_apnea.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 /// \brief dive screen for Gauge mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 /// \author Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 /// \date 1-Feb-2017
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 /// \details
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 /// $Id$
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ///////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 /// This program is free software: you can redistribute it and/or modify
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 /// it under the terms of the GNU General Public License as published by
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 /// the Free Software Foundation, either version 3 of the License, or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 /// (at your option) any later version.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 /// This program is distributed in the hope that it will be useful,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 /// GNU General Public License for more details.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 ///
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 /// You should have received a copy of the GNU General Public License
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 //////////////////////////////////////////////////////////////////////////////
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 #include "t6_apnea.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 #include "data_exchange_main.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 #include "decom.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 #include "gfx_fonts.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 #include "math.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 #include "tHome.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 #include "simulation.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 #include "timer.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 #include "unit.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 GFX_DrawCfgScreen t6screen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 GFX_DrawCfgWindow t6l1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 GFX_DrawCfgWindow t6r1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 GFX_DrawCfgWindow t6c1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 GFX_DrawCfgWindow t6c2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 GFX_DrawCfgWindow t6c3; // for menu text
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 uint8_t t6_selection_customview = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 /* Importend function prototypes ---------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 /* Private types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 #define CUSTOMBOX_LINE_LEFT (250)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 #define CUSTOMBOX_LINE_RIGHT (549)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 #define CUSTOMBOX_INSIDE_OFFSET (2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 #define CUSTOMBOX_OUTSIDE_OFFSET (2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 #define TEXTSIZE 16
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 const uint8_t t6_customviewsStandard[] =
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 CVIEW_noneOrDebug,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 CVIEW_T3_Temperature,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 CVIEW_T3_END
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 };
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 const uint8_t *t6_customviews = t6_customviewsStandard;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 const uint8_t t6_customviewSurfaceMode = CVIEW_T3_ApnoeSurfaceInfo;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 void t6_refresh_divemode(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 void t6_refresh_customview(float depth);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 uint8_t t6_test_customview_warnings(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 // for tHomeDiveMenuControl() in tHome.c and t6_refresh_customview
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 uint8_t t6_getCustomView(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 if(stateUsed->lifeData.counterSecondsShallowDepth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 return t6_customviewSurfaceMode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 return t6_selection_customview;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 void t6_init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 t6_selection_customview = t6_customviewsStandard[0];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 t6screen.FBStartAdress = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 t6screen.ImageHeight = 480;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 t6screen.ImageWidth = 800;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 t6screen.LayerIndex = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 t6l1.Image = &t6screen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 t6l1.WindowNumberOfTextLines = 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 t6l1.WindowLineSpacing = 19; // Abstand von Y0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 t6l1.WindowTab = 100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 t6l1.WindowX0 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 t6l1.WindowX1 = BigFontSeperationLeftRight - 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 t6l1.WindowY0 = BigFontSeperationTopBottom + 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 t6l1.WindowY1 = 479;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 t6r1.Image = &t6screen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 t6r1.WindowNumberOfTextLines = t6l1.WindowNumberOfTextLines;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 t6r1.WindowLineSpacing = t6l1.WindowLineSpacing;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 t6r1.WindowTab = t6l1.WindowTab;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 t6r1.WindowX0 = BigFontSeperationLeftRight + 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 t6r1.WindowX1 = 799;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 t6r1.WindowY0 = t6l1.WindowY0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 t6r1.WindowY1 = t6l1.WindowY1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 t6c1.Image = &t6screen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 t6c1.WindowNumberOfTextLines = 2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 t6c1.WindowLineSpacing = t6l1.WindowLineSpacing;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 t6c1.WindowX0 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 t6c1.WindowX1 = 799;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 t6c1.WindowY0 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 t6c1.WindowY1 = BigFontSeperationTopBottom - 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 t6c2.Image = &t6screen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 t6c2.WindowNumberOfTextLines = 3;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 t6c2.WindowLineSpacing = 58;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 t6c2.WindowX0 = 370;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 t6c2.WindowX1 = 799;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 t6c2.WindowY0 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 t6c2.WindowY1 = BigFontSeperationTopBottom - 5;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 t6c2.WindowTab = 600;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 t6c3.Image = &t6screen;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 t6c3.WindowNumberOfTextLines = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 t6c3.WindowLineSpacing = 0; // Abstand von Y0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 t6c3.WindowTab = 100;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 t6c3.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 t6c3.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 t6c3.WindowY0 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 t6c3.WindowY1 = 69;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 void t6_refresh(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 static uint8_t last_mode = MODE_SURFACE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 SStateList status;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 get_globalStateList(&status);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 if(stateUsed->mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 last_mode = MODE_SURFACE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 settingsGetPointer()->design = 7;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 if(t6screen.FBStartAdress)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 releaseFrame(24,t6screen.FBStartAdress);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 t6screen.FBStartAdress = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 if(status.base != BaseHome)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 return;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 t6screen.FBStartAdress = getFrame(24);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 if(last_mode != MODE_DIVE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 last_mode = MODE_DIVE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 t6_selection_customview = *t6_customviews;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 if(status.page == PageSurface)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 set_globalState(StD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 t6_refresh_divemode();
166
255eedad4155 cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents: 138
diff changeset
178 GFX_SetFramesTopBottom(t6screen.FBStartAdress, 0,480);
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 releaseAllFramesExcept(24,t6screen.FBStartAdress);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 void t6_refresh_divemode(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 char text[512];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 uint8_t customview_warnings = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 float depth_meter = 0.0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 // everything like lines, depth, ascent graph and divetime or counterSecondsShallowDepth
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 depth_meter = t3_basics_lines_depth_and_divetime(&t6screen, &t6l1, &t6r1, DIVEMODE_Apnea);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 // customview
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 if(stateUsed->warnings.numWarnings)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 customview_warnings = t6_test_customview_warnings();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 if(customview_warnings && warning_count_high_time)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 t3_basics_show_customview_warnings(&t6c1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 t6_refresh_customview(depth_meter);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 if(stateUsed->warnings.lowBattery)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 t3_basics_battery_low_customview_extra(&t6c1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 /* Menu Selection (and gas mix) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 if(get_globalState() == StDBEAR)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveBearingQ);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 else if(get_globalState() == StDRAVG)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveResetAvgQ);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 else if(get_globalState() == StDQUIT)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 else if(get_globalState() == StDSIM1)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 snprintf(text,TEXTSIZE,"\a\001%c%c", TXT_2BYTE, TXT2BYTE_DiveQuitQ);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 else if(get_globalState() == StDSIM2)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 snprintf(text,TEXTSIZE,"\a\001" " Sim:-3.33ft ");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 snprintf(text,TEXTSIZE,"\a\001" " Sim:-1m ");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 snprintf(text,TEXTSIZE,"\a\f %u %c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 , unit_depth_integer(simulation_get_aim_depth())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 , unit_depth_char1()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 , unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 else if(get_globalState() == StDSIM3)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 if(settingsGetPointer()->nonMetricalSystem)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 snprintf(text,TEXTSIZE,"\a\001" " Sim:+3.33ft ");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 snprintf(text,TEXTSIZE,"\a\001" " Sim:+1m ");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 snprintf(text,TEXTSIZE,"\a\f %u %c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 , unit_depth_integer(simulation_get_aim_depth())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 , unit_depth_char1()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 , unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 else if(get_globalState() == StDSIM4)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 snprintf(text,TEXTSIZE,"\a\001" " Sim:+5' ");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 GFX_write_string_color(&FontT48,&t6c3,text,0,CLUT_WarningYellow);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 snprintf(text,TEXTSIZE,"\a\f %u %c%c"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 , unit_depth_integer(simulation_get_aim_depth())
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 , unit_depth_char1()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 , unit_depth_char2()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 GFX_write_string_color(&FontT42,&t6l1,text,0,CLUT_WarningYellow);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 // keep empty
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 void t6_battery_low_customview_extra(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 char TextC1[256];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 TextC1[0] = '\002';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 TextC1[1] = '\f';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 TextC1[2] = '\025';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 TextC1[3] = '3';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 TextC1[4] = '1';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 TextC1[5] = '1';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 TextC1[6] = '1';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 TextC1[7] = '1';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 TextC1[8] = '1';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 TextC1[9] = '1';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 TextC1[10] = '1';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 TextC1[11] = '1';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 TextC1[12] = '1';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 TextC1[13] = '1';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 TextC1[14] = '0';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 TextC1[15] = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 if(!warning_count_high_time)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 TextC1[4] = '2';
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 GFX_write_string(&Batt24,&t6c1,TextC1,0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 void t6_change_customview(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 t3_basics_change_customview(&t6_selection_customview, t6_customviews);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 void t6_refresh_customview(float depth)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 uint8_t customViewLeftSide = CVIEW_T3_MaxDepth;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 if((t6_selection_customview == CVIEW_sensors) &&(stateUsed->diveSettings.ccrOption == 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 t6_change_customview();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 if(t6_getCustomView() == CVIEW_T3_ApnoeSurfaceInfo)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 customViewLeftSide = CVIEW_T3_ApnoeSurfaceInfo;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 t3_basics_refresh_customview(depth, customViewLeftSide, &t6screen, &t6c1, &t6c2, DIVEMODE_Apnea);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 t3_basics_refresh_apnoeRight(depth, t6_getCustomView(), &t6screen, &t6c1, &t6c2, DIVEMODE_Apnea);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 uint8_t t6_test_customview_warnings(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 uint8_t count = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 count = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 return count;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 }