Mercurial > public > ostc4
annotate Discovery/Src/tMenuSystem.c @ 805:dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
This can be used to time safety stops, or to prebreathe a CCR (or to boil your breakfast eggs if you are so inclined). The duration of the timer is configurable from 1 second to 9:59 minutes in the System menu.
The timer is started by switching to the custom view, and remaining on it until a 10 second delay has elapsed. Once the timer has started the custom view can be changed and the timer will continue running in the background.
After the timer has run out 'Finished' will be shown for 10 seconds in the timer custom view, and then automatic switching of custom views (if configured) resumes.
In surface mode the dive computer will not go to sleep while the timer is running, and a mini timer will be shown when the timer custom view is not showing. (mikeller)
author | heinrichsweikamp |
---|---|
date | Mon, 21 Aug 2023 17:20:07 +0200 |
parents | 54c5ec8416c4 |
children | ce8f71217f45 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuSystem.c | |
5 /// \brief Main Template file for Menu Page System settings | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 05-Aug-2014 | |
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 "tMenu.h" | |
31 #include "tMenuSystem.h" | |
32 #include "tHome.h" // for enum CUSTOMVIEWS and init_t7_compass() | |
33 | |
379 | 34 static uint8_t customviewsSubpage = 0; |
35 | |
38 | 36 /* Private function prototypes -----------------------------------------------*/ |
37 char customview_TXT2BYTE_helper(uint8_t customViewId); | |
38 | |
379 | 39 void set_CustomsviewsSubpage(uint8_t page) |
40 { | |
41 customviewsSubpage = page; | |
42 } | |
43 | |
38 | 44 /* Exported functions --------------------------------------------------------*/ |
45 | |
46 uint32_t tMSystem_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext) | |
47 { | |
48 SSettings *data; | |
379 | 49 int i; |
38 | 50 uint8_t textPointer; |
51 uint8_t dateFormat; | |
52 uint8_t RTEhigh, RTElow; | |
53 RTC_DateTypeDef Sdate; | |
54 RTC_TimeTypeDef Stime; | |
55 const SDiveState * pStateReal = stateRealGetPointer(); | |
56 | |
57 data = settingsGetPointer(); | |
58 textPointer = 0; | |
59 *tab = 300; | |
60 *subtext = 0; | |
61 | |
62 // dive mode | |
63 if(actual_menu_content != MENU_SURFACE) | |
64 { | |
65 uint8_t id; | |
66 | |
379 | 67 for(i=0; i<5;i++) /* fill maximum 5 items and leave last one for sub page selection */ |
38 | 68 { |
379 | 69 id = cv_changelist[customviewsSubpage * 5 + i]; |
70 if(id == CVIEW_END) /* last list item? */ | |
71 { | |
72 break; | |
73 } | |
74 else | |
75 { | |
76 text[textPointer++] = '\006' - CHECK_BIT_THOME(data->cv_configuration,id); | |
77 text[textPointer++] = ' '; | |
78 textPointer += snprintf(&text[textPointer], 60, | |
79 "%c%c\n\r", | |
80 TXT_2BYTE, customview_TXT2BYTE_helper(id)); | |
81 } | |
38 | 82 } |
379 | 83 text[textPointer++] = TXT_2BYTE; |
84 text[textPointer++] = TXT2BYTE_ButtonNext; | |
38 | 85 text[textPointer] = 0; |
86 | |
379 | 87 for(;i<5;i++) /* clear empty lines in case menu shows less than 5 entries */ |
88 { | |
89 text[textPointer++]='\n'; | |
90 text[textPointer++]='\r'; | |
91 text[textPointer] = 0; | |
92 } | |
93 | |
38 | 94 return StMSYS; |
95 } | |
96 | |
97 // surface mode | |
139
decb0461302a
Get version from local memory instead from incoming data
Ideenmodellierer
parents:
138
diff
changeset
|
98 getActualRTEandFONTversion(&RTEhigh,&RTElow,NULL,NULL); |
38 | 99 |
100 if((RTEhigh == 0xFF) || (RTElow == 0xFF)) | |
101 { | |
102 RTEhigh = 0; | |
103 RTElow = 0; | |
104 } | |
105 | |
106 if((line == 0) || (line == 1)) | |
107 { | |
108 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); | |
109 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); | |
110 | |
111 dateFormat = data->date_format; | |
112 | |
113 textPointer += snprintf(&text[textPointer], 40, | |
114 "Date" | |
115 "\016\016" | |
116 " " | |
117 ); | |
118 | |
119 if(dateFormat == DDMMYY) | |
120 { | |
121 textPointer += snprintf(&text[textPointer], 40, | |
122 "DDMMYY" | |
123 "\017" | |
124 "\t" | |
125 "%02d-%02d-%02d" | |
126 " " | |
127 , Sdate.Date, Sdate.Month, 2000 + Sdate.Year | |
128 ); | |
129 } | |
130 else | |
131 if(dateFormat == MMDDYY) | |
132 { | |
133 textPointer += snprintf(&text[textPointer], 40, | |
134 "MMDDYY" | |
135 "\017" | |
136 "\t" | |
137 "%02d-%02d-%02d" | |
138 " " | |
139 ,Sdate.Month, Sdate.Date, 2000 + Sdate.Year | |
140 ); | |
141 } | |
142 else | |
143 if(dateFormat == YYMMDD) | |
144 { | |
145 textPointer += snprintf(&text[textPointer], 40, | |
146 "YYMMDD" | |
147 "\017" | |
148 "\t" | |
149 "%02d-%02d-%02d" | |
150 " " | |
151 , 2000 + Sdate.Year, Sdate.Month, Sdate.Date | |
152 ); | |
153 } | |
154 | |
155 textPointer += snprintf(&text[textPointer], 60, | |
156 "%02d:%02d:%02d" | |
157 "\n\r" | |
158 ,Stime.Hours, Stime.Minutes, Stime.Seconds | |
159 ); | |
160 } | |
161 else | |
162 { | |
163 strcpy(&text[textPointer],"\n\r"); | |
164 textPointer += 2; | |
165 } | |
166 | |
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
536
diff
changeset
|
167 if (line == 0 || line == 2) { |
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
536
diff
changeset
|
168 textPointer += snprintf(&text[textPointer], 21, "%c%c\t%u:%02u \016\016[m:ss]\017\n\r", TXT_2BYTE, TXT2BYTE_Timer, data->timerDurationS / 60, data->timerDurationS % 60); |
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
536
diff
changeset
|
169 } else { |
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
536
diff
changeset
|
170 textPointer += snprintf(&text[textPointer], 3, "\n\r"); |
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
536
diff
changeset
|
171 } |
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
536
diff
changeset
|
172 |
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
536
diff
changeset
|
173 if((line == 0) || (line == 3)) |
38 | 174 { |
175 text[textPointer++] = TXT_Language; | |
176 text[textPointer++] = '\t'; | |
177 text[textPointer++] = TXT_LanguageName; | |
178 text[textPointer++] = '\n'; | |
179 text[textPointer++] = '\r'; | |
180 text[textPointer] = 0; | |
181 } | |
182 else | |
183 { | |
184 strcpy(&text[textPointer],"\n\r"); | |
185 textPointer += 2; | |
186 } | |
187 | |
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
536
diff
changeset
|
188 if((line == 0) || (line == 4)) |
38 | 189 { |
190 text[textPointer++] = TXT_2BYTE; | |
191 text[textPointer++] = TXT2BYTE_Layout; | |
192 text[textPointer++] = '\t'; | |
193 | |
194 if(!data->showDebugInfo) | |
195 { | |
196 text[textPointer++] = TXT_2BYTE; | |
197 if(data->nonMetricalSystem == 0) | |
198 text[textPointer++] = TXT2BYTE_Units_metric; | |
199 else | |
200 text[textPointer++] = TXT2BYTE_Units_feet; | |
201 | |
202 if(data->tX_colorscheme != 0) | |
203 { | |
536
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
204 text[textPointer++] = ' '; |
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
205 text[textPointer++] = '/'; |
38 | 206 text[textPointer++] = '\027'; |
207 text[textPointer++] = ' '; | |
208 text[textPointer++] = '0' + data->tX_colorscheme; | |
209 text[textPointer++] = '\020'; | |
210 } | |
211 } | |
212 else | |
213 { | |
214 if(data->nonMetricalSystem == 0) | |
215 { | |
216 text[textPointer++] = 'm'; | |
536
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
217 text[textPointer++] = ' '; |
38 | 218 text[textPointer++] = '/'; |
536
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
219 text[textPointer++] = ' '; |
38 | 220 text[textPointer++] = 'C'; |
536
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
221 text[textPointer++] = ' '; |
38 | 222 } |
223 else | |
224 { | |
225 text[textPointer++] = 'f'; | |
226 text[textPointer++] = 't'; | |
227 text[textPointer++] = ' '; | |
228 text[textPointer++] = '/'; | |
229 text[textPointer++] = ' '; | |
536
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
230 text[textPointer++] = 'F'; |
38 | 231 text[textPointer++] = ' '; |
536
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
232 } |
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
233 if(data->tX_colorscheme != 0) |
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
234 { |
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
235 text[textPointer++] = '/'; |
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
236 text[textPointer++] = '\027'; |
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
237 text[textPointer++] = ' '; |
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
238 text[textPointer++] = '0' + data->tX_colorscheme; |
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
239 text[textPointer++] = ' '; |
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
240 text[textPointer++] = '\020'; |
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
241 } |
54c5ec8416c4
Changed visualization of Depth / temperatur / debugview entry
Ideenmodellierer
parents:
520
diff
changeset
|
242 text[textPointer++] = '/'; |
38 | 243 text[textPointer++] = ' '; |
244 text[textPointer++] = 'd'; | |
245 text[textPointer++] = 'e'; | |
246 text[textPointer++] = 'b'; | |
247 text[textPointer++] = 'u'; | |
248 text[textPointer++] = 'g'; | |
249 } | |
250 | |
251 text[textPointer++] = '\n'; | |
252 text[textPointer++] = '\r'; | |
253 text[textPointer] = 0; | |
254 } | |
255 else | |
256 { | |
257 strcpy(&text[textPointer],"\n\r"); | |
258 textPointer += 2; | |
259 } | |
260 | |
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
536
diff
changeset
|
261 if((line == 0) || (line == 5)) |
38 | 262 { |
263 text[textPointer++] = TXT_Information; | |
264 text[textPointer++] = '\t'; | |
265 textPointer += snprintf(&text[textPointer],29,"RTE %u.%u OS %i.%i.%i" | |
266 ,RTEhigh | |
267 ,RTElow | |
268 ,firmwareDataGetPointer()->versionFirst | |
269 ,firmwareDataGetPointer()->versionSecond | |
270 ,firmwareDataGetPointer()->versionThird | |
271 ); | |
272 } | |
273 strcpy(&text[textPointer],"\n\r"); | |
274 textPointer += 2; | |
275 | |
805
dd7ce655db26
Adds a simple countdown timer, available as a custom view in surface and dive mode.
heinrichsweikamp
parents:
536
diff
changeset
|
276 if((line == 0) || (line == 6)) |
38 | 277 { |
278 text[textPointer++] = TXT_2BYTE; | |
279 text[textPointer++] = TXT2BYTE_ResetMenu; | |
280 text[textPointer] = 0; | |
281 } | |
282 strcpy(&text[textPointer],"\n\r"); | |
283 textPointer += 2; | |
284 | |
285 return StMSYS; | |
286 } | |
287 | |
288 | |
289 /* Private functions ---------------------------------------------------------*/ |