10 #include "../includes/config.h"
15 #include "../includes/blower.h"
16 #include "../includes/buzzer.h"
17 #include "../includes/calibration.h"
18 #include "../includes/keyboard.h"
19 #include "../includes/mass_flow_meter.h"
20 #include "../includes/pressure.h"
21 #include "../includes/pressure_valve.h"
22 #include "../includes/screen.h"
23 #include "../includes/telemetry.h"
38 #define RESTART_READ_KEYBOARD_DELAY 100
62 int32_t inspiratoryPressureSensorOffset = 0;
65 inspiratoryPressureSensorOffset =
68 inspiratoryPressureSensorOffset = 0;
98 #ifdef MASS_FLOW_METER_ENABLED
102 int32_t flowMeterFlowAtStarting = 0;
111 #ifdef MASS_FLOW_METER_ENABLED
114 int32_t flowMeterFlowWithBlowerOn = 30000;
120 bool isMassFlowMeterOutOfRange = ((flowMeterFlowAtStarting < -1000)
121 || (flowMeterFlowAtStarting > 1000));
123 if ((isMassFlowMeterOutOfRange ==
true)
124 || ((flowMeterFlowWithBlowerOn < 20000) || (flowMeterFlowWithBlowerOn > 100000))) {
140 if (isMassFlowMeterOutOfRange ==
true) {
147 flowMeterFlowAtStarting,
148 flowMeterFlowWithBlowerOn);
160 #ifdef MASS_FLOW_METER_ENABLED
172 uint16_t start = millis();
184 while ((millis() - start) < ms) {
void Buzzer_High_Prio_Start(void)
Activate the buzzer pattern for high priority alarms.
void Buzzer_Boot_Start(void)
Activate boot bip.
void Calibration_Init()
Initialization of calibration process.
void Calibration_Wait_Measure_Pressure(uint16_t ms)
Block execution for a given duration.
uint32_t pressureOffsetCount
uint32_t restartWaitTimer
#define RESTART_READ_KEYBOARD_DELAY
void Calibration_Read_Keyboard_Delayed()
Read keyboard duing calibration process (delayed)
bool Calibration_Started()
Check if calibration mode is started.
int32_t pressureOffsetSum
void Calibration_Restart()
Restart calibration process.
void stop()
Stops the blower.
void runSpeed(uint16_t p_runSpeed)
Run the blower to a given speed.
int32_t read()
Read the current pressure for the feedback control.
void setPressureSensorOffset(int32_t p_pressureSensorOffest)
Set the pressure sensor offset.
void execute()
Command the valve to go to the requested aperture.
void open()
Request opening of the Pressure Valve.
void close()
Request closing of the Pressure Valve.
void keyboardLoop()
Handle button events.
int32_t MFM_getOffset(void)
Get massflow meter offset.
int8_t MFM_calibrateZero(void)
If the massflow meter needs to be calibrated, this function will be usefull.
int32_t MFM_read_airflow(void)
Read instant air flow.
#define LED_START_INACTIVE
#define DEFAULT_BLOWER_SPEED
#define LED_YELLOW_INACTIVE
#define LED_GREEN_INACTIVE
#define LED_YELLOW_ACTIVE
#define MAX_PRESSURE_OFFSET
PressureSensor inspiratoryPressureSensor
PressureValve inspiratoryValve
PressureValve expiratoryValve
void displayPressureOffsetUnstable(uint32_t p_minOffsetValue, uint32_t p_maxOffsetValue)
Display error when pressure offset is unstable.
void displayFlowMeterOffset(int32_t p_flowMeterFlowOffset)
Display flow meter offset.
void displayPressureOffset(int32_t p_inspiratoryPressureSensorOffset)
Display pressure offset.
void displayPatientMustBeUnplugged()
Display the "calibration in progress" message.
void resetScreen()
Erase everything that is on the screen.
void displayFlowMeterFail(int32_t p_flowMeterFlowAtStarting, int32_t p_flowMeterFlowWithBlowerOn)
Display error when flow meter fails.
void sendMassFlowMeterFatalError(void)
Send a "mass flow meter" fatal error.
void sendCalibrationFatalError(int16_t pressureOffsetValue, int16_t minPressureValue, int16_t maxPressureValue, int16_t flowAtStartingValue, int16_t flowWithBlowerOnValue)
void sendInconsistentPressureFatalError(uint16_t pressureValue)