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