Mercurial > public > ostc4
annotate Discovery/Src/tInfo.c @ 845:17d9d6eddd8d Evo_2_23
Added new PreDiveCheck info page:
In case a DiveO2 sensor is connected to the OSTC than the values of the DiveO2 internal pressure and temperature sensors may be used for predive checks. The pressure sensors is used for over / under pressure test and the values are visualized using a graph to make it easier to check if the pressure keeps stable. The temperature measurement gives an indication if the scrubber is getting active. This view is highly dependend on the surface temperature but may be useful e.g. for diving in european area.
In addition the values ofthe connected sensors are shown.
author | Ideenmodellierer |
---|---|
date | Sun, 21 Jan 2024 22:24:36 +0100 |
parents | a370741a743b |
children | 92a5dc16d52b |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tInfo.c | |
5 /// \brief Main Template file for Info menu page on left side | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 11-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 "tInfo.h" | |
31 | |
32 #include "data_exchange.h" | |
33 #include "tDebug.h" | |
34 #include "gfx_fonts.h" | |
35 #include "tHome.h" | |
36 //#include "tInfoDive.h" | |
37 //#include "tInfoSurface.h" | |
38 #include "tInfoCompass.h" | |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
39 #include "tInfoSensor.h" |
845 | 40 #include "tInfoPreDive.h" |
38 | 41 #include "tMenu.h" |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
42 #include "tMenuEdit.h" |
38 | 43 |
44 #include <string.h> | |
45 | |
46 /* Private types -------------------------------------------------------------*/ | |
47 | |
48 typedef struct | |
49 { | |
50 uint32_t pEventFunction; | |
51 uint32_t callerID; | |
52 } SInfoEventHandler; | |
53 | |
54 typedef struct | |
55 { | |
56 char orgText[32]; | |
57 char newText[32]; | |
699 | 58 uint8_t input; |
38 | 59 char symbolCounter; |
60 int8_t begin[4], size[4]; | |
61 uint16_t coord[3]; | |
62 tFont *fontUsed; | |
63 uint32_t callerID; | |
64 uint8_t maintype; | |
65 uint8_t subtype; | |
66 } SInfoIdent; | |
67 | |
68 typedef enum | |
69 { | |
70 FIELD_BUTTON = 1, | |
71 FIELD_SELECT, | |
72 FIELD_SYMBOL, | |
73 FIELD_TOGGLE, | |
74 FIELD_ON_OFF, | |
75 FIELD_END | |
76 } SInfoField; | |
77 | |
78 /* Private variables ---------------------------------------------------------*/ | |
79 GFX_DrawCfgScreen tIscreen; | |
80 GFX_DrawCfgScreen tIcursor; | |
81 | |
82 uint8_t infoColor = CLUT_InfoSurface; | |
83 | |
84 int8_t TIid = 0; | |
85 int8_t TIidLast = -1; | |
86 SInfoIdent TIident[10]; | |
87 | |
88 int8_t TIevid = 0; | |
89 int8_t TIevidLast = -1; | |
90 SInfoEventHandler TIevent[10]; | |
91 | |
92 /* Private function prototypes -----------------------------------------------*/ | |
93 void tInfo_build_page(void); | |
94 | |
95 void tI_set_cursor(uint8_t forThisIdentID); | |
96 void tI_startInfoFieldSelect(void); | |
97 void tInfo_write_content_of_actual_Id(void); | |
98 void tI_clean_content_of_actual_Id(void); | |
99 void tInfo_write_content_without_Id(void); | |
100 | |
101 void tI_clean_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font); | |
102 void tInfo_write_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color); | |
103 | |
104 void tI_evaluateNewString (uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4); | |
105 | |
106 //void tI_tInfo_newInput (uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4); | |
107 //void tI_tInfo_newButtonText (uint32_t editID, char *text); | |
108 | |
109 void tI_enterInfoField(void); | |
110 void tI_nextInfoField(void); | |
111 | |
112 /* Announced function prototypes -----------------------------------------------*/ | |
113 //uint8_t OnAction_ILoglist (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
114 //uint8_t OnAction_ISimulator (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
115 | |
116 /* Exported functions --------------------------------------------------------*/ | |
117 | |
118 void tI_init(void) | |
119 { | |
120 tIscreen.FBStartAdress = 0; | |
121 tIscreen.ImageHeight = 480; | |
122 tIscreen.ImageWidth = 800; | |
123 tIscreen.LayerIndex = 1; | |
124 | |
125 tIcursor.FBStartAdress = getFrame(12); | |
126 tIcursor.ImageHeight = 480; | |
127 tIcursor.ImageWidth = 800; | |
128 tIcursor.LayerIndex = 0; | |
129 | |
130 GFX_fill_buffer(tIcursor.FBStartAdress, 0xFF, CLUT_InfoCursor); | |
131 } | |
132 | |
133 | |
134 void openInfo(uint32_t modeToStart) | |
135 { | |
136 if((modeToStart != StILOGLIST) && (modeToStart != StIDEBUG)) | |
137 return; | |
138 | |
139 TIid = 0; | |
140 TIidLast = -1; | |
141 TIevid = 0; | |
142 TIevidLast = -1; | |
143 | |
144 if(tIscreen.FBStartAdress) | |
145 releaseFrame(14,tIscreen.FBStartAdress); | |
146 tIscreen.FBStartAdress = getFrame(14); | |
147 | |
148 // GFX_SetFramesTopBottom(tIscreen.FBStartAdress, tIcursor.FBStartAdress,480); | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
149 GFX_SetFramesTopBottom(tIscreen.FBStartAdress, 0,480); |
38 | 150 infoColor = CLUT_InfoSurface; |
151 | |
152 if(modeToStart == StIDEBUG) | |
153 { | |
154 tDebug_start(); | |
155 } | |
156 else | |
157 { | |
158 openLog(0); | |
159 } | |
160 // openInfoLogLastDive(); | |
161 } | |
162 | |
163 /* | |
164 void openInfo(void) | |
165 { | |
166 if((stateUsed->mode == MODE_DIVE) && (!is_stateUsedSetToSim())) | |
167 { | |
168 return; | |
169 } | |
170 | |
171 TIid = 0; | |
172 TIidLast = -1; | |
173 TIevid = 0; | |
174 TIevidLast = -1; | |
175 | |
176 if(tIscreen.FBStartAdress) | |
177 releaseFrame(14,tIscreen.FBStartAdress); | |
178 tIscreen.FBStartAdress = getFrame(14); | |
179 | |
180 GFX_SetFramesTopBottom(tIscreen.FBStartAdress, tIcursor.FBStartAdress,480); | |
181 | |
182 if(stateUsed->mode == MODE_DIVE) | |
183 { | |
184 infoColor = CLUT_InfoSurface; | |
185 openInfo_Dive(); | |
186 } | |
187 else | |
188 { | |
189 infoColor = CLUT_InfoDive; | |
190 openInfo_Surface(); | |
191 } | |
192 } | |
193 */ | |
194 | |
195 /* | |
196 uint8_t OnAction_ILoglist (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
197 { | |
198 return 255; | |
199 } | |
200 */ | |
201 | |
202 void tInfo_refresh(void) | |
203 { | |
204 uint32_t oldIscreen; | |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
205 uint32_t globalState = get_globalState(); |
38 | 206 oldIscreen = tIscreen.FBStartAdress; |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
207 |
38 | 208 if(inDebugMode()) |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
209 { |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
210 tIscreen.FBStartAdress = getFrame(14); |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
211 infoColor = CLUT_InfoCompass; |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
212 tDebug_refresh(); |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
213 } |
38 | 214 else |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
215 { |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
216 switch(globalState) |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
217 { |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
218 case StICOMPASS: tIscreen.FBStartAdress = getFrame(14); |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
219 infoColor = CLUT_InfoCompass; |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
220 refreshInfo_Compass(tIscreen); |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
221 break; |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
222 case StISENINFO: tIscreen.FBStartAdress = getFrame(14); |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
223 infoColor = CLUT_MenuPageHardware; |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
224 refreshInfo_Sensor(tIscreen); |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
225 break; |
845 | 226 case StIPREDIVE: tIscreen.FBStartAdress = getFrame(14); |
227 infoColor = CLUT_MenuPageGasCC; | |
228 refreshInfo_PreDive(tIscreen); | |
229 break; | |
230 | |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
231 default: |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
232 break; |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
233 } |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
234 } |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
235 if(oldIscreen != tIscreen.FBStartAdress) |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
236 { |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
237 GFX_SetFramesTopBottom(tIscreen.FBStartAdress, 0,480); |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
238 if(oldIscreen) |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
239 { |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
240 releaseFrame(14,oldIscreen); |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
241 } |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
242 } |
38 | 243 } |
244 | |
245 | |
246 void exitInfo(void) | |
247 { | |
248 set_globalState_tHome(); | |
249 releaseFrame(14,tIscreen.FBStartAdress); | |
250 exitDebugMode(); | |
251 } | |
252 | |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
253 void exitInfoToBack(void) |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
254 { |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
255 releaseFrame(14,tIscreen.FBStartAdress); |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
256 exitMenuEdit_to_BackMenu(); |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
257 } |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
699
diff
changeset
|
258 |
38 | 259 |
260 void sendActionToInfo(uint8_t sendAction) | |
261 { | |
262 if(inDebugMode()) | |
263 { | |
264 tDebugControl(sendAction); | |
265 return; | |
266 } | |
267 | |
268 if(get_globalState() == StICOMPASS) | |
269 return; | |
270 | |
271 switch(sendAction) | |
272 { | |
273 case ACTION_BUTTON_ENTER: | |
274 tI_enterInfoField(); | |
275 break; | |
276 case ACTION_BUTTON_NEXT: | |
277 tI_nextInfoField(); | |
278 break; | |
279 case ACTION_TIMEOUT: | |
280 case ACTION_MODE_CHANGE: | |
281 case ACTION_BUTTON_BACK: | |
282 exitInfo(); | |
130
b7689d9e888a
Minor changes to improved code quality and to eliminate warnings
Ideenmodellierer
parents:
38
diff
changeset
|
283 break; |
38 | 284 default: |
285 break; | |
286 case ACTION_IDLE_TICK: | |
287 case ACTION_IDLE_SECOND: | |
288 break; | |
289 } | |
290 | |
291 } | |
292 | |
293 /* Private functions ---------------------------------------------------------*/ | |
294 | |
295 void tInfo_build_page(void) | |
296 { | |
297 tInfo_write_content_simple( 30, 340, 90, &FontT48, "Logbook", CLUT_Font020); | |
298 | |
299 } | |
300 | |
301 void tInfo_write_content_simple(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) | |
302 { | |
303 GFX_DrawCfgWindow hgfx; | |
304 | |
305 if(XrightGimpStyle > 799) | |
306 XrightGimpStyle = 799; | |
307 if(XleftGimpStyle >= XrightGimpStyle) | |
308 XleftGimpStyle = 0; | |
309 if(YtopGimpStyle > 479) | |
310 YtopGimpStyle = 479; | |
311 hgfx.Image = &tIscreen; | |
312 hgfx.WindowNumberOfTextLines = 1; | |
313 hgfx.WindowLineSpacing = 0; | |
314 hgfx.WindowTab = 400; | |
315 hgfx.WindowX0 = XleftGimpStyle; | |
316 hgfx.WindowX1 = XrightGimpStyle; | |
317 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
318 |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
319 |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
320 if(!settingsGetPointer()->FlipDisplay) |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
321 { |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
322 hgfx.WindowY1 = 479 - YtopGimpStyle; |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
323 if(hgfx.WindowY1 < Font->height) |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
324 hgfx.WindowY0 = 0; |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
325 else |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
326 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
327 } |
38 | 328 else |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
329 { |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
330 hgfx.WindowY0 = YtopGimpStyle; |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
331 hgfx.WindowY1 = YtopGimpStyle + Font->height; |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
332 } |
38 | 333 |
334 GFX_write_string_color(Font, &hgfx, text, 0, color); | |
335 } | |
336 | |
337 /* Exported functions --------------------------------------------------------*/ | |
338 | |
339 void tI_startInfoFieldSelect(void) | |
340 { | |
341 TIid = 0; | |
342 tI_set_cursor(TIid); | |
343 } | |
344 | |
345 | |
346 void tI_nextInfoField(void) | |
347 { | |
348 if(TIid < TIidLast) | |
349 TIid++; | |
350 else | |
351 TIid = 0; | |
352 tI_set_cursor(TIid); | |
353 } | |
354 | |
355 | |
356 void tI_previousInfoField(void) | |
357 { | |
358 if(TIid > 0) | |
359 TIid--; | |
360 else | |
361 TIid = TIidLast; | |
362 tI_set_cursor(TIid); | |
363 } | |
364 | |
365 | |
366 uint8_t tI_get_newContent_of_actual_id_block_and_subBlock(uint8_t action) | |
367 { | |
368 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); | |
369 uint8_t content; | |
370 | |
371 if(TIevent[TIevid].callerID != TIident[TIid].callerID) | |
372 return 0; | |
373 | |
374 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(TIevent[TIevid].pEventFunction); | |
375 | |
376 if(TIident[TIid].maintype == FIELD_ON_OFF) | |
377 content = TIident[TIid].input; | |
378 else | |
379 content = 0; /* just a default for protection */ | |
380 | |
381 return onActionFunc(TIident[TIid].callerID, 0, 0, content, action); | |
382 } | |
383 | |
384 | |
385 void tI_enterInfoField(void) | |
386 { | |
387 uint8_t newContent; | |
388 | |
389 TIevid = 0; | |
390 while((TIevid < TIevidLast) && (TIevent[TIevid].callerID != TIident[TIid].callerID)) | |
391 { | |
392 TIevid++; | |
393 } | |
394 | |
395 if(TIevent[TIevid].callerID != TIident[TIid].callerID) | |
396 return; | |
397 | |
398 newContent = tI_get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_ENTER); | |
399 | |
400 if(newContent == 255) | |
401 { | |
402 exitInfo(); | |
403 return; | |
404 } | |
405 | |
406 switch(TIident[TIid].maintype) | |
407 { | |
408 case FIELD_BUTTON: | |
409 break; | |
410 case FIELD_ON_OFF: | |
411 break; | |
412 case FIELD_SYMBOL: | |
413 TIident[TIid].input += 1; | |
414 if(TIident[TIid].input >= TIident[TIid].symbolCounter) | |
415 TIident[TIid].input = 0; | |
416 TIident[TIid].newText[0] = TIident[TIid].orgText[TIident[TIid].input]; | |
417 tInfo_write_content_of_actual_Id(); | |
418 break; | |
419 } | |
420 } | |
421 | |
422 | |
423 void tI_evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4) | |
424 { | |
425 if(editID != TIident[TIid].callerID) | |
426 return; | |
427 | |
428 uint8_t i, digitCount, digit; | |
429 uint32_t sum[4], multiplier; | |
430 | |
431 for(i=0;i<4;i++) | |
432 sum[i] = 0; | |
433 | |
434 i = 0; | |
435 while( TIident[TIid].size[i] && (i < 4)) | |
436 { | |
437 multiplier = 1; | |
438 for(digitCount = 1; digitCount < TIident[TIid].size[i]; digitCount++) | |
439 multiplier *= 10; | |
440 | |
441 for(digitCount = 0; digitCount < TIident[TIid].size[i]; digitCount++) | |
442 { | |
443 digit = TIident[TIid].newText[TIident[TIid].begin[i] + digitCount]; | |
444 | |
445 if(digit > '0') | |
446 digit -= '0'; | |
447 else | |
448 digit = 0; | |
449 | |
450 if(digit > 9) | |
451 digit = 9; | |
452 | |
453 sum[i] += digit * multiplier; | |
454 | |
455 if(multiplier >= 10) | |
456 multiplier /= 10; | |
457 else | |
458 multiplier = 0; | |
459 } | |
460 i++; | |
461 } | |
462 | |
463 *pNewValue1 = sum[0]; | |
464 *pNewValue2 = sum[1]; | |
465 *pNewValue3 = sum[2]; | |
466 *pNewValue4 = sum[3]; | |
467 } | |
468 | |
469 | |
470 uint8_t tI_get_id_of(uint32_t editID) | |
471 { | |
472 uint8_t temp_id; | |
473 | |
474 if(editID == TIident[TIid].callerID) | |
475 return TIid; | |
476 else | |
477 { | |
478 temp_id = 0; | |
479 while((temp_id < 9) && (editID != TIident[temp_id].callerID)) | |
480 temp_id++; | |
481 if(editID != TIident[temp_id].callerID) | |
482 temp_id = 255; | |
483 return temp_id; | |
484 } | |
485 } | |
486 | |
487 | |
488 void tI_newButtonText(uint32_t editID, char *text) | |
489 { | |
490 uint8_t backup_id, temp_id; | |
491 | |
492 temp_id = tI_get_id_of(editID); | |
493 if(temp_id == 255) | |
494 return; | |
495 | |
496 backup_id = TIid; | |
497 TIid = temp_id; | |
498 | |
499 strncpy(TIident[TIid].newText, text, 32); | |
500 TIident[TIid].newText[31] = 0; | |
501 | |
502 tI_clean_content_of_actual_Id(); | |
503 tInfo_write_content_of_actual_Id(); | |
504 | |
505 TIid = backup_id; | |
506 } | |
507 | |
508 | |
699 | 509 void tInfo_set_on_off(uint32_t editID, uint8_t int1) |
38 | 510 { |
511 uint8_t backup_id, temp_id; | |
512 | |
513 temp_id = tI_get_id_of(editID); | |
514 if(temp_id == 255) | |
515 return; | |
516 | |
517 backup_id = TIid; | |
518 TIid = temp_id; | |
519 | |
520 TIident[TIid].input = int1; | |
521 | |
522 if(int1) | |
523 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoActive); | |
524 else | |
525 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoInActive); | |
526 | |
527 tInfo_write_content_of_actual_Id(); | |
528 | |
529 TIid = backup_id; | |
530 } | |
531 | |
532 | |
533 void tInfo_write_content_without_Id(void) | |
534 { | |
535 tInfo_write_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed, TIident[TIid].newText, CLUT_InfoFieldRegular); | |
536 } | |
537 | |
538 | |
539 void tInfo_write_content_of_actual_Id(void) | |
540 { | |
541 tInfo_write_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed, TIident[TIid].newText, (CLUT_InfoField0 + TIid)); | |
542 } | |
543 | |
544 | |
545 void tI_clean_content_of_actual_Id(void) | |
546 { | |
547 tI_clean_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed); | |
548 } | |
549 | |
550 | |
551 void tInfo_write_field_button(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
552 { | |
553 if(TIidLast >= 9) | |
554 return; | |
555 | |
556 TIident[TIid].maintype = FIELD_BUTTON; | |
557 TIident[TIid].subtype = FIELD_BUTTON; | |
558 | |
559 TIident[TIid].coord[0] = XleftGimpStyle; | |
560 TIident[TIid].coord[1] = XrightGimpStyle; | |
561 TIident[TIid].coord[2] = YtopGimpStyle; | |
562 TIident[TIid].fontUsed = (tFont *)Font; | |
563 TIident[TIid].callerID = editID; | |
564 | |
565 strncpy(TIident[TIid].orgText, text, 32); | |
566 strncpy(TIident[TIid].newText, text, 32); | |
567 TIident[TIid].orgText[31] = 0; | |
568 TIident[TIid].newText[31] = 0; | |
569 | |
570 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoButtonColor1); | |
571 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
572 if(editID == 0) |
38 | 573 tInfo_write_content_without_Id(); |
574 else | |
575 { | |
576 tInfo_write_content_of_actual_Id(); | |
577 TIidLast = TIid; | |
578 TIid++; | |
579 } | |
580 } | |
581 | |
582 | |
583 void tInfo_write_field_symbol(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1) | |
584 { | |
585 if(TIidLast >= 9) | |
586 return; | |
587 | |
588 TIident[TIid].maintype = FIELD_SYMBOL; | |
589 TIident[TIid].subtype = FIELD_SYMBOL; | |
590 | |
591 TIident[TIid].coord[0] = XleftGimpStyle; | |
592 TIident[TIid].coord[1] = XrightGimpStyle; | |
593 TIident[TIid].coord[2] = YtopGimpStyle; | |
594 TIident[TIid].fontUsed = (tFont *)Font; | |
595 TIident[TIid].callerID = editID; | |
596 | |
597 strncpy(TIident[TIid].orgText, text, 32); | |
598 strncpy(TIident[TIid].newText, text, 32); | |
599 TIident[TIid].orgText[31] = 0; | |
600 | |
601 TIident[TIid].newText[0] = text[0]; | |
602 TIident[TIid].newText[1] = 0; | |
603 | |
604 TIident[TIid].input = int1; | |
605 TIident[TIid].symbolCounter = strlen(TIident[TIid].orgText); | |
606 | |
607 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoButtonColor1); | |
608 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
609 if(editID == 0) |
38 | 610 tInfo_write_content_without_Id(); |
611 else | |
612 { | |
613 tInfo_write_content_of_actual_Id(); | |
614 TIidLast = TIid; | |
615 TIid++; | |
616 } | |
617 } | |
618 | |
619 | |
620 void tInfo_write_field_on_off(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1) | |
621 { | |
622 if(TIidLast >= 9) | |
623 return; | |
624 | |
625 TIident[TIid].maintype = FIELD_ON_OFF; | |
626 TIident[TIid].subtype = FIELD_ON_OFF; | |
627 | |
628 TIident[TIid].coord[0] = XleftGimpStyle; | |
629 TIident[TIid].coord[1] = XrightGimpStyle; | |
630 TIident[TIid].coord[2] = YtopGimpStyle; | |
631 TIident[TIid].fontUsed = (tFont *)Font; | |
632 TIident[TIid].callerID = editID; | |
633 | |
634 strncpy(TIident[TIid].orgText, text, 32); | |
635 strncpy(TIident[TIid].newText, text, 32); | |
636 TIident[TIid].orgText[31] = 0; | |
637 TIident[TIid].newText[31] = 0; | |
638 | |
639 | |
640 if(int1) | |
641 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoActive); | |
642 else | |
643 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoInActive); | |
644 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
645 if(editID == 0) |
38 | 646 tInfo_write_content_without_Id(); |
647 else | |
648 { | |
649 tInfo_write_content_of_actual_Id(); | |
650 TIidLast = TIid; | |
651 TIid++; | |
652 } | |
653 } | |
654 | |
655 | |
656 void tInfo_setEvent(uint32_t inputEventID, uint32_t inputFunctionCall) | |
657 { | |
658 if(TIevidLast >= 9) | |
659 return; | |
660 | |
661 /* set cursor to first field */ | |
662 if(TIevidLast < 0) | |
663 { | |
664 tI_startInfoFieldSelect(); | |
665 } | |
666 | |
667 TIevent[TIevid].callerID = inputEventID; | |
668 TIevent[TIevid].pEventFunction = inputFunctionCall; | |
669 | |
670 TIevidLast = TIevid; | |
671 TIevid++; | |
672 } | |
673 | |
674 | |
675 void tI_set_cursor(uint8_t forThisIdentID) | |
676 { | |
677 int16_t x0, x1, y0, y1; | |
678 | |
679 uint32_t xtra_left_right = 10; | |
680 uint32_t xtra_top_bottom = 10; | |
681 | |
682 /* y geht von 0 bis 799 */ | |
683 /* x geht von 0 bis 479 */ | |
684 | |
685 x0 = (int16_t)TIident[forThisIdentID].coord[0]; | |
686 x1 = (int16_t)TIident[forThisIdentID].coord[1]; | |
687 y0 = (int16_t)TIident[forThisIdentID].coord[2]; | |
688 y1 = y0 + (int16_t)TIident[forThisIdentID].fontUsed->height; | |
689 | |
690 if(((int16_t)TIident[forThisIdentID].fontUsed->height) > 70) | |
691 { | |
692 xtra_left_right = 10; | |
693 xtra_top_bottom = 10; | |
694 } | |
695 else | |
696 { | |
697 xtra_left_right = 10; | |
698 xtra_top_bottom = 0; | |
699 } | |
700 | |
701 x0 -= xtra_left_right; | |
702 x1 += xtra_left_right; | |
703 y0 -= xtra_top_bottom; | |
704 y1 += xtra_top_bottom; | |
705 | |
706 GFX_SetWindowLayer0(tIcursor.FBStartAdress, x0, x1, y0, y1); | |
707 } | |
708 | |
709 | |
710 void tInfo_write_label_var(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
711 { | |
712 GFX_DrawCfgWindow hgfx; | |
713 | |
714 if(XrightGimpStyle > 799) | |
715 XrightGimpStyle = 799; | |
716 if(XleftGimpStyle >= XrightGimpStyle) | |
717 XleftGimpStyle = 0; | |
718 if(YtopGimpStyle > 479) | |
719 YtopGimpStyle = 479; | |
720 hgfx.Image = &tIscreen; | |
721 hgfx.WindowNumberOfTextLines = 1; | |
722 hgfx.WindowLineSpacing = 0; | |
723 hgfx.WindowTab = 0; | |
724 hgfx.WindowX0 = XleftGimpStyle; | |
725 hgfx.WindowX1 = XrightGimpStyle; | |
726 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
727 if(hgfx.WindowY1 < Font->height) | |
728 hgfx.WindowY0 = 0; | |
729 else | |
730 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
731 | |
732 GFX_write_label(Font, &hgfx, text, infoColor); | |
733 } | |
734 | |
735 | |
736 void tInfo_write_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) | |
737 { | |
738 GFX_DrawCfgWindow hgfx; | |
739 | |
740 if(XrightGimpStyle > 799) | |
741 XrightGimpStyle = 799; | |
742 if(XleftGimpStyle >= XrightGimpStyle) | |
743 XleftGimpStyle = 0; | |
744 if(YtopGimpStyle > 479) | |
745 YtopGimpStyle = 479; | |
746 hgfx.Image = &tIscreen; | |
747 hgfx.WindowNumberOfTextLines = 1; | |
748 hgfx.WindowLineSpacing = 0; | |
749 hgfx.WindowTab = 0; | |
750 hgfx.WindowX0 = XleftGimpStyle; | |
751 hgfx.WindowX1 = XrightGimpStyle; | |
752 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
753 if(hgfx.WindowY1 < Font->height) | |
754 hgfx.WindowY0 = 0; | |
755 else | |
756 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
757 | |
758 GFX_write_label(Font, &hgfx, text, color); | |
759 } | |
760 | |
761 | |
762 void tInfo_write_label_fix(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char textId) | |
763 { | |
764 char text[2]; | |
765 | |
766 text[0] = textId; | |
767 text[1] = 0; | |
768 | |
769 tInfo_write_label_var(XleftGimpStyle, XrightGimpStyle, YtopGimpStyle, Font, text); | |
770 } | |
771 | |
772 | |
773 void tI_clean_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font) | |
774 { | |
775 GFX_DrawCfgWindow hgfx; | |
776 | |
777 if(XrightGimpStyle > 799) | |
778 XrightGimpStyle = 799; | |
779 if(XleftGimpStyle >= XrightGimpStyle) | |
780 XleftGimpStyle = 0; | |
781 if(YtopGimpStyle > 479) | |
782 YtopGimpStyle = 479; | |
783 hgfx.Image = &tIscreen; | |
784 hgfx.WindowX0 = XleftGimpStyle; | |
785 hgfx.WindowX1 = XrightGimpStyle; | |
786 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
787 if(hgfx.WindowY1 < Font->height) | |
788 hgfx.WindowY0 = 0; | |
789 else | |
790 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
791 | |
792 GFX_clear_window_immediately(&hgfx); | |
793 } | |
794 | |
795 | |
796 void tInfo_write_buttonTextline(GFX_DrawCfgScreen *screenPtr, uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) | |
797 { | |
798 GFX_clean_area(&tIscreen, 0, 800, 480-24,480); | |
799 | |
800 char localtext[32]; | |
801 | |
802 if(left2ByteCode) | |
803 { | |
804 localtext[0] = TXT_2BYTE; | |
805 localtext[1] = left2ByteCode; | |
806 localtext[2] = 0; | |
807 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
808 } | |
809 | |
810 if(middle2ByteCode) | |
811 { | |
812 localtext[0] = '\001'; | |
813 localtext[1] = TXT_2BYTE; | |
814 localtext[2] = middle2ByteCode; | |
815 localtext[3] = 0; | |
816 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
817 } | |
818 | |
819 if(right2ByteCode) | |
820 { | |
821 localtext[0] = '\002'; | |
822 localtext[1] = TXT_2BYTE; | |
823 localtext[2] = right2ByteCode; | |
824 localtext[3] = 0; | |
825 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
826 } | |
827 } | |
845 | 828 void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) |
829 { | |
830 char localtext[32]; | |
831 | |
832 if(left2ByteCode) | |
833 { | |
834 localtext[0] = TXT_2BYTE; | |
835 localtext[1] = left2ByteCode; | |
836 localtext[2] = 0; | |
837 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
838 } | |
839 | |
840 if(middle2ByteCode) | |
841 { | |
842 localtext[0] = '\001'; | |
843 localtext[1] = TXT_2BYTE; | |
844 localtext[2] = middle2ByteCode; | |
845 localtext[3] = 0; | |
846 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
847 } | |
848 | |
849 if(right2ByteCode) | |
850 { | |
851 localtext[0] = '\002'; | |
852 localtext[1] = TXT_2BYTE; | |
853 localtext[2] = right2ByteCode; | |
854 localtext[3] = 0; | |
855 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
856 } | |
857 } |