Browse Source

Fix compilation errors in PZEM004TSensor class (#837)

rfm69
Xose Pérez 6 years ago
parent
commit
edcc6a7152
1 changed files with 8 additions and 11 deletions
  1. +8
    -11
      code/espurna/sensors/PZEM004TSensor.h

+ 8
- 11
code/espurna/sensors/PZEM004TSensor.h View File

@ -20,9 +20,10 @@ class PZEM004TSensor : public BaseSensor {
// Public
// ---------------------------------------------------------------------
PZEM004TSensor(): BaseSensor(), _data() {
PZEM004TSensor(): BaseSensor() {
_count = 4;
_sensor_id = SENSOR_PZEM004T_ID;
_ip = IPAddress(192,168,1,1);
}
~PZEM004TSensor() {
@ -43,7 +44,7 @@ class PZEM004TSensor : public BaseSensor {
_dirty = true;
}
void setSerial(Stream & serial) {
void setSerial(HardwareSerial * serial) {
_serial = serial;
_dirty = true;
}
@ -58,10 +59,6 @@ class PZEM004TSensor : public BaseSensor {
return _pin_tx;
}
Stream & getSerial() {
return _serial;
}
// ---------------------------------------------------------------------
// Sensor API
// ---------------------------------------------------------------------
@ -72,10 +69,10 @@ class PZEM004TSensor : public BaseSensor {
if (!_dirty) return;
if (_pzem) delete _pzem;
if (_serial == NULL) {
_pzem = PZEM004T(_pin_rx, _pin_tx);
if (_serial) {
_pzem = new PZEM004T(_serial);
} else {
_pzem = PZEM004T(_serial);
_pzem = new PZEM004T(_pin_rx, _pin_tx);
}
_pzem->setAddress(_ip);
@ -127,8 +124,8 @@ class PZEM004TSensor : public BaseSensor {
unsigned int _pin_rx = PZEM004T_RX_PIN;
unsigned int _pin_tx = PZEM004T_TX_PIN;
Stream & _serial = NULL;
IPAddress _ip(192,168,1,1);
IPAddress _ip;
HardwareSerial * _serial = NULL;
PZEM004T * _pzem = NULL;
};


Loading…
Cancel
Save