Browse Source

relay: type is always valid

resolve #2416
mcspr-patch-1
Maxim Prokhorov 3 years ago
parent
commit
8e659c9486
2 changed files with 2 additions and 10 deletions
  1. +2
    -9
      code/espurna/relay.cpp
  2. +0
    -1
      code/espurna/relay.h

+ 2
- 9
code/espurna/relay.cpp View File

@ -118,7 +118,6 @@ template <>
RelayType convert(const String& value) {
auto type = static_cast<RelayType>(value.toInt());
switch (type) {
case RelayType::None:
case RelayType::Normal:
case RelayType::Inverse:
case RelayType::Latched:
@ -126,7 +125,7 @@ RelayType convert(const String& value) {
return type;
}
return RelayType::None;
return RelayType::Normal;
}
template <>
@ -278,10 +277,6 @@ struct GpioProvider : public RelayProviderBase {
}
bool setup() override {
if (_type == RelayType::None) {
return false;
}
if (!_pin) {
return false;
}
@ -300,8 +295,6 @@ struct GpioProvider : public RelayProviderBase {
void change(bool status) override {
switch (_type) {
case RelayType::None:
break;
case RelayType::Normal:
_pin->digitalWrite(status);
break;
@ -333,7 +326,7 @@ struct GpioProvider : public RelayProviderBase {
private:
unsigned char _id { RELAY_NONE };
RelayType _type { RelayType::None };
RelayType _type { RelayType::Normal };
std::unique_ptr<BasePin> _pin;
std::unique_ptr<BasePin> _reset_pin;
};


+ 0
- 1
code/espurna/relay.h View File

@ -14,7 +14,6 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
constexpr size_t RelaysMax = 32;
enum class RelayType : int {
None,
Normal,
Inverse,
Latched,


Loading…
Cancel
Save