Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: GHVentilatorChannel.h
- Revision:
- 4:de69851cf725
- Parent:
- 3:d15b6579b5ae
- Child:
- 5:da629056644f
--- a/GHVentilatorChannel.h Wed Apr 08 07:16:51 2020 +0000 +++ b/GHVentilatorChannel.h Wed Apr 08 11:28:42 2020 +0000 @@ -10,18 +10,9 @@ #pragma once #ifndef GHVentilatorChannelDecl #define GHVentilatorChannelDecl -#include <mbedBug.h> -using namespace mbedBug; #include "GHVentilatorConfig.h" #include "BMP280.h" -#ifndef GHVentilatorChannelsCount -#define GHVentilatorChannelsCount 1 -#endif - -#define GHVentilatorPressureHysteresis 0.000001f -#define GHVentilatorPressureTemperature 0.000001f - volatile int CurrentChannel = -1; volatile bool TooMuchAir = false; @@ -29,73 +20,69 @@ /* A Gravity Hookah Ventilator channel for one patient. */ class GHVentilatorChannel { - public: + public: - int Ticks, //< Ticks since the beginning of the inhale. - TicksInhale, //< The ticks in the inhale duty half-period. - TicksExhale; //< The period of the breathing. - volatile int TicksFlowLast, //< The previous saved count. - TicksFlow; //< Flow sensor pulse count. - int TicksFlowInhale, //< Number of flow sensor ticks on the last exhale. - ServoClosed, //< The min servo duty cycle of no air flow. - ServoOpen; //< The max servo duty cycle of an open tube. - float ReferencePressure, //< The pressure in the mask at one atmosphere. - ReferenceTemperature; //< The refernce temperature, - BMP280 Atmosphere; //< The air Atmosphere going to the patient. - InterruptIn Sensor; //< The flow sensor pin. - DigitalOut Valve, //< The Solenoid valve. - Status; //< The Status LED and optional alarm. - PwmOut Servo; //< The Servo for reducing the pressrue. - AnalogIn PulseOximeter; //< The PulseOximeterentiometer pin. + int Ticks, //< Ticks since the beginning of the inhale. + TicksExhale, //< The period of the breathing. + TicksInhale, //< The tick count in the inhale duty cycle. + TicksFlowInhale; //< Flow sensor tick count on the last exhale. + volatile int TicksFlowLast, //< The previous saved count. + TicksFlow; //< Flow sensor pulse count. + BMP280 Atmosphere; //< The air Atmosphere going to the patient. + float PressureReference, //< The pressure in the mask at one atmosphere. + TemperatureReference; //< The refernce temperature, + AnalogIn PulseOximeter; //< The 7-pin pulse oximeter pin. + InterruptIn FlowSensor; //< The flow sensor pin. + DigitalOut Valve, //< The Solenoid valve. + Status; //< The Status LED and optional alarm. + PwmOut Servo; //< The Servo for reducing the pressrue. + int ServoClosed, //< The min servo duty cycle of no air flow. + ServoOpen; //< The max servo duty cycle of an open tube. - /* Constructs a smart waterer. */ - GHVentilatorChannel (PinName SensorPin, - PinName PulseOximeterPin, - PinName SolenoidPin, - PinName StatusPin, - PinName ServoPin, - I2C& I2CBus, char I2CAddress); + /* Constructs a smart waterer. */ + GHVentilatorChannel (PinName PulseOximeterPin, + PinName SensorPin, + PinName SolenoidPin, + PinName StatusPin, + PinName ServoPin, + I2C& AtmosphereAddress, char I2CAddress, + float PressureHysteresis); - /* Returns a pointer to this. */ - GHVentilatorChannel* This(); + /* Returns a pointer to this. */ + GHVentilatorChannel* This(); - /* Sets the number of ticks on the inhale and exhale. */ - void TicksInhaleExhaleSet (int NewTicksInhale, int NewTicksExhale); + /* Sets the number of ticks on the inhale and exhale. */ + void TicksInhaleExhaleSet (int NewTicksInhale, int NewTicksExhale); - /* BreatheStarts to the begining of the watering cycle. */ - void BreatheStart (int Index); + /* BreatheStarts to the begining of the watering cycle. */ + void BreatheStart (int Index); - /* Increments theflow rate sensor pulse counter. */ - void PulseFlowSensor (); + /* Increments theflow rate sensor pulse counter. */ + void PulseFlowSensor (); - /* Prints the state of object to the debug stream. */ - void Print (int Index); + /* Prints the state of object to the debug stream. */ + void Print (int Index); - /* Polls the PulseOximeter and updates the target flow. */ - void Update (int Index); + /* Polls the PulseOximeter and updates the target flow. */ + void Update (int Index); - /* Updates the float rate. */ - bool CheckIfDoneBreathing (int Index); + /* Updates the float rate. */ + bool CheckIfDoneBreathing (int Index); - /* Opens the solenoid valve. */ - void Inhale (); + /* Opens the solenoid valve. */ + void Inhale (); - /* Closes the solenoid valve. */ - void Exhale (); - - /* Handles any errors. */ - void HandleError (); + /* Closes the solenoid valve. */ + void Exhale (); - /* Samples the Atmospheric pressure and temperature. */ - void Tare (); + /* Handles any errors. */ + void HandleError (); - /* Updates the channel with the DeviceTick. */ - void Update(); + /* Samples the Atmospheric pressure and temperature. */ + void Tare (); - private: - - /* Calculates the pulse target value from the PulseOximeter value. */ - inline int CalcPulseTarget (); + /* Updates the channel with the DeviceTick. */ + void Update(); }; } //< namespace SickBay -#endif //< GHVentilatorChannelDecl +#endif