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.
GHVentilatorChannel.h@9:256989faeb3b, 2020-04-10 (annotated)
- Committer:
- kabukistarship
- Date:
- Fri Apr 10 11:56:58 2020 +0000
- Revision:
- 9:256989faeb3b
- Parent:
- 8:fa5cc1397510
Change.GHVentilator.Firmware.Switch to Arduino and mbed compatible format. #74
Who changed what in which revision?
User | Revision | Line number | New 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 | #pragma once |
kabukistarship | 2:1578ecfa9377 | 10 | #ifndef GHVentilatorChannelDecl |
kabukistarship | 2:1578ecfa9377 | 11 | #define GHVentilatorChannelDecl |
kabukistarship | 9:256989faeb3b | 12 | #include <stdint.h> |
kabukistarship | 9:256989faeb3b | 13 | #ifndef GHVentilatorChannelCount |
kabukistarship | 9:256989faeb3b | 14 | #error You must define the GHVentilatorChannelCount before including \ |
kabukistarship | 9:256989faeb3b | 15 | "GHVentilator.hpp" |
kabukistarship | 9:256989faeb3b | 16 | #endif |
kabukistarship | 2:1578ecfa9377 | 17 | namespace SickBay { |
kabukistarship | 9:256989faeb3b | 18 | |
kabukistarship | 9:256989faeb3b | 19 | class GHVentilator; |
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 | 6:b2672da545f1 | 24 | |
kabukistarship | 6:b2672da545f1 | 25 | enum { |
kabukistarship | 9:256989faeb3b | 26 | StateInhaling = 1, //< The inhaling state is where Ticks < 0. |
kabukistarship | 9:256989faeb3b | 27 | StateOff = 0, //< The off state is where Ticks = 0. |
kabukistarship | 9:256989faeb3b | 28 | StateExhaling = -1, //< The exhaling state is where Ticks > 0. |
kabukistarship | 6:b2672da545f1 | 29 | }; |
kabukistarship | 9:256989faeb3b | 30 | |
kabukistarship | 9:256989faeb3b | 31 | GHVentilator* Parent; //< The GHVentilator this is part of. |
kabukistarship | 9:256989faeb3b | 32 | int Ticks, //< Ticks since the beginning of the inhale. |
kabukistarship | 9:256989faeb3b | 33 | TicksInhale, //< The tick count in the inhale duty cycle. |
kabukistarship | 9:256989faeb3b | 34 | TicksExhale, //< The period of the breathing. |
kabukistarship | 9:256989faeb3b | 35 | TicksFlow, //< The number of flow sensor ticks. |
kabukistarship | 9:256989faeb3b | 36 | TicksFlowLast, //< The previous inhale cycle TicksFlow count. |
kabukistarship | 9:256989faeb3b | 37 | PulseOximeter, //< The 7-pin pulse oximeter value. |
kabukistarship | 9:256989faeb3b | 38 | Servo, //< The Servo for reducing the pressrue. |
kabukistarship | 9:256989faeb3b | 39 | ServoClosed, //< The min servo duty cycle of no air flow. |
kabukistarship | 9:256989faeb3b | 40 | ServoOpen; //< The max servo duty cycle of an open tube. |
kabukistarship | 9:256989faeb3b | 41 | int32_t Temperature, //< The Temperature of the patients breath. |
kabukistarship | 9:256989faeb3b | 42 | TemperatureReference; //< The refernce temperature upon Tare. |
kabukistarship | 9:256989faeb3b | 43 | uint32_t Pressure, //< The pressure in the patient's mask. |
kabukistarship | 9:256989faeb3b | 44 | PressureReference, //< About 1 atmosphere + the hysteresis delta. |
kabukistarship | 9:256989faeb3b | 45 | PressureHysteresis; //< The hysteresis above the PressureReference. |
kabukistarship | 9:256989faeb3b | 46 | |
kabukistarship | 9:256989faeb3b | 47 | /* Initializes the channel. |
kabukistarship | 9:256989faeb3b | 48 | @param PressureHysteresis 1.0 + the percent hysteresis up and down from the |
kabukistarship | 9:256989faeb3b | 49 | center the |
kabukistarship | 9:256989faeb3b | 50 | */ |
kabukistarship | 9:256989faeb3b | 51 | void Init (GHVentilator* Parent, int TicksInhale, int TicksExhale, |
kabukistarship | 9:256989faeb3b | 52 | float ChannelPressureHysteresis); |
kabukistarship | 6:b2672da545f1 | 53 | |
kabukistarship | 9:256989faeb3b | 54 | /* Doesn't do anything and requires a call to . */ |
kabukistarship | 9:256989faeb3b | 55 | GHVentilatorChannel (); |
kabukistarship | 2:1578ecfa9377 | 56 | |
kabukistarship | 4:de69851cf725 | 57 | /* Returns a pointer to this. */ |
kabukistarship | 4:de69851cf725 | 58 | GHVentilatorChannel* This(); |
kabukistarship | 6:b2672da545f1 | 59 | |
kabukistarship | 9:256989faeb3b | 60 | void ChannelValveSet (GHVentilatorChannel* Channel, int Value); |
kabukistarship | 6:b2672da545f1 | 61 | |
kabukistarship | 9:256989faeb3b | 62 | /* Turns this channel off. */ |
kabukistarship | 9:256989faeb3b | 63 | void TurnOff (); |
kabukistarship | 2:1578ecfa9377 | 64 | |
kabukistarship | 4:de69851cf725 | 65 | /* Sets the number of ticks on the inhale and exhale. */ |
kabukistarship | 4:de69851cf725 | 66 | void TicksInhaleExhaleSet (int NewTicksInhale, int NewTicksExhale); |
kabukistarship | 2:1578ecfa9377 | 67 | |
kabukistarship | 4:de69851cf725 | 68 | /* Increments theflow rate sensor pulse counter. */ |
kabukistarship | 6:b2672da545f1 | 69 | void TickFlow (); |
kabukistarship | 2:1578ecfa9377 | 70 | |
kabukistarship | 4:de69851cf725 | 71 | /* Prints the state of object to the debug stream. */ |
kabukistarship | 4:de69851cf725 | 72 | void Print (int Index); |
kabukistarship | 2:1578ecfa9377 | 73 | |
kabukistarship | 4:de69851cf725 | 74 | /* Opens the solenoid valve. */ |
kabukistarship | 4:de69851cf725 | 75 | void Inhale (); |
kabukistarship | 2:1578ecfa9377 | 76 | |
kabukistarship | 4:de69851cf725 | 77 | /* Closes the solenoid valve. */ |
kabukistarship | 4:de69851cf725 | 78 | void Exhale (); |
kabukistarship | 3:d15b6579b5ae | 79 | |
kabukistarship | 4:de69851cf725 | 80 | /* Samples the Atmospheric pressure and temperature. */ |
kabukistarship | 6:b2672da545f1 | 81 | void Tare (float PressureHysteresis); |
kabukistarship | 6:b2672da545f1 | 82 | |
kabukistarship | 6:b2672da545f1 | 83 | /* Monitor the channel for if errors. */ |
kabukistarship | 6:b2672da545f1 | 84 | int Monitor (); |
kabukistarship | 2:1578ecfa9377 | 85 | |
kabukistarship | 4:de69851cf725 | 86 | /* Updates the channel with the DeviceTick. */ |
kabukistarship | 4:de69851cf725 | 87 | void Update(); |
kabukistarship | 2:1578ecfa9377 | 88 | }; |
kabukistarship | 2:1578ecfa9377 | 89 | } //< namespace SickBay |
kabukistarship | 4:de69851cf725 | 90 | #endif |