comparison Discovery/Src/check_warning.c @ 756:6de83d8205a0

Added visualization of CO2 during dive: In the previous version CO2 values were available in sufrace mode only. Now the display of Co2 value has been added to the lower left corner view. In addition a Co2 alarm has been added. Early Co2 warning vaues will be displayed in yellow while critical values are shown in red.
author Ideenmodellierer
date Tue, 07 Mar 2023 20:02:05 +0100
parents b456be1e152d
children 29d9b5bc7946
comparison
equal deleted inserted replaced
755:92bf7bf9fb8a 756:6de83d8205a0
39 #include "tCCR.h" 39 #include "tCCR.h"
40 40
41 41
42 #define DEBOUNCE_FALLBACK_TIME_MS (5000u) /* set warning after 5 seconds of pending error condition */ 42 #define DEBOUNCE_FALLBACK_TIME_MS (5000u) /* set warning after 5 seconds of pending error condition */
43 43
44
44 /* Private variables with access ----------------------------------------------*/ 45 /* Private variables with access ----------------------------------------------*/
45 static uint8_t betterGasId = 0; 46 static uint8_t betterGasId = 0;
46 static uint8_t betterSetpointId = 0; 47 static uint8_t betterSetpointId = 0;
47 static int8_t fallback = 0; 48 static int8_t fallback = 0;
48 static uint16_t debounceFallbackTimeMS = 0; 49 static uint16_t debounceFallbackTimeMS = 0;
59 static int8_t check_BetterSetpoint(SDiveState * pDiveState); 60 static int8_t check_BetterSetpoint(SDiveState * pDiveState);
60 static int8_t check_Battery(SDiveState * pDiveState); 61 static int8_t check_Battery(SDiveState * pDiveState);
61 #ifdef ENABLE_BOTTLE_SENSOR 62 #ifdef ENABLE_BOTTLE_SENSOR
62 static int8_t check_pressureSensor(SDiveState * pDiveState); 63 static int8_t check_pressureSensor(SDiveState * pDiveState);
63 #endif 64 #endif
65 #ifdef ENABLE_CO2_SUPPORT
66 static int8_t check_co2(SDiveState * pDiveState);
67 #endif
64 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2); 68 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2);
65 69
66 /* Exported functions --------------------------------------------------------*/ 70 /* Exported functions --------------------------------------------------------*/
67 71
68 void check_warning(void) 72 void check_warning(void)
85 pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState); 89 pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState);
86 pDiveState->warnings.numWarnings += check_Battery(pDiveState); 90 pDiveState->warnings.numWarnings += check_Battery(pDiveState);
87 pDiveState->warnings.numWarnings += check_fallback(pDiveState); 91 pDiveState->warnings.numWarnings += check_fallback(pDiveState);
88 #ifdef ENABLE_BOTTLE_SENSOR 92 #ifdef ENABLE_BOTTLE_SENSOR
89 pDiveState->warnings.numWarnings += check_pressureSensor(pDiveState); 93 pDiveState->warnings.numWarnings += check_pressureSensor(pDiveState);
94 #endif
95 #ifdef ENABLE_CO2_SUPPORT
96 pDiveState->warnings.numWarnings += check_co2(pDiveState);
90 #endif 97 #endif
91 } 98 }
92 99
93 100
94 void set_warning_fallback(void) 101 void set_warning_fallback(void)
431 } 438 }
432 return ret; 439 return ret;
433 } 440 }
434 #endif 441 #endif
435 442
443 #ifdef ENABLE_CO2_SUPPORT
444 static int8_t check_co2(SDiveState * pDiveState)
445 {
446 if(pDiveState->mode != MODE_DIVE)
447 {
448 pDiveState->warnings.co2High = 0;
449 }
450 else
451 {
452 if(pDiveState->lifeData.CO2_data.CO2_ppm > CO2_ALARM_LEVEL_PPM)
453 {
454 pDiveState->warnings.co2High = 1;
455 }
456 else
457 {
458 pDiveState->warnings.co2High = 0;
459 }
460 }
461 return pDiveState->warnings.co2High;
462 }
463 #endif
464
436 uint8_t debounce_warning_fallback(uint16_t debounceStepms) 465 uint8_t debounce_warning_fallback(uint16_t debounceStepms)
437 { 466 {
438 uint8_t retVal = 0; 467 uint8_t retVal = 0;
439 468
440 debounceFallbackTimeMS += debounceStepms; 469 debounceFallbackTimeMS += debounceStepms;