diff --git a/.github/workflows/tagging.yml b/.github/workflows/tagging.yml index 4021d6e..29b4b62 100644 --- a/.github/workflows/tagging.yml +++ b/.github/workflows/tagging.yml @@ -23,7 +23,7 @@ jobs: uses: actions/upload-artifact@v4 with: retention-days: 1 - name: build-outputs + name: prepared-outputs path: .pio/**/*.bin build: @@ -44,7 +44,7 @@ jobs: steps: - uses: actions/download-artifact@v4 with: - name: build-outputs + name: prepared-outputs path: .pio - name: Install esptools.py run: pip install --upgrade esptool @@ -85,7 +85,7 @@ jobs: - name: Create release uses: ncipollo/release-action@v1 with: - artifacts: "*/*.bin,*/*.sha256" + artifacts: "**/*.bin,**/*.sha256" allowUpdates: true removeArtifacts: true makeLatest: true \ No newline at end of file diff --git a/src/config.cpp b/src/config.cpp index 0c30984..9363094 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -5,6 +5,7 @@ Preferences preferences; const char *ntpServer = "pool.ntp.org"; const long gmtOffset_sec = 0; const int daylightOffset_sec = 3600; +TaskHandle_t OTAHandle = NULL; #define STA_SSID "" #define STA_PASS "" @@ -201,4 +202,22 @@ void setupOTA() else if (error == OTA_END_ERROR) Serial.println("End Failed"); }); ArduinoOTA.begin(); -} \ No newline at end of file + + xTaskCreatePinnedToCore( + OTAUpdateTask, // Task function + "OTAUpdateTask", // Task name + 4096, // Stack size + NULL, // Task parameters + 1, // Priority (higher value means higher priority) + &OTAHandle, // Task handle + 0 // Core to run the task (0 or 1) + ); +} + + +void OTAUpdateTask(void *pvParameters) { + for (;;) { + ArduinoOTA.handle(); // Handle OTA updates + vTaskDelay(1000 / portTICK_PERIOD_MS); // Delay to avoid high CPU usage + } +} diff --git a/src/config.hpp b/src/config.hpp index f3bb73d..2def29c 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -15,6 +15,8 @@ void setupTime(); void setupPreferences(); void setupWifi(); void setupOTA(); +void OTAUpdateTask(void *pvParameters); + void wakeModemSleep(); void setModemSleep(); diff --git a/src/main.cpp b/src/main.cpp index b510d3e..049c592 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,7 +23,7 @@ GxEPD2_BW display = EPD_CLASS(5, 3, 2, 1); typedef void (*MethodPtr)(String); -MethodPtr methods[] = { nullptr, updateRow1, updateRow2, updateRow3 }; +MethodPtr methods[] = {nullptr, updateRow1, updateRow2, updateRow3}; WiFiClientSecure client; uint currentPrice = 0; @@ -45,7 +45,7 @@ void setup() setupWifi(); setupTime(); - if (!inPowerSaveMode()) + if (!inPowerSaveMode()) { setupWebserver(); setupOTA(); @@ -57,8 +57,8 @@ void setup() void loop() { - ArduinoOTA.handle(); - if (isUpdating) { + if (isUpdating) + { return; } @@ -93,47 +93,48 @@ void loop() } } - - - for (uint i = 1; i <= 3; i++) { + for (uint i = 1; i <= 3; i++) + { String rowContent = ""; char keyName[5]; snprintf(keyName, sizeof(keyName), "row%d", i); Serial.print(keyName); Serial.print(" "); Serial.println(preferences.getUInt(keyName)); - switch (preferences.getUInt(keyName)) { - case LINE_BLOCKHEIGHT: - rowContent = getBlock(); - break; - case LINE_MEMPOOL_FEES: - rowContent = getMempoolFees(); - break; - case LINE_MEMPOOL_FEES_MEDIAN: - rowContent = "NOT IMPL"; - break; - case LINE_HALVING_COUNTDOWN: - rowContent = "NOT IMPL"; - break; - case LINE_SATSPERUNIT: { - uint satsPerDollar = int(round(1 / float(getPrice()) * 10e7)); - rowContent = satsPerDollar; - break; - } - case LINE_FIATPRICE: - rowContent = getPrice(); - break; - case LINE_MARKETCAP: - rowContent = "NOT IMPL"; - break; - case LINE_TIME: - rowContent = "NOT IMPL"; - break; - case LINE_DATE: - rowContent = "NOT IMPL"; - break; - default: - rowContent = "DEFAULT"; + switch (preferences.getUInt(keyName)) + { + case LINE_BLOCKHEIGHT: + rowContent = getBlock(); + break; + case LINE_MEMPOOL_FEES: + rowContent = getMempoolFees(); + break; + case LINE_MEMPOOL_FEES_MEDIAN: + rowContent = "NOT IMPL"; + break; + case LINE_HALVING_COUNTDOWN: + rowContent = "NOT IMPL"; + break; + case LINE_SATSPERUNIT: + { + uint satsPerDollar = int(round(1 / float(getPrice()) * 10e7)); + rowContent = satsPerDollar; + break; + } + case LINE_FIATPRICE: + rowContent = getPrice(); + break; + case LINE_MARKETCAP: + rowContent = "NOT IMPL"; + break; + case LINE_TIME: + rowContent = "NOT IMPL"; + break; + case LINE_DATE: + rowContent = "NOT IMPL"; + break; + default: + rowContent = "DEFAULT"; } methods[i](rowContent); @@ -231,17 +232,20 @@ void loop() delay(2 * 1000); - if (inPowerSaveMode()) { + if (inPowerSaveMode()) + { display.hibernate(); setModemSleep(); esp_sleep_enable_timer_wakeup(50 * 1000000); esp_light_sleep_start(); display.init(0, false); wakeModemSleep(); - } else { + } + else + { Serial.println(F("Sleeping")); sleep(50); -// delay(50 * 1000); + // delay(50 * 1000); Serial.println(F("Waking up")); } }