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