diff --git a/src/lib/block_notify.cpp b/src/lib/block_notify.cpp index 6f82646..10900e8 100644 --- a/src/lib/block_notify.cpp +++ b/src/lib/block_notify.cpp @@ -104,25 +104,25 @@ void onWebsocketEvent(void *handler_args, esp_event_base_t base, esp_websocket_event_data_t *data = (esp_websocket_event_data_t *)event_data; const String sub = "{\"action\": \"want\", \"data\":[\"blocks\"]}"; switch (event_id) { - case WEBSOCKET_EVENT_CONNECTED: - Serial.println(F("Connected to Mempool.space WebSocket")); + case WEBSOCKET_EVENT_CONNECTED: + Serial.println(F("Connected to Mempool.space WebSocket")); - Serial.println(sub); - if (esp_websocket_client_send_text(blockNotifyClient, sub.c_str(), - sub.length(), portMAX_DELAY) == -1) { - Serial.println(F("Mempool.space WS Block Subscribe Error")); - } + Serial.println(sub); + if (esp_websocket_client_send_text(blockNotifyClient, sub.c_str(), + sub.length(), portMAX_DELAY) == -1) { + Serial.println(F("Mempool.space WS Block Subscribe Error")); + } - break; - case WEBSOCKET_EVENT_DATA: - onWebsocketMessage(data); - break; - case WEBSOCKET_EVENT_ERROR: - Serial.println(F("Mempool.space WS Connnection error")); - break; - case WEBSOCKET_EVENT_DISCONNECTED: - Serial.println(F("Mempool.space WS Connnection Closed")); - break; + break; + case WEBSOCKET_EVENT_DATA: + onWebsocketMessage(data); + break; + case WEBSOCKET_EVENT_ERROR: + Serial.println(F("Mempool.space WS Connnection error")); + break; + case WEBSOCKET_EVENT_DISCONNECTED: + Serial.println(F("Mempool.space WS Connnection Closed")); + break; } } @@ -161,7 +161,7 @@ void onWebsocketMessage(esp_websocket_event_data_t *event_data) { if (getCurrentScreen() == SCREEN_BLOCK_HEIGHT && preferences.getBool("ledFlashOnUpd", false)) { - vTaskDelay(pdMS_TO_TICKS(250)); // Wait until screens are updated + vTaskDelay(pdMS_TO_TICKS(250)); // Wait until screens are updated queueLedEffect(LED_FLASH_BLOCK_NOTIFY); } } @@ -177,8 +177,7 @@ void setBlockHeight(uint newBlockHeight) { } bool isBlockNotifyConnected() { - if (blockNotifyClient == NULL) - return false; + if (blockNotifyClient == NULL) return false; return esp_websocket_client_is_connected(blockNotifyClient); } diff --git a/src/lib/block_notify.hpp b/src/lib/block_notify.hpp index a3bcc30..3603846 100644 --- a/src/lib/block_notify.hpp +++ b/src/lib/block_notify.hpp @@ -1,15 +1,17 @@ #pragma once +#include +#include +#include +#include +#include + +#include +#include + #include "lib/led_handler.hpp" #include "lib/screen_handler.hpp" #include "lib/shared.hpp" -#include -#include -#include -#include -#include -#include -#include // using namespace websockets; diff --git a/src/lib/button_handler.cpp b/src/lib/button_handler.cpp index f09cfed..a74b37b 100644 --- a/src/lib/button_handler.cpp +++ b/src/lib/button_handler.cpp @@ -17,18 +17,18 @@ void buttonTask(void *parameter) { uint pin = mcp1.getLastInterruptPin(); switch (pin) { - case 3: - toggleTimerActive(); - break; - case 2: - nextScreen(); - break; - case 1: - previousScreen(); - break; - case 0: - showSystemStatusScreen(); - break; + case 3: + toggleTimerActive(); + break; + case 2: + nextScreen(); + break; + case 1: + previousScreen(); + break; + case 0: + showSystemStatusScreen(); + break; } } mcp1.clearInterrupts(); @@ -51,7 +51,7 @@ void IRAM_ATTR handleButtonInterrupt() { void setupButtonTask() { xTaskCreate(buttonTask, "ButtonTask", 4096, NULL, tskIDLE_PRIORITY, - &buttonTaskHandle); // Create the FreeRTOS task + &buttonTaskHandle); // Create the FreeRTOS task // Use interrupt instead of task attachInterrupt(MCP_INT_PIN, handleButtonInterrupt, CHANGE); } diff --git a/src/lib/button_handler.hpp b/src/lib/button_handler.hpp index 652f77e..03e1b36 100644 --- a/src/lib/button_handler.hpp +++ b/src/lib/button_handler.hpp @@ -1,8 +1,9 @@ #pragma once +#include + #include "lib/screen_handler.hpp" #include "lib/shared.hpp" -#include extern TaskHandle_t buttonTaskHandle; diff --git a/src/lib/config.cpp b/src/lib/config.cpp index e4a1aba..09cf4fc 100644 --- a/src/lib/config.cpp +++ b/src/lib/config.cpp @@ -222,7 +222,6 @@ void setupTimers() { } void finishSetup() { - if (preferences.getBool("ledStatus", false)) { restoreLedState(); } else { @@ -364,80 +363,80 @@ std::vector getLocalUrl() { bool onImprovCommandCallback(improv::ImprovCommand cmd) { switch (cmd.command) { - case improv::Command::GET_CURRENT_STATE: { - if ((WiFi.status() == WL_CONNECTED)) { - improv_set_state(improv::State::STATE_PROVISIONED); - std::vector data = improv::build_rpc_response( - improv::GET_CURRENT_STATE, getLocalUrl(), false); - improv_send_response(data); - } else { - improv_set_state(improv::State::STATE_AUTHORIZED); - } + case improv::Command::GET_CURRENT_STATE: { + if ((WiFi.status() == WL_CONNECTED)) { + improv_set_state(improv::State::STATE_PROVISIONED); + std::vector data = improv::build_rpc_response( + improv::GET_CURRENT_STATE, getLocalUrl(), false); + improv_send_response(data); + } else { + improv_set_state(improv::State::STATE_AUTHORIZED); + } - break; - } - - case improv::Command::WIFI_SETTINGS: { - if (cmd.ssid.length() == 0) { - improv_set_error(improv::Error::ERROR_INVALID_RPC); break; } - improv_set_state(improv::STATE_PROVISIONING); - queueLedEffect(LED_EFFECT_WIFI_CONNECTING); + case improv::Command::WIFI_SETTINGS: { + if (cmd.ssid.length() == 0) { + improv_set_error(improv::Error::ERROR_INVALID_RPC); + break; + } - if (improv_connectWifi(cmd.ssid, cmd.password)) { - queueLedEffect(LED_EFFECT_WIFI_CONNECT_SUCCESS); + improv_set_state(improv::STATE_PROVISIONING); + queueLedEffect(LED_EFFECT_WIFI_CONNECTING); - // std::array epdContent = {"S", "U", "C", "C", "E", - // "S", "S"}; setEpdContent(epdContent); + if (improv_connectWifi(cmd.ssid, cmd.password)) { + queueLedEffect(LED_EFFECT_WIFI_CONNECT_SUCCESS); - preferences.putBool("wifiConfigured", true); + // std::array epdContent = {"S", "U", "C", "C", + // "E", "S", "S"}; setEpdContent(epdContent); - improv_set_state(improv::STATE_PROVISIONED); - std::vector data = improv::build_rpc_response( - improv::WIFI_SETTINGS, getLocalUrl(), false); - improv_send_response(data); + preferences.putBool("wifiConfigured", true); - delay(2500); - ESP.restart(); - setupWebserver(); - } else { - queueLedEffect(LED_EFFECT_WIFI_CONNECT_ERROR); + improv_set_state(improv::STATE_PROVISIONED); + std::vector data = improv::build_rpc_response( + improv::WIFI_SETTINGS, getLocalUrl(), false); + improv_send_response(data); - improv_set_state(improv::STATE_STOPPED); - improv_set_error(improv::Error::ERROR_UNABLE_TO_CONNECT); + delay(2500); + ESP.restart(); + setupWebserver(); + } else { + queueLedEffect(LED_EFFECT_WIFI_CONNECT_ERROR); + + improv_set_state(improv::STATE_STOPPED); + improv_set_error(improv::Error::ERROR_UNABLE_TO_CONNECT); + } + + break; } - break; - } + case improv::Command::GET_DEVICE_INFO: { + std::vector infos = {// Firmware name + "BTClock", + // Firmware version + "1.0.0", + // Hardware chip/variant + "ESP32S3", + // Device name + "BTClock"}; + std::vector data = + improv::build_rpc_response(improv::GET_DEVICE_INFO, infos, false); + improv_send_response(data); + break; + } - case improv::Command::GET_DEVICE_INFO: { - std::vector infos = {// Firmware name - "BTClock", - // Firmware version - "1.0.0", - // Hardware chip/variant - "ESP32S3", - // Device name - "BTClock"}; - std::vector data = - improv::build_rpc_response(improv::GET_DEVICE_INFO, infos, false); - improv_send_response(data); - break; - } + case improv::Command::GET_WIFI_NETWORKS: { + improvGetAvailableWifiNetworks(); + // std::array epdContent = {"W", "E", "B", "W", "I", + // "F", "I"}; setEpdContent(epdContent); + break; + } - case improv::Command::GET_WIFI_NETWORKS: { - improvGetAvailableWifiNetworks(); - // std::array epdContent = {"W", "E", "B", "W", "I", - // "F", "I"}; setEpdContent(epdContent); - break; - } - - default: { - improv_set_error(improv::ERROR_UNKNOWN_RPC); - return false; - } + default: { + improv_set_error(improv::ERROR_UNKNOWN_RPC); + return false; + } } return true; @@ -452,8 +451,7 @@ void improv_set_state(improv::State state) { data[9] = state; uint8_t checksum = 0x00; - for (uint8_t d : data) - checksum += d; + for (uint8_t d : data) checksum += d; data[10] = checksum; Serial.write(data.data(), data.size()); @@ -468,8 +466,7 @@ void improv_send_response(std::vector &response) { data.insert(data.end(), response.begin(), response.end()); uint8_t checksum = 0x00; - for (uint8_t d : data) - checksum += d; + for (uint8_t d : data) checksum += d; data.push_back(checksum); Serial.write(data.data(), data.size()); @@ -484,8 +481,7 @@ void improv_set_error(improv::Error error) { data[9] = error; uint8_t checksum = 0x00; - for (uint8_t d : data) - checksum += d; + for (uint8_t d : data) checksum += d; data[10] = checksum; Serial.write(data.data(), data.size()); @@ -497,74 +493,73 @@ void WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { Serial.printf("[WiFi-event] event: %d\n", event); switch (event) { - case ARDUINO_EVENT_WIFI_READY: - Serial.println("WiFi interface ready"); - break; - case ARDUINO_EVENT_WIFI_SCAN_DONE: - Serial.println("Completed scan for access points"); - break; - case ARDUINO_EVENT_WIFI_STA_START: - Serial.println("WiFi client started"); - break; - case ARDUINO_EVENT_WIFI_STA_STOP: - Serial.println("WiFi clients stopped"); - break; - case ARDUINO_EVENT_WIFI_STA_CONNECTED: - Serial.println("Connected to access point"); - break; - case ARDUINO_EVENT_WIFI_STA_DISCONNECTED: { - if (!first_connect) { - Serial.println("Disconnected from WiFi access point"); - queueLedEffect(LED_EFFECT_WIFI_CONNECT_ERROR); - uint8_t reason = info.wifi_sta_disconnected.reason; - if (reason) - Serial.printf("Disconnect reason: %s, ", - WiFi.disconnectReasonName((wifi_err_reason_t)reason)); + case ARDUINO_EVENT_WIFI_READY: + Serial.println("WiFi interface ready"); + break; + case ARDUINO_EVENT_WIFI_SCAN_DONE: + Serial.println("Completed scan for access points"); + break; + case ARDUINO_EVENT_WIFI_STA_START: + Serial.println("WiFi client started"); + break; + case ARDUINO_EVENT_WIFI_STA_STOP: + Serial.println("WiFi clients stopped"); + break; + case ARDUINO_EVENT_WIFI_STA_CONNECTED: + Serial.println("Connected to access point"); + break; + case ARDUINO_EVENT_WIFI_STA_DISCONNECTED: { + if (!first_connect) { + Serial.println("Disconnected from WiFi access point"); + queueLedEffect(LED_EFFECT_WIFI_CONNECT_ERROR); + uint8_t reason = info.wifi_sta_disconnected.reason; + if (reason) + Serial.printf("Disconnect reason: %s, ", + WiFi.disconnectReasonName((wifi_err_reason_t)reason)); + } + break; } - break; - } - case ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE: - Serial.println("Authentication mode of access point has changed"); - break; - case ARDUINO_EVENT_WIFI_STA_GOT_IP: { - Serial.print("Obtained IP address: "); - Serial.println(WiFi.localIP()); - if (!first_connect) - queueLedEffect(LED_EFFECT_WIFI_CONNECT_SUCCESS); - first_connect = false; - break; - } - case ARDUINO_EVENT_WIFI_STA_LOST_IP: - Serial.println("Lost IP address and IP address is reset to 0"); - queueLedEffect(LED_EFFECT_WIFI_CONNECT_ERROR); - WiFi.reconnect(); - break; - case ARDUINO_EVENT_WIFI_AP_START: - Serial.println("WiFi access point started"); - break; - case ARDUINO_EVENT_WIFI_AP_STOP: - Serial.println("WiFi access point stopped"); - break; - case ARDUINO_EVENT_WIFI_AP_STACONNECTED: - Serial.println("Client connected"); - break; - case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED: - Serial.println("Client disconnected"); - break; - case ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED: - Serial.println("Assigned IP address to client"); - break; - case ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED: - Serial.println("Received probe request"); - break; - case ARDUINO_EVENT_WIFI_AP_GOT_IP6: - Serial.println("AP IPv6 is preferred"); - break; - case ARDUINO_EVENT_WIFI_STA_GOT_IP6: - Serial.println("STA IPv6 is preferred"); - break; - default: - break; + case ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE: + Serial.println("Authentication mode of access point has changed"); + break; + case ARDUINO_EVENT_WIFI_STA_GOT_IP: { + Serial.print("Obtained IP address: "); + Serial.println(WiFi.localIP()); + if (!first_connect) queueLedEffect(LED_EFFECT_WIFI_CONNECT_SUCCESS); + first_connect = false; + break; + } + case ARDUINO_EVENT_WIFI_STA_LOST_IP: + Serial.println("Lost IP address and IP address is reset to 0"); + queueLedEffect(LED_EFFECT_WIFI_CONNECT_ERROR); + WiFi.reconnect(); + break; + case ARDUINO_EVENT_WIFI_AP_START: + Serial.println("WiFi access point started"); + break; + case ARDUINO_EVENT_WIFI_AP_STOP: + Serial.println("WiFi access point stopped"); + break; + case ARDUINO_EVENT_WIFI_AP_STACONNECTED: + Serial.println("Client connected"); + break; + case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED: + Serial.println("Client disconnected"); + break; + case ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED: + Serial.println("Assigned IP address to client"); + break; + case ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED: + Serial.println("Received probe request"); + break; + case ARDUINO_EVENT_WIFI_AP_GOT_IP6: + Serial.println("AP IPv6 is preferred"); + break; + case ARDUINO_EVENT_WIFI_STA_GOT_IP6: + Serial.println("STA IPv6 is preferred"); + break; + default: + break; } } diff --git a/src/lib/config.hpp b/src/lib/config.hpp index 47da213..228beea 100644 --- a/src/lib/config.hpp +++ b/src/lib/config.hpp @@ -6,6 +6,7 @@ #include #include #include + #include #include "lib/block_notify.hpp" diff --git a/src/lib/epd.cpp b/src/lib/epd.cpp index da62860..921cc44 100644 --- a/src/lib/epd.cpp +++ b/src/lib/epd.cpp @@ -124,7 +124,7 @@ void setupDisplays() { *taskParam = i; xTaskCreate(updateDisplay, ("EpdUpd" + String(i)).c_str(), 2048, taskParam, - 11, &tasks[i]); // create task + 11, &tasks[i]); // create task } epdContent = {"B", "T", "C", "L", "O", "C", "K"}; @@ -185,7 +185,6 @@ void prepareDisplayUpdateTask(void *pvParameters) { } else if (epdContent[epdIndex].length() > 5) { renderText(epdIndex, epdContent[epdIndex], updatePartial); } else { - if (epdContent[epdIndex].length() > 1) { showChars(epdIndex, epdContent[epdIndex], updatePartial, &FONT_MEDIUM); @@ -237,8 +236,7 @@ extern "C" void updateDisplay(void *pvParameters) noexcept { if (displays[epdIndex].displayWithReturn(updatePartial)) { displays[epdIndex].powerOff(); currentEpdContent[epdIndex] = epdContent[epdIndex]; - if (!updatePartial) - lastFullRefresh[epdIndex] = millis(); + if (!updatePartial) lastFullRefresh[epdIndex] = millis(); if (eventSourceTaskHandle != NULL) xTaskNotifyGive(eventSourceTaskHandle); diff --git a/src/lib/epd.hpp b/src/lib/epd.hpp index 72bcda0..275aaae 100644 --- a/src/lib/epd.hpp +++ b/src/lib/epd.hpp @@ -1,16 +1,18 @@ #pragma once -#include "fonts/fonts.hpp" -#include "lib/config.hpp" -#include "lib/shared.hpp" #include #include #include + #include #include #include #include +#include "fonts/fonts.hpp" +#include "lib/config.hpp" +#include "lib/shared.hpp" + #ifdef USE_QR #include "qrcodegen.h" #endif diff --git a/src/lib/improv.cpp b/src/lib/improv.cpp index bc3ce30..3de3ef5 100644 --- a/src/lib/improv.cpp +++ b/src/lib/improv.cpp @@ -54,35 +54,25 @@ bool parse_improv_serial_byte(size_t position, uint8_t byte, const uint8_t *buffer, std::function &&callback, std::function &&on_error) { - if (position == 0) - return byte == 'I'; - if (position == 1) - return byte == 'M'; - if (position == 2) - return byte == 'P'; - if (position == 3) - return byte == 'R'; - if (position == 4) - return byte == 'O'; - if (position == 5) - return byte == 'V'; + if (position == 0) return byte == 'I'; + if (position == 1) return byte == 'M'; + if (position == 2) return byte == 'P'; + if (position == 3) return byte == 'R'; + if (position == 4) return byte == 'O'; + if (position == 5) return byte == 'V'; - if (position == 6) - return byte == IMPROV_SERIAL_VERSION; + if (position == 6) return byte == IMPROV_SERIAL_VERSION; - if (position <= 8) - return true; + if (position <= 8) return true; uint8_t type = buffer[7]; uint8_t data_len = buffer[8]; - if (position <= 8 + data_len) - return true; + if (position <= 8 + data_len) return true; if (position == 8 + data_len + 1) { uint8_t checksum = 0x00; - for (size_t i = 0; i < position; i++) - checksum += buffer[i]; + for (size_t i = 0; i < position; i++) checksum += buffer[i]; if (checksum != byte) { on_error(ERROR_INVALID_RPC); @@ -148,6 +138,6 @@ std::vector build_rpc_response(Command command, } return out; } -#endif // ARDUINO +#endif // ARDUINO -} // namespace improv \ No newline at end of file +} // namespace improv \ No newline at end of file diff --git a/src/lib/improv.hpp b/src/lib/improv.hpp index c8c8d57..1c9453d 100644 --- a/src/lib/improv.hpp +++ b/src/lib/improv.hpp @@ -2,7 +2,7 @@ #ifdef ARDUINO #include -#endif // ARDUINO +#endif // ARDUINO #include #include @@ -81,6 +81,6 @@ std::vector build_rpc_response(Command command, std::vector build_rpc_response(Command command, const std::vector &datum, bool add_checksum = true); -#endif // ARDUINO +#endif // ARDUINO -} // namespace improv \ No newline at end of file +} // namespace improv \ No newline at end of file diff --git a/src/lib/led_handler.cpp b/src/lib/led_handler.cpp index 5e03697..f07fbc2 100644 --- a/src/lib/led_handler.cpp +++ b/src/lib/led_handler.cpp @@ -18,106 +18,103 @@ void ledTask(void *parameter) { } switch (ledTaskParams) { - case LED_POWER_TEST: - ledRainbow(20); - pixels.clear(); - break; - case LED_EFFECT_WIFI_CONNECT_ERROR: - blinkDelayTwoColor(100, 3, pixels.Color(8, 161, 236), - pixels.Color(255, 0, 0)); - break; - case LED_FLASH_ERROR: - blinkDelayColor(250, 3, 255, 0, 0); - break; - case LED_EFFECT_HEARTBEAT: - blinkDelayColor(150, 2, 0, 0, 255); - break; - case LED_EFFECT_WIFI_CONNECT_SUCCESS: - case LED_FLASH_SUCCESS: - blinkDelayColor(150, 3, 0, 255, 0); - break; - case LED_PROGRESS_100: - pixels.setPixelColor(0, pixels.Color(0, 255, 0)); - case LED_PROGRESS_75: - pixels.setPixelColor(1, pixels.Color(0, 255, 0)); - case LED_PROGRESS_50: - pixels.setPixelColor(2, pixels.Color(0, 255, 0)); - case LED_PROGRESS_25: - pixels.setPixelColor(3, pixels.Color(0, 255, 0)); - pixels.show(); - break; - case LED_FLASH_UPDATE: - break; - case LED_FLASH_BLOCK_NOTIFY: - blinkDelayTwoColor(250, 3, pixels.Color(224, 67, 0), - pixels.Color(8, 2, 0)); - break; - case LED_EFFECT_WIFI_WAIT_FOR_CONFIG: - blinkDelayTwoColor(100, 1, pixels.Color(8, 161, 236), - pixels.Color(156, 225, 240)); - break; - case LED_EFFECT_WIFI_ERASE_SETTINGS: - blinkDelay(100, 3); - break; - case LED_EFFECT_WIFI_CONNECTING: - for (int i = NEOPIXEL_COUNT; i >= 0; i--) { - for (int j = NEOPIXEL_COUNT; j >= 0; j--) { - if (j == i) { - pixels.setPixelColor(i, pixels.Color(16, 197, 236)); - } else { - pixels.setPixelColor(j, pixels.Color(0, 0, 0)); + case LED_POWER_TEST: + ledRainbow(20); + pixels.clear(); + break; + case LED_EFFECT_WIFI_CONNECT_ERROR: + blinkDelayTwoColor(100, 3, pixels.Color(8, 161, 236), + pixels.Color(255, 0, 0)); + break; + case LED_FLASH_ERROR: + blinkDelayColor(250, 3, 255, 0, 0); + break; + case LED_EFFECT_HEARTBEAT: + blinkDelayColor(150, 2, 0, 0, 255); + break; + case LED_EFFECT_WIFI_CONNECT_SUCCESS: + case LED_FLASH_SUCCESS: + blinkDelayColor(150, 3, 0, 255, 0); + break; + case LED_PROGRESS_100: + pixels.setPixelColor(0, pixels.Color(0, 255, 0)); + case LED_PROGRESS_75: + pixels.setPixelColor(1, pixels.Color(0, 255, 0)); + case LED_PROGRESS_50: + pixels.setPixelColor(2, pixels.Color(0, 255, 0)); + case LED_PROGRESS_25: + pixels.setPixelColor(3, pixels.Color(0, 255, 0)); + pixels.show(); + break; + case LED_FLASH_UPDATE: + break; + case LED_FLASH_BLOCK_NOTIFY: + blinkDelayTwoColor(250, 3, pixels.Color(224, 67, 0), + pixels.Color(8, 2, 0)); + break; + case LED_EFFECT_WIFI_WAIT_FOR_CONFIG: + blinkDelayTwoColor(100, 1, pixels.Color(8, 161, 236), + pixels.Color(156, 225, 240)); + break; + case LED_EFFECT_WIFI_ERASE_SETTINGS: + blinkDelay(100, 3); + break; + case LED_EFFECT_WIFI_CONNECTING: + for (int i = NEOPIXEL_COUNT; i >= 0; i--) { + for (int j = NEOPIXEL_COUNT; j >= 0; j--) { + if (j == i) { + pixels.setPixelColor(i, pixels.Color(16, 197, 236)); + } else { + pixels.setPixelColor(j, pixels.Color(0, 0, 0)); + } } + pixels.show(); + vTaskDelay(pdMS_TO_TICKS(100)); } - pixels.show(); - vTaskDelay(pdMS_TO_TICKS(100)); - } - break; - case LED_EFFECT_PAUSE_TIMER: - for (int i = NEOPIXEL_COUNT; i >= 0; i--) { - for (int j = NEOPIXEL_COUNT; j >= 0; j--) { - uint32_t c = pixels.Color(0, 0, 0); - if (i == j) - c = pixels.Color(0, 255, 0); - pixels.setPixelColor(j, c); - } + break; + case LED_EFFECT_PAUSE_TIMER: + for (int i = NEOPIXEL_COUNT; i >= 0; i--) { + for (int j = NEOPIXEL_COUNT; j >= 0; j--) { + uint32_t c = pixels.Color(0, 0, 0); + if (i == j) c = pixels.Color(0, 255, 0); + pixels.setPixelColor(j, c); + } + pixels.show(); + + delay(100); + } + pixels.setPixelColor(0, pixels.Color(255, 0, 0)); pixels.show(); - delay(100); - } - pixels.setPixelColor(0, pixels.Color(255, 0, 0)); - pixels.show(); - - delay(900); - - pixels.clear(); - pixels.show(); - break; - case LED_EFFECT_START_TIMER: - pixels.clear(); - pixels.setPixelColor((NEOPIXEL_COUNT - 1), pixels.Color(255, 0, 0)); - pixels.show(); - - delay(900); - - for (int i = NEOPIXEL_COUNT; i--; i > 0) { - - for (int j = NEOPIXEL_COUNT; j--; j > 0) { - uint32_t c = pixels.Color(0, 0, 0); - if (i == j) - c = pixels.Color(0, 255, 0); - - pixels.setPixelColor(j, c); - } + delay(900); + pixels.clear(); + pixels.show(); + break; + case LED_EFFECT_START_TIMER: + pixels.clear(); + pixels.setPixelColor((NEOPIXEL_COUNT - 1), pixels.Color(255, 0, 0)); pixels.show(); - delay(100); - } + delay(900); - pixels.clear(); - pixels.show(); - break; + for (int i = NEOPIXEL_COUNT; i--; i > 0) { + for (int j = NEOPIXEL_COUNT; j--; j > 0) { + uint32_t c = pixels.Color(0, 0, 0); + if (i == j) c = pixels.Color(0, 255, 0); + + pixels.setPixelColor(j, c); + } + + pixels.show(); + + delay(100); + } + + pixels.clear(); + pixels.show(); + break; } // revert to previous state unless power test @@ -155,7 +152,6 @@ void setupLedTask() { void blinkDelay(int d, int times) { for (int j = 0; j < times; j++) { - pixels.setPixelColor(0, pixels.Color(255, 0, 0)); pixels.setPixelColor(1, pixels.Color(0, 255, 0)); pixels.setPixelColor(2, pixels.Color(255, 0, 0)); @@ -218,7 +214,6 @@ void clearLeds() { void setLights(int r, int g, int b) { setLights(pixels.Color(r, g, b)); } void setLights(uint32_t color) { - bool ledStatus = true; for (int i = 0; i < NEOPIXEL_COUNT; i++) { @@ -282,43 +277,43 @@ void ledRainbow(int wait) { pixels.rainbow(firstPixelHue); // Above line is equivalent to: // strip.rainbow(firstPixelHue, 1, 255, 255, true); - pixels.show(); // Update strip with new contents + pixels.show(); // Update strip with new contents delayMicroseconds(wait); // vTaskDelay(pdMS_TO_TICKS(wait)); // Pause for a moment } } void ledTheaterChase(uint32_t color, int wait) { - for (int a = 0; a < 10; a++) { // Repeat 10 times... - for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2... - pixels.clear(); // Set all pixels in RAM to 0 (off) + for (int a = 0; a < 10; a++) { // Repeat 10 times... + for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2... + pixels.clear(); // Set all pixels in RAM to 0 (off) // 'c' counts up from 'b' to end of strip in steps of 3... for (int c = b; c < pixels.numPixels(); c += 3) { - pixels.setPixelColor(c, color); // Set pixel 'c' to value 'color' + pixels.setPixelColor(c, color); // Set pixel 'c' to value 'color' } - pixels.show(); // Update strip with new contents - vTaskDelay(pdMS_TO_TICKS(wait)); // Pause for a moment + pixels.show(); // Update strip with new contents + vTaskDelay(pdMS_TO_TICKS(wait)); // Pause for a moment } } } void ledTheaterChaseRainbow(int wait) { - int firstPixelHue = 0; // First pixel starts at red (hue 0) - for (int a = 0; a < 30; a++) { // Repeat 30 times... - for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2... - pixels.clear(); // Set all pixels in RAM to 0 (off) + int firstPixelHue = 0; // First pixel starts at red (hue 0) + for (int a = 0; a < 30; a++) { // Repeat 30 times... + for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2... + pixels.clear(); // Set all pixels in RAM to 0 (off) // 'c' counts up from 'b' to end of strip in increments of 3... for (int c = b; c < pixels.numPixels(); c += 3) { // hue of pixel 'c' is offset by an amount to make one full // revolution of the color wheel (range 65536) along the length // of the strip (strip.numPixels() steps): int hue = firstPixelHue + c * 65536L / pixels.numPixels(); - uint32_t color = pixels.gamma32(pixels.ColorHSV(hue)); // hue -> RGB - pixels.setPixelColor(c, color); // Set pixel 'c' to value 'color' + uint32_t color = pixels.gamma32(pixels.ColorHSV(hue)); // hue -> RGB + pixels.setPixelColor(c, color); // Set pixel 'c' to value 'color' } - pixels.show(); // Update strip with new contents - vTaskDelay(pdMS_TO_TICKS(wait)); // Pause for a moment - firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames + pixels.show(); // Update strip with new contents + vTaskDelay(pdMS_TO_TICKS(wait)); // Pause for a moment + firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames } } } diff --git a/src/lib/led_handler.hpp b/src/lib/led_handler.hpp index c4cc8f9..c5b3780 100644 --- a/src/lib/led_handler.hpp +++ b/src/lib/led_handler.hpp @@ -1,12 +1,13 @@ #pragma once -#include "lib/shared.hpp" -#include "lib/webserver.hpp" #include #include #include #include +#include "lib/shared.hpp" +#include "lib/webserver.hpp" + #ifndef NEOPIXEL_PIN #define NEOPIXEL_PIN 34 #endif diff --git a/src/lib/ota.cpp b/src/lib/ota.cpp index 3ae7ff7..d23929f 100644 --- a/src/lib/ota.cpp +++ b/src/lib/ota.cpp @@ -64,7 +64,7 @@ void onOTAStart() { void handleOTATask(void *parameter) { for (;;) { - ArduinoOTA.handle(); // Allow OTA updates to occur + ArduinoOTA.handle(); // Allow OTA updates to occur vTaskDelay(pdMS_TO_TICKS(2500)); } } diff --git a/src/lib/ota.hpp b/src/lib/ota.hpp index 6d20bb6..8b2ad75 100644 --- a/src/lib/ota.hpp +++ b/src/lib/ota.hpp @@ -1,12 +1,13 @@ -#include "lib/config.hpp" -#include "lib/shared.hpp" #include #include +#include "lib/config.hpp" +#include "lib/shared.hpp" + void setupOTA(); void onOTAStart(); void handleOTATask(void *parameter); void onOTAProgress(unsigned int progress, unsigned int total); void downloadUpdate(); void onOTAError(ota_error_t error); -void onOTAComplete(); \ No newline at end of file +void onOTAComplete(); diff --git a/src/lib/price_fetch.cpp b/src/lib/price_fetch.cpp index 5ac7a7b..73606a2 100644 --- a/src/lib/price_fetch.cpp +++ b/src/lib/price_fetch.cpp @@ -1,7 +1,8 @@ #include "price_fetch.hpp" -const PROGMEM char *cgApiUrl = "https://api.coingecko.com/api/v3/simple/" - "price?ids=bitcoin&vs_currencies=usd%2Ceur"; +const PROGMEM char *cgApiUrl = + "https://api.coingecko.com/api/v3/simple/" + "price?ids=bitcoin&vs_currencies=usd%2Ceur"; TaskHandle_t priceFetchTaskHandle; diff --git a/src/lib/price_fetch.hpp b/src/lib/price_fetch.hpp index 59b1818..7016dda 100644 --- a/src/lib/price_fetch.hpp +++ b/src/lib/price_fetch.hpp @@ -1,8 +1,9 @@ -#include "lib/config.hpp" -#include "lib/shared.hpp" #include #include +#include "lib/config.hpp" +#include "lib/shared.hpp" + extern TaskHandle_t priceFetchTaskHandle; void setupPriceFetchTask(); diff --git a/src/lib/price_notify.cpp b/src/lib/price_notify.cpp index d3bfaa8..f901cc0 100644 --- a/src/lib/price_notify.cpp +++ b/src/lib/price_notify.cpp @@ -57,18 +57,18 @@ void onWebsocketPriceEvent(void *handler_args, esp_event_base_t base, esp_websocket_event_data_t *data = (esp_websocket_event_data_t *)event_data; switch (event_id) { - case WEBSOCKET_EVENT_CONNECTED: - Serial.println(F("Connected to CoinCap.io WebSocket")); - break; - case WEBSOCKET_EVENT_DATA: - onWebsocketPriceMessage(data); - break; - case WEBSOCKET_EVENT_ERROR: - Serial.println(F("Price WS Connnection error")); - break; - case WEBSOCKET_EVENT_DISCONNECTED: - Serial.println(F("Price WS Connnection Closed")); - break; + case WEBSOCKET_EVENT_CONNECTED: + Serial.println(F("Connected to CoinCap.io WebSocket")); + break; + case WEBSOCKET_EVENT_DATA: + onWebsocketPriceMessage(data); + break; + case WEBSOCKET_EVENT_ERROR: + Serial.println(F("Price WS Connnection error")); + break; + case WEBSOCKET_EVENT_DISCONNECTED: + Serial.println(F("Price WS Connnection Closed")); + break; } } @@ -79,7 +79,6 @@ void onWebsocketPriceMessage(esp_websocket_event_data_t *event_data) { if (doc.containsKey("bitcoin")) { if (currentPrice != doc["bitcoin"].as()) { - uint minSecPriceUpd = preferences.getUInt( "minSecPriceUpd", DEFAULT_SECONDS_BETWEEN_PRICE_UPDATE); uint currentTime = esp_timer_get_time() / 1000000; @@ -108,8 +107,7 @@ uint getPrice() { return currentPrice; } void setPrice(uint newPrice) { currentPrice = newPrice; } bool isPriceNotifyConnected() { - if (clientPrice == NULL) - return false; + if (clientPrice == NULL) return false; return esp_websocket_client_is_connected(clientPrice); } diff --git a/src/lib/price_notify.hpp b/src/lib/price_notify.hpp index 15375c5..d320b2a 100644 --- a/src/lib/price_notify.hpp +++ b/src/lib/price_notify.hpp @@ -2,13 +2,12 @@ #include #include +#include + #include -#include #include "lib/screen_handler.hpp" -// using namespace websockets; - void setupPriceNotify(); void onWebsocketPriceEvent(void *handler_args, esp_event_base_t base, diff --git a/src/lib/screen_handler.cpp b/src/lib/screen_handler.cpp index d7b5a2f..dd30233 100644 --- a/src/lib/screen_handler.cpp +++ b/src/lib/screen_handler.cpp @@ -12,19 +12,6 @@ std::array taskEpdContent = {"", "", "", "", "", "", ""}; std::string priceString; -// typedef enum -// { -// TASK_PRICE_UPDATE, -// TASK_BLOCK_UPDATE, -// TASK_TIME_UPDATE -// } TaskType; - -// typedef struct -// { -// TaskType type; -// unsigned long data; -// } WorkItem; - #define WORK_QUEUE_SIZE 10 QueueHandle_t workQueue = NULL; @@ -40,66 +27,67 @@ void workerTask(void *pvParameters) { // Process the work item based on its type switch (receivedItem.type) { - case TASK_PRICE_UPDATE: { - uint price = getPrice(); - char priceSymbol = '$'; - if (preferences.getBool("fetchEurPrice", false)) { - priceSymbol = '['; - } - if (getCurrentScreen() == SCREEN_BTC_TICKER) { - taskEpdContent = parsePriceData(price, priceSymbol); - } else if (getCurrentScreen() == SCREEN_MSCW_TIME) { - taskEpdContent = parseSatsPerCurrency(price, priceSymbol); - } else { - taskEpdContent = - parseMarketCap(getBlockHeight(), price, priceSymbol, - preferences.getBool("mcapBigChar", true)); - } - - setEpdContent(taskEpdContent); - break; - } - case TASK_BLOCK_UPDATE: { - if (getCurrentScreen() != SCREEN_HALVING_COUNTDOWN) { - taskEpdContent = parseBlockHeight(getBlockHeight()); - } else { - taskEpdContent = parseHalvingCountdown(getBlockHeight()); - } - - if (getCurrentScreen() == SCREEN_HALVING_COUNTDOWN || - getCurrentScreen() == SCREEN_BLOCK_HEIGHT) { - setEpdContent(taskEpdContent); - } - break; - } - case TASK_TIME_UPDATE: { - if (getCurrentScreen() == SCREEN_TIME) { - time_t currentTime; - struct tm timeinfo; - time(¤tTime); - localtime_r(¤tTime, &timeinfo); - std::string timeString; - - String minute = String(timeinfo.tm_min); - if (minute.length() < 2) { - minute = "0" + minute; + case TASK_PRICE_UPDATE: { + uint price = getPrice(); + char priceSymbol = '$'; + if (preferences.getBool("fetchEurPrice", false)) { + priceSymbol = '['; + } + if (getCurrentScreen() == SCREEN_BTC_TICKER) { + taskEpdContent = parsePriceData(price, priceSymbol); + } else if (getCurrentScreen() == SCREEN_MSCW_TIME) { + taskEpdContent = parseSatsPerCurrency(price, priceSymbol); + } else { + taskEpdContent = + parseMarketCap(getBlockHeight(), price, priceSymbol, + preferences.getBool("mcapBigChar", true)); } - timeString = std::to_string(timeinfo.tm_hour) + ":" + minute.c_str(); - timeString.insert(timeString.begin(), - NUM_SCREENS - timeString.length(), ' '); - taskEpdContent[0] = std::to_string(timeinfo.tm_mday) + "/" + - std::to_string(timeinfo.tm_mon + 1); - - for (uint i = 1; i < NUM_SCREENS; i++) { - taskEpdContent[i] = timeString[i]; - } setEpdContent(taskEpdContent); + break; } + case TASK_BLOCK_UPDATE: { + if (getCurrentScreen() != SCREEN_HALVING_COUNTDOWN) { + taskEpdContent = parseBlockHeight(getBlockHeight()); + } else { + taskEpdContent = parseHalvingCountdown(getBlockHeight()); + } - break; - } - // Add more cases for additional task types + if (getCurrentScreen() == SCREEN_HALVING_COUNTDOWN || + getCurrentScreen() == SCREEN_BLOCK_HEIGHT) { + setEpdContent(taskEpdContent); + } + break; + } + case TASK_TIME_UPDATE: { + if (getCurrentScreen() == SCREEN_TIME) { + time_t currentTime; + struct tm timeinfo; + time(¤tTime); + localtime_r(¤tTime, &timeinfo); + std::string timeString; + + String minute = String(timeinfo.tm_min); + if (minute.length() < 2) { + minute = "0" + minute; + } + + timeString = + std::to_string(timeinfo.tm_hour) + ":" + minute.c_str(); + timeString.insert(timeString.begin(), + NUM_SCREENS - timeString.length(), ' '); + taskEpdContent[0] = std::to_string(timeinfo.tm_mday) + "/" + + std::to_string(timeinfo.tm_mon + 1); + + for (uint i = 1; i < NUM_SCREENS; i++) { + taskEpdContent[i] = timeString[i]; + } + setEpdContent(taskEpdContent); + } + + break; + } + // Add more cases for additional task types } } } @@ -145,11 +133,6 @@ void IRAM_ATTR screenRotateTimerISR(void *arg) { void setupTasks() { workQueue = xQueueCreate(WORK_QUEUE_SIZE, sizeof(WorkItem)); - // xTaskCreate(taskPriceUpdate, "updatePrice", 1024, NULL, tskIDLE_PRIORITY, - // &priceUpdateTaskHandle); xTaskCreate(taskBlockUpdate, "updateBlock", 1024, - // NULL, tskIDLE_PRIORITY, &blockUpdateTaskHandle); - // xTaskCreate(taskTimeUpdate, "updateTime", 1024, NULL, tskIDLE_PRIORITY, - // &timeUpdateTaskHandle); xTaskCreate(workerTask, "workerTask", 4096, NULL, tskIDLE_PRIORITY, &workerTaskHandle); @@ -214,8 +197,7 @@ void setTimerActive(bool status) { preferences.putBool("timerActive", false); } - if (eventSourceTaskHandle != NULL) - xTaskNotifyGive(eventSourceTaskHandle); + if (eventSourceTaskHandle != NULL) xTaskNotifyGive(eventSourceTaskHandle); } void toggleTimerActive() { setTimerActive(!isTimerActive()); } @@ -230,31 +212,30 @@ void setCurrentScreen(uint newScreen) { currentScreen = newScreen; switch (currentScreen) { - case SCREEN_TIME: { - WorkItem timeUpdate = {TASK_TIME_UPDATE, 0}; - xQueueSend(workQueue, &timeUpdate, portMAX_DELAY); - // xTaskNotifyGive(timeUpdateTaskHandle); - break; - } - case SCREEN_HALVING_COUNTDOWN: - case SCREEN_BLOCK_HEIGHT: { - WorkItem blockUpdate = {TASK_BLOCK_UPDATE, 0}; - xQueueSend(workQueue, &blockUpdate, portMAX_DELAY); - // xTaskNotifyGive(blockUpdateTaskHandle); - break; - } - case SCREEN_MARKET_CAP: - case SCREEN_MSCW_TIME: - case SCREEN_BTC_TICKER: { - WorkItem priceUpdate = {TASK_PRICE_UPDATE, 0}; - xQueueSend(workQueue, &priceUpdate, portMAX_DELAY); - // xTaskNotifyGive(priceUpdateTaskHandle); - break; - } + case SCREEN_TIME: { + WorkItem timeUpdate = {TASK_TIME_UPDATE, 0}; + xQueueSend(workQueue, &timeUpdate, portMAX_DELAY); + // xTaskNotifyGive(timeUpdateTaskHandle); + break; + } + case SCREEN_HALVING_COUNTDOWN: + case SCREEN_BLOCK_HEIGHT: { + WorkItem blockUpdate = {TASK_BLOCK_UPDATE, 0}; + xQueueSend(workQueue, &blockUpdate, portMAX_DELAY); + // xTaskNotifyGive(blockUpdateTaskHandle); + break; + } + case SCREEN_MARKET_CAP: + case SCREEN_MSCW_TIME: + case SCREEN_BTC_TICKER: { + WorkItem priceUpdate = {TASK_PRICE_UPDATE, 0}; + xQueueSend(workQueue, &priceUpdate, portMAX_DELAY); + // xTaskNotifyGive(priceUpdateTaskHandle); + break; + } } - if (eventSourceTaskHandle != NULL) - xTaskNotifyGive(eventSourceTaskHandle); + if (eventSourceTaskHandle != NULL) xTaskNotifyGive(eventSourceTaskHandle); } void nextScreen() { @@ -269,7 +250,6 @@ void nextScreen() { } void previousScreen() { - int newCurrentScreen = modulo(getCurrentScreen() - 1, SCREEN_COUNT); String key = "screen" + String(newCurrentScreen) + "Visible"; diff --git a/src/lib/screen_handler.hpp b/src/lib/screen_handler.hpp index e7da416..464969b 100644 --- a/src/lib/screen_handler.hpp +++ b/src/lib/screen_handler.hpp @@ -1,11 +1,11 @@ #pragma once #include - -#include #include #include +#include + #include "lib/epd.hpp" #include "lib/price_fetch.hpp" #include "lib/shared.hpp" diff --git a/src/lib/shared.hpp b/src/lib/shared.hpp index 2f56ea3..c4c6fab 100644 --- a/src/lib/shared.hpp +++ b/src/lib/shared.hpp @@ -5,8 +5,8 @@ #include #include #include -#include +#include #include extern Adafruit_MCP23X17 mcp1; diff --git a/src/lib/webserver.cpp b/src/lib/webserver.cpp index f74d90d..8bb1a73 100644 --- a/src/lib/webserver.cpp +++ b/src/lib/webserver.cpp @@ -5,7 +5,6 @@ AsyncEventSource events("/events"); TaskHandle_t eventSourceTaskHandle; void setupWebserver() { - events.onConnect([](AsyncEventSourceClient *client) { client->send("welcome", NULL, millis(), 1000); }); @@ -139,8 +138,7 @@ StaticJsonDocument<512> getLedStatusObject() { } void eventSourceUpdate() { - if (!events.count()) - return; + if (!events.count()) return; StaticJsonDocument<768> root = getStatusObject(); JsonArray data = root.createNestedArray("data"); @@ -232,7 +230,7 @@ void onApiShowText(AsyncWebServerRequest *request) { if (request->hasParam("t")) { AsyncWebParameter *p = request->getParam("t"); String t = p->value(); - t.toUpperCase(); // This is needed as long as lowercase letters are glitchy + t.toUpperCase(); // This is needed as long as lowercase letters are glitchy std::array textEpdContent; for (uint i = 0; i < NUM_SCREENS; i++) { @@ -369,8 +367,7 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json) { void onApiRestart(AsyncWebServerRequest *request) { request->send(200); - if (events.count()) - events.send("closing"); + if (events.count()) events.send("closing"); delay(500); @@ -474,7 +471,7 @@ void onApiSettingsPost(AsyncWebServerRequest *request) { int params = request->params(); for (int i = 0; i < params; i++) { AsyncWebParameter *p = request->getParam(i); - if (p->isFile()) { // p->isPost() is also true + if (p->isFile()) { // p->isPost() is also true Serial.printf("FILE[%s]: %s, size: %u\n", p->name().c_str(), p->value().c_str(), p->size()); } else if (p->isPost()) { @@ -742,7 +739,6 @@ void onApiLightsSetJson(AsyncWebServerRequest *request, JsonVariant &json) { if (lights[i].containsKey("red") && lights[i].containsKey("green") && lights[i].containsKey("blue")) { - red = lights[i]["red"].as(); green = lights[i]["green"].as(); blue = lights[i]["blue"].as(); diff --git a/src/lib/webserver.hpp b/src/lib/webserver.hpp index 9251228..f9dc01f 100644 --- a/src/lib/webserver.hpp +++ b/src/lib/webserver.hpp @@ -1,5 +1,6 @@ #pragma once +// Keep order of includes because of conflicts #include "WebServer.h" #include "ESPAsyncWebServer.h" #include @@ -8,20 +9,10 @@ #include "AsyncJson.h" #include - -// #include "AsyncJson.h" -// #include "ESPAsyncWebServer.h" -// #include "WebServer.h" -// #include -// #include -// #include -// #include - #include "lib/block_notify.hpp" #include "lib/led_handler.hpp" #include "lib/price_notify.hpp" #include "lib/screen_handler.hpp" - #include "webserver/OneParamRewrite.hpp" extern TaskHandle_t eventSourceTaskHandle; diff --git a/src/lib/webserver/OneParamRewrite.cpp b/src/lib/webserver/OneParamRewrite.cpp index 0a9764b..f2b9439 100644 --- a/src/lib/webserver/OneParamRewrite.cpp +++ b/src/lib/webserver/OneParamRewrite.cpp @@ -2,7 +2,6 @@ OneParamRewrite::OneParamRewrite(const char *from, const char *to) : AsyncWebRewrite(from, to) { - _paramIndex = _from.indexOf('{'); if (_paramIndex >= 0 && _from.endsWith("}")) { diff --git a/src/lib/webserver/OneParamRewrite.hpp b/src/lib/webserver/OneParamRewrite.hpp index 26e4439..ae51cd2 100644 --- a/src/lib/webserver/OneParamRewrite.hpp +++ b/src/lib/webserver/OneParamRewrite.hpp @@ -3,12 +3,12 @@ #include "ESPAsyncWebServer.h" class OneParamRewrite : public AsyncWebRewrite { -protected: + protected: String _urlPrefix; int _paramIndex; String _paramsBackup; -public: + public: OneParamRewrite(const char *from, const char *to); bool match(AsyncWebServerRequest *request) override; }; \ No newline at end of file