comparison Discovery/Src/tMenuEditXtra.c @ 696:cc542448fb28

Merge
author heinrichsweikamp
date Fri, 19 Aug 2022 11:30:24 +0200
parents 1b995079c045
children e81afd727993
comparison
equal deleted inserted replaced
661:87bee7cc77b3 696:cc542448fb28
33 #include "simulation.h" 33 #include "simulation.h"
34 #include "timer.h" 34 #include "timer.h"
35 #include "tMenuEdit.h" 35 #include "tMenuEdit.h"
36 #include "data_exchange_main.h" 36 #include "data_exchange_main.h"
37 #include "motion.h" 37 #include "motion.h"
38 #include "configuration.h"
38 39
39 40
40 /* Private function prototypes -----------------------------------------------*/ 41 /* Private function prototypes -----------------------------------------------*/
41 void openEdit_CompassHeading(void); 42 void openEdit_CompassHeading(void);
42 void openEdit_ResetStopwatch(void); 43 void openEdit_ResetStopwatch(void);
45 void openEdit_SetEndDive(void); 46 void openEdit_SetEndDive(void);
46 void openEdit_CalibViewport(void); 47 void openEdit_CalibViewport(void);
47 static void openEdit_ScrubberTimer(uint8_t line); 48 static void openEdit_ScrubberTimer(uint8_t line);
48 static void openEdit_ScrubberReset(void); 49 static void openEdit_ScrubberReset(void);
49 static void openEdit_ScrubberTimerMode(void); 50 static void openEdit_ScrubberTimerMode(void);
51 #ifdef ENABLE_PSCR_MODE
52 static void openEdit_PSCRO2Drop(uint8_t line);
53 static void openEdit_PSCRLungRatio(uint8_t line);
54 #endif
55 #ifdef ENABLE_CO2_SUPPORT
56 static void openEdit_CO2Sensor(void);
57 #endif
50 58
51 /* Announced function prototypes -----------------------------------------------*/ 59 /* Announced function prototypes -----------------------------------------------*/
52 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);
53 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 #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);
64 static uint8_t OnAction_PSCRLungRation(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
65 #endif
66
67 #ifdef ENABLE_CO2_SUPPORT
68 static uint8_t OnAction_CO2OnOff(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
69 static uint8_t OnAction_CO2Calib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
70 #endif
54 71
55 /* Exported functions --------------------------------------------------------*/ 72 /* Exported functions --------------------------------------------------------*/
56 73
57 void openEdit_Xtra(uint8_t line) 74 void openEdit_Xtra(uint8_t line)
58 { 75 {
89 break; 106 break;
90 } 107 }
91 } 108 }
92 else /* surface mode */ 109 else /* surface mode */
93 { 110 {
111 if((settingsGetPointer()->dive_mode != DIVEMODE_PSCR) && (line > 3)) /* PSCR items are only optional */
112 {
113 line = 6;
114 }
115
94 switch(line) 116 switch(line)
95 { 117 {
96 case 1: openEdit_ScrubberTimer(line); 118 case 1: openEdit_ScrubberTimer(line);
97 break; 119 break;
98 case 2: openEdit_ScrubberReset(); 120 case 2: openEdit_ScrubberReset();
99 break; 121 break;
100 case 3: openEdit_ScrubberTimerMode(); 122 case 3: openEdit_ScrubberTimerMode();
101 break; 123 break;
124 #ifdef ENABLE_PSCR_MODE
125 case 4: openEdit_PSCRO2Drop(line);
126 break;
127 case 5: openEdit_PSCRLungRatio(line);
128 break;
129 #endif
130 #ifdef ENABLE_CO2_SUPPORT
131 case 6: openEdit_CO2Sensor();
132 break;
133 #endif
102 default: 134 default:
103 break; 135 break;
104 } 136 }
105 } 137 }
106 } 138 }
189 } 221 }
190 pSettings->scrubTimerMode = newMode; 222 pSettings->scrubTimerMode = newMode;
191 exitMenuEdit_to_Menu_with_Menu_Update(); 223 exitMenuEdit_to_Menu_with_Menu_Update();
192 } 224 }
193 225
226 #ifdef ENABLE_PSCR_MODE
227 static void openEdit_PSCRO2Drop(uint8_t line)
228 {
229 uint8_t localO2Drop;
230 uint16_t y_line;
231
232 char text[32];
233 SSettings *pSettings = settingsGetPointer();
234 localO2Drop = pSettings->pscr_o2_drop;
235
236 y_line = ME_Y_LINE_BASE + (line * ME_Y_LINE_STEP);
237
238 text[0] = '\001';
239 text[1] = TXT_PSCRO2Drop;
240 text[2] = 0;
241 write_topline(text);
242
243 text[0] = '\002';
244 text[1] = '\016';
245 text[2] = '\016';
246 text[3] = '%';
247 text[4] = 0;
248 write_label_fix( 20, 800, y_line, &FontT48, TXT_PSCRO2Drop);
249 write_label_var( 435, 780, y_line, &FontT48, text);
250 write_field_udigit(StMXTRA_PSCR_O2_Drop, 710, 779, y_line, &FontT48, "##", (uint32_t)localO2Drop, 0, 0, 0);
251
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
274 text[0] = '\002';
275 text[1] = '1';
276 text[2] = '/';
277 text[3] = 0;
278
279 write_label_fix( 20, 800, y_line, &FontT48, TXT_PSCRLungRatio);
280 write_label_var( 435, 710, y_line, &FontT48, text);
281 write_field_udigit(StMXTRA_PSCR_LUNG_RATIO, 710, 779, y_line, &FontT48, "##", (uint32_t)localLungRatio, 0, 0, 0);
282
283 write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus);
284
285 setEvent(StMXTRA_PSCR_LUNG_RATIO, (uint32_t)OnAction_PSCRLungRation);
286 startEdit();
287 }
288 #endif
289
290 #ifdef ENABLE_CO2_SUPPORT
291 static void openEdit_CO2Sensor()
292 {
293 char text[32];
294 snprintf(text,32,"\001%c",TXT_CO2Sensor);
295 write_topline(text);
296
297 refresh_CO2Data();
298 if(settingsGetPointer()->co2_sensor_active)
299 {
300 text[0] = '\005';
301 }
302 else
303 {
304 text[0] = '\006';
305 }
306 text[0] = TXT_CO2Sensor;
307 text[1] = 0;
308
309 write_field_on_off(StMXTRA_CO2_Sensor, 30, 95, ME_Y_LINE3, &FontT48, text, settingsGetPointer()->co2_sensor_active);
310
311 text[0] = TXT_2BYTE;
312 text[1] = TXT2BYTE_O2Calib;
313 text[2] = 0;
314 write_field_button(StMXTRA_CO2_Sensor_Calib,30, 800, ME_Y_LINE4, &FontT48, text);
315
316 setEvent(StMXTRA_CO2_Sensor, (uint32_t)OnAction_CO2OnOff);
317 setEvent(StMXTRA_CO2_Sensor_Calib, (uint32_t)OnAction_CO2Calib);
318
319 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
320 }
321 #endif
322
194 void refresh_CompassHeading(void) 323 void refresh_CompassHeading(void)
195 { 324 {
196 uint16_t heading; 325 uint16_t heading;
197 char text[32]; 326 char text[32];
198 327
205 heading = (uint16_t)stateUsed->lifeData.compass_heading; 334 heading = (uint16_t)stateUsed->lifeData.compass_heading;
206 snprintf(text,32,"\001%03i`",heading); 335 snprintf(text,32,"\001%03i`",heading);
207 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text); 336 write_label_var( 0, 800, ME_Y_LINE1, &FontT54, text);
208 337
209 tMenuEdit_refresh_field(StMXTRA_CompassHeading); 338 tMenuEdit_refresh_field(StMXTRA_CompassHeading);
339 }
340
341 void refresh_CO2Data(void)
342 {
343 char text[32];
344
345 snprintf(text,32,"\001%c",TXT_CO2Sensor);
346 write_topline(text);
347
348 snprintf(text,32,"CO2: %d ppm",stateUsed->lifeData.CO2_data.CO2_ppm);
349 write_label_var( 30, 800, ME_Y_LINE1, &FontT48, text);
350
351 snprintf(text,32,"Signal: %d",stateUsed->lifeData.CO2_data.signalStrength);
352 write_label_var( 30, 800, ME_Y_LINE2, &FontT48, text);
353
354 tMenuEdit_refresh_field(StMXTRA_CO2_Sensor);
355 tMenuEdit_refresh_field(StMXTRA_CO2_Sensor_Calib);
210 } 356 }
211 357
212 void openEdit_CompassHeading(void) 358 void openEdit_CompassHeading(void)
213 { 359 {
214 360
265 if(digitContentNew < '0') 411 if(digitContentNew < '0')
266 digitContentNew = '9'; 412 digitContentNew = '9';
267 } 413 }
268 return digitContentNew; 414 return digitContentNew;
269 } 415 }
270 416 #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)
418 {
419 SSettings *pSettings;
420 uint8_t digitContentNew = EXIT_TO_MENU;
421 uint32_t newO2Drop;
422
423 if(action == ACTION_BUTTON_ENTER)
424 {
425 return digitContent;
426 }
427 if(action == ACTION_BUTTON_ENTER_FINAL)
428 {
429 evaluateNewString(editId, &newO2Drop, 0, 0, 0);
430
431 if(newO2Drop > PSCR_MAX_O2_DROP)
432 newO2Drop = PSCR_MAX_O2_DROP;
433
434 pSettings = settingsGetPointer();
435 pSettings->pscr_o2_drop = newO2Drop;
436
437 tMenuEdit_newInput(editId, newO2Drop, 0, 0, 0);
438 digitContentNew = UPDATE_AND_EXIT_TO_MENU;
439 }
440 if(action == ACTION_BUTTON_NEXT)
441 {
442 digitContentNew = digitContent + 1;
443 if(digitContentNew > '9')
444 digitContentNew = '0';
445 }
446 if(action == ACTION_BUTTON_BACK)
447 {
448 digitContentNew = digitContent - 1;
449 if(digitContentNew < '0')
450 digitContentNew = '9';
451 }
452 return digitContentNew;
453 }
454
455 static uint8_t OnAction_PSCRLungRation(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
456 {
457 SSettings *pSettings;
458 uint8_t digitContentNew = EXIT_TO_MENU;
459 uint32_t newLungRatio;
460
461 if(action == ACTION_BUTTON_ENTER)
462 {
463 return digitContent;
464 }
465 if(action == ACTION_BUTTON_ENTER_FINAL)
466 {
467 evaluateNewString(editId, &newLungRatio, 0, 0, 0);
468
469 if(newLungRatio > PSCR_MAX_LUNG_RATIO)
470 newLungRatio = PSCR_MAX_LUNG_RATIO;
471
472 if(newLungRatio < PSCR_MIN_LUNG_RATIO)
473 newLungRatio = PSCR_MIN_LUNG_RATIO;
474
475 pSettings = settingsGetPointer();
476 pSettings->pscr_lung_ratio = newLungRatio;
477
478 tMenuEdit_newInput(editId, newLungRatio, 0, 0, 0);
479 digitContentNew = UPDATE_AND_EXIT_TO_MENU;
480 }
481 if(action == ACTION_BUTTON_NEXT)
482 {
483 digitContentNew = digitContent + 1;
484 if(digitContentNew > '9')
485 digitContentNew = '0';
486 }
487 if(action == ACTION_BUTTON_BACK)
488 {
489 digitContentNew = digitContent - 1;
490 if(digitContentNew < '0')
491 digitContentNew = '9';
492 }
493 return digitContentNew;
494 }
495 #endif
496
497 #ifdef ENABLE_CO2_SUPPORT
498 static uint8_t OnAction_CO2OnOff(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
499 {
500 SSettings *pSettings = settingsGetPointer();
501 if(pSettings->co2_sensor_active)
502 {
503 pSettings->co2_sensor_active = 0;
504 tMenuEdit_set_on_off(StMXTRA_CO2_Sensor,0);
505 }
506 else
507 {
508 pSettings->co2_sensor_active = 1;
509 tMenuEdit_set_on_off(StMXTRA_CO2_Sensor,1);
510 }
511 return UPDATE_DIVESETTINGS;
512 }
513
514 static uint8_t OnAction_CO2Calib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
515 {
516 DataEX_setExtInterface_Cmd(EXT_INTERFACE_CO2_CALIB);
517 return UPDATE_DIVESETTINGS;
518 }
519 #endif