Skip to content

Commit

Permalink
Fixes for Rev. B black PCB
Browse files Browse the repository at this point in the history
  • Loading branch information
dsbaars committed Sep 16, 2024
1 parent 630943e commit 5dd47c2
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion data
2 changes: 1 addition & 1 deletion sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/fonts/fonts.hpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
23 changes: 22 additions & 1 deletion src/lib/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ void setup()
{
preferences.clear();
queueLedEffect(LED_EFFECT_WIFI_ERASE_SETTINGS);
nvs_flash_erase();
delay(1000);

ESP.restart();
}
}
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -509,7 +529,7 @@ void setupHardware()
}

#ifdef IS_HW_REV_B
pinMode(39, INPUT_PULLUP);
pinMode(39, INPUT_PULLDOWN);

#endif

Expand Down Expand Up @@ -690,6 +710,7 @@ String getHwRev()
bool isWhiteVersion()
{
#ifdef IS_HW_REV_B
pinMode(39, INPUT_PULLDOWN);
return digitalRead(39);
#else
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <WiFiManager.h>
#include <base64.h>
#include <esp_task_wdt.h>

#include <nvs_flash.h>
#include <map>

#include "lib/block_notify.hpp"
Expand Down
10 changes: 5 additions & 5 deletions src/lib/led_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions src/lib/nostr_notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<std::string, NUM_SCREENS> textEpdContent = parseZapNotify(satsAmount, preferences.getBool("useSatsSymbol", DEFAULT_USE_SATS_SYMBOL));

Expand Down
2 changes: 1 addition & 1 deletion src/lib/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5dd47c2

Please sign in to comment.