diff --git a/data b/data index f0fa58b..266a99b 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit f0fa58b5ea60f695aeaae9ddd7138cbb3686e96a +Subproject commit 266a99be96189bea92e0ef593f930bb92d3b5b20 diff --git a/lib/btclock/data_handler.cpp b/lib/btclock/data_handler.cpp index b489bb8..eaf4538 100644 --- a/lib/btclock/data_handler.cpp +++ b/lib/btclock/data_handler.cpp @@ -73,7 +73,7 @@ std::array parsePriceData(std::uint32_t price, char cu std::string priceString; if (std::to_string(price).length() >= NUM_SCREENS || useSuffixFormat) { - int numScreens = shareDot && !mowMode ? NUM_SCREENS - 1 : NUM_SCREENS - 2; + int numScreens = shareDot || mowMode ? NUM_SCREENS - 1 : NUM_SCREENS - 2; priceString = getCurrencySymbol(currencySymbol) + formatNumberWithSuffix(price, numScreens, mowMode); } else @@ -85,7 +85,14 @@ std::array parsePriceData(std::uint32_t price, char cu { priceString.insert(priceString.begin(), NUM_SCREENS - priceString.length(), ' '); - ret[0] = "BTC/" + getCurrencyCode(currencySymbol); + if (mowMode) + { + ret[0] = "MOW/UNITS"; + } + else + { + ret[0] = "BTC/" + getCurrencyCode(currencySymbol); + } firstIndex = 1; diff --git a/lib/btclock/utils.cpp b/lib/btclock/utils.cpp index 9056d14..0e19962 100644 --- a/lib/btclock/utils.cpp +++ b/lib/btclock/utils.cpp @@ -83,14 +83,31 @@ std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters, bool mo } // Add suffix - int len = snprintf(result, sizeof(result), "%.0f%c", numDouble, suffix); + int len; + + // Mow Mode always uses string truncation to avoid rounding + std::string mowAsString = std::to_string(numDouble); + if (mowMode) { + // Default to one decimal place + len = snprintf(result, sizeof(result), "%s%c", mowAsString.substr(0, mowAsString.find(".") + 2).c_str(), suffix); + } + else + { + len = snprintf(result, sizeof(result), "%.0f%c", numDouble, suffix); + } // If there's room, add more decimal places if (len < numCharacters) { int restLen = mowMode ? numCharacters - len : numCharacters - len - 1; - - snprintf(result, sizeof(result), "%.*f%c", restLen, numDouble, suffix); + + if (mowMode) { + snprintf(result, sizeof(result), "%s%c", mowAsString.substr(0, mowAsString.find(".") + 2 + restLen).c_str(), suffix); + } + else + { + snprintf(result, sizeof(result), "%.*f%c", restLen, numDouble, suffix); + } } return result; diff --git a/src/lib/defaults.hpp b/src/lib/defaults.hpp index 8af3b5b..11df69a 100644 --- a/src/lib/defaults.hpp +++ b/src/lib/defaults.hpp @@ -45,6 +45,8 @@ #define DEFAULT_FL_EFFECT_DELAY 15 #define DEFAULT_LUX_LIGHT_TOGGLE 128 +#define DEFAULT_FL_OFF_WHEN_DARK true + #define DEFAULT_FL_ALWAYS_ON false #define DEFAULT_FL_FLASH_ON_UPDATE false @@ -68,3 +70,4 @@ #define DEFAULT_ACTIVE_CURRENCIES "USD,EUR,JPY" #define DEFAULT_GIT_RELEASE_URL "https://git.btclock.dev/api/v1/repos/btclock/btclock_v3/releases/latest" +#define DEFAULT_VERTICAL_DESC true diff --git a/src/lib/epd.cpp b/src/lib/epd.cpp index 3ef06e6..1e27eae 100644 --- a/src/lib/epd.cpp +++ b/src/lib/epd.cpp @@ -373,7 +373,11 @@ extern "C" void updateDisplay(void *pvParameters) noexcept void splitText(const uint dispNum, const String &top, const String &bottom, bool partial) { - displays[dispNum].setRotation(2); + if(preferences.getBool("verticalDesc", DEFAULT_VERTICAL_DESC) && dispNum == 0) { + displays[dispNum].setRotation(1); + } else { + displays[dispNum].setRotation(2); + } displays[dispNum].setFont(&FONT_SMALL); displays[dispNum].setTextColor(getFgColor()); diff --git a/src/lib/webserver.cpp b/src/lib/webserver.cpp index 777fe0b..11b9024 100644 --- a/src/lib/webserver.cpp +++ b/src/lib/webserver.cpp @@ -546,9 +546,10 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json) "mdnsEnabled", "otaEnabled", "stealFocus", "mcapBigChar", "useSatsSymbol", "useBlkCountdown", "suffixPrice", "disableLeds", "ownDataSource", - "mowMode", "suffixShareDot", + "mowMode", "suffixShareDot", "flOffWhenDark", "flAlwaysOn", "flDisable", "flFlashOnUpd", "mempoolSecure", "useNostr", "bitaxeEnabled", + "verticalDesc", "nostrZapNotify", "stagingSource", "httpAuthEnabled"}; for (String setting : boolSettings) @@ -689,6 +690,8 @@ void onApiSettingsGet(AsyncWebServerRequest *request) root["suffixPrice"] = preferences.getBool("suffixPrice", DEFAULT_SUFFIX_PRICE); root["disableLeds"] = preferences.getBool("disableLeds", DEFAULT_DISABLE_LEDS); root["mowMode"] = preferences.getBool("mowMode", DEFAULT_MOW_MODE); + root["verticalDesc"] = preferences.getBool("verticalDesc", DEFAULT_VERTICAL_DESC); + root["suffixShareDot"] = preferences.getBool("suffixShareDot", DEFAULT_SUFFIX_SHARE_DOT); root["hostnamePrefix"] = preferences.getString("hostnamePrefix", DEFAULT_HOSTNAME_PREFIX); @@ -726,6 +729,8 @@ void onApiSettingsGet(AsyncWebServerRequest *request) root["hasLightLevel"] = hasLightLevel(); root["luxLightToggle"] = preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE); + root["flOffWhenDark"] = preferences.getBool("flOffWhenDark", DEFAULT_FL_OFF_WHEN_DARK); + #else root["hasFrontlight"] = false; root["hasLightLevel"] = false; diff --git a/src/main.cpp b/src/main.cpp index 908f155..b9d2ae7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,7 +51,7 @@ extern "C" void app_main() if (hasLightLevel()) { if (preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE) != 0) { - if (hasLightLevel() && getLightLevel() <= 2) + if (hasLightLevel() && getLightLevel() <= 1 && preferences.getBool("flOffWhenDark", DEFAULT_FL_OFF_WHEN_DARK)) { if (frontlightIsOn()) { frontlightFadeOutAll(); diff --git a/test/test_datahandler/test_main.cpp b/test/test_datahandler/test_main.cpp index b09c9b1..24118e4 100644 --- a/test/test_datahandler/test_main.cpp +++ b/test/test_datahandler/test_main.cpp @@ -143,7 +143,7 @@ void test_PriceSuffixModeCompact2(void) void test_PriceSuffixModeMow(void) { - std::array output = parsePriceData(93000, '$', true, true); + std::array output = parsePriceData(93600, '$', true, true); std::string joined = joinArrayWithBrackets(output); @@ -158,11 +158,11 @@ void test_PriceSuffixModeMow(void) void test_PriceSuffixModeMowCompact(void) { - std::array output = parsePriceData(93000, '$', true, true, true); + std::array output = parsePriceData(93600, '$', true, true, true); std::string joined = joinArrayWithBrackets(output); - TEST_ASSERT_EQUAL_STRING_MESSAGE("BTC/USD", output[0].c_str(), joined.c_str()); + TEST_ASSERT_EQUAL_STRING_MESSAGE("MOW/UNITS", output[0].c_str(), joined.c_str()); TEST_ASSERT_EQUAL_STRING_MESSAGE("$", output[NUM_SCREENS - 6].c_str(), joined.c_str()); TEST_ASSERT_EQUAL_STRING_MESSAGE("0.", output[NUM_SCREENS - 5].c_str(), joined.c_str());