From 4779d02a9e7e1e8abf25c3afc185d16616c18ac3 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Fri, 24 Dec 2021 01:28:16 +0100 Subject: [PATCH 1/2] Update submodules --- components/TFT_eSPI | 2 +- components/arduino-esp32 | 2 +- components/cpputils | 2 +- components/esp-gui-lib | 2 +- components/espchrono | 2 +- components/espwifistack | 2 +- main/debuginputhandler.cpp | 199 ++++++++++++++------------ main/displays/popups/alertdisplay.cpp | 22 +-- main/displays/starfielddisplay.cpp | 2 +- 9 files changed, 123 insertions(+), 112 deletions(-) diff --git a/components/TFT_eSPI b/components/TFT_eSPI index aa7279c..7f378c4 160000 --- a/components/TFT_eSPI +++ b/components/TFT_eSPI @@ -1 +1 @@ -Subproject commit aa7279cb293d55ff6327f9584e8a76d78e515892 +Subproject commit 7f378c458ff153adb8f02556597313757a05f3d0 diff --git a/components/arduino-esp32 b/components/arduino-esp32 index aa9f5dc..6c49028 160000 --- a/components/arduino-esp32 +++ b/components/arduino-esp32 @@ -1 +1 @@ -Subproject commit aa9f5dc65ad7f0679f6d5eab7efcf0e0425747e3 +Subproject commit 6c49028af8f4cdf1afbaab6a0a1efc39dc1a256c diff --git a/components/cpputils b/components/cpputils index 3ae9aab..92c54c9 160000 --- a/components/cpputils +++ b/components/cpputils @@ -1 +1 @@ -Subproject commit 3ae9aab9777ed9f4901aa983ab6b1aa77eebbaea +Subproject commit 92c54c9dbbf1a8fa2fe644298433a31a41647d1b diff --git a/components/esp-gui-lib b/components/esp-gui-lib index 9ce52a1..9cf1c9a 160000 --- a/components/esp-gui-lib +++ b/components/esp-gui-lib @@ -1 +1 @@ -Subproject commit 9ce52a1901d2a741e26961b34e09845e62a43488 +Subproject commit 9cf1c9a78c4af48d6ee7cc6592179cc4cf7f3997 diff --git a/components/espchrono b/components/espchrono index 4d02e16..eff113c 160000 --- a/components/espchrono +++ b/components/espchrono @@ -1 +1 @@ -Subproject commit 4d02e16f4c2c54f8c23d04891ad94f60bb4a79e1 +Subproject commit eff113c393d7549ae2fe381e12553c98d8317de5 diff --git a/components/espwifistack b/components/espwifistack index e09e111..ea56b58 160000 --- a/components/espwifistack +++ b/components/espwifistack @@ -1 +1 @@ -Subproject commit e09e111151a63b097af22234b8651a9a6f315e5b +Subproject commit ea56b58a23c2e10a8bd64692d62f36f259bd9c6b diff --git a/main/debuginputhandler.cpp b/main/debuginputhandler.cpp index 16ca8bc..6de067a 100644 --- a/main/debuginputhandler.cpp +++ b/main/debuginputhandler.cpp @@ -1,10 +1,15 @@ #include "debuginputhandler.h" -// Arduino includes -#include +// system includes +#include + +// esp-idf includes +#include +#include // 3rdparty lib includes #include +#include // local includes #include "globals.h" @@ -12,117 +17,123 @@ #include "screens.h" #include "buttons.h" -using namespace espgui; +namespace { +constexpr const char * const TAG = "DEBUG"; -//wl_status_t last_status; -//IPAddress last_ip; +uint8_t consoleControlCharsReceived{}; +bool uart0Initialized{}; +} // namespace void initDebugInput() { - Serial.begin(115200); - //Serial.setDebugOutput(true); + if (const auto result = uart_set_pin(UART_NUM_0, UART_PIN_NO_CHANGE, 3, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); result != ESP_OK) + { + ESP_LOGE(TAG, "uart_set_pin() failed with %s", esp_err_to_name(result)); + } + + if (const auto result = uart_driver_install(UART_NUM_0, SOC_UART_FIFO_LEN + 1, 0, 10, nullptr, 0); result != ESP_OK) + ESP_LOGE(TAG, "uart_driver_install() failed with %s", esp_err_to_name(result)); + else + uart0Initialized = true; + pinMode(3, INPUT_PULLUP); } void handleDebugInput() { - //const auto status = WiFi.status(); - //if (last_status != status) - //{ - //Serial.print("Status changed to: "); - //Serial.println(to_string(status).c_str()); - //last_status = status; - //} + if (!uart0Initialized) + return; - //const auto ip = WiFi.localIP(); - //if (last_ip != ip) - //{ - //Serial.print("IP changed to: "); - //Serial.println(to_string(ip).c_str()); - //last_ip = ip; - //} - - while(Serial.available()) + size_t length{}; + if (const auto result = uart_get_buffered_data_len(UART_NUM_0, &length); result != ESP_OK) { - const auto c = Serial.read(); + ESP_LOGW(TAG, "uart_get_buffered_data_len() failed with %s", esp_err_to_name(result)); + } + else if (length) + { + char data[length]; + length = uart_read_bytes(UART_NUM_0, data, length, 0); - switch (c) + for (char c : std::string_view{data, length}) { - case 'i': - case 'I': - tft.init(); - break; - case 'p': - case 'P': - { - const auto firstPower = controllers.front.command.poweroff; - for (Controller &controller : controllers) - controller.command.poweroff = !firstPower; - break; - } - case 'l': - case 'L': - { - const auto firstLed = controllers.front.command.led; - for (Controller &controller : controllers) - controller.command.led = !firstLed; - break; - } - case 'r': - case 'R': - loadSettings(); - break; - case 's': - case 'S': - saveSettings(); - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - for (Controller &controller : controllers) - controller.command.buzzer.freq = c-'0'; - break; - case 'A': - InputDispatcher::rotate(-1); - break; - case 'B': - InputDispatcher::rotate(1); - break; - case 'C': - InputDispatcher::confirmButton(true); - InputDispatcher::confirmButton(false); - break; - case 'D': - InputDispatcher::backButton(true); - InputDispatcher::backButton(false); - break; - case 'z': - case 'Z': + switch (c) + { + case 'i': + case 'I': + espgui::tft.init(); + break; + case 'p': + case 'P': + { + const auto firstPower = controllers.front.command.poweroff; + for (Controller &controller : controllers) + controller.command.poweroff = !firstPower; + break; + } + case 'l': + case 'L': + { + const auto firstLed = controllers.front.command.led; + for (Controller &controller : controllers) + controller.command.led = !firstLed; + break; + } + case 'r': + case 'R': + loadSettings(); + break; + case 's': + case 'S': + saveSettings(); + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + for (Controller &controller : controllers) + controller.command.buzzer.freq = c-'0'; + break; + case 'A': + InputDispatcher::rotate(-1); + break; + case 'B': + InputDispatcher::rotate(1); + break; + case 'C': + InputDispatcher::confirmButton(true); + InputDispatcher::confirmButton(false); + break; + case 'D': + InputDispatcher::backButton(true); + InputDispatcher::backButton(false); + break; + case 'z': + case 'Z': #ifndef LEDSTRIP_WRONG_DIRECTION - InputDispatcher::blinkLeftButton(true); - InputDispatcher::blinkLeftButton(false); + InputDispatcher::blinkLeftButton(true); + InputDispatcher::blinkLeftButton(false); #else - InputDispatcher::blinkRightButton(true); - InputDispatcher::blinkRightButton(false); + InputDispatcher::blinkRightButton(true); + InputDispatcher::blinkRightButton(false); #endif - break; - case 'u': - case 'U': + break; + case 'u': + case 'U': #ifndef LEDSTRIP_WRONG_DIRECTION - InputDispatcher::blinkRightButton(true); - InputDispatcher::blinkRightButton(false); + InputDispatcher::blinkRightButton(true); + InputDispatcher::blinkRightButton(false); #else - InputDispatcher::blinkLeftButton(true); - InputDispatcher::blinkLeftButton(false); + InputDispatcher::blinkLeftButton(true); + InputDispatcher::blinkLeftButton(false); #endif - break; + break; + } } } } diff --git a/main/displays/popups/alertdisplay.cpp b/main/displays/popups/alertdisplay.cpp index 7adf1fd..f89a971 100644 --- a/main/displays/popups/alertdisplay.cpp +++ b/main/displays/popups/alertdisplay.cpp @@ -45,11 +45,11 @@ void AlertDisplay::initOverlay() //espgui::tft.fillRect(leftMargin + 1, topMargin + 1, espgui::tft.width() - leftMargin - rightMargin - 2, espgui::tft.height() - topMargin - bottomMargin - 2, TFT_BLACK); espgui::tft.drawSunkenRect(leftMargin, topMargin, width, height, - espgui::tft.color565(240, 240, 240), - espgui::tft.color565(100, 100, 100), - espgui::tft.color565(30, 30, 30)); + color565(240, 240, 240), + color565(100, 100, 100), + color565(30, 30, 30)); - espgui::tft.setTextColor(TFT_WHITE, espgui::tft.color565(30, 30, 30)); + espgui::tft.setTextColor(TFT_WHITE, color565(30, 30, 30)); int x = leftMargin + 5; int y = topMargin + 5; @@ -71,23 +71,23 @@ void AlertDisplay::initOverlay() break; } - espgui::tft.setTextColor(TFT_BLACK, espgui::tft.color565(170, 170, 170)); + espgui::tft.setTextColor(TFT_BLACK, color565(170, 170, 170)); espgui::tft.drawSunkenRect(leftMargin + 15, bottom - 40, (width - 15 - 10 - 15) / 2, 30, - espgui::tft.color565(240, 240, 240), - espgui::tft.color565(100, 100, 100), - espgui::tft.color565(170, 170, 170)); + color565(240, 240, 240), + color565(100, 100, 100), + color565(170, 170, 170)); espgui::tft.drawString("Yes", leftMargin + 18, bottom - 37); espgui::tft.drawSunkenRect(leftMargin + 15 + ((width - 15 - 30 - 15) / 2) + 15, bottom - 40, (width - 15 - 10 - 15) / 2, 30, - espgui::tft.color565(240, 240, 240), - espgui::tft.color565(100, 100, 100), - espgui::tft.color565(170, 170, 170)); + color565(240, 240, 240), + color565(100, 100, 100), + color565(170, 170, 170)); espgui::tft.drawString("No", leftMargin + 18 + ((width - 15 - 30 - 15) / 2) + 15 + 1, bottom - 37); } diff --git a/main/displays/starfielddisplay.cpp b/main/displays/starfielddisplay.cpp index 7ddaa0c..80e0121 100644 --- a/main/displays/starfielddisplay.cpp +++ b/main/displays/starfielddisplay.cpp @@ -69,7 +69,7 @@ void StarfieldDisplay::redraw() { uint8_t r, g, b; r = g = b = 255 - sz[i]; - espgui::tft.drawPixel(screen_x, screen_y, espgui::tft.color565(r,g,b)); + espgui::tft.drawPixel(screen_x, screen_y, color565(r,g,b)); } else sz[i] = 0; // Out of screen, die. From 8d7e94958a24d1ea236693a5c8a983bde216e029 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Fri, 24 Dec 2021 01:30:22 +0100 Subject: [PATCH 2/2] Disable shallow clone for user configs --- .github/workflows/userconfigs.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/userconfigs.yml b/.github/workflows/userconfigs.yml index f49e7da..4a03b01 100644 --- a/.github/workflows/userconfigs.yml +++ b/.github/workflows/userconfigs.yml @@ -18,8 +18,6 @@ jobs: - name: Checkout (without submodules) uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Checkout and install esp-idf uses: 0xFEEDC0DE64/checkout_install_esp_idf@main