From 5dd47c227529bc05b4b756e334d78db310d380eb Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Mon, 16 Sep 2024 21:50:28 +0200 Subject: [PATCH] Fixes for Rev. B black PCB --- data | 2 +- sdkconfig.defaults | 2 +- src/fonts/fonts.hpp | 2 +- src/lib/config.cpp | 23 ++++++++++++++++++++++- src/lib/config.hpp | 2 +- src/lib/led_handler.cpp | 10 +++++----- src/lib/nostr_notify.cpp | 7 +++++-- src/lib/webserver.cpp | 2 +- 8 files changed, 37 insertions(+), 13 deletions(-) diff --git a/data b/data index 6c40b54..761c7f2 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 6c40b54273b7f7c7d6c2624d3c2a066435f27756 +Subproject commit 761c7f2991d347e97e77470ea3bf5511d7a7e507 diff --git a/sdkconfig.defaults b/sdkconfig.defaults index ab761ec..59b2ec3 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -44,5 +44,5 @@ CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=3120 CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=n CONFIG_SPIRAM_CACHE_WORKAROUND=y -CONFIG_COMPILER_OPTIMIZATION_PERF=y +CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_NEWLIB_NANO_FORMAT=y \ No newline at end of file diff --git a/src/fonts/fonts.hpp b/src/fonts/fonts.hpp index 1c12d49..099c4e0 100644 --- a/src/fonts/fonts.hpp +++ b/src/fonts/fonts.hpp @@ -1,7 +1,7 @@ #pragma once #include "antonio-semibold20.h" -#include "antonio-semibold30.h" +//#include "antonio-semibold30.h" #include "antonio-semibold40.h" #include "antonio-semibold90.h" #include "sats-symbol.h" diff --git a/src/lib/config.cpp b/src/lib/config.cpp index c295b93..cc50719 100644 --- a/src/lib/config.cpp +++ b/src/lib/config.cpp @@ -58,6 +58,9 @@ void setup() { preferences.clear(); queueLedEffect(LED_EFFECT_WIFI_ERASE_SETTINGS); + nvs_flash_erase(); + delay(1000); + ESP.restart(); } } @@ -229,6 +232,9 @@ void setupWifi() // esp_task_wdt_deinit(); // esp_task_wdt_reset(); } + + + setFgColor(preferences.getUInt("fgColor", isWhiteVersion() ? GxEPD_BLACK : GxEPD_WHITE)); setBgColor(preferences.getUInt("bgColor", isWhiteVersion() ? GxEPD_WHITE : GxEPD_BLACK)); } @@ -274,6 +280,16 @@ void setupPreferences() else setCurrentCurrency(CURRENCY_USD); + if (!preferences.isKey("flDisable")) { + preferences.putBool("flDisable", isWhiteVersion() ? false : true); + } + + if (!preferences.isKey("fgColor")) { + preferences.putUInt("fgColor", isWhiteVersion() ? GxEPD_BLACK : GxEPD_WHITE); + preferences.putUInt("bgColor", isWhiteVersion() ? GxEPD_WHITE : GxEPD_BLACK); + } + + addScreenMapping(SCREEN_BLOCK_HEIGHT, "Block Height"); addScreenMapping(SCREEN_TIME, "Time"); @@ -455,6 +471,10 @@ void setupHardware() Serial.println(F("An Error has occurred while mounting LittleFS")); } + if (HW_REV == "REV_B_EPD_2_13" && !isWhiteVersion()) { + Serial.println(F("Black Rev B")); + } + if (!LittleFS.open("/index.html.gz", "r")) { Serial.println(F("Error loading WebUI")); @@ -509,7 +529,7 @@ void setupHardware() } #ifdef IS_HW_REV_B - pinMode(39, INPUT_PULLUP); + pinMode(39, INPUT_PULLDOWN); #endif @@ -690,6 +710,7 @@ String getHwRev() bool isWhiteVersion() { #ifdef IS_HW_REV_B + pinMode(39, INPUT_PULLDOWN); return digitalRead(39); #else return false; diff --git a/src/lib/config.hpp b/src/lib/config.hpp index e8fcffa..8c9da90 100644 --- a/src/lib/config.hpp +++ b/src/lib/config.hpp @@ -7,7 +7,7 @@ #include #include #include - +#include #include #include "lib/block_notify.hpp" diff --git a/src/lib/led_handler.cpp b/src/lib/led_handler.cpp index a40097b..4f882e0 100644 --- a/src/lib/led_handler.cpp +++ b/src/lib/led_handler.cpp @@ -13,7 +13,7 @@ bool flInTransition = false; void frontlightFlash(int flDelayTime) { - if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL)) + if (preferences.getBool("flDisable")) return; if (frontlightOn) @@ -68,7 +68,7 @@ void frontlightFadeInAll(int flDelayTime) void frontlightFadeInAll(int flDelayTime, bool staggered) { - if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL)) + if (preferences.getBool("flDisable")) return; if (frontlightIsOn()) return; @@ -120,7 +120,7 @@ void frontlightFadeOutAll(int flDelayTime) void frontlightFadeOutAll(int flDelayTime, bool staggered) { - if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL)) + if (preferences.getBool("flDisable")) return; if (!frontlightIsOn()) return; @@ -186,7 +186,7 @@ bool frontlightIsOn() void frontlightFadeIn(uint num, int flDelayTime) { - if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL)) + if (preferences.getBool("flDisable")) return; for (int dutyCycle = 0; dutyCycle <= preferences.getUInt("flMaxBrightness"); dutyCycle += 5) { @@ -197,7 +197,7 @@ void frontlightFadeIn(uint num, int flDelayTime) void frontlightFadeOut(uint num, int flDelayTime) { - if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL)) + if (preferences.getBool("flDisable")) return; if (!frontlightIsOn()) return; diff --git a/src/lib/nostr_notify.cpp b/src/lib/nostr_notify.cpp index f9ac019..2e044bb 100644 --- a/src/lib/nostr_notify.cpp +++ b/src/lib/nostr_notify.cpp @@ -76,7 +76,8 @@ void setupNostrNotify(bool asDatasource, bool zapNotify) }else if(status==nostr::ConnectionStatus::ERROR){ sstatus = "ERROR"; } - Serial.println("[ Nostr ] Connection status changed: " + sstatus); }); + //Serial.println("[ Nostr ] Connection status changed: " + sstatus); + }); } } catch (const std::exception &e) @@ -204,9 +205,11 @@ void handleNostrZapCallback(const String &subId, nostr::SignedNostrEvent *event) if (strcmp(key, "bolt11") == 0) { - Serial.println(F("Got a zap")); + Serial.print(F("Got a zap of ")); int64_t satsAmount = getAmountInSatoshis(std::string(value)); + Serial.print(satsAmount); + Serial.println(F(" sats")); std::array textEpdContent = parseZapNotify(satsAmount, preferences.getBool("useSatsSymbol", DEFAULT_USE_SATS_SYMBOL)); diff --git a/src/lib/webserver.cpp b/src/lib/webserver.cpp index 3d8b6da..801c286 100644 --- a/src/lib/webserver.cpp +++ b/src/lib/webserver.cpp @@ -705,7 +705,7 @@ void onApiSettingsGet(AsyncWebServerRequest *request) #ifdef HAS_FRONTLIGHT root["hasFrontlight"] = true; - root["flDisable"] = preferences.getBool("flDisable", DEFAULT_DISABLE_FL); + root["flDisable"] = preferences.getBool("flDisable"); root["flMaxBrightness"] = preferences.getUInt("flMaxBrightness", DEFAULT_FL_MAX_BRIGHTNESS); root["flAlwaysOn"] = preferences.getBool("flAlwaysOn", DEFAULT_FL_ALWAYS_ON); root["flEffectDelay"] = preferences.getUInt("flEffectDelay", DEFAULT_FL_EFFECT_DELAY);