forked from btclock/btclock_v3
Compare commits
No commits in common. "4a52fc0bf22c050a440eca7aa885cf18bcd42f10" and "d6604d28d66a4e8458a8f412fff5a13c92c2599a" have entirely different histories.
4a52fc0bf2
...
d6604d28d6
8 changed files with 12 additions and 48 deletions
2
data
2
data
|
@ -1 +1 @@
|
||||||
Subproject commit 266a99be96189bea92e0ef593f930bb92d3b5b20
|
Subproject commit f0fa58b5ea60f695aeaae9ddd7138cbb3686e96a
|
|
@ -73,7 +73,7 @@ std::array<std::string, NUM_SCREENS> parsePriceData(std::uint32_t price, char cu
|
||||||
std::string priceString;
|
std::string priceString;
|
||||||
if (std::to_string(price).length() >= NUM_SCREENS || useSuffixFormat)
|
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);
|
priceString = getCurrencySymbol(currencySymbol) + formatNumberWithSuffix(price, numScreens, mowMode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -85,14 +85,7 @@ std::array<std::string, NUM_SCREENS> parsePriceData(std::uint32_t price, char cu
|
||||||
{
|
{
|
||||||
priceString.insert(priceString.begin(), NUM_SCREENS - priceString.length(), ' ');
|
priceString.insert(priceString.begin(), NUM_SCREENS - priceString.length(), ' ');
|
||||||
|
|
||||||
if (mowMode)
|
|
||||||
{
|
|
||||||
ret[0] = "MOW/UNITS";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret[0] = "BTC/" + getCurrencyCode(currencySymbol);
|
ret[0] = "BTC/" + getCurrencyCode(currencySymbol);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
firstIndex = 1;
|
firstIndex = 1;
|
||||||
|
|
|
@ -83,32 +83,15 @@ std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters, bool mo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add suffix
|
// Add suffix
|
||||||
int len;
|
int len = snprintf(result, sizeof(result), "%.0f%c", numDouble, suffix);
|
||||||
|
|
||||||
// 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 there's room, add more decimal places
|
||||||
if (len < numCharacters)
|
if (len < numCharacters)
|
||||||
{
|
{
|
||||||
int restLen = mowMode ? numCharacters - len : numCharacters - len - 1;
|
int restLen = mowMode ? numCharacters - len : numCharacters - len - 1;
|
||||||
|
|
||||||
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);
|
snprintf(result, sizeof(result), "%.*f%c", restLen, numDouble, suffix);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,6 @@
|
||||||
#define DEFAULT_FL_EFFECT_DELAY 15
|
#define DEFAULT_FL_EFFECT_DELAY 15
|
||||||
|
|
||||||
#define DEFAULT_LUX_LIGHT_TOGGLE 128
|
#define DEFAULT_LUX_LIGHT_TOGGLE 128
|
||||||
#define DEFAULT_FL_OFF_WHEN_DARK true
|
|
||||||
|
|
||||||
#define DEFAULT_FL_ALWAYS_ON false
|
#define DEFAULT_FL_ALWAYS_ON false
|
||||||
#define DEFAULT_FL_FLASH_ON_UPDATE false
|
#define DEFAULT_FL_FLASH_ON_UPDATE false
|
||||||
|
|
||||||
|
@ -70,4 +68,3 @@
|
||||||
#define DEFAULT_ACTIVE_CURRENCIES "USD,EUR,JPY"
|
#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_GIT_RELEASE_URL "https://git.btclock.dev/api/v1/repos/btclock/btclock_v3/releases/latest"
|
||||||
#define DEFAULT_VERTICAL_DESC true
|
|
||||||
|
|
|
@ -373,11 +373,7 @@ extern "C" void updateDisplay(void *pvParameters) noexcept
|
||||||
void splitText(const uint dispNum, const String &top, const String &bottom,
|
void splitText(const uint dispNum, const String &top, const String &bottom,
|
||||||
bool partial)
|
bool partial)
|
||||||
{
|
{
|
||||||
if(preferences.getBool("verticalDesc", DEFAULT_VERTICAL_DESC) && dispNum == 0) {
|
|
||||||
displays[dispNum].setRotation(1);
|
|
||||||
} else {
|
|
||||||
displays[dispNum].setRotation(2);
|
displays[dispNum].setRotation(2);
|
||||||
}
|
|
||||||
displays[dispNum].setFont(&FONT_SMALL);
|
displays[dispNum].setFont(&FONT_SMALL);
|
||||||
displays[dispNum].setTextColor(getFgColor());
|
displays[dispNum].setTextColor(getFgColor());
|
||||||
|
|
||||||
|
|
|
@ -546,10 +546,9 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json)
|
||||||
"mdnsEnabled", "otaEnabled", "stealFocus",
|
"mdnsEnabled", "otaEnabled", "stealFocus",
|
||||||
"mcapBigChar", "useSatsSymbol", "useBlkCountdown",
|
"mcapBigChar", "useSatsSymbol", "useBlkCountdown",
|
||||||
"suffixPrice", "disableLeds", "ownDataSource",
|
"suffixPrice", "disableLeds", "ownDataSource",
|
||||||
"mowMode", "suffixShareDot", "flOffWhenDark",
|
"mowMode", "suffixShareDot",
|
||||||
"flAlwaysOn", "flDisable", "flFlashOnUpd",
|
"flAlwaysOn", "flDisable", "flFlashOnUpd",
|
||||||
"mempoolSecure", "useNostr", "bitaxeEnabled",
|
"mempoolSecure", "useNostr", "bitaxeEnabled",
|
||||||
"verticalDesc",
|
|
||||||
"nostrZapNotify", "stagingSource", "httpAuthEnabled"};
|
"nostrZapNotify", "stagingSource", "httpAuthEnabled"};
|
||||||
|
|
||||||
for (String setting : boolSettings)
|
for (String setting : boolSettings)
|
||||||
|
@ -690,8 +689,6 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
|
||||||
root["suffixPrice"] = preferences.getBool("suffixPrice", DEFAULT_SUFFIX_PRICE);
|
root["suffixPrice"] = preferences.getBool("suffixPrice", DEFAULT_SUFFIX_PRICE);
|
||||||
root["disableLeds"] = preferences.getBool("disableLeds", DEFAULT_DISABLE_LEDS);
|
root["disableLeds"] = preferences.getBool("disableLeds", DEFAULT_DISABLE_LEDS);
|
||||||
root["mowMode"] = preferences.getBool("mowMode", DEFAULT_MOW_MODE);
|
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["suffixShareDot"] = preferences.getBool("suffixShareDot", DEFAULT_SUFFIX_SHARE_DOT);
|
||||||
|
|
||||||
root["hostnamePrefix"] = preferences.getString("hostnamePrefix", DEFAULT_HOSTNAME_PREFIX);
|
root["hostnamePrefix"] = preferences.getString("hostnamePrefix", DEFAULT_HOSTNAME_PREFIX);
|
||||||
|
@ -729,8 +726,6 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
|
||||||
|
|
||||||
root["hasLightLevel"] = hasLightLevel();
|
root["hasLightLevel"] = hasLightLevel();
|
||||||
root["luxLightToggle"] = preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE);
|
root["luxLightToggle"] = preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE);
|
||||||
root["flOffWhenDark"] = preferences.getBool("flOffWhenDark", DEFAULT_FL_OFF_WHEN_DARK);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
root["hasFrontlight"] = false;
|
root["hasFrontlight"] = false;
|
||||||
root["hasLightLevel"] = false;
|
root["hasLightLevel"] = false;
|
||||||
|
|
|
@ -51,7 +51,7 @@ extern "C" void app_main()
|
||||||
if (hasLightLevel()) {
|
if (hasLightLevel()) {
|
||||||
if (preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE) != 0)
|
if (preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE) != 0)
|
||||||
{
|
{
|
||||||
if (hasLightLevel() && getLightLevel() <= 1 && preferences.getBool("flOffWhenDark", DEFAULT_FL_OFF_WHEN_DARK))
|
if (hasLightLevel() && getLightLevel() <= 2)
|
||||||
{
|
{
|
||||||
if (frontlightIsOn()) {
|
if (frontlightIsOn()) {
|
||||||
frontlightFadeOutAll();
|
frontlightFadeOutAll();
|
||||||
|
|
|
@ -143,7 +143,7 @@ void test_PriceSuffixModeCompact2(void)
|
||||||
|
|
||||||
void test_PriceSuffixModeMow(void)
|
void test_PriceSuffixModeMow(void)
|
||||||
{
|
{
|
||||||
std::array<std::string, NUM_SCREENS> output = parsePriceData(93600, '$', true, true);
|
std::array<std::string, NUM_SCREENS> output = parsePriceData(93000, '$', true, true);
|
||||||
|
|
||||||
std::string joined = joinArrayWithBrackets(output);
|
std::string joined = joinArrayWithBrackets(output);
|
||||||
|
|
||||||
|
@ -158,11 +158,11 @@ void test_PriceSuffixModeMow(void)
|
||||||
|
|
||||||
void test_PriceSuffixModeMowCompact(void)
|
void test_PriceSuffixModeMowCompact(void)
|
||||||
{
|
{
|
||||||
std::array<std::string, NUM_SCREENS> output = parsePriceData(93600, '$', true, true, true);
|
std::array<std::string, NUM_SCREENS> output = parsePriceData(93000, '$', true, true, true);
|
||||||
|
|
||||||
std::string joined = joinArrayWithBrackets(output);
|
std::string joined = joinArrayWithBrackets(output);
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING_MESSAGE("MOW/UNITS", output[0].c_str(), joined.c_str());
|
TEST_ASSERT_EQUAL_STRING_MESSAGE("BTC/USD", 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("$", output[NUM_SCREENS - 6].c_str(), joined.c_str());
|
||||||
TEST_ASSERT_EQUAL_STRING_MESSAGE("0.", output[NUM_SCREENS - 5].c_str(), joined.c_str());
|
TEST_ASSERT_EQUAL_STRING_MESSAGE("0.", output[NUM_SCREENS - 5].c_str(), joined.c_str());
|
||||||
|
|
Loading…
Reference in a new issue