From 735b4a170b6b7c7b39b484138d05fab6bf0e6950 Mon Sep 17 00:00:00 2001
From: Lars Michelsen
Date: Fri, 11 Oct 2024 21:07:58 +0200
Subject: [PATCH] Fix support for Adafruit HUZZAH32 V2 ESP32 Featherwing 3.5 V2
* The board of "env:huzzah32-v2-featherwing-35-v2" was changed to
adafruit_feather_esp32_v2
Previously it was pointing to the v1 board. See also:
V1: https://github.com/platformio/platform-espressif32/blob/develop/boards/featheresp32.json
V2: https://github.com/platformio/platform-espressif32/blob/develop/boards/adafruit_feather_esp32_v2.json
* Fixed the port numbers
* hasp_gpio_type_t::BUTTON had to be renamed because adafruit_feather_esp32_v2/pins_arduino.h
defines a macro named BUTTON.
---
src/sys/gpio/hasp_gpio.cpp | 14 +++++++-------
src/sys/gpio/hasp_gpio.h | 4 ++--
src/sys/svc/hasp_http.cpp | 4 ++--
src/sys/svc/hasp_http_async.cpp | 6 +++---
.../esp32/huzzah32-v2-featherwing-35-v2.ini | 17 +++++++++--------
5 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/src/sys/gpio/hasp_gpio.cpp b/src/sys/gpio/hasp_gpio.cpp
index 693eec7b7..52b60a966 100644
--- a/src/sys/gpio/hasp_gpio.cpp
+++ b/src/sys/gpio/hasp_gpio.cpp
@@ -123,7 +123,7 @@ static void gpio_event_handler(AceButton* button, uint8_t eventType, uint8_t but
bool state = false;
switch(eventType) {
case AceButton::kEventPressed:
- if(gpioConfig[btnid].type != hasp_gpio_type_t::BUTTON) {
+ if(gpioConfig[btnid].type != hasp_gpio_type_t::BUTTON_TYPE) {
eventid = HASP_EVENT_ON;
} else {
eventid = HASP_EVENT_DOWN;
@@ -146,7 +146,7 @@ static void gpio_event_handler(AceButton* button, uint8_t eventType, uint8_t but
// state = true; // do not repeat DOWN + LONG + HOLD
// break;
case AceButton::kEventReleased:
- if(gpioConfig[btnid].type != hasp_gpio_type_t::BUTTON) {
+ if(gpioConfig[btnid].type != hasp_gpio_type_t::BUTTON_TYPE) {
eventid = HASP_EVENT_OFF;
} else {
eventid = HASP_EVENT_RELEASE;
@@ -253,7 +253,7 @@ static void gpio_setup_pin(uint8_t index)
pinMode(gpio->pin, input_mode);
gpio->max = 0;
break;
- case hasp_gpio_type_t::BUTTON:
+ case hasp_gpio_type_t::BUTTON_TYPE:
if(gpio->btn) delete gpio->btn;
gpio->btn = new AceButton(&buttonConfig, gpio->pin, default_state, index);
gpio->power = gpio->btn->isPressedRaw();
@@ -849,7 +849,7 @@ void gpio_discovery(JsonObject& input, JsonArray& relay, JsonArray& light, JsonA
relay.add(gpioConfig[i].pin);
break;
- case BUTTON ... TOUCH:
+ case BUTTON_TYPE ... TOUCH:
event.add(gpioConfig[i].pin);
break;
@@ -861,7 +861,7 @@ void gpio_discovery(JsonObject& input, JsonArray& relay, JsonArray& light, JsonA
dimmer.add(gpioConfig[i].pin);
break;
- // case BUTTON ... TOUCH:
+ // case BUTTON_TYPE ... TOUCH:
case SWITCH:
strcpy_P(description, PSTR("none"));
break;
@@ -955,7 +955,7 @@ void gpio_discovery(JsonObject& input, JsonArray& relay, JsonArray& light, JsonA
}
if((gpioConfig[i].type >= hasp_gpio_type_t::SWITCH && gpioConfig[i].type <= hasp_gpio_type_t::WINDOW)) {
- // || (gpioConfig[i].type >= hasp_gpio_type_t::BUTTON && gpioConfig[i].type <= hasp_gpio_type_t::TOUCH)) {
+ // || (gpioConfig[i].type >= hasp_gpio_type_t::BUTTON_TYPE && gpioConfig[i].type <= hasp_gpio_type_t::TOUCH)) {
JsonArray arr = input[description];
if(arr.isNull()) arr = input.createNestedArray(description);
arr.add(gpioConfig[i].pin);
@@ -1040,4 +1040,4 @@ bool gpioSetConfig(const JsonObject& settings)
return changed;
}
-#endif // HASP_USE_CONFIG
\ No newline at end of file
+#endif // HASP_USE_CONFIG
diff --git a/src/sys/gpio/hasp_gpio.h b/src/sys/gpio/hasp_gpio.h
index 105f44608..559bc7620 100644
--- a/src/sys/gpio/hasp_gpio.h
+++ b/src/sys/gpio/hasp_gpio.h
@@ -134,7 +134,7 @@ enum hasp_gpio_type_t {
TAMPER = 0xBB,
UPDATE = 0xBC,
- BUTTON = 0xF0,
+ BUTTON_TYPE = 0xF0,
BUTTON_TOGGLE_UP = 0xF1,
BUTTON_TOGGLE_DOWN = 0xF2,
BUTTON_TOGGLE_BOTH = 0xF3,
@@ -153,4 +153,4 @@ enum hasp_gpio_type_t {
} /* extern "C" */
#endif
-#endif
\ No newline at end of file
+#endif
diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp
index eba778bb6..06af58d85 100644
--- a/src/sys/svc/hasp_http.cpp
+++ b/src/sys/svc/hasp_http.cpp
@@ -1804,7 +1804,7 @@ static void webHandleGpioConfig()
switch(conf.type) {
- case hasp_gpio_type_t::BUTTON:
+ case hasp_gpio_type_t::BUTTON_TYPE:
httpMessage += D_GPIO_BUTTON;
break;
case hasp_gpio_type_t::SWITCH:
@@ -2049,7 +2049,7 @@ static void webHandleGpioInput()
httpMessage += F("
");
httpMessage += F("Type