Kabuki Starship / Mbed 2 deprecated GHVentilator

Dependencies:   mbed SickBayTek

Committer:
kabukistarship
Date:
Wed Apr 08 11:28:42 2020 +0000
Revision:
4:de69851cf725
Parent:
3:d15b6579b5ae
Child:
5:da629056644f
Misc fixes.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kabukistarship 2:1578ecfa9377 1 /** Gravity Hookah Ventilator @version 0.x
kabukistarship 2:1578ecfa9377 2 @link https://github.com/KabukiStarship/SickBay.git
kabukistarship 2:1578ecfa9377 3 @file /GHVentilatorChannel.h
kabukistarship 2:1578ecfa9377 4 @author Cale McCollough <https://cale-mccollough.github.io>
kabukistarship 2:1578ecfa9377 5 @license Copyright 2020 (C) Kabuki Starship <kabukistarship.com>.
kabukistarship 2:1578ecfa9377 6 This Source Code Form is subject to the terms of the Mozilla Public License,
kabukistarship 2:1578ecfa9377 7 v. 2.0. If a copy of the MPL was not distributed with this file, you can obtain
kabukistarship 2:1578ecfa9377 8 one at <https://mozilla.org/MPL/2.0/>. */
kabukistarship 2:1578ecfa9377 9
kabukistarship 2:1578ecfa9377 10 #pragma once
kabukistarship 2:1578ecfa9377 11 #ifndef GHVentilatorChannelDecl
kabukistarship 2:1578ecfa9377 12 #define GHVentilatorChannelDecl
kabukistarship 2:1578ecfa9377 13 #include "GHVentilatorConfig.h"
kabukistarship 2:1578ecfa9377 14 #include "BMP280.h"
kabukistarship 2:1578ecfa9377 15
kabukistarship 2:1578ecfa9377 16 volatile int CurrentChannel = -1;
kabukistarship 2:1578ecfa9377 17 volatile bool TooMuchAir = false;
kabukistarship 2:1578ecfa9377 18
kabukistarship 2:1578ecfa9377 19 namespace SickBay {
kabukistarship 2:1578ecfa9377 20
kabukistarship 2:1578ecfa9377 21 /* A Gravity Hookah Ventilator channel for one patient. */
kabukistarship 2:1578ecfa9377 22 class GHVentilatorChannel {
kabukistarship 4:de69851cf725 23 public:
kabukistarship 2:1578ecfa9377 24
kabukistarship 4:de69851cf725 25 int Ticks, //< Ticks since the beginning of the inhale.
kabukistarship 4:de69851cf725 26 TicksExhale, //< The period of the breathing.
kabukistarship 4:de69851cf725 27 TicksInhale, //< The tick count in the inhale duty cycle.
kabukistarship 4:de69851cf725 28 TicksFlowInhale; //< Flow sensor tick count on the last exhale.
kabukistarship 4:de69851cf725 29 volatile int TicksFlowLast, //< The previous saved count.
kabukistarship 4:de69851cf725 30 TicksFlow; //< Flow sensor pulse count.
kabukistarship 4:de69851cf725 31 BMP280 Atmosphere; //< The air Atmosphere going to the patient.
kabukistarship 4:de69851cf725 32 float PressureReference, //< The pressure in the mask at one atmosphere.
kabukistarship 4:de69851cf725 33 TemperatureReference; //< The refernce temperature,
kabukistarship 4:de69851cf725 34 AnalogIn PulseOximeter; //< The 7-pin pulse oximeter pin.
kabukistarship 4:de69851cf725 35 InterruptIn FlowSensor; //< The flow sensor pin.
kabukistarship 4:de69851cf725 36 DigitalOut Valve, //< The Solenoid valve.
kabukistarship 4:de69851cf725 37 Status; //< The Status LED and optional alarm.
kabukistarship 4:de69851cf725 38 PwmOut Servo; //< The Servo for reducing the pressrue.
kabukistarship 4:de69851cf725 39 int ServoClosed, //< The min servo duty cycle of no air flow.
kabukistarship 4:de69851cf725 40 ServoOpen; //< The max servo duty cycle of an open tube.
kabukistarship 2:1578ecfa9377 41
kabukistarship 4:de69851cf725 42 /* Constructs a smart waterer. */
kabukistarship 4:de69851cf725 43 GHVentilatorChannel (PinName PulseOximeterPin,
kabukistarship 4:de69851cf725 44 PinName SensorPin,
kabukistarship 4:de69851cf725 45 PinName SolenoidPin,
kabukistarship 4:de69851cf725 46 PinName StatusPin,
kabukistarship 4:de69851cf725 47 PinName ServoPin,
kabukistarship 4:de69851cf725 48 I2C& AtmosphereAddress, char I2CAddress,
kabukistarship 4:de69851cf725 49 float PressureHysteresis);
kabukistarship 2:1578ecfa9377 50
kabukistarship 4:de69851cf725 51 /* Returns a pointer to this. */
kabukistarship 4:de69851cf725 52 GHVentilatorChannel* This();
kabukistarship 2:1578ecfa9377 53
kabukistarship 4:de69851cf725 54 /* Sets the number of ticks on the inhale and exhale. */
kabukistarship 4:de69851cf725 55 void TicksInhaleExhaleSet (int NewTicksInhale, int NewTicksExhale);
kabukistarship 2:1578ecfa9377 56
kabukistarship 4:de69851cf725 57 /* BreatheStarts to the begining of the watering cycle. */
kabukistarship 4:de69851cf725 58 void BreatheStart (int Index);
kabukistarship 2:1578ecfa9377 59
kabukistarship 4:de69851cf725 60 /* Increments theflow rate sensor pulse counter. */
kabukistarship 4:de69851cf725 61 void PulseFlowSensor ();
kabukistarship 2:1578ecfa9377 62
kabukistarship 4:de69851cf725 63 /* Prints the state of object to the debug stream. */
kabukistarship 4:de69851cf725 64 void Print (int Index);
kabukistarship 2:1578ecfa9377 65
kabukistarship 4:de69851cf725 66 /* Polls the PulseOximeter and updates the target flow. */
kabukistarship 4:de69851cf725 67 void Update (int Index);
kabukistarship 2:1578ecfa9377 68
kabukistarship 4:de69851cf725 69 /* Updates the float rate. */
kabukistarship 4:de69851cf725 70 bool CheckIfDoneBreathing (int Index);
kabukistarship 2:1578ecfa9377 71
kabukistarship 4:de69851cf725 72 /* Opens the solenoid valve. */
kabukistarship 4:de69851cf725 73 void Inhale ();
kabukistarship 2:1578ecfa9377 74
kabukistarship 4:de69851cf725 75 /* Closes the solenoid valve. */
kabukistarship 4:de69851cf725 76 void Exhale ();
kabukistarship 3:d15b6579b5ae 77
kabukistarship 4:de69851cf725 78 /* Handles any errors. */
kabukistarship 4:de69851cf725 79 void HandleError ();
kabukistarship 2:1578ecfa9377 80
kabukistarship 4:de69851cf725 81 /* Samples the Atmospheric pressure and temperature. */
kabukistarship 4:de69851cf725 82 void Tare ();
kabukistarship 2:1578ecfa9377 83
kabukistarship 4:de69851cf725 84 /* Updates the channel with the DeviceTick. */
kabukistarship 4:de69851cf725 85 void Update();
kabukistarship 2:1578ecfa9377 86 };
kabukistarship 2:1578ecfa9377 87 } //< namespace SickBay
kabukistarship 4:de69851cf725 88 #endif