Add functionality to disable all LEDs

This commit is contained in:
Djuri Baars 2024-03-11 21:21:15 +01:00
parent 969d2137c3
commit 3e00f1b4a6
6 changed files with 15 additions and 7 deletions

2
data

@ -1 +1 @@
Subproject commit 1b8ab93da64dd7383a2fb34c967b75fdab072718 Subproject commit dcdf98964a42ccd83b2d2501bbed46a640bbc300

View File

@ -1,11 +1,11 @@
#include "data_handler.hpp" #include "data_handler.hpp"
std::array<std::string, NUM_SCREENS> parsePriceData(std::uint32_t price, char currencySymbol) std::array<std::string, NUM_SCREENS> parsePriceData(std::uint32_t price, char currencySymbol, bool useSuffixFormat)
{ {
std::array<std::string, NUM_SCREENS> ret; std::array<std::string, NUM_SCREENS> ret;
std::string priceString; std::string priceString;
if (std::to_string(price).length() >= NUM_SCREENS) { if (std::to_string(price).length() >= NUM_SCREENS || useSuffixFormat) {
priceString = formatNumberWithSuffix(price, NUM_SCREENS-2); priceString = currencySymbol + formatNumberWithSuffix(price, NUM_SCREENS-2);
} else { } else {
priceString = currencySymbol + std::to_string(price); priceString = currencySymbol + std::to_string(price);
} }

View File

@ -5,7 +5,7 @@
#include "utils.hpp" #include "utils.hpp"
std::array<std::string, NUM_SCREENS> parsePriceData(std::uint32_t price, char currencySymbol); std::array<std::string, NUM_SCREENS> parsePriceData(std::uint32_t price, char currencySymbol, bool useSuffixFormat = false);
std::array<std::string, NUM_SCREENS> parseSatsPerCurrency(std::uint32_t price, char currencySymbol, bool withSatsSymbol); std::array<std::string, NUM_SCREENS> parseSatsPerCurrency(std::uint32_t price, char currencySymbol, bool withSatsSymbol);
std::array<std::string, NUM_SCREENS> parseBlockHeight(std::uint32_t blockHeight); std::array<std::string, NUM_SCREENS> parseBlockHeight(std::uint32_t blockHeight);
std::array<std::string, NUM_SCREENS> parseHalvingCountdown(std::uint32_t blockHeight, bool asBlocks); std::array<std::string, NUM_SCREENS> parseHalvingCountdown(std::uint32_t blockHeight, bool asBlocks);

View File

@ -10,6 +10,11 @@ void ledTask(void *parameter) {
if (ledTaskQueue != NULL) { if (ledTaskQueue != NULL) {
if (xQueueReceive(ledTaskQueue, &ledTaskParams, portMAX_DELAY) == if (xQueueReceive(ledTaskQueue, &ledTaskParams, portMAX_DELAY) ==
pdPASS) { pdPASS) {
if (preferences.getBool("disableLeds", false)) {
continue;
}
uint32_t oldLights[NEOPIXEL_COUNT]; uint32_t oldLights[NEOPIXEL_COUNT];
// get current state // get current state

View File

@ -34,7 +34,7 @@ void workerTask(void *pvParameters) {
priceSymbol = '['; priceSymbol = '[';
} }
if (getCurrentScreen() == SCREEN_BTC_TICKER) { if (getCurrentScreen() == SCREEN_BTC_TICKER) {
taskEpdContent = parsePriceData(price, priceSymbol); taskEpdContent = parsePriceData(price, priceSymbol, preferences.getBool("suffixPrice", false));
} else if (getCurrentScreen() == SCREEN_MSCW_TIME) { } else if (getCurrentScreen() == SCREEN_MSCW_TIME) {
taskEpdContent = parseSatsPerCurrency(price, priceSymbol, preferences.getBool("useSatsSymbol", false)); taskEpdContent = parseSatsPerCurrency(price, priceSymbol, preferences.getBool("useSatsSymbol", false));
} else { } else {

View File

@ -320,7 +320,8 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json) {
String boolSettings[] = {"fetchEurPrice", "ledTestOnPower", "ledFlashOnUpd", String boolSettings[] = {"fetchEurPrice", "ledTestOnPower", "ledFlashOnUpd",
"mdnsEnabled", "otaEnabled", "stealFocus", "mdnsEnabled", "otaEnabled", "stealFocus",
"mcapBigChar", "useSatsSymbol", "useBlkCountdown"}; "mcapBigChar", "useSatsSymbol", "useBlkCountdown",
"suffixPrice", "disableLeds"};
for (String setting : boolSettings) { for (String setting : boolSettings) {
if (settings.containsKey(setting)) { if (settings.containsKey(setting)) {
@ -409,6 +410,8 @@ void onApiSettingsGet(AsyncWebServerRequest *request) {
root["fetchEurPrice"] = preferences.getBool("fetchEurPrice", false); root["fetchEurPrice"] = preferences.getBool("fetchEurPrice", false);
root["useSatsSymbol"] = preferences.getBool("useSatsSymbol", false); root["useSatsSymbol"] = preferences.getBool("useSatsSymbol", false);
root["useBlkCountdown"] = preferences.getBool("useBlkCountdown", false); root["useBlkCountdown"] = preferences.getBool("useBlkCountdown", false);
root["suffixPrice"] = preferences.getBool("suffixPrice", false);
root["disableLeds"] = preferences.getBool("disableLeds", false);
root["hostnamePrefix"] = preferences.getString("hostnamePrefix", "btclock"); root["hostnamePrefix"] = preferences.getString("hostnamePrefix", "btclock");
root["hostname"] = getMyHostname(); root["hostname"] = getMyHostname();