Mercurial > public > ostc4
comparison Discovery/Src/tMenuEditHardware.c @ 584:830de438e0b0
Added option for 100% o2 calibration:
For the implementation of the selection of the calib gas the reactivation of the menu elemen "FIELD_TOGGLE" was necessary. Within the calibration menu item it is now possible to select between air and 100% o2 calibration. The calibration itself no consideres the ambient pressure during calculation of the coeff.
author | Ideenmodellierer |
---|---|
date | Sat, 12 Dec 2020 21:05:11 +0100 |
parents | ec76fa85009e |
children | 1f665e31aca2 |
comparison
equal
deleted
inserted
replaced
583:3860b8fa4b29 | 584:830de438e0b0 |
---|---|
70 /* Exported functions --------------------------------------------------------*/ | 70 /* Exported functions --------------------------------------------------------*/ |
71 | 71 |
72 | 72 |
73 #define O2_CALIB_FRACTION_AIR (0.209F) | 73 #define O2_CALIB_FRACTION_AIR (0.209F) |
74 | 74 |
75 static uint8_t O2_calib_gas = 21; | |
75 | 76 |
76 void openEdit_Hardware(uint8_t line) | 77 void openEdit_Hardware(uint8_t line) |
77 { | 78 { |
78 set_globalState_Menu_Line(line); | 79 set_globalState_Menu_Line(line); |
79 resetMenuEdit(CLUT_MenuPageHardware); | 80 resetMenuEdit(CLUT_MenuPageHardware); |
308 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); | 309 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); |
309 } | 310 } |
310 else | 311 else |
311 { | 312 { |
312 text[0] = TXT_2BYTE; | 313 text[0] = TXT_2BYTE; |
313 text[1] = TXT2BYTE_O2CalibAir; | 314 text[1] = TXT2BYTE_O2Calib; |
314 text[2] = 0; | 315 text[2] = 0; |
315 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); | 316 write_label_var( 30, 340, ME_Y_LINE4, &FontT48, text); |
317 snprintf(text, 20,"%d%%", O2_calib_gas); | |
318 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, text); | |
316 } | 319 } |
317 | 320 |
318 for(int i=0;i<3;i++) | 321 for(int i=0;i<3;i++) |
319 { | 322 { |
320 snprintf(text, 20,"%01.2f, %01.1fmV", pStateReal->lifeData.ppO2Sensor_bar[i], pStateReal->lifeData.sensorVoltage_mV[i]); | 323 snprintf(text, 20,"%01.2f, %01.1fmV", pStateReal->lifeData.ppO2Sensor_bar[i], pStateReal->lifeData.sensorVoltage_mV[i]); |
342 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); | 345 tMenuEdit_refresh_field(StMHARD3_O2_Sensor1); |
343 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); | 346 tMenuEdit_refresh_field(StMHARD3_O2_Sensor2); |
344 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); | 347 tMenuEdit_refresh_field(StMHARD3_O2_Sensor3); |
345 tMenuEdit_refresh_field(StMHARD3_O2_Fallback); | 348 tMenuEdit_refresh_field(StMHARD3_O2_Fallback); |
346 | 349 |
347 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | 350 if(get_globalState() == StMHARD3_O2_Calibrate) |
351 { | |
352 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_O2Calib,TXT2BYTE_ButtonPlus); | |
353 } | |
354 else | |
355 { | |
356 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
357 } | |
348 } | 358 } |
349 | 359 |
350 | 360 |
351 void openEdit_O2Sensors(void) | 361 void openEdit_O2Sensors(void) |
352 { | 362 { |
367 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); | 377 write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); |
368 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); | 378 write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); |
369 | 379 |
370 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) | 380 if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANALOG) |
371 { | 381 { |
372 write_field_button(StMHARD3_O2_Calibrate, 30, 800, ME_Y_LINE4, &FontT48, ""); | 382 write_label_fix( 30, 800, ME_Y_LINE4, &FontT48, TXT2BYTE_O2Calib); |
383 write_label_var( 400, 800, ME_Y_LINE4, &FontT48, "\016\016 %\017"); | |
384 | |
385 write_field_toggle(StMHARD3_O2_Calibrate, 400, 800, ME_Y_LINE4, &FontT48, "", 21, 100); | |
373 } | 386 } |
374 | 387 |
375 text[0] = TXT_Fallback; | 388 text[0] = TXT_Fallback; |
376 text[1] = 1; | 389 text[1] = 1; |
377 | 390 |
466 uint8_t OnAction_O2_Calibrate (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 479 uint8_t OnAction_O2_Calibrate (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
467 { | 480 { |
468 uint8_t loop; | 481 uint8_t loop; |
469 const SDiveState *pStateReal = stateRealGetPointer(); | 482 const SDiveState *pStateReal = stateRealGetPointer(); |
470 SSettings* pSettings = settingsGetPointer(); | 483 SSettings* pSettings = settingsGetPointer(); |
471 | 484 uint8_t retVal = UNSPECIFIC_RETURN; |
472 for(loop=0;loop<3;loop++) | 485 float compensatedRef; |
473 { | 486 |
474 if((pSettings->ppo2sensors_deactivated & (0x1 << loop)) == 0) | 487 if(action == ACTION_BUTTON_ENTER_FINAL) |
488 { | |
489 if(O2_calib_gas == 21) | |
490 { | |
491 compensatedRef = O2_CALIB_FRACTION_AIR * pStateReal->lifeData.pressure_ambient_bar / 1.0; | |
492 } | |
493 else | |
494 { | |
495 compensatedRef = 100.0 * pStateReal->lifeData.pressure_ambient_bar / 1.0; | |
496 } | |
497 for(loop=0;loop<3;loop++) | |
498 { | |
499 if((pSettings->ppo2sensors_deactivated & (0x1 << loop)) == 0) | |
500 { | |
501 if(pStateReal->lifeData.sensorVoltage_mV[loop] > 0.0001) /* sensor connected ?*/ | |
502 { | |
503 pSettings->ppo2sensors_calibCoeff[loop] = compensatedRef / pStateReal->lifeData.sensorVoltage_mV[loop]; | |
504 } | |
505 else | |
506 { | |
507 pSettings->ppo2sensors_calibCoeff[loop] = 0.0; | |
508 settingsGetPointer()->ppo2sensors_deactivated |= 0x1 << loop; | |
509 } | |
510 } | |
511 } | |
512 tMenuEdit_newInput(editId, O2_calib_gas, 0, 0, 0); | |
513 retVal = UPDATE_DIVESETTINGS; | |
514 } | |
515 if(action == ACTION_BUTTON_NEXT) | |
516 { | |
517 if(O2_calib_gas == 21) | |
475 { | 518 { |
476 if(pStateReal->lifeData.sensorVoltage_mV[loop] > 0.0001) /* sensor connected ?*/ | 519 O2_calib_gas = 100; |
477 { | |
478 pSettings->ppo2sensors_calibCoeff[loop] = O2_CALIB_FRACTION_AIR / pStateReal->lifeData.sensorVoltage_mV[loop]; | |
479 } | |
480 else | |
481 { | |
482 pSettings->ppo2sensors_calibCoeff[loop] = 0.0; | |
483 settingsGetPointer()->ppo2sensors_deactivated |= 0x1 << loop; | |
484 tMenuEdit_set_on_off(editId, 0); | |
485 } | |
486 } | 520 } |
487 } | 521 else |
488 | 522 { |
489 return UPDATE_DIVESETTINGS; | 523 O2_calib_gas = 21; |
524 } | |
525 } | |
526 retVal = O2_calib_gas; | |
527 | |
528 if(action == ACTION_BUTTON_BACK) | |
529 { | |
530 exitMenuEditField(); | |
531 } | |
532 | |
533 return retVal; | |
490 } | 534 } |
491 uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 535 uint8_t OnAction_O2_Source (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
492 { | 536 { |
493 uint8_t source = settingsGetPointer()->ppo2sensors_source; | 537 uint8_t source = settingsGetPointer()->ppo2sensors_source; |
494 | 538 |