Mercurial > public > ostc4
annotate Discovery/Src/tMenuEdit.c @ 785:3c0b16473af4
Change support from Pyroscience -> DiveO2 sensors
author | heinrichsweikamp |
---|---|
date | Wed, 31 May 2023 08:44:07 +0200 |
parents | c31237d20491 |
children | 19ab6f3ed52a |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuEdit.c | |
5 /// \brief Main Template file for Menu Setting Modifications | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 04-July-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 ------------------------------------------------------------------*/ | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
30 #include <stdlib.h> |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
31 |
38 | 32 #include "tMenuEdit.h" |
33 | |
34 #include "externLogbookFlash.h" | |
35 #include "gfx_fonts.h" | |
36 #include "tHome.h" | |
37 #include "tInfoCompass.h" | |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
38 #include "tInfoSensor.h" |
38 | 39 #include "tMenuEditHardware.h" |
40 #include "tMenuEditPlanner.h" | |
41 #include "tMenuEditSystem.h" | |
42 #include "tMenuEditXtra.h" | |
508 | 43 #include "tMenuEditCustom.h" |
38 | 44 |
45 /* Private types -------------------------------------------------------------*/ | |
46 #define TEXTSIZE 16 | |
47 | |
48 typedef struct | |
49 { | |
50 uint32_t pEventFunction; | |
51 uint32_t callerID; | |
52 } SEventHandler; | |
53 | |
54 typedef struct | |
55 { | |
56 uint32_t pEventFunction; | |
57 uint8_t functionParameter; | |
58 uint8_t line; | |
59 } SBackMenuHandler; | |
60 | |
61 typedef struct | |
62 { | |
63 char orgText[32]; | |
64 char newText[32]; | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
65 uint32_t input[4]; |
38 | 66 uint16_t coord[3]; |
67 int8_t begin[4], size[4]; | |
68 tFont *fontUsed; | |
69 uint32_t callerID; | |
70 uint8_t maintype; | |
71 uint8_t subtype; | |
72 } SEditIdent; | |
73 | |
74 typedef enum | |
75 { | |
76 FIELD_NUMBERS = 0, | |
77 FIELD_BUTTON, | |
78 FIELD_SELECT, | |
79 FIELD_SYMBOL, | |
80 FIELD_TOGGLE, | |
81 FIELD_ON_OFF, | |
82 FIELD_UDIGIT, | |
83 FIELD_2DIGIT, | |
84 FIELD_3DIGIT, | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
85 FIELD_SDIGIT, |
38 | 86 FIELD_FLOAT, |
87 FIELD_END | |
88 } SField; | |
89 | |
90 /* Private variables ---------------------------------------------------------*/ | |
91 GFX_DrawCfgScreen tMEscreen; | |
92 GFX_DrawCfgScreen tMEcursor; | |
93 GFX_DrawCfgScreen tMEcursorNew; | |
94 | |
508 | 95 static uint32_t menuID; |
96 static uint8_t menuColor; | |
38 | 97 |
508 | 98 static int8_t id = 0; |
99 static int8_t idLast = -1; | |
100 static SEditIdent ident[10]; | |
101 static int8_t tME_stop = 0; | |
38 | 102 |
508 | 103 static int8_t evid = 0; |
104 static int8_t evidLast = -1; | |
105 static SEventHandler event[10]; | |
38 | 106 |
508 | 107 static SBackMenuHandler backmenu; |
38 | 108 |
508 | 109 static int8_t block = 0; |
110 static int8_t subBlockPosition = 0; | |
38 | 111 |
508 | 112 static _Bool EnterPressedBeforeButtonAction = 0; |
113 static _Bool EnterPressed = 0; | |
38 | 114 |
508 | 115 static _Bool WriteSettings = 0; |
38 | 116 |
117 /* Private function prototypes -----------------------------------------------*/ | |
118 void draw_tMEdesign(void); | |
119 void set_cursorNew(uint8_t forThisIdentID); | |
120 void startMenuEditFieldSelect(void); | |
121 void create_newText_for_actual_Id(void); | |
122 void write_content_of_actual_Id(void); | |
123 void clean_content_of_actual_Id(void); | |
124 void write_content_without_Id(void); | |
125 | |
126 void nextMenuEditFieldDigit(void); | |
127 void upMenuEditFieldDigit(void); | |
128 void downMenuEditFieldDigit(void); | |
129 | |
130 void draw_tMEcursorNewDesign(void); | |
131 | |
132 uint8_t split_Content_to_Digit_helper(uint8_t inContentAscii, uint8_t *outDigit100, uint8_t *outDigit10, uint8_t *outDigit1); | |
133 | |
134 /* Exported functions --------------------------------------------------------*/ | |
135 | |
136 void tMenuEdit_init(void) | |
137 { | |
138 tMEcursor.FBStartAdress = getFrame(7); | |
139 tMEcursor.ImageHeight = 480; | |
140 tMEcursor.ImageWidth = 800; | |
141 tMEcursor.LayerIndex = 0; | |
142 | |
143 GFX_fill_buffer(tMEcursor.FBStartAdress, 0xFF, CLUT_MenuEditCursor); | |
144 | |
145 tMEcursorNew.FBStartAdress = getFrame(8); | |
146 tMEcursorNew.ImageHeight = 390; | |
147 tMEcursorNew.ImageWidth = 800; | |
148 tMEcursorNew.LayerIndex = 0; | |
149 | |
150 draw_tMEcursorNewDesign(); | |
151 } | |
152 | |
153 void stop_cursor_fields(void) | |
154 { | |
155 tME_stop = 1; | |
156 } | |
157 | |
158 void resetMenuEdit(uint8_t color) | |
159 { | |
160 id = 0; | |
161 idLast = -1; | |
162 evid = 0; | |
163 evidLast = -1; | |
164 tME_stop = 0; | |
165 EnterPressed = 0; | |
166 EnterPressedBeforeButtonAction = 0; | |
167 | |
168 setBackMenu(0,0,0); | |
169 | |
170 releaseFrame(9,tMEscreen.FBStartAdress); | |
171 | |
172 tMEscreen.FBStartAdress = getFrame(9); | |
173 tMEscreen.ImageHeight = 480; | |
174 tMEscreen.ImageWidth = 800; | |
175 tMEscreen.LayerIndex = 1; | |
176 | |
177 /* | |
178 write_content_simple(&tMEscreen, 0, 38, 0, &Awe48,"x",CLUT_ButtonSymbols); | |
179 write_content_simple(&tMEscreen, 800-46, 800, 0, &Awe48,"u",CLUT_ButtonSymbols); | |
180 write_content_simple(&tMEscreen, 0, 45, 480-45, &Awe48,"d",CLUT_ButtonSymbols); | |
181 write_content_simple(&tMEscreen, 800-48, 800, 480-45, &Awe48,"e",CLUT_ButtonSymbols); | |
182 */ | |
183 menuID = get_globalState(); | |
184 | |
185 menuColor = color; | |
186 | |
187 // draw_tMEdesign(); | |
188 // GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, tMEcursor.FBStartAdress,480); | |
189 uint8_t line = 1; | |
190 // GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, (tMEcursorNew.FBStartAdress) + 65*2*(line - 1),390); | |
191 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
192 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
193 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
194 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress) + 65*2*(line - 1), 0, 25, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
195 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
196 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
197 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
198 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress)+ (390 - 65 *(line)) *2, 0, 480-390-25, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
199 } |
38 | 200 } |
201 | |
202 | |
203 void tMenuEdit_refresh_live_content(void) | |
204 { | |
508 | 205 uint32_t globState = get_globalState(); |
206 void (*refreshFct)() = NULL; | |
38 | 207 |
508 | 208 |
209 switch(globState) | |
210 { | |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
211 case (StMHARD3_O2_Sensor1): |
562
ec76fa85009e
Added ADC sensor interface to O2 sensore menu structure:
Ideenmodellierer
parents:
552
diff
changeset
|
212 case (StMHARD3_O2_Sensor1 & MaskFieldDigit): |
584 | 213 case (StMHARD3_O2_Calibrate): |
734
190e5814b2f5
Removed interface selection from sensor menu:
Ideenmodellierer
parents:
718
diff
changeset
|
214 case (StMHARD3_Sensor_Detect): |
190e5814b2f5
Removed interface selection from sensor menu:
Ideenmodellierer
parents:
718
diff
changeset
|
215 case (StMHARD3_Sensor_Info): refreshFct = refresh_O2Sensors; |
508 | 216 break; |
774
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
217 case (StMHARD2_Compass_SetCourse & MaskFieldDigit): |
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
218 refreshFct = refresh_CompassEdit; |
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
219 |
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
220 break; |
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
221 case (StMXTRA_CompassHeading & MaskFieldDigit): |
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
222 refreshFct = refresh_CompassHeading; |
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
223 |
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
224 break; |
707
e81afd727993
Menu cleanup rebreather specific settings:
Ideenmodellierer
parents:
662
diff
changeset
|
225 case (StMXTRA_PSCR_O2_Drop & MaskFieldDigit): |
774
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
226 if (settingsGetPointer()->dive_mode != DIVEMODE_PSCR) { /* workaround because PSCR mode is set dynamic */ |
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
227 refreshFct = refresh_CO2Data; |
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
228 } |
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
229 |
6169309d6eb9
more menu items for the compass menu: Delete bearing, and reset to land based bearing. I have also re-enabled the real time bearing display in the menu - makes it easier to set the correct bearing. (mikeller)
heinrichsweikamp
parents:
734
diff
changeset
|
230 break; |
662 | 231 case (StMXTRA_CO2_Sensor & MaskFieldDigit): refreshFct = refresh_CO2Data; |
232 break; | |
520 | 233 case (StMSYS4_Info & MaskFieldDigit): refreshFct = &refresh_InformationPage; |
508 | 234 break; |
235 case (StMPLAN5_ExitResult & MaskFieldDigit): refreshFct = refresh_PlanResult; | |
236 break; | |
237 case (StMHARD5_Button1 & MaskFieldDigit): // will not be executed in EditFieldMode as global state is different | |
238 refreshFct = refresh_ButtonValuesFromPIC; | |
239 break; | |
240 case (StMSYS3_Units & MaskFieldDigit): refreshFct = refresh_Design; | |
241 break; | |
520 | 242 case (StMCustom1_CViewTimeout & MaskFieldDigit):refreshFct = refresh_Customviews; |
508 | 243 break; |
531 | 244 case (StMCustom4_CViewSelection1 & MaskFieldDigit): |
245 case (StMCustom3_CViewSelection1 & MaskFieldDigit): | |
521
e221cf762f45
Move Bigfont and motion Ctrl selection menu out of custom view submenu:
Ideenmodellierer
parents:
520
diff
changeset
|
246 case StMCustom3_CViewSelection2: |
e221cf762f45
Move Bigfont and motion Ctrl selection menu out of custom view submenu:
Ideenmodellierer
parents:
520
diff
changeset
|
247 case StMCustom3_CViewSelection3: |
e221cf762f45
Move Bigfont and motion Ctrl selection menu out of custom view submenu:
Ideenmodellierer
parents:
520
diff
changeset
|
248 case StMCustom3_CViewSelection4: |
e221cf762f45
Move Bigfont and motion Ctrl selection menu out of custom view submenu:
Ideenmodellierer
parents:
520
diff
changeset
|
249 case StMCustom3_CViewSelection5: |
531 | 250 case StMCustom3_CViewSelection6: refreshFct = CustomviewDivemode_refresh; |
508 | 251 break; |
604
fb5bb04ad914
Merged menu items of viewport and motion control:
Ideenmodellierer
parents:
584
diff
changeset
|
252 case (StMCustom5_CViewPortCalib & MaskFieldDigit): |
fb5bb04ad914
Merged menu items of viewport and motion control:
Ideenmodellierer
parents:
584
diff
changeset
|
253 case StMCustom5_CViewPortLayout: |
fb5bb04ad914
Merged menu items of viewport and motion control:
Ideenmodellierer
parents:
584
diff
changeset
|
254 case StMCustom5_CViewPortAmbient: refreshFct = refresh_ViewPort; |
552
531e7818b737
Added menu structure to acces viewport calibration:
Ideenmodellierer
parents:
531
diff
changeset
|
255 break; |
508 | 256 default: /* no menu has been updated */ |
257 break; | |
258 } | |
259 | |
260 if(refreshFct != NULL) | |
261 { | |
262 uint32_t rememberPage = tMEscreen.FBStartAdress; | |
263 tMEscreen.FBStartAdress = getFrame(9); | |
264 | |
265 refreshFct(); | |
266 | |
267 GFX_SetFrameTop(tMEscreen.FBStartAdress); | |
268 releaseFrame(9,rememberPage); | |
269 } | |
38 | 270 } |
271 | |
272 void tMenuEdit_writeSettingsToFlash(void) | |
273 { | |
274 if(WriteSettings) | |
275 { | |
662 | 276 reset_SettingWarning(); |
38 | 277 GFX_logoAutoOff(); |
427 | 278 ext_flash_write_settings(0); |
38 | 279 WriteSettings = 0; |
280 } | |
281 } | |
282 | |
283 void helperLeaveMenuEditField(uint8_t idID) | |
284 { | |
285 if(ident[idID].maintype == FIELD_NUMBERS) | |
286 { | |
287 change_CLUT_entry((CLUT_MenuEditField0 + idID), CLUT_MenuEditFieldRegular); | |
288 } | |
289 } | |
290 | |
291 | |
292 void helperGotoMenuEditField(uint8_t idID) | |
293 { | |
294 /* | |
295 if(ident[idID].maintype == FIELD_NUMBERS) | |
296 { | |
297 change_CLUT_entry((CLUT_MenuEditField0 + idID), CLUT_MenuEditFieldSelected); | |
298 } | |
299 */ | |
300 set_cursorNew(idID); | |
301 // set_cursor(idID); | |
302 } | |
303 | |
304 | |
305 void exitMenuEdit_to_BackMenu(void) | |
306 { | |
307 _Bool EnterPressedBackup = EnterPressed; | |
308 | |
309 if(backmenu.pEventFunction) | |
310 { | |
311 ((void (*)(uint8_t))(backmenu.pEventFunction))(backmenu.functionParameter); | |
312 | |
313 EnterPressed = EnterPressedBackup; | |
314 // if(backmenu.line > 1) | |
315 // helperGotoMenuEditField(backmenu.line); | |
316 } | |
317 } | |
318 | |
319 | |
320 void exitMenuEdit_to_Menu_with_Menu_Update(void) | |
321 { | |
322 EnterPressed = 1; | |
323 exitMenuEdit(1); | |
324 } | |
325 | |
326 | |
327 void exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only(void) | |
328 { | |
329 EnterPressed = 1; | |
330 exitMenuEdit(0); | |
331 } | |
332 | |
333 | |
334 void exitMenuEdit_to_Home_with_Menu_Update(void) | |
335 { | |
336 EnterPressed = 1; | |
337 exitMenuEdit(1); | |
338 set_globalState_tHome(); | |
339 } | |
340 | |
341 | |
342 void exitMenuEdit_to_InfoCompassCalibration(void) | |
343 { | |
344 exitMenuEdit(1); | |
345 openInfo_Compass(); | |
346 } | |
347 | |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
348 void exitMenuEdit_to_InfoSensor(void) |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
349 { |
783 | 350 uint32_t globState = get_globalState(); |
351 | |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
352 exitMenuEdit(1); |
783 | 353 switch(globState) |
354 { | |
355 case (StMHARD3_O2_Sensor3): openInfo_Sensor(3); | |
356 break; | |
357 case (StMHARD3_O2_Sensor2): openInfo_Sensor(2); | |
358 break; | |
359 default: | |
360 case (StMHARD3_O2_Sensor1): openInfo_Sensor(1); | |
361 break; | |
362 } | |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
363 } |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
364 |
38 | 365 |
366 void exitMenuEdit_to_Home(void) | |
367 { | |
368 exitMenuEdit(1); | |
369 set_globalState_tHome(); | |
370 } | |
371 | |
372 | |
373 void exitMenuEdit(uint8_t writeSettingsIfEnterPressed) | |
374 { | |
375 openMenu(0); | |
376 if(EnterPressed) | |
377 { | |
378 updateMenu(); | |
379 if((stateUsed->mode == MODE_SURFACE) && writeSettingsIfEnterPressed) | |
380 WriteSettings = 1; | |
381 } | |
382 releaseFrame(9,tMEscreen.FBStartAdress); | |
383 } | |
384 | |
385 | |
386 void exitMenuEditBackMenuOption(void) | |
387 { | |
388 if(backmenu.pEventFunction == 0) | |
389 exitMenuEdit(1); | |
390 else | |
391 exitMenuEdit_to_BackMenu(); | |
392 } | |
393 | |
394 | |
395 void startMenuEditFieldSelect(void) | |
396 { | |
397 id = 0; | |
398 helperGotoMenuEditField(id); | |
399 } | |
400 | |
401 | |
402 void nextMenuEditField(void) | |
403 { | |
404 helperLeaveMenuEditField(id); | |
405 | |
406 if(id < idLast) | |
407 id++; | |
408 else | |
409 id = 0; | |
410 helperGotoMenuEditField(id); | |
411 } | |
412 | |
413 /* | |
414 void previousMenuEditField(void) | |
415 { | |
416 helperLeaveMenuEditField(id); | |
417 if(id > 0) | |
418 id--; | |
419 else | |
420 id = idLast; | |
421 helperGotoMenuEditField(id); | |
422 } | |
423 */ | |
424 | |
425 _Bool inc_subBlock_or_block_of_actual_id(void) | |
426 { | |
427 if(event[evid].callerID != ident[id].callerID) | |
428 return 0; | |
429 | |
430 if((ident[id].subtype != FIELD_3DIGIT) && (ident[id].subtype != FIELD_2DIGIT) && ((subBlockPosition + 1) < ident[id].size[block])) | |
431 { | |
432 subBlockPosition++; | |
433 return 1; | |
434 } | |
435 | |
436 if(((block + 1) < 4) && (ident[id].size[block+1] > 0)) | |
437 { | |
438 block++; | |
439 subBlockPosition = 0; | |
440 return 1; | |
441 } | |
442 | |
443 return 0; | |
444 } | |
445 | |
446 | |
447 uint8_t get_newContent_of_actual_id_block_and_subBlock(uint8_t action) | |
448 { | |
449 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); | |
450 uint8_t content; | |
451 | |
452 if(event[evid].callerID != ident[id].callerID) | |
453 return 0; | |
454 | |
455 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[evid].pEventFunction); | |
456 | |
457 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT)) | |
458 { | |
459 content = 100 * ( ident[id].newText[ident[id].begin[block] + 0] - '0'); | |
460 content += 10 * ( ident[id].newText[ident[id].begin[block] + 1] - '0'); | |
461 content += ident[id].newText[ident[id].begin[block] + 2]; | |
462 } | |
463 else | |
464 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT)) | |
465 { | |
466 content = 10 * (ident[id].newText[ident[id].begin[block] + 0] - '0'); | |
467 content += ident[id].newText[ident[id].begin[block] + 1]; | |
468 } | |
469 else | |
470 if(ident[id].maintype == FIELD_NUMBERS) | |
471 content = ident[id].newText[ident[id].begin[block] + subBlockPosition]; | |
472 else | |
584 | 473 if((ident[id].maintype == FIELD_ON_OFF) || (ident[id].maintype == FIELD_TOGGLE)) |
38 | 474 content = ident[id].input[block]; |
475 else | |
476 content = 0; /* just a default for protection */ | |
477 | |
478 return onActionFunc(ident[id].callerID, block, subBlockPosition, content, action); | |
479 } | |
480 | |
481 void mark_digit_of_actual_id_with_this_block_and_subBlock(int8_t oldblock, int8_t oldsubblockpos) | |
482 { | |
483 char oneCharText[2]; | |
484 uint16_t positionOffset; | |
485 | |
486 if(event[evid].callerID != ident[id].callerID) | |
487 return; | |
488 | |
489 if(ident[id].maintype == FIELD_NUMBERS) | |
490 { | |
491 oneCharText[0] = ident[id].newText[ident[id].begin[oldblock] + oldsubblockpos]; | |
492 oneCharText[1] = 0; | |
493 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[oldblock] + oldsubblockpos); | |
494 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditFieldSelected); | |
495 } | |
496 } | |
497 | |
498 | |
499 void mark_new_2digit_of_actual_id_block(void) | |
500 { | |
501 char oneCharText[3]; | |
502 uint16_t positionOffset; | |
503 | |
504 if(event[evid].callerID != ident[id].callerID) | |
505 return; | |
506 | |
507 if(ident[id].maintype == FIELD_NUMBERS) | |
508 { | |
509 oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0]; | |
510 oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1]; | |
511 oneCharText[2] = 0; | |
512 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0); | |
513 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); | |
514 } | |
515 } | |
516 | |
517 | |
518 void mark_new_3digit_of_actual_id_block(void) | |
519 { | |
520 char oneCharText[4]; | |
521 uint16_t positionOffset; | |
522 | |
523 if(event[evid].callerID != ident[id].callerID) | |
524 return; | |
525 | |
526 if(ident[id].maintype == FIELD_NUMBERS) | |
527 { | |
528 oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0]; | |
529 oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1]; | |
530 oneCharText[2] = ident[id].newText[ident[id].begin[block] + 2]; | |
531 oneCharText[3] = 0; | |
532 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0); | |
533 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); | |
534 } | |
535 } | |
536 | |
537 | |
538 void mark_new_digit_of_actual_id_block_and_subBlock(void) | |
539 { | |
540 char oneCharText[2]; | |
541 uint16_t positionOffset; | |
542 | |
543 if(event[evid].callerID != ident[id].callerID) | |
544 return; | |
545 | |
546 if(ident[id].maintype == FIELD_NUMBERS) | |
547 { | |
548 oneCharText[0] = ident[id].newText[ident[id].begin[block] + subBlockPosition]; | |
549 oneCharText[1] = 0; | |
550 positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + subBlockPosition); | |
551 write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit); | |
552 } | |
553 } | |
554 | |
555 | |
556 void enterMenuEditField(void) | |
557 { | |
558 uint8_t newContent; | |
559 uint8_t digit100; | |
560 uint8_t digit10; | |
561 uint8_t digit1; | |
562 | |
563 evid = 0; | |
564 while((evid < evidLast) && (event[evid].callerID != ident[id].callerID)) | |
565 { | |
566 evid++; | |
567 } | |
568 | |
569 if(event[evid].callerID != ident[id].callerID) | |
570 return; | |
571 | |
572 set_globalState(event[evid].callerID); | |
573 block = 0; | |
574 subBlockPosition = 0; | |
575 | |
576 | |
577 if(ident[id].maintype == FIELD_NUMBERS) | |
578 { | |
579 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); | |
580 // old stuff? hw 150916, reactivated 150923, this shows which digit will be changed now as it marks the other grey/black | |
581 // now fixed for button settings with newContent <= '0'+99 condition | |
582 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldSelected); | |
583 } | |
584 | 584 if(ident[id].maintype == FIELD_TOGGLE) |
585 { | |
586 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor); | |
587 } | |
588 | |
38 | 589 |
590 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_ENTER); | |
591 | |
592 if (((newContent == UPDATE_DIVESETTINGS) || (newContent == UPDATE_AND_EXIT_TO_HOME) || (newContent == UPDATE_AND_EXIT_TO_MENU)) && (actual_menu_content == MENU_SURFACE)) | |
593 createDiveSettings(); | |
594 | |
595 if(newContent == EXIT_TO_MENU_WITH_LOGO) | |
596 { | |
597 GFX_logoAutoOff(); | |
598 } | |
599 | |
600 if((newContent == EXIT_TO_MENU) || (newContent == UPDATE_AND_EXIT_TO_MENU) || (newContent == EXIT_TO_MENU_WITH_LOGO)) | |
601 { | |
602 if(backmenu.pEventFunction == 0) | |
603 exitMenuEdit(1); | |
604 else | |
605 exitMenuEdit_to_BackMenu(); | |
606 return; | |
607 } | |
608 | |
609 if((newContent == EXIT_TO_HOME) || (newContent == UPDATE_AND_EXIT_TO_HOME)) | |
610 { | |
611 exitMenuEdit_to_Home(); | |
612 return; | |
613 } | |
614 | |
615 if(newContent == EXIT_TO_INFO_COMPASS) | |
616 { | |
617 exitMenuEdit_to_InfoCompassCalibration(); | |
618 return; | |
619 } | |
620 | |
718
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
621 if(newContent == EXIT_TO_INFO_SENSOR) |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
622 { |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
623 exitMenuEdit_to_InfoSensor(); |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
624 return; |
b9f699d2e3d0
Updated menu structure to support new sensor information page:
Ideenmodellierer
parents:
707
diff
changeset
|
625 } |
38 | 626 |
627 switch(ident[id].maintype) | |
628 { | |
629 case FIELD_NUMBERS: | |
630 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); | |
631 | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
632 switch (ident[id].subtype) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
633 case FIELD_UDIGIT: |
38 | 634 if((newContent >= '0') && (newContent <= '9')) |
635 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | |
636 | |
637 mark_new_digit_of_actual_id_block_and_subBlock(); | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
638 |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
639 break; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
640 case FIELD_3DIGIT: |
38 | 641 if((newContent >= '0') && (newContent <= '0'+200)) |
642 { | |
643 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); | |
644 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; | |
645 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; | |
646 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; | |
647 mark_new_3digit_of_actual_id_block(); | |
648 } | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
649 |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
650 break; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
651 case FIELD_2DIGIT: |
38 | 652 if((newContent >= '0') && (newContent <= '0'+99)) |
653 { | |
654 ident[id].newText[ident[id].begin[block]] = '0' + (newContent - '0')/10; | |
655 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | |
656 mark_new_2digit_of_actual_id_block(); | |
657 } | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
658 |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
659 break; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
660 case FIELD_SDIGIT: |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
661 if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
662 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
663 } |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
664 |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
665 mark_new_digit_of_actual_id_block_and_subBlock(); |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
666 |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
667 break; |
38 | 668 } |
669 break; | |
670 case FIELD_BUTTON: | |
671 set_globalState(menuID); | |
672 break; | |
673 case FIELD_ON_OFF: | |
674 set_globalState(menuID); | |
675 break; | |
676 case FIELD_SYMBOL: | |
677 ident[id].input[0] += 1; | |
678 if(ident[id].input[0] >= ident[id].input[1]) | |
679 ident[id].input[0] = 0; | |
680 ident[id].newText[0] = ident[id].orgText[ident[id].input[0]]; | |
681 write_content_of_actual_Id(); | |
682 set_globalState(menuID); | |
683 break; | |
684 } | |
685 } | |
686 | |
687 | |
688 void exitMenuEditField(void) | |
689 { | |
690 uint8_t newContent; | |
691 | |
692 set_globalState(menuID); | |
693 | |
694 if(event[evid].callerID != ident[id].callerID) | |
695 return; | |
696 | |
697 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_TIMEOUT); | |
698 | |
699 /* | |
700 uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t); | |
701 uint8_t newContent; | |
702 | |
703 onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[evid].pEventFunction); | |
704 | |
705 newContent = onActionFunc(ident[id].callerID, 0, 0, 255, ACTION_BUTTON_BACK); | |
706 */ | |
707 | |
708 /* destroy changes of editing in newText */ | |
709 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuLineSelected); | |
710 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
711 | |
712 create_newText_for_actual_Id(); | |
713 write_content_of_actual_Id(); | |
714 | |
715 if((newContent == EXIT_TO_MENU) || (newContent == UPDATE_AND_EXIT_TO_MENU)) | |
716 { | |
717 exitMenuEdit(1); | |
718 return; | |
719 } | |
720 | |
721 if((newContent == EXIT_TO_HOME) || (newContent == UPDATE_AND_EXIT_TO_HOME)) | |
722 { | |
723 exitMenuEdit_to_Home(); | |
724 return; | |
725 } | |
726 | |
727 } | |
728 | |
729 void nextMenuEditFieldDigit(void) | |
730 { | |
731 uint8_t action; | |
732 uint8_t newContent; | |
733 int8_t blockOld = 0; | |
734 int8_t subBlockPositionOld = 0; | |
735 | |
736 if(event[evid].callerID != ident[id].callerID) | |
737 return; | |
738 | |
739 blockOld = block; | |
740 subBlockPositionOld = subBlockPosition; | |
741 | |
742 if(inc_subBlock_or_block_of_actual_id()) | |
743 action = ACTION_BUTTON_ENTER; | |
744 else | |
745 action = ACTION_BUTTON_ENTER_FINAL; | |
746 | |
747 newContent = get_newContent_of_actual_id_block_and_subBlock(action); | |
748 | |
749 if(action == ACTION_BUTTON_ENTER_FINAL) | |
750 { | |
751 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
752 | |
753 change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuLineSelected); | |
754 for(int i = 0;i<=9;i++) | |
755 change_CLUT_entry((CLUT_MenuEditField0 + i), CLUT_MenuEditFieldRegular); | |
756 | |
757 if(((newContent == UPDATE_DIVESETTINGS) || (newContent == UPDATE_AND_EXIT_TO_HOME) || (newContent == UPDATE_AND_EXIT_TO_MENU)) && (actual_menu_content == MENU_SURFACE)) | |
758 createDiveSettings(); | |
759 | |
760 if((newContent == EXIT_TO_MENU) || (newContent == UPDATE_AND_EXIT_TO_MENU)) | |
761 { | |
762 exitMenuEdit(1); | |
763 return; | |
764 } | |
765 | |
766 if((newContent == EXIT_TO_HOME) || (newContent == UPDATE_AND_EXIT_TO_HOME)) | |
767 { | |
768 exitMenuEdit_to_Home(); | |
769 return; | |
770 } | |
771 } | |
772 | |
773 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) | |
774 { | |
775 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/100; | |
776 ident[id].newText[ident[id].begin[block] + 1] = '0' + (newContent - '0')/10; | |
777 ident[id].newText[ident[id].begin[block] + 2] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | |
778 } | |
779 else | |
780 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99)) | |
781 { | |
782 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; | |
783 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
784 } else if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT && action == ACTION_BUTTON_ENTER && subBlockPosition == 0) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
785 if (newContent == '+' || newContent == '-') { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
786 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
787 } |
38 | 788 } |
789 else | |
790 if((ident[id].maintype == FIELD_NUMBERS) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9')) | |
791 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; | |
792 | |
793 if(action == ACTION_BUTTON_ENTER) | |
794 { | |
795 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT)) | |
796 { | |
797 mark_new_3digit_of_actual_id_block(); | |
798 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0); | |
799 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,1); | |
800 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,2); | |
801 } | |
802 else | |
803 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT)) | |
804 { | |
805 mark_new_2digit_of_actual_id_block(); | |
806 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0); | |
807 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,1); | |
808 } | |
809 else | |
810 { | |
811 mark_new_digit_of_actual_id_block_and_subBlock(); | |
812 mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,subBlockPositionOld); | |
813 } | |
814 } | |
815 else /* action == ACTION_BUTTON_ENTER_FINAL */ | |
816 set_globalState(menuID); | |
817 } | |
818 | |
819 uint8_t split_Content_to_Digit_helper(uint8_t inContentAscii, uint8_t *outDigit100, uint8_t *outDigit10, uint8_t *outDigit1) | |
820 { | |
821 uint8_t newContent, tempDigit, CopyContent; | |
822 | |
823 newContent = inContentAscii - '0'; | |
824 CopyContent = newContent; | |
825 | |
826 tempDigit = newContent / 100; | |
827 newContent -= tempDigit * 100; | |
828 if(outDigit100) | |
829 *outDigit100 = tempDigit; | |
830 | |
831 tempDigit = newContent / 10; | |
832 newContent -= tempDigit * 10; | |
833 if(outDigit10) | |
834 *outDigit10 = tempDigit; | |
835 | |
836 tempDigit = newContent; | |
837 if(outDigit1) | |
838 *outDigit1 = tempDigit; | |
839 | |
840 return CopyContent; | |
841 } | |
842 | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
843 |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
844 static void checkUpdateSDigit(uint8_t newContent) |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
845 { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
846 if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
847 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
848 } |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
849 } |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
850 |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
851 |
38 | 852 void upMenuEditFieldDigit(void) |
853 { | |
854 uint8_t newContent; | |
855 uint8_t digit100; | |
856 uint8_t digit10; | |
857 uint8_t digit1; | |
858 | |
859 if(event[evid].callerID != ident[id].callerID) | |
860 return; | |
861 | |
862 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_NEXT); | |
863 | |
864 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) | |
865 { | |
866 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); | |
867 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; | |
868 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; | |
869 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; | |
870 mark_new_3digit_of_actual_id_block(); | |
871 return; | |
872 } | |
873 | |
874 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) | |
875 { | |
876 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; | |
877 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | |
878 mark_new_2digit_of_actual_id_block(); | |
879 return; | |
880 } | |
881 | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
882 if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
883 checkUpdateSDigit(newContent); |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
884 } else if (ident[id].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { |
38 | 885 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
886 } |
38 | 887 |
888 mark_new_digit_of_actual_id_block_and_subBlock(); | |
889 } | |
890 | |
891 | |
892 void downMenuEditFieldDigit(void) | |
893 { | |
894 uint8_t newContent; | |
895 uint8_t digit100; | |
896 uint8_t digit10; | |
897 uint8_t digit1; | |
898 | |
899 if(event[evid].callerID != ident[id].callerID) | |
900 return; | |
901 | |
902 newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_BACK); | |
903 | |
904 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200)) | |
905 { | |
906 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1); | |
907 ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100; | |
908 ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10; | |
909 ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1; | |
910 mark_new_3digit_of_actual_id_block(); | |
911 return; | |
912 } | |
913 | |
914 if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99)) | |
915 { | |
916 ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10; | |
917 ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10))); | |
918 mark_new_2digit_of_actual_id_block(); | |
919 return; | |
920 } | |
921 | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
922 if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
923 checkUpdateSDigit(newContent); |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
924 } else if (ident[id].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') { |
38 | 925 ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent; |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
926 } |
38 | 927 |
928 mark_new_digit_of_actual_id_block_and_subBlock(); | |
929 } | |
930 | |
931 | |
932 void evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4) | |
933 { | |
934 if(editID != ident[id].callerID) | |
935 return; | |
936 | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
937 bool isSigned = ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
938 |
38 | 939 uint8_t i, digitCount, digit; |
940 uint32_t sum[4], multiplier; | |
941 | |
942 for(i=0;i<4;i++) | |
943 sum[i] = 0; | |
944 | |
945 i = 0; | |
946 while( ident[id].size[i] && (i < 4)) | |
947 { | |
948 multiplier = 1; | |
949 for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++) | |
950 multiplier *= 10; | |
951 | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
952 bool isNegative = false; |
38 | 953 for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++) |
954 { | |
955 digit = ident[id].newText[ident[id].begin[i] + digitCount]; | |
956 | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
957 if (isSigned && digitCount == 0) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
958 if (digit == '-') { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
959 isNegative = true; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
960 } |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
961 } else { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
962 if(digit > '0') |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
963 digit -= '0'; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
964 else |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
965 digit = 0; |
38 | 966 |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
967 if(digit > 9) |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
968 digit = 9; |
38 | 969 |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
970 sum[i] += digit * multiplier; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
971 } |
38 | 972 |
973 if(multiplier >= 10) | |
974 multiplier /= 10; | |
975 else | |
976 multiplier = 0; | |
977 } | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
978 |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
979 if (isSigned) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
980 int32_t value = sum[i]; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
981 if (isNegative) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
982 value = -value; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
983 } |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
984 sum[i] = ((input_u)value).uint32; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
985 } |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
986 |
38 | 987 i++; |
988 } | |
989 | |
990 *pNewValue1 = sum[0]; | |
991 *pNewValue2 = sum[1]; | |
992 *pNewValue3 = sum[2]; | |
993 *pNewValue4 = sum[3]; | |
994 } | |
995 | |
996 | |
997 uint8_t get_id_of(uint32_t editID) | |
998 { | |
999 uint8_t temp_id; | |
1000 | |
1001 if(editID == ident[id].callerID) | |
1002 return id; | |
1003 else | |
1004 { | |
1005 temp_id = 0; | |
1006 while((temp_id < 9) && (editID != ident[temp_id].callerID)) | |
1007 temp_id++; | |
1008 if(editID != ident[temp_id].callerID) | |
1009 temp_id = 255; | |
1010 return temp_id; | |
1011 } | |
1012 } | |
1013 | |
1014 | |
1015 void tMenuEdit_newButtonText(uint32_t editID, char *text) | |
1016 { | |
1017 uint8_t backup_id, temp_id; | |
1018 | |
1019 temp_id = get_id_of(editID); | |
1020 if(temp_id == 255) | |
1021 return; | |
1022 | |
1023 backup_id = id; | |
1024 id = temp_id; | |
1025 | |
1026 strncpy(ident[id].newText, text, 32); | |
1027 ident[id].newText[31] = 0; | |
1028 | |
1029 clean_content_of_actual_Id(); | |
1030 write_content_of_actual_Id(); | |
1031 | |
1032 id = backup_id; | |
1033 } | |
1034 | |
1035 | |
1036 void tMenuEdit_set_on_off(uint32_t editID, uint32_t int1) | |
1037 { | |
1038 uint8_t backup_id, temp_id; | |
1039 | |
1040 temp_id = get_id_of(editID); | |
1041 if(temp_id == 255) | |
1042 return; | |
1043 | |
1044 backup_id = id; | |
1045 id = temp_id; | |
1046 | |
1047 ident[id].input[0] = int1; | |
1048 | |
1049 if(int1) | |
1050 ident[id].newText[0] = '\005'; | |
1051 else | |
1052 ident[id].newText[0] = '\006'; | |
1053 | |
1054 clean_content_of_actual_Id(); | |
1055 write_content_of_actual_Id(); | |
1056 | |
1057 id = backup_id; | |
1058 } | |
1059 | |
508 | 1060 void tMenuEdit_select(uint32_t editID) |
1061 { | |
1062 uint8_t id_local = 0; | |
1063 id_local = get_id_of(editID); | |
38 | 1064 |
508 | 1065 if(id_local <= idLast) |
1066 { | |
1067 id = id_local; | |
1068 set_cursorNew(id); | |
1069 } | |
1070 } | |
1071 | |
1072 #if OLD_SELECTION | |
38 | 1073 void tMenuEdit_select(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) |
1074 { | |
1075 if(int1 > 4) | |
1076 return; | |
1077 | |
1078 uint8_t backup_id, temp_id; | |
1079 | |
1080 temp_id = get_id_of(editID); | |
1081 if(temp_id == 255) | |
1082 return; | |
1083 | |
1084 backup_id = id; | |
1085 id = temp_id; | |
1086 | |
1087 ident[id].input[0] = int1; | |
1088 ident[id].input[1] = int1; | |
1089 ident[id].input[2] = int1; | |
1090 ident[id].input[3] = int1; | |
1091 | |
1092 create_newText_for_actual_Id(); | |
1093 clean_content_of_actual_Id(); | |
1094 write_content_of_actual_Id(); | |
1095 | |
1096 id = backup_id; | |
1097 } | |
508 | 1098 #endif |
38 | 1099 |
1100 | |
1101 void tMenuEdit_newInput(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | |
1102 { | |
1103 uint8_t backup_id, temp_id; | |
1104 | |
1105 temp_id = get_id_of(editID); | |
1106 if(temp_id == 255) | |
1107 return; | |
1108 | |
1109 backup_id = id; | |
1110 id = temp_id; | |
1111 | |
1112 if(editID != ident[id].callerID) | |
1113 { | |
1114 temp_id = 0; | |
1115 while((temp_id < 9) && (editID != ident[temp_id].callerID)) | |
1116 temp_id++; | |
1117 if(editID != ident[temp_id].callerID) | |
1118 return; | |
1119 id = temp_id; | |
1120 } | |
1121 ident[id].input[0] = int1; | |
1122 ident[id].input[1] = int2; | |
1123 ident[id].input[2] = int3; | |
1124 ident[id].input[3] = int4; | |
1125 | |
1126 create_newText_for_actual_Id(); | |
1127 if(id <= idLast) | |
1128 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1129 write_content_of_actual_Id(); | |
1130 | |
1131 id = backup_id; | |
1132 } | |
1133 | |
1134 | |
1135 void resetEnterPressedToStateBeforeButtonAction(void) | |
1136 { | |
1137 EnterPressed = EnterPressedBeforeButtonAction; | |
1138 } | |
1139 | |
1140 | |
1141 void sendActionToMenuEdit(uint8_t sendAction) | |
1142 { | |
1143 if(get_globalState() == menuID) | |
1144 { | |
1145 switch(sendAction) | |
1146 { | |
1147 case ACTION_BUTTON_ENTER: | |
1148 EnterPressedBeforeButtonAction = EnterPressed; | |
1149 EnterPressed = 1; | |
1150 enterMenuEditField(); | |
1151 break; | |
1152 case ACTION_BUTTON_NEXT: | |
1153 nextMenuEditField(); | |
1154 // previousMenuEditField(); | |
1155 break; | |
1156 case ACTION_BUTTON_BACK: | |
1157 exitMenuEditBackMenuOption(); | |
1158 break; | |
1159 case ACTION_TIMEOUT: | |
1160 case ACTION_MODE_CHANGE: | |
1161 exitMenuEdit(1); | |
1162 break; | |
1163 case ACTION_IDLE_TICK: | |
1164 case ACTION_IDLE_SECOND: | |
219 | 1165 default: |
38 | 1166 break; |
219 | 1167 |
38 | 1168 } |
1169 } | |
1170 else | |
1171 if(get_globalState() == event[evid].callerID) | |
1172 { | |
1173 switch(sendAction) | |
1174 { | |
1175 case ACTION_BUTTON_ENTER: | |
1176 nextMenuEditFieldDigit(); | |
1177 break; | |
1178 case ACTION_BUTTON_NEXT: | |
1179 upMenuEditFieldDigit(); | |
1180 break; | |
1181 case ACTION_BUTTON_BACK: | |
1182 downMenuEditFieldDigit(); | |
1183 break; | |
1184 case ACTION_TIMEOUT: | |
1185 case ACTION_MODE_CHANGE: | |
1186 exitMenuEditField(); | |
1187 break; | |
1188 case ACTION_IDLE_TICK: | |
1189 case ACTION_IDLE_SECOND: | |
1190 break; | |
219 | 1191 default: |
1192 break; | |
38 | 1193 } |
1194 } | |
1195 else | |
1196 { | |
1197 switch(sendAction) | |
1198 { | |
1199 case ACTION_BUTTON_ENTER: | |
1200 break; | |
1201 case ACTION_BUTTON_NEXT: | |
1202 break; | |
1203 case ACTION_BUTTON_BACK: | |
1204 break; | |
1205 case ACTION_TIMEOUT: | |
1206 case ACTION_MODE_CHANGE: | |
1207 exitMenuEdit(1); | |
1208 break; | |
1209 case ACTION_IDLE_TICK: | |
1210 case ACTION_IDLE_SECOND: | |
1211 break; | |
219 | 1212 default: |
1213 break; | |
38 | 1214 } |
1215 } | |
1216 } | |
1217 | |
1218 | |
1219 void create_newText_for_actual_Id_and_field_select(void) | |
1220 { | |
1221 uint8_t i; | |
1222 | |
1223 i = 0; | |
1224 while( ident[id].size[i] && (i < 4)) | |
1225 { | |
1226 if(ident[id].input[i]) | |
1227 ident[id].newText[ident[id].begin[i]] = '\005'; | |
1228 else | |
1229 ident[id].newText[ident[id].begin[i]] = '\006'; | |
1230 i++; | |
1231 } | |
1232 } | |
1233 | |
1234 | |
1235 void create_newText_for_actual_Id(void) | |
1236 { | |
1237 if( ident[id].maintype == FIELD_SELECT) | |
1238 { | |
1239 create_newText_for_actual_Id_and_field_select(); | |
1240 return; | |
1241 } | |
1242 | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1243 bool isSigned = ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1244 |
38 | 1245 uint8_t i, digitCount; |
1246 uint32_t remainder, digit, divider; | |
1247 | |
1248 i = 0; | |
1249 while( ident[id].size[i] && (i < 4)) | |
1250 { | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1251 bool isNegative = false; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1252 if (isSigned) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1253 int32_t value = ((input_u)ident[id].input[i]).int32; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1254 if (value < 0) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1255 isNegative = true; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1256 } |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1257 remainder = abs(value); |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1258 } else { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1259 remainder = ident[id].input[i]; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1260 } |
38 | 1261 divider = 1; |
1262 | |
1263 for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++) | |
1264 divider *= 10; | |
1265 | |
1266 for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++) | |
1267 { | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1268 if (isSigned && digitCount == 0) { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1269 ident[id].newText[ident[id].begin[i] + digitCount] = isNegative ? '-' : '+'; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1270 } else { |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1271 digit = remainder / divider; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1272 remainder -= digit * divider; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1273 if(digit < 10) |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1274 ident[id].newText[ident[id].begin[i] + digitCount] = digit + '0'; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1275 else |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1276 ident[id].newText[ident[id].begin[i] + digitCount] = 'x'; |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1277 } |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1278 |
38 | 1279 divider /= 10; |
1280 } | |
1281 i++; | |
1282 } | |
1283 } | |
1284 | |
1285 | |
1286 void write_content_without_Id(void) | |
1287 { | |
1288 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, CLUT_MenuEditFieldRegular); | |
1289 } | |
1290 | |
1291 | |
1292 void write_content_of_actual_Id(void) | |
1293 { | |
1294 write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, (CLUT_MenuEditField0 + id)); | |
1295 } | |
1296 | |
1297 | |
1298 void clean_content_of_actual_Id(void) | |
1299 { | |
1300 clean_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed); | |
1301 } | |
1302 | |
1303 | |
1304 void write_field_udigit_and_2digit(uint8_t subtype, uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | |
1305 { | |
1306 if(id >= 9) | |
1307 return; | |
1308 | |
1309 ident[id].maintype = FIELD_NUMBERS; | |
1310 ident[id].subtype = subtype; | |
1311 | |
1312 ident[id].coord[0] = XleftGimpStyle; | |
1313 ident[id].coord[1] = XrightGimpStyle; | |
1314 ident[id].coord[2] = YtopGimpStyle; | |
1315 ident[id].fontUsed = (tFont *)Font; | |
1316 ident[id].callerID = editID; | |
1317 | |
1318 strncpy(ident[id].orgText, text, 32); | |
1319 strncpy(ident[id].newText, text, 32); | |
1320 ident[id].orgText[31] = 0; | |
1321 ident[id].newText[31] = 0; | |
1322 | |
1323 /* uint32_t has max 10 digits */ | |
1324 | |
1325 int8_t beginTmp, sizeTmp; | |
1326 uint8_t i; | |
1327 | |
1328 ident[id].input[0] = int1; | |
1329 ident[id].input[1] = int2; | |
1330 ident[id].input[2] = int3; | |
1331 ident[id].input[3] = int4; | |
1332 | |
1333 for(i=0;i<4;i++) | |
1334 ident[id].size[i] = 0; | |
1335 | |
1336 beginTmp = 0; | |
1337 for(i=0;i<4;i++) | |
1338 { | |
1339 while((ident[id].orgText[beginTmp] != '#')&& ident[id].orgText[beginTmp]) | |
1340 beginTmp++; | |
1341 | |
1342 if(ident[id].orgText[beginTmp] == '#') | |
1343 { | |
1344 sizeTmp = 1; | |
1345 while(ident[id].orgText[beginTmp + sizeTmp] == '#') | |
1346 sizeTmp++; | |
1347 | |
1348 ident[id].begin[i] = beginTmp; | |
1349 ident[id].size[i] = sizeTmp; | |
1350 beginTmp = ident[id].begin[i] + ident[id].size[i]; | |
1351 } | |
1352 else | |
1353 break; | |
1354 } | |
1355 | |
1356 if(!tME_stop) | |
1357 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1358 else | |
1359 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo); | |
1360 | |
1361 create_newText_for_actual_Id(); | |
1362 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1363 if(editID == 0) |
38 | 1364 write_content_without_Id(); |
1365 else | |
1366 { | |
1367 write_content_of_actual_Id(); | |
1368 if(!tME_stop) | |
1369 idLast = id; | |
1370 id++; | |
1371 } | |
1372 } | |
1373 | |
1374 void write_field_udigit(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | |
1375 { | |
1376 write_field_udigit_and_2digit(FIELD_UDIGIT, editID,XleftGimpStyle,XrightGimpStyle,YtopGimpStyle,Font,text,int1,int2,int3,int4); | |
1377 } | |
1378 | |
1379 void write_field_2digit(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | |
1380 { | |
1381 write_field_udigit_and_2digit(FIELD_2DIGIT, editID,XleftGimpStyle,XrightGimpStyle,YtopGimpStyle,Font,text,int1,int2,int3,int4); | |
1382 } | |
1383 | |
1384 void write_field_3digit(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) | |
1385 { | |
1386 write_field_udigit_and_2digit(FIELD_3DIGIT, editID,XleftGimpStyle,XrightGimpStyle,YtopGimpStyle,Font,text,int1,int2,int3,int4); | |
1387 } | |
1388 | |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1389 |
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1390 void write_field_sdigit(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, int32_t int1, int32_t int2, int32_t int3, int32_t int4) |
38 | 1391 { |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1392 write_field_udigit_and_2digit(FIELD_SDIGIT, editID, XleftGimpStyle, XrightGimpStyle, YtopGimpStyle, Font, text, ((input_u)int1).uint32, ((input_u)int2).uint32, ((input_u)int3).uint32, ((input_u)int4).uint32); |
38 | 1393 } |
776
45b8f3c2acce
Add support for a configurable compass declination in a range of -99 to 99 degrees.
heinrichsweikamp
parents:
774
diff
changeset
|
1394 |
38 | 1395 |
1396 void write_field_select(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1, uint8_t int2, uint8_t int3, uint8_t int4) | |
1397 { | |
1398 if(id >= 9) | |
1399 return; | |
1400 | |
1401 int8_t beginTmp; | |
1402 | |
1403 ident[id].maintype = FIELD_SELECT; | |
1404 ident[id].subtype = FIELD_SELECT; | |
1405 | |
1406 ident[id].coord[0] = XleftGimpStyle; | |
1407 ident[id].coord[1] = XrightGimpStyle; | |
1408 ident[id].coord[2] = YtopGimpStyle; | |
1409 ident[id].fontUsed = (tFont *)Font; | |
1410 ident[id].callerID = editID; | |
1411 | |
1412 strncpy(ident[id].orgText, text, 32); | |
1413 strncpy(ident[id].newText, text, 32); | |
1414 ident[id].orgText[31] = 0; | |
1415 ident[id].newText[31] = 0; | |
1416 | |
1417 ident[id].input[0] = int1; | |
1418 ident[id].input[1] = int2; | |
1419 ident[id].input[2] = int3; | |
1420 ident[id].input[3] = int4; | |
1421 | |
1422 for(int i=0;i<4;i++) | |
1423 ident[id].size[i] = 0; | |
1424 | |
1425 beginTmp = 0; | |
1426 for(int i=0;i<4;i++) | |
1427 { | |
1428 while((ident[id].orgText[beginTmp] != '#')&& ident[id].orgText[beginTmp]) | |
1429 beginTmp++; | |
1430 | |
1431 if(ident[id].orgText[beginTmp] == '#') | |
1432 { | |
1433 | |
1434 ident[id].begin[i] = beginTmp; | |
1435 ident[id].size[i] = 1; | |
1436 beginTmp = ident[id].begin[i] + ident[id].size[i]; | |
1437 } | |
1438 else | |
1439 break; | |
1440 } | |
1441 | |
1442 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1443 | |
1444 create_newText_for_actual_Id(); | |
1445 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1446 if(editID == 0) |
38 | 1447 write_content_without_Id(); |
1448 else | |
1449 { | |
1450 write_content_of_actual_Id(); | |
1451 if(!tME_stop) | |
1452 idLast = id; | |
1453 id++; | |
1454 } | |
1455 } | |
1456 | |
1457 void write_field_button(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
1458 { | |
1459 if(id >= 9) | |
1460 return; | |
1461 | |
1462 ident[id].maintype = FIELD_BUTTON; | |
1463 ident[id].subtype = FIELD_BUTTON; | |
1464 | |
1465 ident[id].coord[0] = XleftGimpStyle; | |
1466 ident[id].coord[1] = XrightGimpStyle; | |
1467 ident[id].coord[2] = YtopGimpStyle; | |
1468 ident[id].fontUsed = (tFont *)Font; | |
1469 ident[id].callerID = editID; | |
1470 | |
1471 strncpy(ident[id].orgText, text, 32); | |
1472 strncpy(ident[id].newText, text, 32); | |
1473 ident[id].orgText[31] = 0; | |
1474 ident[id].newText[31] = 0; | |
1475 | |
1476 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1); | |
1477 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1478 if(editID == 0) |
38 | 1479 write_content_without_Id(); |
1480 else | |
1481 { | |
1482 write_content_of_actual_Id(); | |
1483 if(!tME_stop) | |
1484 idLast = id; | |
1485 id++; | |
1486 } | |
1487 } | |
1488 | |
1489 | |
1490 void write_field_symbol(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1) | |
1491 { | |
1492 if(id >= 9) | |
1493 return; | |
1494 | |
1495 ident[id].maintype = FIELD_SYMBOL; | |
1496 ident[id].subtype = FIELD_SYMBOL; | |
1497 | |
1498 ident[id].coord[0] = XleftGimpStyle; | |
1499 ident[id].coord[1] = XrightGimpStyle; | |
1500 ident[id].coord[2] = YtopGimpStyle; | |
1501 ident[id].fontUsed = (tFont *)Font; | |
1502 ident[id].callerID = editID; | |
1503 | |
1504 strncpy(ident[id].orgText, text, 32); | |
1505 strncpy(ident[id].newText, text, 32); | |
1506 ident[id].orgText[31] = 0; | |
1507 | |
1508 ident[id].newText[0] = text[0]; | |
1509 ident[id].newText[1] = 0; | |
1510 | |
1511 ident[id].input[0] = int1; | |
1512 ident[id].input[1] = strlen(ident[id].orgText); | |
1513 | |
1514 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1); | |
1515 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1516 if(editID == 0) |
38 | 1517 write_content_without_Id(); |
1518 else | |
1519 { | |
1520 write_content_of_actual_Id(); | |
1521 if(!tME_stop) | |
1522 idLast = id; | |
1523 id++; | |
1524 } | |
1525 } | |
584 | 1526 void write_field_toggle(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1, uint8_t int2) |
1527 { | |
1528 if(id >= 9) return; | |
1529 ident[id].maintype = FIELD_TOGGLE; | |
1530 ident[id].subtype = FIELD_TOGGLE; | |
1531 ident[id].coord[0] = XleftGimpStyle; | |
1532 ident[id].coord[1] = XrightGimpStyle; | |
1533 ident[id].coord[2] = YtopGimpStyle; | |
1534 ident[id].fontUsed = (tFont *)Font; | |
1535 ident[id].callerID = editID; | |
1536 strncpy(ident[id].orgText, text, 32); | |
1537 strncpy(ident[id].newText, text, 32); | |
1538 ident[id].orgText[31] = 0; | |
1539 ident[id].newText[31] = 0; | |
1540 | |
1541 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditButtonColor1); | |
1542 | |
1543 if(editID == 0) write_content_without_Id(); | |
1544 else | |
1545 { | |
1546 write_content_of_actual_Id(); | |
1547 if(!tME_stop) idLast = id; | |
1548 id++; | |
1549 } | |
1550 } | |
1551 | |
38 | 1552 |
1553 | |
1554 /* was build for field_on_off | |
1555 * to be tested for other purposes first | |
1556 */ | |
1557 void tMenuEdit_refresh_field(uint32_t editID) | |
1558 { | |
1559 uint8_t temp_id; | |
1560 | |
1561 temp_id = get_id_of(editID); | |
1562 if(temp_id == 255) | |
1563 return; | |
1564 | |
1565 clean_content( ident[temp_id].coord[0], ident[temp_id].coord[1], ident[temp_id].coord[2], ident[temp_id].fontUsed); | |
1566 write_content( ident[temp_id].coord[0], ident[temp_id].coord[1], ident[temp_id].coord[2], ident[temp_id].fontUsed, ident[temp_id].newText, (CLUT_MenuEditField0 + temp_id)); | |
1567 } | |
1568 | |
1569 | |
1570 void 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) | |
1571 { | |
1572 if(id >= 9) | |
1573 return; | |
1574 | |
1575 ident[id].maintype = FIELD_ON_OFF; | |
1576 ident[id].subtype = FIELD_ON_OFF; | |
1577 | |
1578 ident[id].coord[0] = XleftGimpStyle; | |
1579 ident[id].coord[1] = XrightGimpStyle; | |
1580 ident[id].coord[2] = YtopGimpStyle; | |
1581 ident[id].fontUsed = (tFont *)Font; | |
1582 ident[id].callerID = editID; | |
1583 | |
1584 if(int1) | |
1585 ident[id].orgText[0] = '\005'; | |
1586 else | |
1587 ident[id].orgText[0] = '\006'; | |
1588 | |
1589 ident[id].orgText[1] = ' '; | |
1590 | |
1591 strncpy(&ident[id].orgText[2], text, 30); | |
1592 strncpy(ident[id].newText, ident[id].orgText, 32); | |
1593 ident[id].orgText[31] = 0; | |
1594 ident[id].newText[31] = 0; | |
1595 | |
1596 if(!tME_stop) | |
1597 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1598 else | |
1599 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo); | |
1600 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1601 if(editID == 0) |
38 | 1602 write_content_without_Id(); |
1603 else | |
1604 { | |
1605 write_content_of_actual_Id(); | |
1606 if(!tME_stop) | |
1607 idLast = id; | |
1608 id++; | |
1609 } | |
1610 } | |
1611 | |
1612 | |
1613 void write_field_fpoint(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, float input) | |
1614 { | |
1615 if(id >= 9) | |
1616 return; | |
1617 | |
1618 ident[id].maintype = FIELD_NUMBERS; | |
1619 ident[id].subtype = FIELD_FLOAT; | |
1620 | |
1621 ident[id].coord[0] = XleftGimpStyle; | |
1622 ident[id].coord[1] = XrightGimpStyle; | |
1623 ident[id].coord[2] = YtopGimpStyle; | |
1624 ident[id].fontUsed = (tFont *)Font; | |
1625 ident[id].callerID = editID; | |
1626 | |
1627 strncpy(ident[id].orgText, text, 32); | |
1628 strncpy(ident[id].newText, text, 32); | |
1629 ident[id].orgText[31] = 0; | |
1630 ident[id].newText[31] = 0; | |
1631 | |
1632 change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular); | |
1633 | |
166
255eedad4155
cleanup: get rid of some compile warnings
Jan Mulder <jlmulder@xs4all.nl>
parents:
138
diff
changeset
|
1634 if(editID == 0) |
38 | 1635 write_content_without_Id(); |
1636 else | |
1637 { | |
1638 write_content_of_actual_Id(); | |
1639 if(!tME_stop) | |
1640 idLast = id; | |
1641 id++; | |
1642 } | |
1643 } | |
1644 | |
1645 | |
1646 void setBackMenu(uint32_t inputFunctionCall, uint8_t functionCallParameter, uint8_t gotoMenuEditField) | |
1647 { | |
1648 backmenu.pEventFunction = inputFunctionCall; | |
1649 backmenu.functionParameter = functionCallParameter; | |
1650 backmenu.line = gotoMenuEditField; | |
1651 } | |
1652 | |
1653 | |
1654 void setEvent(uint32_t inputEventID, uint32_t inputFunctionCall) | |
1655 { | |
1656 if(evidLast >= 9) | |
1657 return; | |
1658 | |
1659 /* set cursor to first field */ | |
1660 if(evidLast < 0) | |
1661 { | |
1662 startMenuEditFieldSelect(); | |
1663 } | |
1664 | |
1665 event[evid].callerID = inputEventID; | |
1666 event[evid].pEventFunction = inputFunctionCall; | |
1667 | |
1668 evidLast = evid; | |
1669 evid++; | |
1670 } | |
1671 | |
1672 void startEdit(void) | |
1673 { | |
1674 EnterPressed = 1; | |
1675 helperGotoMenuEditField(0); | |
1676 enterMenuEditField(); | |
1677 } | |
1678 | |
1679 void exitEditWithUpdate(void) | |
1680 { | |
1681 createDiveSettings(); | |
1682 EnterPressed = 1; | |
1683 exitMenuEdit(1); | |
1684 } | |
1685 | |
1686 /* | |
1687 void set_cursor(uint8_t forThisIdentID) | |
1688 { | |
1689 int16_t x0, x1, y0, y1; | |
1690 | |
1691 uint32_t xtra_left_right = 10; | |
1692 uint32_t xtra_top_bottom = 10; | |
1693 | |
1694 // y geht von 0 bis 799 | |
1695 // x geht von 0 bis 479 | |
1696 | |
1697 x0 = (int16_t)ident[forThisIdentID].coord[0]; | |
1698 x1 = (int16_t)ident[forThisIdentID].coord[1]; | |
1699 y0 = (int16_t)ident[forThisIdentID].coord[2]; | |
1700 y1 = y0 + (int16_t)ident[forThisIdentID].fontUsed->height; | |
1701 | |
1702 if(((int16_t)ident[forThisIdentID].fontUsed->height) > 70) | |
1703 { | |
1704 xtra_left_right = 10; | |
1705 xtra_top_bottom = 10; | |
1706 } | |
1707 else | |
1708 { | |
1709 xtra_left_right = 10; | |
1710 xtra_top_bottom = 0; | |
1711 } | |
1712 | |
1713 x0 -= xtra_left_right; | |
1714 x1 += xtra_left_right; | |
1715 y0 -= xtra_top_bottom; | |
1716 y1 += xtra_top_bottom; | |
1717 | |
1718 GFX_SetWindowLayer0(tMEcursor.FBStartAdress, x0, x1, y0, y1); | |
1719 } | |
1720 */ | |
1721 | |
1722 void set_cursorNew(uint8_t forThisIdentID) | |
1723 { | |
1724 int16_t y0; | |
1725 uint8_t lineMinusOne; | |
1726 | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1727 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1728 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1729 y0 = (int16_t)ident[forThisIdentID].coord[2]; |
117 | 1730 y0 -= ME_Y_LINE1; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1731 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1732 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1733 { |
117 | 1734 y0 = 390 + 25 - (int16_t)ident[forThisIdentID].coord[2]; |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1735 } |
117 | 1736 |
38 | 1737 y0 /= ME_Y_LINE_STEP; |
117 | 1738 if((y0 >= 0) && (y0 <=6)) |
38 | 1739 lineMinusOne = y0; |
1740 else | |
1741 lineMinusOne = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1742 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1743 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1744 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1745 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress) + 65*2*(lineMinusOne), 0, 25, 800, 390); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1746 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1747 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1748 { |
117 | 1749 GFX_SetFrameBottom((tMEcursorNew.FBStartAdress)+ (390 - 65 *(6-lineMinusOne)) *2, 0, 480-390-25, 800, 390); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1750 } |
38 | 1751 } |
1752 | |
1753 | |
1754 void write_topline( char *text) | |
1755 { | |
1756 GFX_DrawCfgWindow hgfx; | |
1757 const tFont *Font = &FontT48; | |
1758 | |
1759 hgfx.Image = &tMEscreen; | |
1760 hgfx.WindowNumberOfTextLines = 1; | |
1761 hgfx.WindowLineSpacing = 0; | |
1762 hgfx.WindowTab = 0; | |
1763 hgfx.WindowX0 = 20; | |
1764 hgfx.WindowX1 = 779; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1765 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1766 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1767 hgfx.WindowY1 = 479; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1768 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1769 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1770 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1771 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1772 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1773 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1774 } |
38 | 1775 GFX_write_label(Font, &hgfx, text, menuColor); |
1776 } | |
1777 | |
1778 | |
1779 void write_buttonTextline( uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode) | |
1780 { | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1781 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1782 SSettings* pSettings; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1783 pSettings = settingsGetPointer(); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1784 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1785 if(!pSettings->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1786 { |
117 | 1787 GFX_clean_area(&tMEscreen, 0, 800, 479-24,480); |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1788 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1789 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1790 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1791 GFX_clean_area(&tMEscreen, 0, 800, 0, 24); |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1792 } |
38 | 1793 |
1794 char localtext[32]; | |
1795 | |
1796 if(left2ByteCode) | |
1797 { | |
1798 localtext[0] = TXT_2BYTE; | |
1799 localtext[1] = left2ByteCode; | |
1800 localtext[2] = 0; | |
117 | 1801 |
1802 write_content_simple(&tMEscreen, 0, 800, 479-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
38 | 1803 } |
1804 | |
1805 if(middle2ByteCode) | |
1806 { | |
1807 localtext[0] = '\001'; | |
1808 localtext[1] = TXT_2BYTE; | |
1809 localtext[2] = middle2ByteCode; | |
1810 localtext[3] = 0; | |
117 | 1811 |
1812 write_content_simple(&tMEscreen, 0, 800, 479-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
38 | 1813 } |
1814 | |
1815 if(right2ByteCode) | |
1816 { | |
1817 localtext[0] = '\002'; | |
1818 localtext[1] = TXT_2BYTE; | |
1819 localtext[2] = right2ByteCode; | |
1820 localtext[3] = 0; | |
117 | 1821 |
1822 write_content_simple(&tMEscreen, 0, 800, 479-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen); | |
38 | 1823 } |
1824 } | |
1825 | |
1826 | |
1827 | |
1828 void write_label_var(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text) | |
1829 { | |
1830 GFX_DrawCfgWindow hgfx; | |
1831 | |
1832 if(XrightGimpStyle > 799) | |
1833 XrightGimpStyle = 799; | |
1834 if(XleftGimpStyle >= XrightGimpStyle) | |
1835 XleftGimpStyle = 0; | |
1836 if(YtopGimpStyle > 479) | |
1837 YtopGimpStyle = 479; | |
1838 hgfx.Image = &tMEscreen; | |
1839 hgfx.WindowNumberOfTextLines = 1; | |
1840 hgfx.WindowLineSpacing = 0; | |
1841 hgfx.WindowTab = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1842 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1843 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1844 hgfx.WindowX0 = XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1845 hgfx.WindowX1 = XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1846 hgfx.WindowY1 = 479 - YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1847 if(hgfx.WindowY1 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1848 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1849 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1850 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1851 } |
38 | 1852 else |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1853 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1854 hgfx.WindowX0 = 800 - XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1855 hgfx.WindowX1 = 800 - XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1856 hgfx.WindowY0 = YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1857 if(hgfx.WindowY0 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1858 hgfx.WindowY1 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1859 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1860 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1861 } |
38 | 1862 GFX_write_label(Font, &hgfx, text, 0);/*menuColor);*/ |
1863 } | |
1864 | |
1865 | |
1866 void write_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color) | |
1867 { | |
1868 GFX_DrawCfgWindow hgfx; | |
1869 | |
1870 if(XrightGimpStyle > 799) | |
1871 XrightGimpStyle = 799; | |
1872 if(XleftGimpStyle >= XrightGimpStyle) | |
1873 XleftGimpStyle = 0; | |
1874 if(YtopGimpStyle > 479) | |
1875 YtopGimpStyle = 479; | |
1876 hgfx.Image = &tMEscreen; | |
1877 hgfx.WindowNumberOfTextLines = 1; | |
1878 hgfx.WindowLineSpacing = 0; | |
1879 hgfx.WindowTab = 0; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1880 |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1881 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1882 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1883 hgfx.WindowX0 = XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1884 hgfx.WindowX1 = XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1885 hgfx.WindowY1 = 479 - YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1886 if(hgfx.WindowY1 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1887 hgfx.WindowY0 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1888 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1889 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1890 } |
38 | 1891 else |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1892 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1893 hgfx.WindowX0 = 800 - XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1894 hgfx.WindowX1 = 800 - XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1895 hgfx.WindowY0 = YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1896 if(hgfx.WindowY0 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1897 hgfx.WindowY1 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1898 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1899 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1900 } |
38 | 1901 GFX_write_label(Font, &hgfx, text, color); |
1902 } | |
1903 | |
1904 | |
1905 void write_label_fix(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char textId) | |
1906 { | |
1907 char text[2]; | |
1908 | |
1909 text[0] = textId; | |
1910 text[1] = 0; | |
1911 | |
1912 write_label_var(XleftGimpStyle, XrightGimpStyle, YtopGimpStyle, Font, text); | |
1913 } | |
1914 | |
1915 | |
1916 void clean_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font) | |
1917 { | |
1918 GFX_DrawCfgWindow hgfx; | |
1919 | |
1920 if(XrightGimpStyle > 799) | |
1921 XrightGimpStyle = 799; | |
1922 if(XleftGimpStyle >= XrightGimpStyle) | |
1923 XleftGimpStyle = 0; | |
1924 if(YtopGimpStyle > 479) | |
1925 YtopGimpStyle = 479; | |
1926 hgfx.Image = &tMEscreen; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1927 if(!settingsGetPointer()->FlipDisplay) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1928 { |
38 | 1929 hgfx.WindowX0 = XleftGimpStyle; |
1930 hgfx.WindowX1 = XrightGimpStyle; | |
1931 hgfx.WindowY1 = 479 - YtopGimpStyle; | |
1932 if(hgfx.WindowY1 < Font->height) | |
1933 hgfx.WindowY0 = 0; | |
1934 else | |
1935 hgfx.WindowY0 = hgfx.WindowY1 - Font->height; | |
110
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1936 } |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1937 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1938 { |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1939 hgfx.WindowX0 = 800 - XrightGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1940 hgfx.WindowX1 = 800 - XleftGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1941 hgfx.WindowY0 = YtopGimpStyle; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1942 if(hgfx.WindowY0 < Font->height) |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1943 hgfx.WindowY1 = 0; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1944 else |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1945 hgfx.WindowY1 = hgfx.WindowY0 + Font->height; |
cc8e24374b83
Added option to handled mirrored display to existing functions
Ideenmodellierer
parents:
38
diff
changeset
|
1946 } |
38 | 1947 GFX_clear_window_immediately(&hgfx); |
1948 } | |
1949 | |
1950 | |
1951 /* Private functions ---------------------------------------------------------*/ | |
1952 | |
1953 void draw_tMEdesign(void) | |
1954 { | |
1955 GFX_draw_header(&tMEscreen,menuColor); | |
1956 } | |
1957 | |
1958 void draw_tMEdesignSubUnselected(uint32_t *ppDestination) | |
1959 { | |
1960 union al88_u | |
1961 { | |
1962 uint8_t al8[2]; | |
1963 uint16_t al88; | |
1964 }; | |
1965 | |
1966 union al88_u color_seperator; | |
1967 union al88_u color_unselected; | |
1968 int i; | |
1969 | |
1970 color_seperator.al8[0] = CLUT_MenuLineUnselectedSeperator; | |
1971 color_unselected.al8[0] = CLUT_MenuLineUnselected; | |
1972 | |
1973 color_seperator.al8[1] = 0xFF; | |
1974 color_unselected.al8[1] = 0xFF; | |
1975 | |
1976 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1977 *ppDestination += 2; | |
1978 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1979 *ppDestination += 2; | |
1980 | |
1981 for(i = 61; i > 0; i--) | |
1982 { | |
1983 *(__IO uint16_t*)*ppDestination = color_unselected.al88; | |
1984 *ppDestination += 2; | |
1985 } | |
1986 | |
1987 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1988 *ppDestination += 2; | |
1989 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
1990 *ppDestination += 2; | |
1991 } | |
1992 | |
1993 | |
1994 void draw_tMEdesignSubSelected(uint32_t *ppDestination) | |
1995 { | |
1996 union al88_u | |
1997 { | |
1998 uint8_t al8[2]; | |
1999 uint16_t al88; | |
2000 }; | |
2001 | |
2002 union al88_u color_selected; | |
2003 union al88_u color_seperator; | |
2004 int i; | |
2005 | |
2006 color_selected.al8[0] = CLUT_MenuEditLineSelected; | |
2007 color_selected.al8[1] = 0xFF; | |
2008 | |
2009 color_seperator.al8[0] = CLUT_MenuLineSelectedSeperator; | |
2010 color_seperator.al8[1] = 0xFF; | |
2011 | |
2012 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
2013 *ppDestination += 2; | |
2014 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
2015 *ppDestination += 2; | |
2016 | |
2017 for(i = 61; i > 0; i--) | |
2018 { | |
2019 *(__IO uint16_t*)*ppDestination = color_selected.al88; | |
2020 *ppDestination += 2; | |
2021 } | |
2022 | |
2023 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
2024 *ppDestination += 2; | |
2025 *(__IO uint16_t*)*ppDestination = color_seperator.al88; | |
2026 *ppDestination += 2; | |
2027 } | |
2028 | |
2029 | |
2030 void draw_tMEdesignSubSelectedBorder(uint32_t *ppDestination) | |
2031 { | |
2032 union al88_u | |
2033 { | |
2034 uint8_t al8[2]; | |
2035 uint16_t al88; | |
2036 }; | |
2037 | |
2038 union al88_u color_selected_sides; | |
2039 | |
2040 int i; | |
2041 | |
2042 color_selected_sides.al8[0] = CLUT_MenuLineSelectedSides; | |
2043 color_selected_sides.al8[1] = 0xFF; | |
2044 | |
2045 for(i = 65; i > 0; i--) | |
2046 { | |
2047 *(__IO uint16_t*)*ppDestination = color_selected_sides.al88; | |
2048 *ppDestination += 2; | |
2049 } | |
2050 } | |
2051 | |
2052 | |
2053 void draw_tMEcursorNewDesign(void) | |
2054 { | |
2055 int i,j; | |
2056 uint32_t pDestination; | |
2057 | |
2058 pDestination = tMEcursorNew.FBStartAdress; | |
2059 | |
2060 for(j = 801; j > 0; j--) | |
2061 { | |
2062 for(i = 5; i > 0; i--) | |
2063 { | |
2064 draw_tMEdesignSubUnselected(&pDestination); | |
2065 } | |
2066 if((j > 787) || (j < 17)) | |
2067 draw_tMEdesignSubSelectedBorder(&pDestination); | |
2068 else | |
2069 draw_tMEdesignSubSelected(&pDestination); | |
2070 } | |
2071 } | |
552
531e7818b737
Added menu structure to acces viewport calibration:
Ideenmodellierer
parents:
531
diff
changeset
|
2072 |
531e7818b737
Added menu structure to acces viewport calibration:
Ideenmodellierer
parents:
531
diff
changeset
|
2073 GFX_DrawCfgScreen* getMenuEditScreen() |
531e7818b737
Added menu structure to acces viewport calibration:
Ideenmodellierer
parents:
531
diff
changeset
|
2074 { |
531e7818b737
Added menu structure to acces viewport calibration:
Ideenmodellierer
parents:
531
diff
changeset
|
2075 return &tMEscreen; |
531e7818b737
Added menu structure to acces viewport calibration:
Ideenmodellierer
parents:
531
diff
changeset
|
2076 } |
531e7818b737
Added menu structure to acces viewport calibration:
Ideenmodellierer
parents:
531
diff
changeset
|
2077 |
531e7818b737
Added menu structure to acces viewport calibration:
Ideenmodellierer
parents:
531
diff
changeset
|
2078 |