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


Loading…
Cancel
Save