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
|
@ -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);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue