Browse Source

Clean up

ech1560
Xose Pérez 6 years ago
parent
commit
96504cbfeb
1 changed files with 10 additions and 10 deletions
  1. +10
    -10
      code/espurna/sensors/PMSX003Sensor.h

+ 10
- 10
code/espurna/sensors/PMSX003Sensor.h View File

@ -212,19 +212,19 @@ class PMSX003Sensor : public BaseSensor, PMSX003 {
// Initialization method, must be idempotent // Initialization method, must be idempotent
void begin() { void begin() {
if (!_dirty) return; if (!_dirty) return;
if (_soft) { if (_soft) {
if (_serial) delete _serial;
_serial = new SoftwareSerial(_pin_rx, _pin_tx, false, 64);
static_cast<SoftwareSerial*>(_serial)->enableIntTx(false);
if (_serial) delete _serial;
_serial = new SoftwareSerial(_pin_rx, _pin_tx, false, 64);
static_cast<SoftwareSerial*>(_serial)->enableIntTx(false);
} }
if (_soft) { if (_soft) {
static_cast<SoftwareSerial*>(_serial)->begin(PMS_BAUD_RATE);
static_cast<SoftwareSerial*>(_serial)->begin(PMS_BAUD_RATE);
} else { } else {
static_cast<HardwareSerial*>(_serial)->begin(PMS_BAUD_RATE);
static_cast<HardwareSerial*>(_serial)->begin(PMS_BAUD_RATE);
} }
passiveMode(); passiveMode();
@ -238,9 +238,9 @@ class PMSX003Sensor : public BaseSensor, PMSX003 {
String description() { String description() {
char buffer[28]; char buffer[28];
if (_soft) { if (_soft) {
snprintf(buffer, sizeof(buffer), "%s @ SwSerial(%u,%u)", pms_specs[_type].name, _pin_rx, _pin_tx);
snprintf(buffer, sizeof(buffer), "%s @ SwSerial(%u,%u)", pms_specs[_type].name, _pin_rx, _pin_tx);
} else { } else {
snprintf(buffer, sizeof(buffer), "%s @ HwSerial", pms_specs[_type].name);
snprintf(buffer, sizeof(buffer), "%s @ HwSerial", pms_specs[_type].name);
} }
return String(buffer); return String(buffer);
@ -250,9 +250,9 @@ class PMSX003Sensor : public BaseSensor, PMSX003 {
String slot(unsigned char index) { String slot(unsigned char index) {
char buffer[36] = {0}; char buffer[36] = {0};
if (_soft) { if (_soft) {
snprintf(buffer, sizeof(buffer), "%d @ %s @ SwSerial(%u,%u)", int(index + 1), pms_specs[_type].name, _pin_rx, _pin_tx);
snprintf(buffer, sizeof(buffer), "%d @ %s @ SwSerial(%u,%u)", int(index + 1), pms_specs[_type].name, _pin_rx, _pin_tx);
} else { } else {
snprintf(buffer, sizeof(buffer), "%d @ %s @ HwSerial", int(index + 1), pms_specs[_type].name);
snprintf(buffer, sizeof(buffer), "%d @ %s @ HwSerial", int(index + 1), pms_specs[_type].name);
} }
return String(buffer); return String(buffer);
} }


Loading…
Cancel
Save