Mining pool bugfixes, improvements and icon optimizations
All checks were successful
BTClock CI / build (push) Successful in 17m35s
BTClock CI / merge (map[name:btclock_v8 version:esp32s3], 213epd) (push) Successful in 27s
BTClock CI / merge (map[name:btclock_rev_b version:esp32s3], 213epd) (push) Successful in 20s
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 213epd) (push) Successful in 25s
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 29epd) (push) Successful in 19s
BTClock CI / release (push) Successful in 36s
All checks were successful
BTClock CI / build (push) Successful in 17m35s
BTClock CI / merge (map[name:btclock_v8 version:esp32s3], 213epd) (push) Successful in 27s
BTClock CI / merge (map[name:btclock_rev_b version:esp32s3], 213epd) (push) Successful in 20s
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 213epd) (push) Successful in 25s
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 29epd) (push) Successful in 19s
BTClock CI / release (push) Successful in 36s
This commit is contained in:
parent
e8a7b221cb
commit
7bcb24bab0
14 changed files with 411 additions and 637 deletions
|
@ -359,68 +359,6 @@ String replaceAmbiguousChars(String input)
|
|||
return input;
|
||||
}
|
||||
|
||||
// void addCurrencyMappings(const std::vector<std::string>& currencies)
|
||||
// {
|
||||
// for (const auto& currency : currencies)
|
||||
// {
|
||||
// int satsPerCurrencyScreen;
|
||||
// int btcTickerScreen;
|
||||
// int marketCapScreen;
|
||||
|
||||
// // Determine the corresponding screen IDs based on the currency code
|
||||
// if (currency == "USD")
|
||||
// {
|
||||
// satsPerCurrencyScreen = SCREEN_SATS_PER_CURRENCY_USD;
|
||||
// btcTickerScreen = SCREEN_BTC_TICKER_USD;
|
||||
// marketCapScreen = SCREEN_MARKET_CAP_USD;
|
||||
// }
|
||||
// else if (currency == "EUR")
|
||||
// {
|
||||
// satsPerCurrencyScreen = SCREEN_SATS_PER_CURRENCY_EUR;
|
||||
// btcTickerScreen = SCREEN_BTC_TICKER_EUR;
|
||||
// marketCapScreen = SCREEN_MARKET_CAP_EUR;
|
||||
// }
|
||||
// else if (currency == "GBP")
|
||||
// {
|
||||
// satsPerCurrencyScreen = SCREEN_SATS_PER_CURRENCY_GBP;
|
||||
// btcTickerScreen = SCREEN_BTC_TICKER_GBP;
|
||||
// marketCapScreen = SCREEN_MARKET_CAP_GBP;
|
||||
// }
|
||||
// else if (currency == "JPY")
|
||||
// {
|
||||
// satsPerCurrencyScreen = SCREEN_SATS_PER_CURRENCY_JPY;
|
||||
// btcTickerScreen = SCREEN_BTC_TICKER_JPY;
|
||||
// marketCapScreen = SCREEN_MARKET_CAP_JPY;
|
||||
// }
|
||||
// else if (currency == "AUD")
|
||||
// {
|
||||
// satsPerCurrencyScreen = SCREEN_SATS_PER_CURRENCY_AUD;
|
||||
// btcTickerScreen = SCREEN_BTC_TICKER_AUD;
|
||||
// marketCapScreen = SCREEN_MARKET_CAP_AUD;
|
||||
// }
|
||||
// else if (currency == "CAD")
|
||||
// {
|
||||
// satsPerCurrencyScreen = SCREEN_SATS_PER_CURRENCY_CAD;
|
||||
// btcTickerScreen = SCREEN_BTC_TICKER_CAD;
|
||||
// marketCapScreen = SCREEN_MARKET_CAP_CAD;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// continue; // Unknown currency, skip it
|
||||
// }
|
||||
|
||||
// // Create the string locally to ensure it persists
|
||||
// std::string satsPerCurrencyString = "Sats per " + currency;
|
||||
// std::string btcTickerString = "Ticker " + currency;
|
||||
// std::string marketCapString = "Market Cap " + currency;
|
||||
|
||||
// // Pass the c_str() to the function
|
||||
// addScreenMapping(satsPerCurrencyScreen, satsPerCurrencyString.c_str());
|
||||
// addScreenMapping(btcTickerScreen, btcTickerString.c_str());
|
||||
// addScreenMapping(marketCapScreen, marketCapString.c_str());
|
||||
// }
|
||||
// }
|
||||
|
||||
void setupWebsocketClients(void *pvParameters)
|
||||
{
|
||||
if (preferences.getBool("ownDataSource", DEFAULT_OWN_DATA_SOURCE))
|
||||
|
@ -823,19 +761,3 @@ const char* getWebUiFilename() {
|
|||
return "littlefs_4MB.bin";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// void loadIcons() {
|
||||
// size_t ocean_logo_size = 886;
|
||||
|
||||
// int iUncompSize = zt.gzip_info((uint8_t *)epd_compress_bitaxe, ocean_logo_size);
|
||||
// Serial.printf("uncompressed size = %d\n", iUncompSize);
|
||||
|
||||
// uint8_t *pUncompressed;
|
||||
// pUncompressed = (uint8_t *)malloc(iUncompSize+4);
|
||||
// int rc = zt.gunzip((uint8_t *)epd_compress_bitaxe, ocean_logo_size, pUncompressed);
|
||||
|
||||
// if (rc == ZT_SUCCESS) {
|
||||
// Serial.println("Decode success");
|
||||
// }
|
||||
// }
|
|
@ -613,8 +613,8 @@ void renderIcon(const uint dispNum, const String &text, bool partial)
|
|||
iconIndex = 2;
|
||||
}
|
||||
else if (text.endsWith("bitaxe")) {
|
||||
width = 122;
|
||||
height = 250;
|
||||
width = 88;
|
||||
height = 220;
|
||||
iconIndex = 3;
|
||||
}
|
||||
else if (text.endsWith("miningpool")) {
|
||||
|
|
|
@ -26,7 +26,7 @@ PoolStats BraiinsPool::parseResponse(const JsonDocument &doc) const
|
|||
LogoData BraiinsPool::getLogo() const {
|
||||
return LogoData{
|
||||
.data = epd_icons_allArray[5],
|
||||
.width = 122,
|
||||
.height = 250
|
||||
.width = 37,
|
||||
.height = 230
|
||||
};
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "lib/mining_pool/mining_pool_interface.hpp"
|
||||
#include <icons/icons.h>
|
||||
#include <utils.hpp>
|
||||
|
||||
class BraiinsPool : public MiningPoolInterface
|
||||
{
|
||||
|
@ -15,6 +16,4 @@ public:
|
|||
bool hasLogo() const override { return true; }
|
||||
std::string getDisplayLabel() const override { return "BRAIINS/POOL"; } // Fallback if needed
|
||||
std::string getDailyEarningsLabel() const override { return "sats/earned"; }
|
||||
private:
|
||||
static int getHashrateMultiplier(const std::string &unit);
|
||||
};
|
|
@ -1,46 +1,19 @@
|
|||
#include "mining_pool_stats_handler.hpp"
|
||||
#include <iostream>
|
||||
|
||||
std::array<std::string, NUM_SCREENS> parseMiningPoolStatsHashRate(std::string text, const MiningPoolInterface& pool)
|
||||
std::array<std::string, NUM_SCREENS> parseMiningPoolStatsHashRate(const std::string& hashrate, const MiningPoolInterface& pool)
|
||||
{
|
||||
std::array<std::string, NUM_SCREENS> ret;
|
||||
ret.fill(""); // Initialize all elements to empty strings
|
||||
std::string hashrate;
|
||||
std::string label;
|
||||
std::string output;
|
||||
|
||||
if (text.length() > 21) {
|
||||
// We are massively future-proof!!
|
||||
label = "ZH/S";
|
||||
hashrate = text.substr(0, text.length() - 21);
|
||||
} else if (text.length() > 18) {
|
||||
label = "EH/S";
|
||||
hashrate = text.substr(0, text.length() - 18);
|
||||
} else if (text.length() > 15) {
|
||||
label = "PH/S";
|
||||
hashrate = text.substr(0, text.length() - 15);
|
||||
} else if (text.length() > 12) {
|
||||
label = "TH/S";
|
||||
hashrate = text.substr(0, text.length() - 12);
|
||||
} else if (text.length() > 9) {
|
||||
label = "GH/S";
|
||||
hashrate = text.substr(0, text.length() - 9);
|
||||
} else if (text.length() > 6) {
|
||||
label = "MH/S";
|
||||
hashrate = text.substr(0, text.length() - 6);
|
||||
} else if (text.length() > 3) {
|
||||
label = "KH/S";
|
||||
hashrate = text.substr(0, text.length() - 3);
|
||||
} else {
|
||||
label = "H/S";
|
||||
hashrate = text;
|
||||
}
|
||||
|
||||
std::size_t textLength = hashrate.length();
|
||||
parseHashrateString(hashrate, label, output, 4);
|
||||
|
||||
std::size_t textLength = output.length();
|
||||
// Calculate the position where the digits should start
|
||||
// Account for the position of the mining pool logo and the hashrate label
|
||||
std::size_t startIndex = NUM_SCREENS - 1 - textLength;
|
||||
|
||||
|
||||
// Insert the pickaxe icon just before the digits
|
||||
if (startIndex > 0)
|
||||
{
|
||||
|
@ -50,7 +23,7 @@ std::array<std::string, NUM_SCREENS> parseMiningPoolStatsHashRate(std::string te
|
|||
// Place the digits
|
||||
for (std::size_t i = 0; i < textLength; ++i)
|
||||
{
|
||||
ret[startIndex + i] = hashrate.substr(i, 1);
|
||||
ret[startIndex + i] = output.substr(i, 1);
|
||||
}
|
||||
|
||||
ret[NUM_SCREENS - 1] = label;
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
#include <array>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <utils.hpp>
|
||||
|
||||
#ifndef UNITY_TEST
|
||||
#include "lib/mining_pool/mining_pool_interface.hpp"
|
||||
#endif
|
||||
|
||||
std::array<std::string, NUM_SCREENS> parseMiningPoolStatsHashRate(std::string text, const MiningPoolInterface& pool);
|
||||
std::array<std::string, NUM_SCREENS> parseMiningPoolStatsHashRate(const std::string& hashrate, const MiningPoolInterface& pool);
|
||||
std::array<std::string, NUM_SCREENS> parseMiningPoolStatsDailyEarnings(int sats, std::string label, const MiningPoolInterface& pool);
|
||||
|
|
|
@ -15,9 +15,13 @@ PoolStats NoderunnersPool::parseResponse(const JsonDocument& doc) const {
|
|||
std::string value = hashrateStr.substr(0, hashrateStr.size() - 1);
|
||||
|
||||
int multiplier = getHashrateMultiplier(unit);
|
||||
double hashrate = std::stod(value) * std::pow(10, multiplier);
|
||||
|
||||
char buffer[32];
|
||||
snprintf(buffer, sizeof(buffer), "%.0f", hashrate);
|
||||
|
||||
return PoolStats{
|
||||
.hashrate = value + std::string(multiplier, '0'),
|
||||
.hashrate = buffer,
|
||||
.dailyEarnings = std::nullopt
|
||||
};
|
||||
}
|
||||
|
@ -28,15 +32,4 @@ LogoData NoderunnersPool::getLogo() const {
|
|||
.width = 122,
|
||||
.height = 122
|
||||
};
|
||||
}
|
||||
|
||||
int NoderunnersPool::getHashrateMultiplier(char unit) {
|
||||
if (unit == '0')
|
||||
return 0;
|
||||
|
||||
static const std::unordered_map<char, int> multipliers = {
|
||||
{'Z', 21}, {'E', 18}, {'P', 15}, {'T', 12},
|
||||
{'G', 9}, {'M', 6}, {'K', 3}
|
||||
};
|
||||
return multipliers.at(unit);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "lib/mining_pool/mining_pool_interface.hpp"
|
||||
#include <icons/icons.h>
|
||||
#include <utils.hpp>
|
||||
|
||||
class NoderunnersPool : public MiningPoolInterface {
|
||||
public:
|
||||
|
@ -16,7 +17,4 @@ public:
|
|||
std::string getDailyEarningsLabel() const override { return ""; }
|
||||
bool hasLogo() const override { return true; }
|
||||
std::string getDisplayLabel() const override { return "NODE/RUNNERS"; } // Fallback if needed
|
||||
|
||||
protected:
|
||||
static int getHashrateMultiplier(char unit);
|
||||
};
|
|
@ -47,6 +47,7 @@ void taskMiningPoolStatsFetch(void *pvParameters)
|
|||
deserializeJson(doc, payload);
|
||||
|
||||
PoolStats stats = poolInterface->parseResponse(doc);
|
||||
|
||||
miningPoolStatsHashrate = stats.hashrate;
|
||||
|
||||
if (stats.dailyEarnings)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue