Mercurial > public > ostc4
comparison Discovery/Src/tInfo.c @ 38:5f11787b4f42
include in ostc4 repository
author | heinrichsweikamp |
---|---|
date | Sat, 28 Apr 2018 11:52:34 +0200 |
parents | |
children | b7689d9e888a |
comparison
equal
deleted
inserted
replaced
37:ccc45c0e1ea2 | 38:5f11787b4f42 |
---|---|
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(); | |
259 default: | |
260 break; | |
261 case ACTION_IDLE_TICK: | |
262 case ACTION_IDLE_SECOND: | |
263 break; | |
264 } | |
265 | |
266 } | |
267 | |
268 /* Private functions ---------------------------------------------------------*/ | |
269 | |
270 void tInfo_build_page(void) | |
271 { | |
272 tInfo_write_content_simple( 30, 340, 90, &FontT48, "Logbook", CLUT_Font020); | |
273 | |
274 } | |
275 | |
276 void tInfo_write_content_simple(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) | |
277 { | |
278 GFX_DrawCfgWindow hgfx; | |
279 | |
280 if(XrightGimpStyle > 799) | |
281 XrightGimpStyle = 799; | |
282 if(XleftGimpStyle >= XrightGimpStyle) | |
283 XleftGimpStyle = 0; | |
284 if(YtopGimpStyle > 479) | |
285 YtopGimpStyle = 479; | |
286 hgfx.Image = &tIscreen; | |
287 hgfx.WindowNumberOfTextLines = 1; | |
288 hgfx.WindowLineSpacing = 0; | |
289 hgfx.WindowTab = 400; | |
290 hgfx.WindowX0 = XleftGimpStyle; | |
291 hgfx.WindowX1 = XrightGimpStyle; | |
292 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
293 if(hgfx.WindowY1 < Font->height) | |
294 hgfx.WindowY0 = 0; | |
295 else | |
296 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
297 | |
298 GFX_write_string_color(Font, &hgfx, text, 0, color); | |
299 } | |
300 | |
301 /* Exported functions --------------------------------------------------------*/ | |
302 | |
303 void tI_startInfoFieldSelect(void) | |
304 { | |
305 TIid = 0; | |
306 tI_set_cursor(TIid); | |
307 } | |
308 | |
309 | |
310 void tI_nextInfoField(void) | |
311 { | |
312 if(TIid < TIidLast) | |
313 TIid++; | |
314 else | |
315 TIid = 0; | |
316 tI_set_cursor(TIid); | |
317 } | |
318 | |
319 | |
320 void tI_previousInfoField(void) | |
321 { | |
322 if(TIid > 0) | |
323 TIid--; | |
324 else | |
325 TIid = TIidLast; | |
326 tI_set_cursor(TIid); | |
327 } | |
328 | |
329 | |
330 uint8_t tI_get_newContent_of_actual_id_block_and_subBlock(uint8_t action) | |
331 { | |
332 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); | |
333 uint8_t content; | |
334 | |
335 if(TIevent[TIevid].callerID != TIident[TIid].callerID) | |
336 return 0; | |
337 | |
338 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(TIevent[TIevid].pEventFunction); | |
339 | |
340 if(TIident[TIid].maintype == FIELD_ON_OFF) | |
341 content = TIident[TIid].input; | |
342 else | |
343 content = 0; /* just a default for protection */ | |
344 | |
345 return onActionFunc(TIident[TIid].callerID, 0, 0, content, action); | |
346 } | |
347 | |
348 | |
349 void tI_enterInfoField(void) | |
350 { | |
351 uint8_t newContent; | |
352 | |
353 TIevid = 0; | |
354 while((TIevid < TIevidLast) && (TIevent[TIevid].callerID != TIident[TIid].callerID)) | |
355 { | |
356 TIevid++; | |
357 } | |
358 | |
359 if(TIevent[TIevid].callerID != TIident[TIid].callerID) | |
360 return; | |
361 | |
362 newContent = tI_get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_ENTER); | |
363 | |
364 if(newContent == 255) | |
365 { | |
366 exitInfo(); | |
367 return; | |
368 } | |
369 | |
370 switch(TIident[TIid].maintype) | |
371 { | |
372 case FIELD_BUTTON: | |
373 break; | |
374 case FIELD_ON_OFF: | |
375 break; | |
376 case FIELD_SYMBOL: | |
377 TIident[TIid].input += 1; | |
378 if(TIident[TIid].input >= TIident[TIid].symbolCounter) | |
379 TIident[TIid].input = 0; | |
380 TIident[TIid].newText[0] = TIident[TIid].orgText[TIident[TIid].input]; | |
381 tInfo_write_content_of_actual_Id(); | |
382 break; | |
383 } | |
384 } | |
385 | |
386 | |
387 void tI_evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4) | |
388 { | |
389 if(editID != TIident[TIid].callerID) | |
390 return; | |
391 | |
392 uint8_t i, digitCount, digit; | |
393 uint32_t sum[4], multiplier; | |
394 | |
395 for(i=0;i<4;i++) | |
396 sum[i] = 0; | |
397 | |
398 i = 0; | |
399 while( TIident[TIid].size[i] && (i < 4)) | |
400 { | |
401 multiplier = 1; | |
402 for(digitCount = 1; digitCount < TIident[TIid].size[i]; digitCount++) | |
403 multiplier *= 10; | |
404 | |
405 for(digitCount = 0; digitCount < TIident[TIid].size[i]; digitCount++) | |
406 { | |
407 digit = TIident[TIid].newText[TIident[TIid].begin[i] + digitCount]; | |
408 | |
409 if(digit > '0') | |
410 digit -= '0'; | |
411 else | |
412 digit = 0; | |
413 | |
414 if(digit > 9) | |
415 digit = 9; | |
416 | |
417 sum[i] += digit * multiplier; | |
418 | |
419 if(multiplier >= 10) | |
420 multiplier /= 10; | |
421 else | |
422 multiplier = 0; | |
423 } | |
424 i++; | |
425 } | |
426 | |
427 *pNewValue1 = sum[0]; | |
428 *pNewValue2 = sum[1]; | |
429 *pNewValue3 = sum[2]; | |
430 *pNewValue4 = sum[3]; | |
431 } | |
432 | |
433 | |
434 uint8_t tI_get_id_of(uint32_t editID) | |
435 { | |
436 uint8_t temp_id; | |
437 | |
438 if(editID == TIident[TIid].callerID) | |
439 return TIid; | |
440 else | |
441 { | |
442 temp_id = 0; | |
443 while((temp_id < 9) && (editID != TIident[temp_id].callerID)) | |
444 temp_id++; | |
445 if(editID != TIident[temp_id].callerID) | |
446 temp_id = 255; | |
447 return temp_id; | |
448 } | |
449 } | |
450 | |
451 | |
452 void tI_newButtonText(uint32_t editID, char *text) | |
453 { | |
454 uint8_t backup_id, temp_id; | |
455 | |
456 temp_id = tI_get_id_of(editID); | |
457 if(temp_id == 255) | |
458 return; | |
459 | |
460 backup_id = TIid; | |
461 TIid = temp_id; | |
462 | |
463 strncpy(TIident[TIid].newText, text, 32); | |
464 TIident[TIid].newText[31] = 0; | |
465 | |
466 tI_clean_content_of_actual_Id(); | |
467 tInfo_write_content_of_actual_Id(); | |
468 | |
469 TIid = backup_id; | |
470 } | |
471 | |
472 | |
473 void tInfo_set_on_off(uint32_t editID, uint32_t int1) | |
474 { | |
475 uint8_t backup_id, temp_id; | |
476 | |
477 temp_id = tI_get_id_of(editID); | |
478 if(temp_id == 255) | |
479 return; | |
480 | |
481 backup_id = TIid; | |
482 TIid = temp_id; | |
483 | |
484 TIident[TIid].input = int1; | |
485 | |
486 if(int1) | |
487 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoActive); | |
488 else | |
489 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoInActive); | |
490 | |
491 tInfo_write_content_of_actual_Id(); | |
492 | |
493 TIid = backup_id; | |
494 } | |
495 | |
496 | |
497 void tInfo_write_content_without_Id(void) | |
498 { | |
499 tInfo_write_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed, TIident[TIid].newText, CLUT_InfoFieldRegular); | |
500 } | |
501 | |
502 | |
503 void tInfo_write_content_of_actual_Id(void) | |
504 { | |
505 tInfo_write_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed, TIident[TIid].newText, (CLUT_InfoField0 + TIid)); | |
506 } | |
507 | |
508 | |
509 void tI_clean_content_of_actual_Id(void) | |
510 { | |
511 tI_clean_content( TIident[TIid].coord[0], TIident[TIid].coord[1], TIident[TIid].coord[2], TIident[TIid].fontUsed); | |
512 } | |
513 | |
514 | |
515 void tInfo_write_field_button(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
516 { | |
517 if(TIidLast >= 9) | |
518 return; | |
519 | |
520 TIident[TIid].maintype = FIELD_BUTTON; | |
521 TIident[TIid].subtype = FIELD_BUTTON; | |
522 | |
523 TIident[TIid].coord[0] = XleftGimpStyle; | |
524 TIident[TIid].coord[1] = XrightGimpStyle; | |
525 TIident[TIid].coord[2] = YtopGimpStyle; | |
526 TIident[TIid].fontUsed = (tFont *)Font; | |
527 TIident[TIid].callerID = editID; | |
528 | |
529 strncpy(TIident[TIid].orgText, text, 32); | |
530 strncpy(TIident[TIid].newText, text, 32); | |
531 TIident[TIid].orgText[31] = 0; | |
532 TIident[TIid].newText[31] = 0; | |
533 | |
534 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoButtonColor1); | |
535 | |
536 if(editID == NULL) | |
537 tInfo_write_content_without_Id(); | |
538 else | |
539 { | |
540 tInfo_write_content_of_actual_Id(); | |
541 TIidLast = TIid; | |
542 TIid++; | |
543 } | |
544 } | |
545 | |
546 | |
547 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) | |
548 { | |
549 if(TIidLast >= 9) | |
550 return; | |
551 | |
552 TIident[TIid].maintype = FIELD_SYMBOL; | |
553 TIident[TIid].subtype = FIELD_SYMBOL; | |
554 | |
555 TIident[TIid].coord[0] = XleftGimpStyle; | |
556 TIident[TIid].coord[1] = XrightGimpStyle; | |
557 TIident[TIid].coord[2] = YtopGimpStyle; | |
558 TIident[TIid].fontUsed = (tFont *)Font; | |
559 TIident[TIid].callerID = editID; | |
560 | |
561 strncpy(TIident[TIid].orgText, text, 32); | |
562 strncpy(TIident[TIid].newText, text, 32); | |
563 TIident[TIid].orgText[31] = 0; | |
564 | |
565 TIident[TIid].newText[0] = text[0]; | |
566 TIident[TIid].newText[1] = 0; | |
567 | |
568 TIident[TIid].input = int1; | |
569 TIident[TIid].symbolCounter = strlen(TIident[TIid].orgText); | |
570 | |
571 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoButtonColor1); | |
572 | |
573 if(editID == NULL) | |
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_on_off(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_ON_OFF; | |
590 TIident[TIid].subtype = FIELD_ON_OFF; | |
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 TIident[TIid].newText[31] = 0; | |
602 | |
603 | |
604 if(int1) | |
605 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoActive); | |
606 else | |
607 change_CLUT_entry((CLUT_InfoField0 + TIid), CLUT_InfoInActive); | |
608 | |
609 if(editID == NULL) | |
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_setEvent(uint32_t inputEventID, uint32_t inputFunctionCall) | |
621 { | |
622 if(TIevidLast >= 9) | |
623 return; | |
624 | |
625 /* set cursor to first field */ | |
626 if(TIevidLast < 0) | |
627 { | |
628 tI_startInfoFieldSelect(); | |
629 } | |
630 | |
631 TIevent[TIevid].callerID = inputEventID; | |
632 TIevent[TIevid].pEventFunction = inputFunctionCall; | |
633 | |
634 TIevidLast = TIevid; | |
635 TIevid++; | |
636 } | |
637 | |
638 | |
639 void tI_set_cursor(uint8_t forThisIdentID) | |
640 { | |
641 int16_t x0, x1, y0, y1; | |
642 | |
643 uint32_t xtra_left_right = 10; | |
644 uint32_t xtra_top_bottom = 10; | |
645 | |
646 /* y geht von 0 bis 799 */ | |
647 /* x geht von 0 bis 479 */ | |
648 | |
649 x0 = (int16_t)TIident[forThisIdentID].coord[0]; | |
650 x1 = (int16_t)TIident[forThisIdentID].coord[1]; | |
651 y0 = (int16_t)TIident[forThisIdentID].coord[2]; | |
652 y1 = y0 + (int16_t)TIident[forThisIdentID].fontUsed->height; | |
653 | |
654 if(((int16_t)TIident[forThisIdentID].fontUsed->height) > 70) | |
655 { | |
656 xtra_left_right = 10; | |
657 xtra_top_bottom = 10; | |
658 } | |
659 else | |
660 { | |
661 xtra_left_right = 10; | |
662 xtra_top_bottom = 0; | |
663 } | |
664 | |
665 x0 -= xtra_left_right; | |
666 x1 += xtra_left_right; | |
667 y0 -= xtra_top_bottom; | |
668 y1 += xtra_top_bottom; | |
669 | |
670 GFX_SetWindowLayer0(tIcursor.FBStartAdress, x0, x1, y0, y1); | |
671 } | |
672 | |
673 | |
674 void tInfo_write_label_var(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
675 { | |
676 GFX_DrawCfgWindow hgfx; | |
677 | |
678 if(XrightGimpStyle > 799) | |
679 XrightGimpStyle = 799; | |
680 if(XleftGimpStyle >= XrightGimpStyle) | |
681 XleftGimpStyle = 0; | |
682 if(YtopGimpStyle > 479) | |
683 YtopGimpStyle = 479; | |
684 hgfx.Image = &tIscreen; | |
685 hgfx.WindowNumberOfTextLines = 1; | |
686 hgfx.WindowLineSpacing = 0; | |
687 hgfx.WindowTab = 0; | |
688 hgfx.WindowX0 = XleftGimpStyle; | |
689 hgfx.WindowX1 = XrightGimpStyle; | |
690 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
691 if(hgfx.WindowY1 < Font->height) | |
692 hgfx.WindowY0 = 0; | |
693 else | |
694 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
695 | |
696 GFX_write_label(Font, &hgfx, text, infoColor); | |
697 } | |
698 | |
699 | |
700 void tInfo_write_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) | |
701 { | |
702 GFX_DrawCfgWindow hgfx; | |
703 | |
704 if(XrightGimpStyle > 799) | |
705 XrightGimpStyle = 799; | |
706 if(XleftGimpStyle >= XrightGimpStyle) | |
707 XleftGimpStyle = 0; | |
708 if(YtopGimpStyle > 479) | |
709 YtopGimpStyle = 479; | |
710 hgfx.Image = &tIscreen; | |
711 hgfx.WindowNumberOfTextLines = 1; | |
712 hgfx.WindowLineSpacing = 0; | |
713 hgfx.WindowTab = 0; | |
714 hgfx.WindowX0 = XleftGimpStyle; | |
715 hgfx.WindowX1 = XrightGimpStyle; | |
716 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
717 if(hgfx.WindowY1 < Font->height) | |
718 hgfx.WindowY0 = 0; | |
719 else | |
720 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
721 | |
722 GFX_write_label(Font, &hgfx, text, color); | |
723 } | |
724 | |
725 | |
726 void tInfo_write_label_fix(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char textId) | |
727 { | |
728 char text[2]; | |
729 | |
730 text[0] = textId; | |
731 text[1] = 0; | |
732 | |
733 tInfo_write_label_var(XleftGimpStyle, XrightGimpStyle, YtopGimpStyle, Font, text); | |
734 } | |
735 | |
736 | |
737 void tI_clean_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font) | |
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.WindowX0 = XleftGimpStyle; | |
749 hgfx.WindowX1 = XrightGimpStyle; | |
750 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
751 if(hgfx.WindowY1 < Font->height) | |
752 hgfx.WindowY0 = 0; | |
753 else | |
754 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
755 | |
756 GFX_clear_window_immediately(&hgfx); | |
757 } | |
758 | |
759 | |
760 void tInfo_write_buttonTextline(GFX_DrawCfgScreen *screenPtr, uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) | |
761 { | |
762 GFX_clean_area(&tIscreen, 0, 800, 480-24,480); | |
763 | |
764 char localtext[32]; | |
765 | |
766 if(left2ByteCode) | |
767 { | |
768 localtext[0] = TXT_2BYTE; | |
769 localtext[1] = left2ByteCode; | |
770 localtext[2] = 0; | |
771 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
772 } | |
773 | |
774 if(middle2ByteCode) | |
775 { | |
776 localtext[0] = '\001'; | |
777 localtext[1] = TXT_2BYTE; | |
778 localtext[2] = middle2ByteCode; | |
779 localtext[3] = 0; | |
780 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
781 } | |
782 | |
783 if(right2ByteCode) | |
784 { | |
785 localtext[0] = '\002'; | |
786 localtext[1] = TXT_2BYTE; | |
787 localtext[2] = right2ByteCode; | |
788 localtext[3] = 0; | |
789 write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
790 } | |
791 } |