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:
- 9:256989faeb3b
- Parent:
- 8:fa5cc1397510
diff -r fa5cc1397510 -r 256989faeb3b GHVentilatorChannel.h --- a/GHVentilatorChannel.h Thu Apr 09 03:18:31 2020 +0000 +++ b/GHVentilatorChannel.h Fri Apr 10 11:56:58 2020 +0000 @@ -6,70 +6,64 @@ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, you can obtain one at <https://mozilla.org/MPL/2.0/>. */ - #pragma once #ifndef GHVentilatorChannelDecl #define GHVentilatorChannelDecl -#include "GHVentilatorConfig.h" -#include "BMP280.h" - +#include <stdint.h> +#ifndef GHVentilatorChannelCount +#error You must define the GHVentilatorChannelCount before including \ + "GHVentilator.hpp" +#endif namespace SickBay { + +class GHVentilator; /* A Gravity Hookah Ventilator channel for one patient. */ class GHVentilatorChannel { public: enum { - StateInhaling = 1, //< The value for the init Ticks inhale value. - StateExhaling = -1, //< The value for the init Ticks exhale value. + StateInhaling = 1, //< The inhaling state is where Ticks < 0. + StateOff = 0, //< The off state is where Ticks = 0. + StateExhaling = -1, //< The exhaling state is where Ticks > 0. }; - - volatile int Ticks; //< Ticks since the beginning of the inhale. - int TicksExhale, //< The period of the breathing. - TicksInhale, //< The tick count in the inhale duty cycle. - TicksPEEP; //< The max ticks between an exhale and inhale. - volatile int TicksFlowLast, //< The previous inhale TicksFlow count. - TicksFlow; //< Flow sensor pulse TicksFlow count. - BMP280 Atmosphere; //< The air Atmosphere going to the patient. - float Temperature, //< The Temperature of the patients breath. - TemperatureReference, //< The refernce temperature, - Pressure, //< The pressure in the patient's mask. - PressureReference; //< The pressure in the mask at one atmosphere. - AnalogIn PulseOximeter; //< The 7-pin pulse oximeter pin. - InterruptIn FlowSensor; //< The flow sensor pin. - DigitalOut Valve; //< 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. - Status; //< The channel Status. + + GHVentilator* Parent; //< The GHVentilator this is part of. + int Ticks, //< Ticks since the beginning of the inhale. + TicksInhale, //< The tick count in the inhale duty cycle. + TicksExhale, //< The period of the breathing. + TicksFlow, //< The number of flow sensor ticks. + TicksFlowLast, //< The previous inhale cycle TicksFlow count. + PulseOximeter, //< The 7-pin pulse oximeter value. + Servo, //< The Servo for reducing the pressrue. + ServoClosed, //< The min servo duty cycle of no air flow. + ServoOpen; //< The max servo duty cycle of an open tube. + int32_t Temperature, //< The Temperature of the patients breath. + TemperatureReference; //< The refernce temperature upon Tare. + uint32_t Pressure, //< The pressure in the patient's mask. + PressureReference, //< About 1 atmosphere + the hysteresis delta. + PressureHysteresis; //< The hysteresis above the PressureReference. + + /* Initializes the channel. + @param PressureHysteresis 1.0 + the percent hysteresis up and down from the + center the + */ + void Init (GHVentilator* Parent, int TicksInhale, int TicksExhale, + float ChannelPressureHysteresis); - /* Constructs a smart waterer. */ - GHVentilatorChannel (PinName PulseOximeterPin, - PinName FlowSensorPin, - PinName SolenoidPin, - PinName ServoPin, - I2C& Bus, char BusAddress); + /* Doesn't do anything and requires a call to . */ + GHVentilatorChannel (); /* Returns a pointer to this. */ GHVentilatorChannel* This(); - /* Sets the TicksPEEP. */ - void TicksPEEPSet (int NewTicksPEEP, int TicksSecond); - - /* Turns off this channel. */ - void TurnOff (); + void ChannelValveSet (GHVentilatorChannel* Channel, int Value); - /* Turns on the this chanel. */ - void TurnOn (); - - /* Polls the hardware for changes. */ - void Poll(); + /* Turns this channel off. */ + void TurnOff (); /* 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); /* Increments theflow rate sensor pulse counter. */ void TickFlow (); @@ -77,9 +71,6 @@ /* Prints the state of object to the debug stream. */ void Print (int Index); - /* Updates the float rate. */ - bool CheckIfDoneBreathing (int Index); - /* Opens the solenoid valve. */ void Inhale ();