Skip to content

Commit ded9165

Browse files
Merge pull request #83 from makers-for-life/dev
Fixes + send all fatal errors to telemetry on startup calibration (full tested w/ UI)
2 parents 6d157e6 + 6f83e19 commit ded9165

File tree

3 files changed

+195
-179
lines changed

3 files changed

+195
-179
lines changed

includes/telemetry.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,20 @@ void sendControlAck(uint8_t setting, uint16_t value);
129129
void sendWatchdogRestartFatalError(void);
130130

131131
// /// Send a "calibration" fatal error
132-
// void sendCalibrationFatalError(int16_t pressureOffsetValue,
133-
// int16_t minPressureValue,
134-
// int16_t maxPressureValue,
135-
// int16_t flowAtStartingValue,
136-
// int16_t flowWithBlowerOnValue);
132+
void sendCalibrationFatalError(int16_t pressureOffsetValue,
133+
int16_t minPressureValue,
134+
int16_t maxPressureValue,
135+
int16_t flowAtStartingValue,
136+
int16_t flowWithBlowerOnValue);
137137

138138
/// Send a "battery deeply discharged" fatal error
139139
void sendBatteryDeeplyDischargedFatalError(uint16_t batteryLevelValue);
140140

141-
// /// Send a "mass flow meter" fatal error
142-
// void sendMassFlowMeterFatalError(void);
141+
/// Send a "mass flow meter" fatal error
142+
void sendMassFlowMeterFatalError(void);
143143

144144
// /// Send a "inconsistent pressure" fatal error
145-
// void sendInconsistentPressureFatalError(uint16_t pressureValue);
145+
void sendInconsistentPressureFatalError(uint16_t pressureValue);
146146

147147
/**
148148
* Convert and round a pressure in mmH2O to a pressure in cmH2O

srcs/calibration.cpp

+19-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "../includes/pressure.h"
2121
#include "../includes/pressure_valve.h"
2222
#include "../includes/screen.h"
23+
#include "../includes/telemetry.h"
2324

2425
// External
2526
#include "Arduino.h"
@@ -71,6 +72,7 @@ void Calibration_Init() {
7172
// Invalid calibration
7273
calibrationValid = false;
7374
displayPressureOffsetUnstable(minOffsetValue, maxOffsetValue);
75+
sendInconsistentPressureFatalError(inspiratoryPressureSensorOffset);
7476
Buzzer_High_Prio_Start();
7577
Calibration_Read_Keyboard();
7678
} else {
@@ -101,11 +103,26 @@ void Calibration_Init() {
101103
blower.stop();
102104

103105
// Happens when flow meter fails
104-
if (((flowMeterFlowAtStarting < -1000) || (flowMeterFlowAtStarting > 1000)
105-
|| (flowMeterFlowWithBlowerOn < 20000) || (flowMeterFlowWithBlowerOn > 100000))) {
106+
bool isMassFlowMeterOutOfRange = ((flowMeterFlowAtStarting < -1000)
107+
|| (flowMeterFlowAtStarting > 1000));
108+
109+
if ((isMassFlowMeterOutOfRange == true)
110+
|| ((flowMeterFlowWithBlowerOn < 20000) || (flowMeterFlowWithBlowerOn > 100000))) {
106111
// Invalid calibration
107112
calibrationValid = false;
108113
displayFlowMeterFail(flowMeterFlowAtStarting, flowMeterFlowWithBlowerOn);
114+
115+
// MFM reports an out-of-range value, it might not be connected
116+
if (isMassFlowMeterOutOfRange == true) {
117+
// MFM failure (eg. not connected)
118+
sendMassFlowMeterFatalError();
119+
} else {
120+
// Other calibration errors
121+
sendCalibrationFatalError(inspiratoryPressureSensorOffset, minOffsetValue,
122+
maxOffsetValue, flowMeterFlowAtStarting,
123+
flowMeterFlowWithBlowerOn);
124+
}
125+
109126
Buzzer_High_Prio_Start();
110127
Calibration_Read_Keyboard();
111128
} else {

0 commit comments

Comments
 (0)