Add Mow mode notation and setting
Some checks failed
BTClock CI / build (push) Failing after 30s
BTClock CI / merge (map[name:btclock_rev_b version:esp32s3], 213epd) (push) Has been skipped
BTClock CI / merge (map[name:btclock_v8 version:esp32s3], 213epd) (push) Has been skipped
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 213epd) (push) Has been skipped
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 29epd) (push) Has been skipped
BTClock CI / release (push) Has been skipped
Some checks failed
BTClock CI / build (push) Failing after 30s
BTClock CI / merge (map[name:btclock_rev_b version:esp32s3], 213epd) (push) Has been skipped
BTClock CI / merge (map[name:btclock_v8 version:esp32s3], 213epd) (push) Has been skipped
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 213epd) (push) Has been skipped
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 29epd) (push) Has been skipped
BTClock CI / release (push) Has been skipped
This commit is contained in:
parent
239297c26d
commit
d37307cccf
10 changed files with 124 additions and 15 deletions
|
@ -67,13 +67,13 @@ char getCurrencyChar(const std::string& input)
|
|||
return CURRENCY_USD; // Assuming USD is the default for unknown inputs
|
||||
}
|
||||
|
||||
std::array<std::string, NUM_SCREENS> parsePriceData(std::uint32_t price, char currencySymbol, bool useSuffixFormat)
|
||||
std::array<std::string, NUM_SCREENS> parsePriceData(std::uint32_t price, char currencySymbol, bool useSuffixFormat, bool mowMode)
|
||||
{
|
||||
std::array<std::string, NUM_SCREENS> ret;
|
||||
std::string priceString;
|
||||
if (std::to_string(price).length() >= NUM_SCREENS || useSuffixFormat)
|
||||
{
|
||||
priceString = getCurrencySymbol(currencySymbol) + formatNumberWithSuffix(price, NUM_SCREENS - 2);
|
||||
priceString = getCurrencySymbol(currencySymbol) + formatNumberWithSuffix(price, NUM_SCREENS - 2, mowMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ const std::string CURRENCY_CODE_JPY = "JPY";
|
|||
const std::string CURRENCY_CODE_AUD = "AUD";
|
||||
const std::string CURRENCY_CODE_CAD = "CAD";
|
||||
|
||||
std::array<std::string, NUM_SCREENS> parsePriceData(std::uint32_t price, char currency, bool useSuffixFormat = false);
|
||||
std::array<std::string, NUM_SCREENS> parsePriceData(std::uint32_t price, char currency, bool useSuffixFormat = false, bool mowMode = false);
|
||||
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> parseHalvingCountdown(std::uint32_t blockHeight, bool asBlocks);
|
||||
|
|
|
@ -28,7 +28,12 @@ double getSupplyAtBlock(std::uint32_t blockNr)
|
|||
return totalBitcoinInCirculation;
|
||||
}
|
||||
|
||||
std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters)
|
||||
std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters)
|
||||
{
|
||||
return formatNumberWithSuffix(num, numCharacters, false);
|
||||
}
|
||||
|
||||
std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters, bool mowMode)
|
||||
{
|
||||
static char result[20]; // Adjust size as needed
|
||||
const long long quadrillion = 1000000000000000LL;
|
||||
|
@ -56,30 +61,36 @@ std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters)
|
|||
numDouble /= billion;
|
||||
suffix = 'B';
|
||||
}
|
||||
else if (num >= million || numDigits > 6)
|
||||
else if (num >= million || numDigits > 6 || (mowMode && num >= thousand))
|
||||
{
|
||||
numDouble /= million;
|
||||
suffix = 'M';
|
||||
}
|
||||
else if (num >= thousand || numDigits > 3)
|
||||
else if (!mowMode && (num >= thousand || numDigits > 3))
|
||||
{
|
||||
numDouble /= thousand;
|
||||
suffix = 'K';
|
||||
}
|
||||
else
|
||||
else if (!mowMode)
|
||||
{
|
||||
snprintf(result, sizeof(result), "%llu", (unsigned long long)num);
|
||||
// sprintf(result, "%llu", (unsigned long long)num);
|
||||
return result;
|
||||
}
|
||||
else // mowMode is true and num < 1000
|
||||
{
|
||||
numDouble /= million;
|
||||
suffix = 'M';
|
||||
}
|
||||
|
||||
// Add suffix
|
||||
int len = snprintf(result, sizeof(result), "%.0f%c", numDouble, suffix);
|
||||
|
||||
// If there's room, add decimal places
|
||||
// If there's room, add more decimal places
|
||||
if (len < numCharacters)
|
||||
{
|
||||
snprintf(result, sizeof(result), "%.*f%c", numCharacters - len - 1, numDouble, suffix);
|
||||
int restLen = mowMode ? numCharacters - len : numCharacters - len - 1;
|
||||
|
||||
snprintf(result, sizeof(result), "%.*f%c", restLen, numDouble, suffix);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -11,4 +11,5 @@ int modulo(int x,int N);
|
|||
double getSupplyAtBlock(std::uint32_t blockNr);
|
||||
|
||||
std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters = 4);
|
||||
std::string formatNumberWithSuffix(std::uint64_t num, int numCharacters, bool mowMode);
|
||||
int64_t getAmountInSatoshis(std::string bolt11);
|
Loading…
Add table
Add a link
Reference in a new issue