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