comparison Discovery/Src/settings.c @ 1014:8c0134a287da GasConsumption

Add a log data event to the scrubber timer at the start of the dive and every time the timer (in minutes) is decremented. The event contains a 12 bit signed integer for the remaining scrubber duration, and two flags for scrubber warning (0x2000, <= 30 minutes remaining) and scrubber error (0x4000, <= 0 minutes remaining). (mikeller)
author heinrichsweikamp
date Sun, 11 May 2025 16:18:20 +0200
parents 085e9c04b76b
children 5924a2d1d3ba
comparison
equal deleted inserted replaced
1013:fa1af49319e5 1014:8c0134a287da
328 .ppo2sensors_calibCoeff[2] = 0.0, 328 .ppo2sensors_calibCoeff[2] = 0.0,
329 .amPMTime = 0, 329 .amPMTime = 0,
330 .autoSetpoint = 0, 330 .autoSetpoint = 0,
331 .scrubTimerMax_Obsolete = 0, 331 .scrubTimerMax_Obsolete = 0,
332 .scrubTimerCur_Obsolete = 0, 332 .scrubTimerCur_Obsolete = 0,
333 .scrubTimerMode = SCRUB_TIMER_OFF, 333 .scrubTimerMode = SCRUB_TIMER_MINUTES,
334 .ext_sensor_map[0] = SENSOR_OPTIC, 334 .ext_sensor_map[0] = SENSOR_OPTIC,
335 .ext_sensor_map[1] = SENSOR_OPTIC, 335 .ext_sensor_map[1] = SENSOR_OPTIC,
336 .ext_sensor_map[2] = SENSOR_OPTIC, 336 .ext_sensor_map[2] = SENSOR_OPTIC,
337 .ext_sensor_map[3] = SENSOR_NONE, 337 .ext_sensor_map[3] = SENSOR_NONE,
338 .ext_sensor_map[4] = SENSOR_NONE, 338 .ext_sensor_map[4] = SENSOR_NONE,
499 case 0xFFFF0017: 499 case 0xFFFF0017:
500 setFlipDisplay(0); 500 setFlipDisplay(0);
501 // no break 501 // no break
502 case 0xFFFF0018: 502 case 0xFFFF0018:
503 pSettings->cv_configuration = 0xFFFFFFFF; 503 pSettings->cv_configuration = 0xFFFFFFFF;
504 pSettings->cv_configuration &= pSettings->cv_configuration ^= 1 << (CVIEW_Timer); 504 pSettings->cv_configuration &= ~(1 << CVIEW_sensors | 1 << CVIEW_sensors_mV | 1 << CVIEW_Timer);
505 // no break 505 // no break
506 case 0xFFFF0019: 506 case 0xFFFF0019:
507 pSettings->MotionDetection = MOTION_DETECT_OFF; 507 pSettings->MotionDetection = MOTION_DETECT_OFF;
508 // no break 508 // no break
509 case 0xFFFF001A: 509 case 0xFFFF001A:
510 /* deactivate new views => to be activated by customer */ 510 /* deactivate new views => to be activated by customer */
511 pSettings->cv_config_BigScreen = 0xFFFFFFFF; 511 pSettings->cv_config_BigScreen = 0xFFFFFFFF;
512 pSettings->cv_config_BigScreen &= pSettings->cv_configuration ^= 1 << (CVIEW_T3_Navigation + LEGACY_T3_START_ID_PRE_TIMER); 512 pSettings->cv_config_BigScreen &= 1 << (CVIEW_T3_Navigation + LEGACY_T3_START_ID_PRE_TIMER);
513 pSettings->cv_config_BigScreen &= pSettings->cv_configuration ^= 1 << (CVIEW_T3_DepthData + LEGACY_T3_START_ID_PRE_TIMER); 513 pSettings->cv_config_BigScreen &= 1 << (CVIEW_T3_DepthData + LEGACY_T3_START_ID_PRE_TIMER);
514 // no break 514 // no break
515 case 0xFFFF001B: 515 case 0xFFFF001B:
516 pSettings->compassInertia = 0; /* no inertia */ 516 pSettings->compassInertia = 0; /* no inertia */
517 pSettings->tX_customViewPrimaryBF = CVIEW_T3_Decostop; 517 pSettings->tX_customViewPrimaryBF = CVIEW_T3_Decostop;
518 pSettings->cv_config_BigScreen &= pSettings->cv_configuration ^= 1 << (CVIEW_T3_DecoTTS + LEGACY_T3_START_ID_PRE_TIMER); 518 pSettings->cv_config_BigScreen &= 1 << (CVIEW_T3_DecoTTS + LEGACY_T3_START_ID_PRE_TIMER);
519 // no break 519 // no break
520 case 0xFFFF001C: 520 case 0xFFFF001C:
521 pSettings->viewPortMode = 0; 521 pSettings->viewPortMode = 0;
522 pSettings->viewRoll = 0; 522 pSettings->viewRoll = 0;
523 pSettings->viewPitch = 0; 523 pSettings->viewPitch = 0;
532 // no break 532 // no break
533 case 0xFFFF001E: 533 case 0xFFFF001E:
534 pSettings->autoSetpoint = 0; 534 pSettings->autoSetpoint = 0;
535 pSettings->scrubTimerMax_Obsolete = 0; 535 pSettings->scrubTimerMax_Obsolete = 0;
536 pSettings->scrubTimerCur_Obsolete = 0; 536 pSettings->scrubTimerCur_Obsolete = 0;
537 pSettings->scrubTimerMode = SCRUB_TIMER_OFF; 537 pSettings->scrubTimerMode = SCRUB_TIMER_MINUTES;
538 // no break 538 // no break
539 case 0xFFFF001F: 539 case 0xFFFF001F:
540 pSettings->pscr_lung_ratio = 10; 540 pSettings->pscr_lung_ratio = 10;
541 pSettings->pscr_o2_drop = 4; 541 pSettings->pscr_o2_drop = 4;
542 // no break 542 // no break
545 // no break; 545 // no break;
546 case 0xFFFF0021: 546 case 0xFFFF0021:
547 pSettings->ext_uart_protocol = 0; 547 pSettings->ext_uart_protocol = 0;
548 // no break; 548 // no break;
549 case 0xFFFF0022: 549 case 0xFFFF0022:
550 pSettings->scubberActiveId = 0; 550 pSettings->scrubberActiveId = 0;
551 pSettings->scrubberData[0].TimerCur = pSettings->scrubTimerCur_Obsolete; 551 pSettings->scrubberData[0].TimerCur = pSettings->scrubTimerCur_Obsolete;
552 pSettings->scrubberData[0].TimerMax = pSettings->scrubTimerMax_Obsolete; 552 pSettings->scrubberData[0].TimerMax = pSettings->scrubTimerMax_Obsolete;
553 pSettings->scrubberData[0].lastDive.WeekDay = 0; 553 pSettings->scrubberData[0].lastDive.WeekDay = 0;
554 pSettings->scrubberData[0].lastDive.Month = 0; 554 pSettings->scrubberData[0].lastDive.Month = 0;
555 pSettings->scrubberData[0].lastDive.Date = 0; 555 pSettings->scrubberData[0].lastDive.Date = 0;
1765 Settings.autoSetpoint = 0; 1765 Settings.autoSetpoint = 0;
1766 corrections++; 1766 corrections++;
1767 setFirstCorrection(parameterId); 1767 setFirstCorrection(parameterId);
1768 } 1768 }
1769 parameterId++; /* 91 */ 1769 parameterId++; /* 91 */
1770 if(Settings.scubberActiveId > 3) /* scrubber active is used as bitfield => two timer => 2 bits in use */ 1770 if (Settings.scrubberActiveId > 0x03) {
1771 { 1771 /* scrubber active is used as bitfield => two timer => 2 bits in use */
1772 Settings.scubberActiveId = 0; 1772 Settings.scrubberActiveId = 0x00;
1773 corrections++; 1773 corrections++;
1774 setFirstCorrection(parameterId); 1774 setFirstCorrection(parameterId);
1775 } 1775 }
1776 parameterId++; /* 92 */ 1776 parameterId++; /* 92 */
1777 if((Settings.scrubberData[0].TimerMax > MAX_SCRUBBER_TIME) || Settings.scrubberData[0].TimerCur < MIN_SCRUBBER_TIME || Settings.scrubberData[0].TimerCur > (int16_t)MAX_SCRUBBER_TIME) 1777 if((Settings.scrubberData[0].TimerMax > MAX_SCRUBBER_TIME) || Settings.scrubberData[0].TimerCur < MIN_SCRUBBER_TIME || Settings.scrubberData[0].TimerCur > (int16_t)MAX_SCRUBBER_TIME)
1778 { 1778 {
1779 Settings.scrubberData[0].TimerMax = 0; 1779 Settings.scrubberData[0].TimerMax = 0;
1788 Settings.scrubberData[1].TimerCur = 0; 1788 Settings.scrubberData[1].TimerCur = 0;
1789 corrections++; 1789 corrections++;
1790 setFirstCorrection(parameterId); 1790 setFirstCorrection(parameterId);
1791 } 1791 }
1792 parameterId++; /* 94 */ 1792 parameterId++; /* 94 */
1793 if(Settings.scrubTimerMode > SCRUB_TIMER_END) 1793 if (Settings.scrubTimerMode == INVALID_SCRUB_TIMER_OFF || Settings.scrubTimerMode > SCRUB_TIMER_END) {
1794 { 1794 Settings.scrubTimerMode = SCRUB_TIMER_MINUTES;
1795 Settings.scrubTimerMode = SCRUB_TIMER_OFF;
1796 corrections++; 1795 corrections++;
1797 setFirstCorrection(parameterId); 1796 setFirstCorrection(parameterId);
1798 } 1797 }
1799 parameterId++; /* 95 */ 1798 parameterId++; /* 95 */
1800 if((Settings.pscr_lung_ratio > PSCR_MAX_LUNG_RATIO) || (Settings.pscr_lung_ratio < PSCR_MIN_LUNG_RATIO)) 1799 if((Settings.pscr_lung_ratio > PSCR_MAX_LUNG_RATIO) || (Settings.pscr_lung_ratio < PSCR_MIN_LUNG_RATIO))
1994 pSettings->firmwareVersion[2] = firmware_FirmwareData.versionThird; 1993 pSettings->firmwareVersion[2] = firmware_FirmwareData.versionThird;
1995 pSettings->firmwareVersion[3] = firmware_FirmwareData.versionBeta; 1994 pSettings->firmwareVersion[3] = firmware_FirmwareData.versionBeta;
1996 1995
1997 memset(pSettings->customtext,0,60); 1996 memset(pSettings->customtext,0,60);
1998 sprintf(pSettings->customtext," <your name>\n <address>"); 1997 sprintf(pSettings->customtext," <your name>\n <address>");
1999 pSettings->cv_configuration &= (pSettings->cv_configuration ^= 1 << (CVIEW_Timer)); 1998 pSettings->cv_configuration &= ~(1 << CVIEW_sensors | 1 << CVIEW_sensors_mV | 1 << CVIEW_Timer);
2000 1999
2001 set_new_settings_missing_in_ext_flash(); 2000 set_new_settings_missing_in_ext_flash();
2002 check_and_correct_settings(); 2001 check_and_correct_settings();
2003 // has to be called too: createDiveSettings(); 2002 // has to be called too: createDiveSettings();
2004 } 2003 }
3387 3386
3388 void reset_SettingWarning() 3387 void reset_SettingWarning()
3389 { 3388 {
3390 settingsWarning = 0; 3389 settingsWarning = 0;
3391 } 3390 }
3391
3392 inline uint8_t isSettingsWarning() 3392 inline uint8_t isSettingsWarning()
3393 { 3393 {
3394 return settingsWarning; 3394 return settingsWarning;
3395 } 3395 }
3396
3397 bool isScrubberError(const SScrubberData *scrubberData)
3398 {
3399 if (scrubberData->TimerCur <= SCRUBBER_ERROR_TIME) {
3400 return true;
3401 }
3402
3403 return false;
3404 }
3405
3406 bool isScrubberWarning(const SScrubberData *scrubberData)
3407 {
3408 if (scrubberData->TimerCur <= SCRUBBER_WARNING_TIME) {
3409 return true;
3410 }
3411
3412 return false;
3413 }