Kabuki Starship / Mbed 2 deprecated GHVentilator

Dependencies:   mbed SickBayTek

GHVentilator.h

Committer:
kabukistarship
Date:
2020-04-07
Revision:
2:1578ecfa9377
Child:
3:d15b6579b5ae

File content as of revision 2:1578ecfa9377:

/** Gravity Hookah Ventilator @version 0.x
@link    https://github.com/KabukiStarship/SickBay.git
@file    /GHVentilator.h
@author  Cale McCollough <https://cale-mccollough.github.io>
@license Copyright 2020 (C) Kabuki Starship <kabukistarship.com>.
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 GHVentilatorDecl
#define GHVentilatorDecl
#include <mbedBug.h>
using namespace mbedBug;
#include "GHVentilatorChannel.h"
namespace SickBay {
/*
void DoGetData(Arguments* input, Reply* output);

RPCFunction getData(&DoGetData, "getData");
 
void DoGetData(Arguments* input, Reply* output) {
    // Arguments are already parsed into argv array of char*
    printf("Object name = %s\n",input->obj_name);
    printf("Method name = %s\n",input->method_name);
    for (int i=0; i < input->argc; i++)
        printf("argv[%1d] = %s \n",i,input->argv[i]);
        
    // Alternatively the arguments can be recovered as the types expected
    // by repeated calls to getArg()
    int arg0 = input->getArg<int>();                      // Expecting argv[0] to be int
    printf("Expecting argv[0] to be int = %d\n",arg0);
    float arg1 = input->getArg<float>();                  // Expecting argv[1] to be float
    printf("Expecting argv[1] to be float = %f\n",arg1);
    const char *arg2 = input->getArg<const char*>();      // Expecting argv[2] to be a string
    printf("Expecting argv[2] to be a string = %s\n",arg2);
 
    // The output parameter string is generated by calls to putData, which separates them with spaces.
    output->putData(arg0);
    output->putData(arg1);
    output->putData(arg2);
}*/

/* A Gravity Hookah Ventilator. */
template<int ChannelCount>
class GHVentilator {
    public:
    
    enum {
        ChannelCountMax = 4,
        StateCalibratingPressureSensor = 0,
        StateRunning = 1,
    };
    
    int   State,             //< The ventilator state.
          Ticks,             //< The tick.
          TicksMax,          //< The max tick count before it gets reset.
          TicksSecond,       //< The number of Ticks per Second.
          TicksInhaleMin,    //< The min inhale ticks.
          TicksInhaleMax,    //< The max breath period of 20 seconds.
          TicksExhaleMin,    //< The min ticks in an exhale.
          TicksExhaleMax;    //< The max ticks in an exhale.
    float PressureMin,       //< The min Pressure.
          PressureMax,       //< The max Pressure.
          Pressure,          //< The Pressure in the tank.
          ServoMin,          //< The min servo value.
          ServoMax;          //< The max servo value.
    /* The amount the Pressure needs to change to count as having changed. */
    float PressureChangeDelta;
    //< The GHV channels.
    GHVentilatorChannel Channels[ChannelCountMax];
    BMP280 Atmosphere;       //< Pressure sensor for the air tank.
    DigitalOut Blower;       //< A blower powered by a Solid State Relay.
    
    GHVentilator (int TicksPerSecond, I2C& I2CBus, char SlaveAddress,
                  PinName BlowerPin, PinName StatusPin,
                  GHVentilatorChannel A);
                  
    GHVentilator (int TicksPerSecond, I2C& I2CBus, char SlaveAddress,
                  PinName BlowerPin, PinName StatusPin,
                  GHVentilatorChannel A,
                  GHVentilatorChannel B);
                  
    GHVentilator (int TicksPerSecond, I2C& I2CBus, char SlaveAddress,
                  PinName BlowerPin, PinName StatusPin,
                  GHVentilatorChannel A,
                  GHVentilatorChannel B,
                  GHVentilatorChannel C);
                  
    GHVentilator (int TicksPerSecond, I2C& I2CBus, char SlaveAddress,
                  PinName BlowerPin, PinName StatusPin,
                  GHVentilatorChannel A,
                  GHVentilatorChannel B,
                  GHVentilatorChannel C,
                  GHVentilatorChannel D);
                  
    void ChannelSet (int ChannelIndex, float DutyCycle = 0.0f, 
                     float Period = 0.0f);
    /* Reads the Atmospher.Pressure() and Atmospher.Temperature () */
    void TarePressure();
    
    /* Starts the system. */             
    int Run ();
    
    /* Updates the main device and it's channels. */
    void Update ();
};

}   //< namespace SickBay
#endif