comparison Discovery/Src/tMenuEdit.c @ 508:21bf40bb8151

Reimplementation of tMenuEdit_select: The function was not used in the previous versions. A less complex version was now needed and implemented to enable the selection a a menu line Reimplemented refresh_livedata function: To increase code readability the if_ then_else chain has been replaced by a function pointer switch
author Ideenmodellierer
date Sun, 30 Aug 2020 17:23:44 +0200
parents b1091e183d52
children 970d8040c0e3
comparison
equal deleted inserted replaced
507:5e3b830b955f 508:21bf40bb8151
35 #include "tInfoCompass.h" 35 #include "tInfoCompass.h"
36 #include "tMenuEditHardware.h" 36 #include "tMenuEditHardware.h"
37 #include "tMenuEditPlanner.h" 37 #include "tMenuEditPlanner.h"
38 #include "tMenuEditSystem.h" 38 #include "tMenuEditSystem.h"
39 #include "tMenuEditXtra.h" 39 #include "tMenuEditXtra.h"
40 #include "tMenuEditCustom.h"
40 41
41 /* Private types -------------------------------------------------------------*/ 42 /* Private types -------------------------------------------------------------*/
42 #define TEXTSIZE 16 43 #define TEXTSIZE 16
43 44
44 typedef struct 45 typedef struct
85 /* Private variables ---------------------------------------------------------*/ 86 /* Private variables ---------------------------------------------------------*/
86 GFX_DrawCfgScreen tMEscreen; 87 GFX_DrawCfgScreen tMEscreen;
87 GFX_DrawCfgScreen tMEcursor; 88 GFX_DrawCfgScreen tMEcursor;
88 GFX_DrawCfgScreen tMEcursorNew; 89 GFX_DrawCfgScreen tMEcursorNew;
89 90
90 uint32_t menuID; 91 static uint32_t menuID;
91 uint8_t menuColor; 92 static uint8_t menuColor;
92 93
93 int8_t id = 0; 94 static int8_t id = 0;
94 int8_t idLast = -1; 95 static int8_t idLast = -1;
95 SEditIdent ident[10]; 96 static SEditIdent ident[10];
96 int8_t tME_stop = 0; 97 static int8_t tME_stop = 0;
97 98
98 int8_t evid = 0; 99 static int8_t evid = 0;
99 int8_t evidLast = -1; 100 static int8_t evidLast = -1;
100 SEventHandler event[10]; 101 static SEventHandler event[10];
101 102
102 SBackMenuHandler backmenu; 103 static SBackMenuHandler backmenu;
103 104
104 int8_t block = 0; 105 static int8_t block = 0;
105 int8_t subBlockPosition = 0; 106 static int8_t subBlockPosition = 0;
106 107
107 _Bool EnterPressedBeforeButtonAction = 0; 108 static _Bool EnterPressedBeforeButtonAction = 0;
108 _Bool EnterPressed = 0; 109 static _Bool EnterPressed = 0;
109 110
110 _Bool WriteSettings = 0; 111 static _Bool WriteSettings = 0;
111 112
112 /* Private function prototypes -----------------------------------------------*/ 113 /* Private function prototypes -----------------------------------------------*/
113 void draw_tMEdesign(void); 114 void draw_tMEdesign(void);
114 void set_cursorNew(uint8_t forThisIdentID); 115 void set_cursorNew(uint8_t forThisIdentID);
115 void startMenuEditFieldSelect(void); 116 void startMenuEditFieldSelect(void);
196 } 197 }
197 198
198 199
199 void tMenuEdit_refresh_live_content(void) 200 void tMenuEdit_refresh_live_content(void)
200 { 201 {
201 202 uint32_t globState = get_globalState();
202 if(get_globalState() == (StMHARD3_O2_Sensor1 & MaskFieldDigit)) 203 void (*refreshFct)() = NULL;
203 { 204
204 uint32_t rememberPage = tMEscreen.FBStartAdress; 205
205 tMEscreen.FBStartAdress = getFrame(9); 206 switch(globState)
206 // draw_tMEdesign(); 207 {
207 refresh_O2Sensors(); 208 case (StMHARD3_O2_Sensor1 & MaskFieldDigit): refreshFct = refresh_O2Sensors;
208 GFX_SetFrameTop(tMEscreen.FBStartAdress); 209 break;
209 releaseFrame(9,rememberPage); 210 case (StMHARD2_Compass_SetCourse & MaskFieldDigit): refreshFct = refresh_CompassEdit;
210 } 211 break;
211 else if(get_globalState() == (StMHARD2_Compass_SetCourse & MaskFieldDigit)) 212 case (StMXTRA_CompassHeading & MaskFieldDigit): refreshFct = refresh_CompassHeading;
212 { 213 break;
213 uint32_t rememberPage = tMEscreen.FBStartAdress; 214 case (StMSYS5_Info & MaskFieldDigit): refreshFct = &refresh_InformationPage;
214 tMEscreen.FBStartAdress = getFrame(9); 215 break;
215 refresh_CompassEdit(); 216 case (StMPLAN5_ExitResult & MaskFieldDigit): refreshFct = refresh_PlanResult;
216 GFX_SetFrameTop(tMEscreen.FBStartAdress); 217 break;
217 releaseFrame(9,rememberPage); 218 case (StMHARD5_Button1 & MaskFieldDigit): // will not be executed in EditFieldMode as global state is different
218 } 219 refreshFct = refresh_ButtonValuesFromPIC;
219 else if(get_globalState() == (StMXTRA_CompassHeading & MaskFieldDigit)) 220 break;
220 { 221 case (StMSYS3_Units & MaskFieldDigit): refreshFct = refresh_Design;
221 uint32_t rememberPage = tMEscreen.FBStartAdress; 222 break;
222 tMEscreen.FBStartAdress = getFrame(9); 223 case (StMCustom1_CViewTimeout & MaskFieldDigit):
223 // draw_tMEdesign(); 224 case (StMSYS4_CViewTimeout & MaskFieldDigit): refreshFct = refresh_Customviews;
224 refresh_CompassHeading(); 225 break;
225 GFX_SetFrameTop(tMEscreen.FBStartAdress); 226 case (StMCustom2_CViewSelection1 & MaskFieldDigit) :
226 releaseFrame(9,rememberPage); 227 case StMCustom2_CViewSelection2:
227 } 228 case StMCustom2_CViewSelection3:
228 else if(get_globalState() == (StMSYS5_Info & MaskFieldDigit)) 229 case StMCustom2_CViewSelection4:
229 { 230 case StMCustom2_CViewSelection5:
230 uint32_t rememberPage = tMEscreen.FBStartAdress; 231 case StMCustom2_CViewSelection6:
231 tMEscreen.FBStartAdress = getFrame(9); 232 case (StMCustom2_BFSelection & MaskFieldDigit) : refreshFct = CustomviewDivemode2_refresh;
232 refresh_InformationPage(); 233 break;
233 GFX_SetFrameTop(tMEscreen.FBStartAdress); 234 default: /* no menu has been updated */
234 releaseFrame(9,rememberPage); 235 break;
235 } 236 }
236 else if(get_globalState() == (StMPLAN5_ExitResult & MaskFieldDigit)) 237
237 { 238 if(refreshFct != NULL)
238 uint32_t rememberPage = tMEscreen.FBStartAdress; 239 {
239 tMEscreen.FBStartAdress = getFrame(9); 240 uint32_t rememberPage = tMEscreen.FBStartAdress;
240 refresh_PlanResult(); 241 tMEscreen.FBStartAdress = getFrame(9);
241 GFX_SetFrameTop(tMEscreen.FBStartAdress); 242
242 releaseFrame(9,rememberPage); 243 refreshFct();
243 } 244
244 else if(get_globalState() == (StMHARD5_Button1 & MaskFieldDigit)) // will not be executed in EditFieldMode as global state is different 245 GFX_SetFrameTop(tMEscreen.FBStartAdress);
245 { 246 releaseFrame(9,rememberPage);
246 uint32_t rememberPage = tMEscreen.FBStartAdress; 247 }
247 tMEscreen.FBStartAdress = getFrame(9);
248 refresh_ButtonValuesFromPIC();
249 GFX_SetFrameTop(tMEscreen.FBStartAdress);
250 releaseFrame(9,rememberPage);
251 }
252 else if(get_globalState() == (StMSYS3_Units & MaskFieldDigit))
253 {
254 uint32_t rememberPage = tMEscreen.FBStartAdress;
255 tMEscreen.FBStartAdress = getFrame(9);
256 refresh_Design();
257 GFX_SetFrameTop(tMEscreen.FBStartAdress);
258 releaseFrame(9,rememberPage);
259 }
260 else if(get_globalState() == (StMSYS4_CViewTimeout & MaskFieldDigit))
261 {
262 uint32_t rememberPage = tMEscreen.FBStartAdress;
263 tMEscreen.FBStartAdress = getFrame(9);
264 refresh_Customviews();
265 GFX_SetFrameTop(tMEscreen.FBStartAdress);
266 releaseFrame(9,rememberPage);
267 }
268 } 248 }
269 249
270 void tMenuEdit_writeSettingsToFlash(void) 250 void tMenuEdit_writeSettingsToFlash(void)
271 { 251 {
272 if(WriteSettings) 252 if(WriteSettings)
978 write_content_of_actual_Id(); 958 write_content_of_actual_Id();
979 959
980 id = backup_id; 960 id = backup_id;
981 } 961 }
982 962
983 963 void tMenuEdit_select(uint32_t editID)
964 {
965 uint8_t id_local = 0;
966 id_local = get_id_of(editID);
967
968 if(id_local <= idLast)
969 {
970 id = id_local;
971 set_cursorNew(id);
972 }
973 }
974
975 #if OLD_SELECTION
984 void tMenuEdit_select(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) 976 void tMenuEdit_select(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4)
985 { 977 {
986 if(int1 > 4) 978 if(int1 > 4)
987 return; 979 return;
988 980
1004 clean_content_of_actual_Id(); 996 clean_content_of_actual_Id();
1005 write_content_of_actual_Id(); 997 write_content_of_actual_Id();
1006 998
1007 id = backup_id; 999 id = backup_id;
1008 } 1000 }
1001 #endif
1009 1002
1010 1003
1011 void tMenuEdit_newInput(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4) 1004 void tMenuEdit_newInput(uint32_t editID, uint32_t int1, uint32_t int2, uint32_t int3, uint32_t int4)
1012 { 1005 {
1013 uint8_t backup_id, temp_id; 1006 uint8_t backup_id, temp_id;