67 lines
1.6 KiB
C++
67 lines
1.6 KiB
C++
#ifndef MY_CONTROLLER_H_INCLUDED
|
|
#define MY_CONTROLLER_H_INCLUDED
|
|
|
|
#include "../OneWire/OneWire.h"
|
|
#include "../DallasTemperature/DallasTemperature.h"
|
|
#include "../display/display.h"
|
|
#include "../common.h"
|
|
|
|
#define _CONVERSION_DELAY 800
|
|
#define _ANALOG_READ_DELAY 500
|
|
|
|
class Controller
|
|
{
|
|
private:
|
|
const uint8_t _aPin;
|
|
parameters *_params;
|
|
values *_vals;
|
|
Display *_display;
|
|
PSensor *_pSensor;
|
|
valveStates *_vStates;
|
|
uint8_t _prPin;
|
|
uint8_t _pfPin;
|
|
uint8_t _t1Pin;
|
|
uint8_t _t2Pin;
|
|
|
|
OneWire _oneWire;
|
|
DallasTemperature _dallas;
|
|
DeviceAddress _tempAddr1;
|
|
|
|
enum States : uint8_t {
|
|
stateIdle, stateRising, stateFalling
|
|
};
|
|
States _tState = stateIdle;
|
|
States _pState = stateIdle;
|
|
|
|
bool _initOk = false;
|
|
bool _requestConversion;
|
|
unsigned long _lastConversion;
|
|
unsigned long _lastAnalogRead;
|
|
uint16_t _rawP;
|
|
|
|
// void _setTState(States curr, States next);
|
|
// void _setPState(States curr, States next);
|
|
void _setT1Valve(uint8_t, States);
|
|
void _setPValves(States);
|
|
// uint16_t _convertFloat(const float &x);
|
|
|
|
public:
|
|
Controller(const uint8_t pAnalaogPin,
|
|
const uint8_t oneWirePin,
|
|
parameters *p,
|
|
values *vals,
|
|
Display *d,
|
|
PSensor *s,
|
|
valveStates *vStates,
|
|
const uint8_t pRisePin,
|
|
const uint8_t t1Pin,
|
|
const uint8_t t2Pin,
|
|
const uint8_t pFallPin
|
|
);
|
|
|
|
void init(bool startup=false);
|
|
void process();
|
|
};
|
|
|
|
#endif // MY_CONTROLLER_H_INCLUDED
|