Pump.h 1.66 KB
Newer Older
João Lino's avatar
João Lino committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#ifndef Pump_h
#define Pump_h

#include "Arduino.h"
#include "../Temperature/Temperature.h"

#define DEFAULT_PUMP_MAX_OPETATION_TEMPERARTURE   90
#define DEFAULT_PUMP_PRIMING_TIME_IN_SECONDS      10

//#define HEATING_ELEMENT_MAX_HEAT_PWM_INTEGER      5
//#define HEATING_ELEMENT_MAX_HEAT_PWM_FLOAT        5.0

class Pump
{
  public:
    Pump( int iOutputPin, int iOffValue, int iMaxValue, int iMaxTemperature, int iPrimingTimeInSeconds );
    Pump( int iOutputPin, int iOffValue, int iMaxValue );

    void shutDown();
    void forcePumpSelfPrime();
    bool process();
    bool process( int iTargetPumpSpeed );

    bool isPumpOn();
    void setCheckTemperatureFunction( Temperature *temperature );
    int  getTargetPumpSpeed();
    void setTargetPumpSpeed( int iTargetPumpSpeed );

    int getNullSpeed();
    int getOneSixthSpeed();
    int getOneThirdSpeed();
    int getHalfSpeed();
    int getTwoThirdSpeed();
    int getMaxSpeed();

João Lino's avatar
João Lino committed
36
    bool setTesting( bool testing );
João Lino's avatar
João Lino committed
37 38 39 40 41

  private:
    int                     _iOutputPin;
    int                     _iOffValue;
    int                     _iMaxValue;
João Lino's avatar
João Lino committed
42
    int                     _testing;
João Lino's avatar
João Lino committed
43 44 45 46 47 48 49 50 51
    boolean                 _selfPrimingMode;
    boolean                 _hasBeenPrimedSinceStartup;
    unsigned long           _millisAtPrimingStart;
    int                     _iPrimingTimeInSeconds;
    int                     _iMaxTemperature;
    int                     _iActualPumpSpeed;             // Time frame to operate in
    int                     _iTargetPumpSpeed;
    Temperature             *_temperature;

João Lino's avatar
João Lino committed
52 53 54
    // Private functions
    int calculateSpeedFraction( double fraction );
    int modeSet( int value );
João Lino's avatar
João Lino committed
55 56 57
};

#endif