Kabuki Starship / Mbed 2 deprecated GHVentilator

Dependencies:   mbed SickBayTek

Committer:
kabukistarship
Date:
Thu Apr 09 03:18:31 2020 +0000
Revision:
8:fa5cc1397510
Parent:
6:b2672da545f1
Child:
9:256989faeb3b
Detail.GHVentilator.Firmware.Mbed.Move BMP280 polling code into main loop; States.Add PEEP state. #67 #D

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kabukistarship 2:1578ecfa9377 1 /** Gravity Hookah Ventilator @version 0.x
kabukistarship 3:d15b6579b5ae 2 @link https://github.com/KabukiStarship/SickBay.git
kabukistarship 3:d15b6579b5ae 3 @file /GHVentilator.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 #pragma once
kabukistarship 2:1578ecfa9377 10 #ifndef GHVentilatorDecl
kabukistarship 2:1578ecfa9377 11 #define GHVentilatorDecl
kabukistarship 2:1578ecfa9377 12 #include "GHVentilatorChannel.h"
kabukistarship 2:1578ecfa9377 13 namespace SickBay {
kabukistarship 2:1578ecfa9377 14
kabukistarship 2:1578ecfa9377 15 /* A Gravity Hookah Ventilator. */
kabukistarship 2:1578ecfa9377 16 class GHVentilator {
kabukistarship 3:d15b6579b5ae 17 public:
kabukistarship 3:d15b6579b5ae 18
kabukistarship 3:d15b6579b5ae 19 enum {
kabukistarship 3:d15b6579b5ae 20 ChannelCountMax = 4,
kabukistarship 6:b2672da545f1 21 StateCalibrateEnterTicks = -1,
kabukistarship 6:b2672da545f1 22 StateRunningEnter = 1,
kabukistarship 3:d15b6579b5ae 23 };
kabukistarship 3:d15b6579b5ae 24
kabukistarship 3:d15b6579b5ae 25 // The tick and negative calibrating positive running states.
kabukistarship 6:b2672da545f1 26 volatile int Ticks;
kabukistarship 6:b2672da545f1 27 int TicksMonitor, //< The max ticks between the Device monitors.
kabukistarship 6:b2672da545f1 28 TicksSecond, //< The number of Ticks per Second.
kabukistarship 6:b2672da545f1 29 TicksInhaleMin, //< The min inhale ticks.
kabukistarship 6:b2672da545f1 30 TicksInhaleMax, //< The max breath period of 20 seconds.
kabukistarship 6:b2672da545f1 31 TicksExhaleMin, //< The min ticks in an exhale.
kabukistarship 6:b2672da545f1 32 TicksExhaleMax, //< The max ticks in an exhale.
kabukistarship 6:b2672da545f1 33 TicksCalibration, //< The number of ticks in the calibration state.
kabukistarship 6:b2672da545f1 34 ChannelsCount; //< The number of GHVentilatorChannels.
kabukistarship 4:de69851cf725 35 GHVentilatorChannel* Channels[ChannelCountMax];
kabukistarship 6:b2672da545f1 36 BMP280 Atmosphere; //< Pressure sensor for the air tank.
kabukistarship 6:b2672da545f1 37 float Temperature, //< The Temperature in the tank.
kabukistarship 6:b2672da545f1 38 TemperatureReference, //< The Temperature in the tank.
kabukistarship 6:b2672da545f1 39 Pressure, //< The Pressure in the tank.
kabukistarship 6:b2672da545f1 40 PressureReference, //< The Pressure when the device is tared.
kabukistarship 6:b2672da545f1 41 PressureMin, //< The min Pressure.
kabukistarship 6:b2672da545f1 42 PressureMax, //< The max Pressure.
kabukistarship 6:b2672da545f1 43 HysteresisChamber, //< The pressure chamber hystersis +/- percent.
kabukistarship 6:b2672da545f1 44 HysteresisPatient; //< The patient Hystersis percent muliplier.
kabukistarship 6:b2672da545f1 45 DigitalOut Blower, //< A blower powered by a Solid State Relay.
kabukistarship 6:b2672da545f1 46 Status; //< Status pin for outputing the Device status.
kabukistarship 6:b2672da545f1 47 Ticker UpdateTicker; //< The x times per second update ticker.
kabukistarship 3:d15b6579b5ae 48
kabukistarship 4:de69851cf725 49 /* Constructs a GHV with 1 channel. */
kabukistarship 8:fa5cc1397510 50 GHVentilator (int TicksPerSecond, int TicksPEEP, int TicksCalibration,
kabukistarship 6:b2672da545f1 51 I2C& Bus, char BusAddress,
kabukistarship 4:de69851cf725 52 float PressureHysteresis,
kabukistarship 5:da629056644f 53 float HysteresisPatient,
kabukistarship 4:de69851cf725 54 PinName BlowerPin, PinName StatusPin,
kabukistarship 4:de69851cf725 55 GHVentilatorChannel* A);
kabukistarship 3:d15b6579b5ae 56
kabukistarship 4:de69851cf725 57 /* Constructs a GHV with 2 channels. */
kabukistarship 8:fa5cc1397510 58 GHVentilator (int TicksPerSecond, int TicksPEEP, int TicksCalibration,
kabukistarship 6:b2672da545f1 59 I2C& Bus, char BusAddress,
kabukistarship 5:da629056644f 60 float HysteresisChamber,
kabukistarship 4:de69851cf725 61 float PressureHysteresis,
kabukistarship 4:de69851cf725 62 PinName BlowerPin, PinName StatusPin,
kabukistarship 4:de69851cf725 63 GHVentilatorChannel* A,
kabukistarship 4:de69851cf725 64 GHVentilatorChannel* B);
kabukistarship 3:d15b6579b5ae 65
kabukistarship 4:de69851cf725 66 /* Constructs a GHV with 3 channels. */
kabukistarship 8:fa5cc1397510 67 GHVentilator (int TicksPerSecond, int TicksPEEP, int TicksCalibration,
kabukistarship 6:b2672da545f1 68 I2C& Bus, char BusAddress,
kabukistarship 4:de69851cf725 69 float PressureHysteresis,
kabukistarship 5:da629056644f 70 float HysteresisPatient,
kabukistarship 4:de69851cf725 71 PinName BlowerPin, PinName StatusPin,
kabukistarship 4:de69851cf725 72 GHVentilatorChannel* A,
kabukistarship 4:de69851cf725 73 GHVentilatorChannel* B,
kabukistarship 4:de69851cf725 74 GHVentilatorChannel* C);
kabukistarship 3:d15b6579b5ae 75
kabukistarship 4:de69851cf725 76 /* Constructs a GHV with 4 channels. */
kabukistarship 8:fa5cc1397510 77 GHVentilator (int TicksPerSecond, int TicksCalibration, int TicksPEEP,
kabukistarship 6:b2672da545f1 78 I2C& Bus, char BusAddress,
kabukistarship 4:de69851cf725 79 float PressureHysteresis,
kabukistarship 5:da629056644f 80 float HysteresisPatient,
kabukistarship 4:de69851cf725 81 PinName BlowerPin, PinName StatusPin,
kabukistarship 4:de69851cf725 82 GHVentilatorChannel* A,
kabukistarship 4:de69851cf725 83 GHVentilatorChannel* B,
kabukistarship 4:de69851cf725 84 GHVentilatorChannel* C,
kabukistarship 4:de69851cf725 85 GHVentilatorChannel* D);
kabukistarship 6:b2672da545f1 86
kabukistarship 8:fa5cc1397510 87 /* Sets the TicksPEEP given 1/64 second > NewTicksPEEP < 1 second. */
kabukistarship 8:fa5cc1397510 88 void TicksPEEPSet (int NewTicksPEEP);
kabukistarship 8:fa5cc1397510 89
kabukistarship 6:b2672da545f1 90 /* Enters the Calibration State. */
kabukistarship 6:b2672da545f1 91 void StateCalibrateEnter ();
kabukistarship 6:b2672da545f1 92
kabukistarship 6:b2672da545f1 93 /* Enters the Calibration State. */
kabukistarship 6:b2672da545f1 94 void StateCalibrateExit ();
kabukistarship 6:b2672da545f1 95
kabukistarship 6:b2672da545f1 96 /* Polls the hardware for changes. */
kabukistarship 6:b2672da545f1 97 void Poll();
kabukistarship 6:b2672da545f1 98
kabukistarship 6:b2672da545f1 99 /* Monitors this Device and it's channels. */
kabukistarship 6:b2672da545f1 100 void Monitor ();
kabukistarship 6:b2672da545f1 101
kabukistarship 6:b2672da545f1 102 /* Turns off the Device and all of it's chanels. */
kabukistarship 6:b2672da545f1 103 void TurnOff ();
kabukistarship 6:b2672da545f1 104
kabukistarship 6:b2672da545f1 105 /* Turns on the Device and all of it's chanels to the Inhale state. */
kabukistarship 6:b2672da545f1 106 void TurnOnAll ();
kabukistarship 3:d15b6579b5ae 107
kabukistarship 3:d15b6579b5ae 108 /* Gets the GHVentilatorChannel with the given Index. \
kabukistarship 3:d15b6579b5ae 109 @return Nil if the Index is out of bounds. */
kabukistarship 3:d15b6579b5ae 110 GHVentilatorChannel* Channel(int Index);
kabukistarship 4:de69851cf725 111
kabukistarship 3:d15b6579b5ae 112 /* Reads the Atmospher.Pressure() and Atmospher.Temperature () */
kabukistarship 5:da629056644f 113 void Tare();
kabukistarship 3:d15b6579b5ae 114
kabukistarship 4:de69851cf725 115 /* Sets the inhale and exhale ticks for the give channel Index. */
kabukistarship 4:de69851cf725 116 int TicksInhaleExhaleSet (int Index, int TicksInhale, int TicksExhale);
kabukistarship 3:d15b6579b5ae 117
kabukistarship 3:d15b6579b5ae 118 /* Starts the system. */
kabukistarship 4:de69851cf725 119 void Run ();
kabukistarship 3:d15b6579b5ae 120
kabukistarship 3:d15b6579b5ae 121 /* Updates the main device and it's channels. */
kabukistarship 3:d15b6579b5ae 122 void Update ();
kabukistarship 2:1578ecfa9377 123 };
kabukistarship 2:1578ecfa9377 124
kabukistarship 2:1578ecfa9377 125 } //< namespace SickBay
kabukistarship 2:1578ecfa9377 126 #endif
kabukistarship 4:de69851cf725 127 #undef GHVentilatorChannelsCount