Mercurial > public > ostc4
annotate Discovery/Src/tInfo.c @ 854:48b6a3b1f3f8 Evo_2_23
Development bugfix menu id handling:
Fixed some issues which showed up after cleanup of the menu id handling
author | Ideenmodellierer |
---|---|
date | Sat, 09 Mar 2024 20:05:33 +0100 |
parents | 92a5dc16d52b |
children |
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; | |
826
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 if(!settingsGetPointer()->FlipDisplay) |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
317 { |
848 | 318 hgfx.WindowX0 = XleftGimpStyle; |
319 hgfx.WindowX1 = XrightGimpStyle; | |
320 | |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
321 hgfx.WindowY1 = 479 - YtopGimpStyle; |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
322 if(hgfx.WindowY1 < Font->height) |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
323 hgfx.WindowY0 = 0; |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
324 else |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
325 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
326 } |
38 | 327 else |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
328 { |
848 | 329 hgfx.WindowX0 = 800 - XrightGimpStyle; |
330 hgfx.WindowX1 = 800 - XleftGimpStyle; | |
826
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
331 hgfx.WindowY0 = YtopGimpStyle; |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
332 hgfx.WindowY1 = YtopGimpStyle + Font->height; |
a370741a743b
Bugfix Line order of info screen with flip screen active:
Ideenmodellierer
parents:
718
diff
changeset
|
333 } |
38 | 334 |
335 GFX_write_string_color(Font, &hgfx, text, 0, color); | |
336 } | |
337 | |
338 /* Exported functions --------------------------------------------------------*/ | |
339 | |
340 void tI_startInfoFieldSelect(void) | |
341 { | |
342 TIid = 0; | |
343 tI_set_cursor(TIid); | |
344 } | |
345 | |
346 | |
347 void tI_nextInfoField(void) | |
348 { | |
349 if(TIid < TIidLast) | |
350 TIid++; | |
351 else | |
352 TIid = 0; | |
353 tI_set_cursor(TIid); | |
354 } | |
355 | |
356 | |
357 void tI_previousInfoField(void) | |
358 { | |
359 if(TIid > 0) | |
360 TIid--; | |
361 else | |
362 TIid = TIidLast; | |
363 tI_set_cursor(TIid); | |
364 } | |
365 | |
366 | |
367 uint8_t tI_get_newContent_of_actual_id_block_and_subBlock(uint8_t action) | |
368 { | |
369 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); | |
370 uint8_t content; | |
371 | |
372 if(TIevent[TIevid].callerID != TIident[TIid].callerID) | |
373 return 0; | |
374 | |
375 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(TIevent[TIevid].pEventFunction); | |
376 | |
377 if(TIident[TIid].maintype == FIELD_ON_OFF) | |
378 content = TIident[TIid].input; | |
379 else | |
380 content = 0; /* just a default for protection */ | |
381 | |
382 return onActionFunc(TIident[TIid].callerID, 0, 0, content, action); | |
383 } | |
384 | |
385 | |
386 void tI_enterInfoField(void) | |
387 { | |
388 uint8_t newContent; | |
389 | |
390 TIevid = 0; | |
391 while((TIevid < TIevidLast) && (TIevent[TIevid].callerID != TIident[TIid].callerID)) | |
392 { | |
393 TIevid++; | |
394 } | |
395 | |
396 if(TIevent[TIevid].callerID != TIident[TIid].callerID) | |
397 return; | |
398 | |
399 newContent = tI_get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_ENTER); | |
400 | |
401 if(newContent == 255) | |
402 { | |
403 exitInfo(); | |
404 return; | |
405 } | |
406 | |
407 switch(TIident[TIid].maintype) | |
408 { | |
409 case FIELD_BUTTON: | |
410 break; | |
411 case FIELD_ON_OFF: | |
412 break; | |
413 case FIELD_SYMBOL: | |
414 TIident[TIid].input += 1; | |
415 if(TIident[TIid].input >= TIident[TIid].symbolCounter) | |
416 TIident[TIid].input = 0; | |
417 TIident[TIid].newText[0] = TIident[TIid].orgText[TIident[TIid].input]; | |
418 tInfo_write_content_of_actual_Id(); | |
419 break; | |
420 } | |
421 } | |
422 | |
423 | |
424 void tI_evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4) | |
425 { | |
426 if(editID != TIident[TIid].callerID) | |
427 return; | |
428 | |
429 uint8_t i, digitCount, digit; | |
430 uint32_t sum[4], multiplier; | |
431 | |
432 for(i=0;i<4;i++) | |
433 sum[i] = 0; | |
434 | |
435 i = 0; | |
436 while( TIident[TIid].size[i] && (i < 4)) | |
437 { | |
438 multiplier = 1; | |
439 for(digitCount = 1; digitCount < TIident[TIid].size[i]; digitCount++) | |
440 multiplier *= 10; | |
441 | |
442 for(digitCount = 0; digitCount < TIident[TIid].size[i]; digitCount++) | |
443 { | |
444 digit = TIident[TIid].newText[TIident[TIid].begin[i] + digitCount]; | |
445 | |
446 if(digit > '0') | |
447 digit -= '0'; | |
448 else | |
449 digit = 0; | |
450 | |
451 if(digit > 9) | |
452 digit = 9; | |
453 | |
454 sum[i] += digit * multiplier; | |
455 | |
456 if(multiplier >= 10) | |
457 multiplier /= 10; | |
458 else | |
459 multiplier = 0; | |
460 } | |
461 i++; | |
462 } | |
463 | |
464 *pNewValue1 = sum[0]; | |
465 *pNewValue2 = sum[1]; | |
466 *pNewValue3 = sum[2]; | |
467 *pNewValue4 = sum[3]; | |
468 } | |
469 | |
470 | |
471 uint8_t tI_get_id_of(uint32_t editID) | |
472 { | |
473 uint8_t temp_id; | |
474 | |
475 if(editID == TIident[TIid].callerID) | |
476 return TIid; | |
477 else | |
478 { | |
479 temp_id = 0; | |
480 while((temp_id < 9) && (editID != TIident[temp_id].callerID)) | |
481 temp_id++; | |
482 if(editID != TIident[temp_id].callerID) | |
483 temp_id = 255; | |
484 return temp_id; | |
485 } | |
486 } | |
487 | |
488 | |
489 void tI_newButtonText(uint32_t editID, char *text) | |
490 { | |
491 uint8_t backup_id, temp_id; | |
492 | |
493 temp_id = tI_get_id_of(editID); | |
494 if(temp_id == 255) | |
495 return; | |
496 | |
497 backup_id = TIid; | |
498 TIid = temp_id; | |
499 | |
500 strncpy(TIident[TIid].newText, text, 32); | |
501 TIident[TIid].newText[31] = 0; | |
502 | |
503 tI_clean_content_of_actual_Id(); | |
504 tInfo_write_content_of_actual_Id(); | |
505 | |
506 TIid = backup_id; | |
507 } | |
508 | |
509 | |
699 | 510 void tInfo_set_on_off(uint32_t editID, uint8_t int1) |
38 | 511 { |
512 uint8_t backup_id, temp_id; | |
513 | |
514 temp_id = tI_get_id_of(editID); | |
515 if(temp_id == 255) | |
516 return; | |
517 | |
518 backup_id = TIid; | |
519 TIid = temp_id; | |
520 | |
521 TIident[TIid].input = int1; | |
522 | |
523 if(int1) | |
524 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoActive); | |
525 else | |
526 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoInActive); | |
527 | |
528 tInfo_write_content_of_actual_Id(); | |
529 | |
530 TIid = backup_id; | |
531 } | |
532 | |
533 | |
534 void tInfo_write_content_without_Id(void) | |
535 { | |
536 tInfo_write_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed, TIident[TIid].newText, CLUT_InfoFieldRegular); | |
537 } | |
538 | |
539 | |
540 void tInfo_write_content_of_actual_Id(void) | |
541 { | |
542 tInfo_write_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed, TIident[TIid].newText, (CLUT_InfoField0 + TIid)); | |
543 } | |
544 | |
545 | |
546 void tI_clean_content_of_actual_Id(void) | |
547 { | |
548 tI_clean_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed); | |
549 } | |
550 | |
551 | |
552 void tInfo_write_field_button(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
553 { | |
554 if(TIidLast >= 9) | |
555 return; | |
556 | |
557 TIident[TIid].maintype = FIELD_BUTTON; | |
558 TIident[TIid].subtype = FIELD_BUTTON; | |
559 | |
560 TIident[TIid].coord[0] = XleftGimpStyle; | |
561 TIident[TIid].coord[1] = XrightGimpStyle; | |
562 TIident[TIid].coord[2] = YtopGimpStyle; | |
563 TIident[TIid].fontUsed = (tFont *)Font; | |
564 TIident[TIid].callerID = editID; | |
565 | |
566 strncpy(TIident[TIid].orgText, text, 32); | |
567 strncpy(TIident[TIid].newText, text, 32); | |
568 TIident[TIid].orgText[31] = 0; | |
569 TIident[TIid].newText[31] = 0; | |
570 | |
571 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoButtonColor1); | |
572 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
573 if(editID == 0) |
38 | 574 tInfo_write_content_without_Id(); |
575 else | |
576 { | |
577 tInfo_write_content_of_actual_Id(); | |
578 TIidLast = TIid; | |
579 TIid++; | |
580 } | |
581 } | |
582 | |
583 | |
584 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) | |
585 { | |
586 if(TIidLast >= 9) | |
587 return; | |
588 | |
589 TIident[TIid].maintype = FIELD_SYMBOL; | |
590 TIident[TIid].subtype = FIELD_SYMBOL; | |
591 | |
592 TIident[TIid].coord[0] = XleftGimpStyle; | |
593 TIident[TIid].coord[1] = XrightGimpStyle; | |
594 TIident[TIid].coord[2] = YtopGimpStyle; | |
595 TIident[TIid].fontUsed = (tFont *)Font; | |
596 TIident[TIid].callerID = editID; | |
597 | |
598 strncpy(TIident[TIid].orgText, text, 32); | |
599 strncpy(TIident[TIid].newText, text, 32); | |
600 TIident[TIid].orgText[31] = 0; | |
601 | |
602 TIident[TIid].newText[0] = text[0]; | |
603 TIident[TIid].newText[1] = 0; | |
604 | |
605 TIident[TIid].input = int1; | |
606 TIident[TIid].symbolCounter = strlen(TIident[TIid].orgText); | |
607 | |
608 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoButtonColor1); | |
609 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
610 if(editID == 0) |
38 | 611 tInfo_write_content_without_Id(); |
612 else | |
613 { | |
614 tInfo_write_content_of_actual_Id(); | |
615 TIidLast = TIid; | |
616 TIid++; | |
617 } | |
618 } | |
619 | |
620 | |
621 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) | |
622 { | |
623 if(TIidLast >= 9) | |
624 return; | |
625 | |
626 TIident[TIid].maintype = FIELD_ON_OFF; | |
627 TIident[TIid].subtype = FIELD_ON_OFF; | |
628 | |
629 TIident[TIid].coord[0] = XleftGimpStyle; | |
630 TIident[TIid].coord[1] = XrightGimpStyle; | |
631 TIident[TIid].coord[2] = YtopGimpStyle; | |
632 TIident[TIid].fontUsed = (tFont *)Font; | |
633 TIident[TIid].callerID = editID; | |
634 | |
635 strncpy(TIident[TIid].orgText, text, 32); | |
636 strncpy(TIident[TIid].newText, text, 32); | |
637 TIident[TIid].orgText[31] = 0; | |
638 TIident[TIid].newText[31] = 0; | |
639 | |
640 | |
641 if(int1) | |
642 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoActive); | |
643 else | |
644 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoInActive); | |
645 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
130
diff
changeset
|
646 if(editID == 0) |
38 | 647 tInfo_write_content_without_Id(); |
648 else | |
649 { | |
650 tInfo_write_content_of_actual_Id(); | |
651 TIidLast = TIid; | |
652 TIid++; | |
653 } | |
654 } | |
655 | |
656 | |
657 void tInfo_setEvent(uint32_t inputEventID, uint32_t inputFunctionCall) | |
658 { | |
659 if(TIevidLast >= 9) | |
660 return; | |
661 | |
662 /* set cursor to first field */ | |
663 if(TIevidLast < 0) | |
664 { | |
665 tI_startInfoFieldSelect(); | |
666 } | |
667 | |
668 TIevent[TIevid].callerID = inputEventID; | |
669 TIevent[TIevid].pEventFunction = inputFunctionCall; | |
670 | |
671 TIevidLast = TIevid; | |
672 TIevid++; | |
673 } | |
674 | |
675 | |
676 void tI_set_cursor(uint8_t forThisIdentID) | |
677 { | |
678 int16_t x0, x1, y0, y1; | |
679 | |
680 uint32_t xtra_left_right = 10; | |
681 uint32_t xtra_top_bottom = 10; | |
682 | |
683 /* y geht von 0 bis 799 */ | |
684 /* x geht von 0 bis 479 */ | |
685 | |
686 x0 = (int16_t)TIident[forThisIdentID].coord[0]; | |
687 x1 = (int16_t)TIident[forThisIdentID].coord[1]; | |
688 y0 = (int16_t)TIident[forThisIdentID].coord[2]; | |
689 y1 = y0 + (int16_t)TIident[forThisIdentID].fontUsed->height; | |
690 | |
691 if(((int16_t)TIident[forThisIdentID].fontUsed->height) > 70) | |
692 { | |
693 xtra_left_right = 10; | |
694 xtra_top_bottom = 10; | |
695 } | |
696 else | |
697 { | |
698 xtra_left_right = 10; | |
699 xtra_top_bottom = 0; | |
700 } | |
701 | |
702 x0 -= xtra_left_right; | |
703 x1 += xtra_left_right; | |
704 y0 -= xtra_top_bottom; | |
705 y1 += xtra_top_bottom; | |
706 | |
707 GFX_SetWindowLayer0(tIcursor.FBStartAdress, x0, x1, y0, y1); | |
708 } | |
709 | |
710 | |
711 void tInfo_write_label_var(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
712 { | |
713 GFX_DrawCfgWindow hgfx; | |
714 | |
715 if(XrightGimpStyle > 799) | |
716 XrightGimpStyle = 799; | |
717 if(XleftGimpStyle >= XrightGimpStyle) | |
718 XleftGimpStyle = 0; | |
719 if(YtopGimpStyle > 479) | |
720 YtopGimpStyle = 479; | |
721 hgfx.Image = &tIscreen; | |
722 hgfx.WindowNumberOfTextLines = 1; | |
723 hgfx.WindowLineSpacing = 0; | |
724 hgfx.WindowTab = 0; | |
725 hgfx.WindowX0 = XleftGimpStyle; | |
726 hgfx.WindowX1 = XrightGimpStyle; | |
727 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
728 if(hgfx.WindowY1 < Font->height) | |
729 hgfx.WindowY0 = 0; | |
730 else | |
731 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
732 | |
733 GFX_write_label(Font, &hgfx, text, infoColor); | |
734 } | |
735 | |
736 | |
737 void tInfo_write_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) | |
738 { | |
739 GFX_DrawCfgWindow hgfx; | |
740 | |
741 if(XrightGimpStyle > 799) | |
742 XrightGimpStyle = 799; | |
743 if(XleftGimpStyle >= XrightGimpStyle) | |
744 XleftGimpStyle = 0; | |
745 if(YtopGimpStyle > 479) | |
746 YtopGimpStyle = 479; | |
747 hgfx.Image = &tIscreen; | |
748 hgfx.WindowNumberOfTextLines = 1; | |
749 hgfx.WindowLineSpacing = 0; | |
750 hgfx.WindowTab = 0; | |
751 hgfx.WindowX0 = XleftGimpStyle; | |
752 hgfx.WindowX1 = XrightGimpStyle; | |
753 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
754 if(hgfx.WindowY1 < Font->height) | |
755 hgfx.WindowY0 = 0; | |
756 else | |
757 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
758 | |
759 GFX_write_label(Font, &hgfx, text, color); | |
760 } | |
761 | |
762 | |
763 void tInfo_write_label_fix(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char textId) | |
764 { | |
765 char text[2]; | |
766 | |
767 text[0] = textId; | |
768 text[1] = 0; | |
769 | |
770 tInfo_write_label_var(XleftGimpStyle, XrightGimpStyle, YtopGimpStyle, Font, text); | |
771 } | |
772 | |
773 | |
774 void tI_clean_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font) | |
775 { | |
776 GFX_DrawCfgWindow hgfx; | |
777 | |
778 if(XrightGimpStyle > 799) | |
779 XrightGimpStyle = 799; | |
780 if(XleftGimpStyle >= XrightGimpStyle) | |
781 XleftGimpStyle = 0; | |
782 if(YtopGimpStyle > 479) | |
783 YtopGimpStyle = 479; | |
784 hgfx.Image = &tIscreen; | |
785 hgfx.WindowX0 = XleftGimpStyle; | |
786 hgfx.WindowX1 = XrightGimpStyle; | |
787 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
788 if(hgfx.WindowY1 < Font->height) | |
789 hgfx.WindowY0 = 0; | |
790 else | |
791 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
792 | |
793 GFX_clear_window_immediately(&hgfx); | |
794 } | |
795 | |
796 | |
797 void tInfo_write_buttonTextline(GFX_DrawCfgScreen *screenPtr, uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) | |
798 { | |
799 GFX_clean_area(&tIscreen, 0, 800, 480-24,480); | |
800 | |
801 char localtext[32]; | |
802 | |
803 if(left2ByteCode) | |
804 { | |
805 localtext[0] = TXT_2BYTE; | |
806 localtext[1] = left2ByteCode; | |
807 localtext[2] = 0; | |
808 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
809 } | |
810 | |
811 if(middle2ByteCode) | |
812 { | |
813 localtext[0] = '\001'; | |
814 localtext[1] = TXT_2BYTE; | |
815 localtext[2] = middle2ByteCode; | |
816 localtext[3] = 0; | |
817 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
818 } | |
819 | |
820 if(right2ByteCode) | |
821 { | |
822 localtext[0] = '\002'; | |
823 localtext[1] = TXT_2BYTE; | |
824 localtext[2] = right2ByteCode; | |
825 localtext[3] = 0; | |
826 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
827 } | |
828 } | |
845 | 829 void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) |
830 { | |
831 char localtext[32]; | |
832 | |
833 if(left2ByteCode) | |
834 { | |
835 localtext[0] = TXT_2BYTE; | |
836 localtext[1] = left2ByteCode; | |
837 localtext[2] = 0; | |
838 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
839 } | |
840 | |
841 if(middle2ByteCode) | |
842 { | |
843 localtext[0] = '\001'; | |
844 localtext[1] = TXT_2BYTE; | |
845 localtext[2] = middle2ByteCode; | |
846 localtext[3] = 0; | |
847 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
848 } | |
849 | |
850 if(right2ByteCode) | |
851 { | |
852 localtext[0] = '\002'; | |
853 localtext[1] = TXT_2BYTE; | |
854 localtext[2] = right2ByteCode; | |
855 localtext[3] = 0; | |
856 tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
857 } | |
858 } |