diff --git a/src/ShellyMini1Gen3/shelly_init.cpp b/src/ShellyMini1Gen3/shelly_init.cpp index 11d4e1e0..677ffbc6 100644 --- a/src/ShellyMini1Gen3/shelly_init.cpp +++ b/src/ShellyMini1Gen3/shelly_init.cpp @@ -22,8 +22,6 @@ #include "shelly_sys_led_btn.hpp" #include "shelly_temp_sensor_ntc.hpp" -#include "driver/gpio.h" - namespace shelly { void CreatePeripherals(std::vector> *inputs, @@ -32,8 +30,6 @@ void CreatePeripherals(std::vector> *inputs, std::unique_ptr *sys_temp) { outputs->emplace_back(new OutputPin(1, 7, 1)); - gpio_hold_dis(GPIO_NUM_7); - auto *in = new InputPin(1, 10, 1, MGOS_GPIO_PULL_NONE, true); in->AddHandler(std::bind(&HandleInputResetSequence, in, LED_GPIO, _1, _2)); in->Init(); diff --git a/src/ShellyMini1PMGen3/shelly_init.cpp b/src/ShellyMini1PMGen3/shelly_init.cpp index e502172a..03e551f9 100644 --- a/src/ShellyMini1PMGen3/shelly_init.cpp +++ b/src/ShellyMini1PMGen3/shelly_init.cpp @@ -22,7 +22,7 @@ #include "shelly_sys_led_btn.hpp" #include "shelly_temp_sensor_ntc.hpp" -#include "driver/gpio.h" + namespace shelly { @@ -32,8 +32,6 @@ void CreatePeripherals(std::vector> *inputs, std::unique_ptr *sys_temp) { outputs->emplace_back(new OutputPin(1, 5, 1)); - gpio_hold_dis(GPIO_NUM_5); - auto *in = new InputPin(1, 10, 1, MGOS_GPIO_PULL_NONE, true); in->AddHandler(std::bind(&HandleInputResetSequence, in, LED_GPIO, _1, _2)); in->Init(); diff --git a/src/shelly_input_pin.cpp b/src/shelly_input_pin.cpp index 20ba527d..4faf0865 100644 --- a/src/shelly_input_pin.cpp +++ b/src/shelly_input_pin.cpp @@ -19,6 +19,10 @@ #include "mgos.hpp" +#if CS_PLATFORM != CS_P_ESP8266 +#include "driver/gpio.h" +#endif + namespace shelly { InputPin::InputPin(int id, int pin, int on_value, enum mgos_gpio_pull_type pull, @@ -39,6 +43,9 @@ void InputPin::Init() { mgos_gpio_setup_input(cfg_.pin, cfg_.pull); mgos_gpio_set_button_handler(cfg_.pin, cfg_.pull, MGOS_GPIO_INT_EDGE_ANY, 20, GPIOIntHandler, this); +#if CS_PLATFORM != CS_P_ESP8266 + gpio_hold_dis((gpio_num_t) cfg_.pin); +#endif bool state = GetState(); LOG(LL_INFO, ("%s %d: pin %d, on_value %d, state %s", "InputPin", id(), cfg_.pin, cfg_.on_value, OnOff(state))); @@ -51,6 +58,9 @@ void InputPin::SetInvert(bool invert) { InputPin::~InputPin() { mgos_gpio_remove_int_handler(cfg_.pin, nullptr, nullptr); +#if CS_PLATFORM != CS_P_ESP8266 + gpio_hold_en((gpio_num_t) cfg_.pin); +#endif } bool InputPin::ReadPin() { diff --git a/src/shelly_output.cpp b/src/shelly_output.cpp index bfd4f4b9..34fa7ab1 100644 --- a/src/shelly_output.cpp +++ b/src/shelly_output.cpp @@ -20,6 +20,11 @@ #include "mgos.hpp" #include "mgos_gpio.h" +#if CS_PLATFORM != CS_P_ESP8266 +#include "driver/gpio.h" +#endif + + #ifdef MGOS_HAVE_PWM #include "mgos_pwm.h" #endif @@ -42,11 +47,17 @@ OutputPin::OutputPin(int id, int pin, int on_value) on_value_(on_value), pulse_timer_(std::bind(&OutputPin::PulseTimerCB, this)) { mgos_gpio_set_mode(pin_, MGOS_GPIO_MODE_OUTPUT); +#if CS_PLATFORM != CS_P_ESP8266 + gpio_hold_dis((gpio_num_t) pin); +#endif LOG(LL_INFO, ("OutputPin %d: pin %d, on_value %d, state %s", id, pin, on_value, OnOff(GetState()))); } OutputPin::~OutputPin() { +#if CS_PLATFORM != CS_P_ESP8266 + gpio_hold_en((gpio_num_t) pin_); +#endif } bool OutputPin::GetState() {