comparison Discovery/Src/tMenuEditXtra.c @ 707:e81afd727993

Menu cleanup rebreather specific settings: In the previous version the selection for Fix setpoint or sensor was in the deco menu and the Fallback option in the hardware menu. As they have a dependency and are only relevant for rebreather operation, they have been moved into the extra menu which is containing rebreather related data and which is only visible in rebreather mode.
author Ideenmodellierer
date Thu, 03 Nov 2022 20:44:21 +0100
parents 1b995079c045
children 8adf9b8fc7fa
comparison
equal deleted inserted replaced
706:10b7d271b9c4 707:e81afd727993
43 void openEdit_ResetStopwatch(void); 43 void openEdit_ResetStopwatch(void);
44 void openEdit_SimFollowDecostops(void); 44 void openEdit_SimFollowDecostops(void);
45 void openEdit_SetManualMarker(void); 45 void openEdit_SetManualMarker(void);
46 void openEdit_SetEndDive(void); 46 void openEdit_SetEndDive(void);
47 void openEdit_CalibViewport(void); 47 void openEdit_CalibViewport(void);
48 static void openEdit_ScrubberTimer(uint8_t line); 48
49 static void openEdit_ScrubberReset(void); 49 static void openEdit_CCRModeSensorOrFixedSP(void);
50 static void openEdit_ScrubberTimerMode(void); 50 static void openEdit_Fallback(void);
51 static void openEdit_Scrubber(void);
51 #ifdef ENABLE_PSCR_MODE 52 #ifdef ENABLE_PSCR_MODE
52 static void openEdit_PSCRO2Drop(uint8_t line); 53 static void openEdit_PSCR(void);
53 static void openEdit_PSCRLungRatio(uint8_t line);
54 #endif 54 #endif
55 #ifdef ENABLE_CO2_SUPPORT 55 #ifdef ENABLE_CO2_SUPPORT
56 static void openEdit_CO2Sensor(void); 56 static void openEdit_CO2Sensor(void);
57 #endif 57 #endif
58 58
59 /* Announced function prototypes -----------------------------------------------*/ 59 /* Announced function prototypes -----------------------------------------------*/
60 uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 60 uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
61 static uint8_t OnAction_ScrubberTimer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 61 static uint8_t OnAction_ScrubberTimer(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
62 static uint8_t OnAction_ScrubberReset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
63 static uint8_t OnAction_ScrubberMode(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
62 #ifdef ENABLE_PSCR_MODE 64 #ifdef ENABLE_PSCR_MODE
63 static uint8_t OnAction_PSCRO2Drop(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 65 static uint8_t OnAction_PSCRO2Drop(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
64 static uint8_t OnAction_PSCRLungRation(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 66 static uint8_t OnAction_PSCRLungRation(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
65 #endif 67 #endif
66 68
72 /* Exported functions --------------------------------------------------------*/ 74 /* Exported functions --------------------------------------------------------*/
73 75
74 void openEdit_Xtra(uint8_t line) 76 void openEdit_Xtra(uint8_t line)
75 { 77 {
76 set_globalState_Menu_Line(line); 78 set_globalState_Menu_Line(line);
77 resetMenuEdit(CLUT_MenuPageXtra); 79
78 80
79 /* DIVE MODE */ 81 /* DIVE MODE */
80 if(actual_menu_content != MENU_SURFACE) 82 if(actual_menu_content != MENU_SURFACE)
81 { 83 {
84 resetMenuEdit(CLUT_MenuPageXtra);
85
82 switch(line) 86 switch(line)
83 { 87 {
84 case 1: 88 case 1:
85 default: 89 default:
86 openEdit_ResetStopwatch(); 90 openEdit_ResetStopwatch();
113 line = 6; 117 line = 6;
114 } 118 }
115 119
116 switch(line) 120 switch(line)
117 { 121 {
118 case 1: openEdit_ScrubberTimer(line); 122 case 1: openEdit_CCRModeSensorOrFixedSP();
119 break; 123 break;
120 case 2: openEdit_ScrubberReset(); 124 case 2: openEdit_Fallback();
121 break; 125 break;
122 case 3: openEdit_ScrubberTimerMode(); 126 case 3: openEdit_Scrubber();
123 break; 127 break;
124 #ifdef ENABLE_PSCR_MODE 128 #ifdef ENABLE_PSCR_MODE
125 case 4: openEdit_PSCRO2Drop(line); 129 case 4: openEdit_PSCR();
126 break; 130 break;
127 case 5: openEdit_PSCRLungRatio(line);
128 break;
129 #endif 131 #endif
130 #ifdef ENABLE_CO2_SUPPORT 132 #ifdef ENABLE_CO2_SUPPORT
131 case 6: openEdit_CO2Sensor(); 133 case 6: openEdit_CO2Sensor();
132 break; 134 break;
133 #endif 135 #endif
168 suspendMotionDetection(0); /* exit to focus mode directly */ 170 suspendMotionDetection(0); /* exit to focus mode directly */
169 exitMenuEdit_to_Home(); 171 exitMenuEdit_to_Home();
170 } 172 }
171 173
172 174
173 175 static void openEdit_CCRModeSensorOrFixedSP(void)
174 static void openEdit_ScrubberTimer(uint8_t line) 176 {
175 { 177 SSettings *pSettings = settingsGetPointer();
178
179 if(pSettings->CCR_Mode == CCRMODE_Sensors)
180 pSettings->CCR_Mode = CCRMODE_FixedSetpoint;
181 else
182 pSettings->CCR_Mode = CCRMODE_Sensors;
183
184 exitEditWithUpdate();
185 }
186
187 static void openEdit_Fallback(void)
188 {
189 /* does not work like this resetEnterPressedToStateBeforeButtonAction(); */
190
191 SSettings *pSettings = settingsGetPointer();
192
193 if(pSettings->fallbackToFixedSetpoint == 0)
194 {
195 pSettings->fallbackToFixedSetpoint = 1;
196 }
197 else
198 {
199 pSettings->fallbackToFixedSetpoint = 0;
200 }
201 exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only();
202 }
203
204
205 static void openEdit_Scrubber(void)
206 {
207 char text[32];
208 uint8_t textIndex = 0;
176 uint16_t localScrubTimer; 209 uint16_t localScrubTimer;
177 uint16_t y_line; 210
178
179 char text[32];
180 SSettings *pSettings = settingsGetPointer(); 211 SSettings *pSettings = settingsGetPointer();
181 localScrubTimer = pSettings->scrubTimerMax; 212
182 213 localScrubTimer = pSettings->scrubTimerMax;
183 y_line = ME_Y_LINE_BASE + (line * ME_Y_LINE_STEP); 214
184 215 resetMenuEdit(CLUT_MenuPageXtra);
185 text[0] = '\001'; 216
186 text[1] = TXT_ScrubTime; 217
187 text[2] = 0; 218 snprintf(&text[textIndex], 32,"\001%c",TXT_ScrubTime);
188 write_topline(text); 219 write_topline(text);
189 220
190 text[0] = '\002'; 221
191 strcpy(&text[1],"\016\016"); 222 snprintf(&text[textIndex], 32,\
192 text[3] = TXT_Minutes; 223 "%c"
193 text[4] = 0; 224 "\016\016(%c)\017"
194 write_label_fix( 20, 800, y_line, &FontT48, TXT_ScrubTime); 225 ,TXT_ScrubTime
195 write_label_var( 435, 780, y_line, &FontT48, text); 226 ,TXT_Maximum);
196 write_field_udigit(StMXTRA_ScrubTimer_Max_Minutes, 600, 779, y_line, &FontT48, "###", (uint32_t)localScrubTimer, 0, 0, 0); 227
197 228 write_label_var( 20, 340, ME_Y_LINE1, &FontT48, text);
198 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); 229 snprintf(&text[textIndex], 32, "\002###\016\016 %c\017",TXT_Minutes);
199 230
200 setEvent(StMXTRA_ScrubTimer_Max_Minutes, (uint32_t)OnAction_ScrubberTimer); 231 write_field_udigit(StMXTRA_ScrubTimer, 610, 780, ME_Y_LINE1, &FontT48, text,localScrubTimer, 0, 0, 0);
201 startEdit(); 232
202 } 233 snprintf(&text[0], 32,\
203 234 "%c\002%03u\016\016 %c\017"
204 static void openEdit_ScrubberReset(void) 235 ,TXT_ScrubTimeReset
205 { 236 ,pSettings->scrubTimerCur
206 SSettings *pSettings; 237 ,TXT_Minutes);
207 pSettings = settingsGetPointer(); 238
208 pSettings->scrubTimerCur = pSettings->scrubTimerMax; 239 write_field_button(StMXTRA_ScrubTimer_Reset, 20, 780, ME_Y_LINE2, &FontT48, text);
209 exitMenuEdit_to_Menu_with_Menu_Update(); 240
210 } 241 switch(pSettings->scrubTimerMode)
211 242 {
212 static void openEdit_ScrubberTimerMode(void) 243 case SCRUB_TIMER_OFF:
213 { 244 default: snprintf(&text[0], 32,"%c\002%c%c",TXT_ScrubTimeMode, TXT_2BYTE, TXT2BYTE_MoCtrlNone );
214 uint8_t newMode; 245 break;
215 SSettings *pSettings; 246 case SCRUB_TIMER_MINUTES: snprintf(&text[0], 32,"%c\002%c",TXT_ScrubTimeMode, TXT_Minutes );
216 pSettings = settingsGetPointer(); 247 break;
217 newMode = pSettings->scrubTimerMode + 1; 248 case SCRUB_TIMER_PERCENT: snprintf(&text[0], 32,"%c\002%c",TXT_ScrubTimeMode, TXT_Percent );
218 if(newMode >= SCRUB_TIMER_END) 249 break;
219 { 250 }
220 newMode = SCRUB_TIMER_OFF; 251 write_field_button(StMXTRA_ScrubTimer_OP_Mode, 30, 780, ME_Y_LINE3, &FontT48, text);
221 } 252
222 pSettings->scrubTimerMode = newMode; 253 setEvent(StMXTRA_ScrubTimer, (uint32_t)OnAction_ScrubberTimer);
223 exitMenuEdit_to_Menu_with_Menu_Update(); 254 setEvent(StMXTRA_ScrubTimer_Reset, (uint32_t)OnAction_ScrubberReset);
224 } 255 setEvent(StMXTRA_ScrubTimer_OP_Mode, (uint32_t)OnAction_ScrubberMode);
225 256
226 #ifdef ENABLE_PSCR_MODE 257 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
227 static void openEdit_PSCRO2Drop(uint8_t line) 258
228 { 259 }
229 uint8_t localO2Drop; 260
230 uint16_t y_line; 261 static void openEdit_PSCR(void)
231 262 {
263 uint8_t localO2Drop,localLungRatio;
232 char text[32]; 264 char text[32];
233 SSettings *pSettings = settingsGetPointer(); 265 SSettings *pSettings = settingsGetPointer();
234 localO2Drop = pSettings->pscr_o2_drop; 266 localO2Drop = pSettings->pscr_o2_drop;
235 267 localLungRatio = pSettings->pscr_lung_ratio;
236 y_line = ME_Y_LINE_BASE + (line * ME_Y_LINE_STEP); 268
237 269 resetMenuEdit(CLUT_MenuPageXtra);
238 text[0] = '\001'; 270
239 text[1] = TXT_PSCRO2Drop; 271 snprintf(text, 32, "\001%c",TXT_PSClosedCircuit);
240 text[2] = 0;
241 write_topline(text); 272 write_topline(text);
242 273
243 text[0] = '\002'; 274 text[0] = '\002';
244 text[1] = '\016'; 275 text[1] = '\016';
245 text[2] = '\016'; 276 text[2] = '\016';
246 text[3] = '%'; 277 text[3] = '%';
247 text[4] = 0; 278 text[4] = 0;
248 write_label_fix( 20, 800, y_line, &FontT48, TXT_PSCRO2Drop); 279 write_label_fix( 20, 800, ME_Y_LINE1, &FontT48, TXT_PSCRO2Drop);
249 write_label_var( 435, 780, y_line, &FontT48, text); 280 write_label_var( 435, 780, ME_Y_LINE1, &FontT48, text);
250 write_field_udigit(StMXTRA_PSCR_O2_Drop, 710, 779, y_line, &FontT48, "##", (uint32_t)localO2Drop, 0, 0, 0); 281 write_field_udigit(StMXTRA_PSCR_O2_Drop, 710, 779, ME_Y_LINE1, &FontT48, "##", (uint32_t)localO2Drop, 0, 0, 0);
251 282
252 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus);
253
254 setEvent(StMXTRA_PSCR_O2_Drop, (uint32_t)OnAction_PSCRO2Drop);
255 startEdit();
256 }
257
258 static void openEdit_PSCRLungRatio(uint8_t line)
259 {
260 uint8_t localLungRatio;
261 uint16_t y_line;
262
263 char text[32];
264 SSettings *pSettings = settingsGetPointer();
265 localLungRatio = pSettings->pscr_lung_ratio;
266
267 y_line = ME_Y_LINE_BASE + (line * ME_Y_LINE_STEP);
268
269 text[0] = '\001';
270 text[1] = TXT_PSCRO2Drop;
271 text[2] = 0;
272 write_topline(text);
273 283
274 text[0] = '\002'; 284 text[0] = '\002';
275 text[1] = '1'; 285 text[1] = '1';
276 text[2] = '/'; 286 text[2] = '/';
277 text[3] = 0; 287 text[3] = 0;
278 288
279 write_label_fix( 20, 800, y_line, &FontT48, TXT_PSCRLungRatio); 289 write_label_fix( 20, 800, ME_Y_LINE2, &FontT48, TXT_PSCRLungRatio);
280 write_label_var( 435, 710, y_line, &FontT48, text); 290 write_label_var( 435, 710, ME_Y_LINE2, &FontT48, text);
281 write_field_udigit(StMXTRA_PSCR_LUNG_RATIO, 710, 779, y_line, &FontT48, "##", (uint32_t)localLungRatio, 0, 0, 0); 291 write_field_udigit(StMXTRA_PSCR_LUNG_RATIO, 710, 779, ME_Y_LINE2, &FontT48, "##", (uint32_t)localLungRatio, 0, 0, 0);
282 292
283 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); 293 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus);
284 294
295 setEvent(StMXTRA_PSCR_O2_Drop, (uint32_t)OnAction_PSCRO2Drop);
285 setEvent(StMXTRA_PSCR_LUNG_RATIO, (uint32_t)OnAction_PSCRLungRation); 296 setEvent(StMXTRA_PSCR_LUNG_RATIO, (uint32_t)OnAction_PSCRLungRation);
286 startEdit(); 297 }
287 } 298
288 #endif
289 299
290 #ifdef ENABLE_CO2_SUPPORT 300 #ifdef ENABLE_CO2_SUPPORT
291 static void openEdit_CO2Sensor() 301 static void openEdit_CO2Sensor()
292 { 302 {
293 char text[32]; 303 char text[32];
355 tMenuEdit_refresh_field(StMXTRA_CO2_Sensor_Calib); 365 tMenuEdit_refresh_field(StMXTRA_CO2_Sensor_Calib);
356 } 366 }
357 367
358 void openEdit_CompassHeading(void) 368 void openEdit_CompassHeading(void)
359 { 369 {
360
361 write_field_button(StMXTRA_CompassHeading,20, 800, ME_Y_LINE4, &FontT48, "Set"); 370 write_field_button(StMXTRA_CompassHeading,20, 800, ME_Y_LINE4, &FontT48, "Set");
362
363 setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading); 371 setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading);
364 // startEdit();
365 } 372 }
366 373
367 374
368 uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 375 uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
369 { 376 {
395 { 402 {
396 pSettings->scrubTimerCur = newScrubberTime; 403 pSettings->scrubTimerCur = newScrubberTime;
397 } 404 }
398 405
399 tMenuEdit_newInput(editId, newScrubberTime, 0, 0, 0); 406 tMenuEdit_newInput(editId, newScrubberTime, 0, 0, 0);
400 digitContentNew = UPDATE_AND_EXIT_TO_MENU; 407 digitContentNew = UNSPECIFIC_RETURN;
401 } 408 }
402 if(action == ACTION_BUTTON_NEXT) 409 if(action == ACTION_BUTTON_NEXT)
403 { 410 {
404 digitContentNew = digitContent + 1; 411 digitContentNew = digitContent + 1;
405 if(digitContentNew > '9') 412 if(digitContentNew > '9')
411 if(digitContentNew < '0') 418 if(digitContentNew < '0')
412 digitContentNew = '9'; 419 digitContentNew = '9';
413 } 420 }
414 return digitContentNew; 421 return digitContentNew;
415 } 422 }
423
424 uint8_t OnAction_ScrubberReset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
425 {
426 char text[32];
427 SSettings *pSettings;
428 pSettings = settingsGetPointer();
429 pSettings->scrubTimerCur = pSettings->scrubTimerMax;
430
431
432 snprintf(&text[0], 32,\
433 "%c\002%03u\016\016 %c\017"
434 ,TXT_ScrubTimeReset
435 ,pSettings->scrubTimerCur
436 ,TXT_Minutes);
437
438 tMenuEdit_refresh_field(StMXTRA_ScrubTimer_Reset);
439
440 return UNSPECIFIC_RETURN;
441 }
442
443 uint8_t OnAction_ScrubberMode(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
444 {
445 char text[32];
446 uint8_t newMode;
447 SSettings *pSettings;
448 pSettings = settingsGetPointer();
449 newMode = pSettings->scrubTimerMode + 1;
450 if(newMode >= SCRUB_TIMER_END)
451 {
452 newMode = SCRUB_TIMER_OFF;
453 }
454 pSettings->scrubTimerMode = newMode;
455
456 switch(pSettings->scrubTimerMode)
457 {
458 case SCRUB_TIMER_OFF:
459 default: snprintf(&text[0], 32,"%c\002%c%c",TXT_ScrubTimeMode, TXT_2BYTE, TXT2BYTE_MoCtrlNone );
460 break;
461 case SCRUB_TIMER_MINUTES: snprintf(&text[0], 32,"%c\002%c",TXT_ScrubTimeMode, TXT_Minutes );
462 break;
463 case SCRUB_TIMER_PERCENT: snprintf(&text[0], 32,"%c\002%c",TXT_ScrubTimeMode, TXT_Percent );
464 break;
465 }
466 tMenuEdit_newButtonText(StMXTRA_ScrubTimer_OP_Mode, text);
467
468 return UNSPECIFIC_RETURN;
469 }
470
416 #ifdef ENABLE_PSCR_MODE 471 #ifdef ENABLE_PSCR_MODE
417 static uint8_t OnAction_PSCRO2Drop(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 472 static uint8_t OnAction_PSCRO2Drop(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
418 { 473 {
419 SSettings *pSettings; 474 SSettings *pSettings;
420 uint8_t digitContentNew = EXIT_TO_MENU; 475 uint8_t digitContentNew = EXIT_TO_MENU;
433 488
434 pSettings = settingsGetPointer(); 489 pSettings = settingsGetPointer();
435 pSettings->pscr_o2_drop = newO2Drop; 490 pSettings->pscr_o2_drop = newO2Drop;
436 491
437 tMenuEdit_newInput(editId, newO2Drop, 0, 0, 0); 492 tMenuEdit_newInput(editId, newO2Drop, 0, 0, 0);
438 digitContentNew = UPDATE_AND_EXIT_TO_MENU; 493 digitContentNew = UNSPECIFIC_RETURN;
439 } 494 }
440 if(action == ACTION_BUTTON_NEXT) 495 if(action == ACTION_BUTTON_NEXT)
441 { 496 {
442 digitContentNew = digitContent + 1; 497 digitContentNew = digitContent + 1;
443 if(digitContentNew > '9') 498 if(digitContentNew > '9')
474 529
475 pSettings = settingsGetPointer(); 530 pSettings = settingsGetPointer();
476 pSettings->pscr_lung_ratio = newLungRatio; 531 pSettings->pscr_lung_ratio = newLungRatio;
477 532
478 tMenuEdit_newInput(editId, newLungRatio, 0, 0, 0); 533 tMenuEdit_newInput(editId, newLungRatio, 0, 0, 0);
479 digitContentNew = UPDATE_AND_EXIT_TO_MENU; 534 digitContentNew = UNSPECIFIC_RETURN;
480 } 535 }
481 if(action == ACTION_BUTTON_NEXT) 536 if(action == ACTION_BUTTON_NEXT)
482 { 537 {
483 digitContentNew = digitContent + 1; 538 digitContentNew = digitContent + 1;
484 if(digitContentNew > '9') 539 if(digitContentNew > '9')