Pump.h 1.55 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#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();


  private:
    
    int                     _iOutputPin;
    int                     _iOffValue;
    int                     _iMaxValue;
    boolean                 _selfPrimingMode;
    boolean                 _hasBeenPrimedSinceStartup;
    unsigned long           _millisAtPrimingStart;
    int                     _iPrimingTimeInSeconds;
    int                     _iMaxTemperature;
    int                     _iActualPumpSpeed;             // Time frame to operate in
    int                     _iTargetPumpSpeed;
    Temperature             *_temperature;

  // Private functions
    int calculateSpeedFraction(double fraction);
};

#endif