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