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