2023-06-07 10:51:46 +02:00
|
|
|
#ifndef MONITOR_API_H
|
|
|
|
#define MONITOR_API_H
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
// Monitor states
|
|
|
|
#define SCREEN_MINING 0
|
|
|
|
#define SCREEN_CLOCK 1
|
2023-06-08 01:11:47 +02:00
|
|
|
#define SCREEN_GLOBAL 2
|
2023-08-11 13:37:25 +02:00
|
|
|
#define NO_SCREEN 3 //Used when board has no TFT
|
2023-06-07 10:51:46 +02:00
|
|
|
|
2023-06-07 14:12:45 +02:00
|
|
|
//Time update period
|
|
|
|
#define UPDATE_PERIOD_h 5
|
|
|
|
|
2023-06-07 17:07:30 +02:00
|
|
|
//API BTC price
|
|
|
|
#define getBTCAPI "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd"
|
|
|
|
#define UPDATE_BTC_min 5
|
|
|
|
|
2023-06-08 01:11:47 +02:00
|
|
|
//API Block height
|
2023-06-07 17:07:30 +02:00
|
|
|
#define getHeightAPI "https://mempool.space/api/blocks/tip/height"
|
2023-06-08 01:11:47 +02:00
|
|
|
#define UPDATE_Height_min 2
|
|
|
|
|
|
|
|
//APIs Global Stats
|
|
|
|
#define getGlobalHash "https://mempool.space/api/v1/mining/hashrate/3d"
|
|
|
|
#define getDifficulty "https://mempool.space/api/v1/difficulty-adjustment"
|
|
|
|
#define getFees "https://mempool.space/api/v1/fees/recommended"
|
|
|
|
#define UPDATE_Global_min 2
|
|
|
|
|
2023-09-11 00:48:09 +02:00
|
|
|
//API public-pool.io
|
|
|
|
// https://public-pool.io:40557/api/client/btcString
|
|
|
|
#define getPublicPool "https://public-pool.io:40557/api/client/" // +btcString
|
|
|
|
#define UPDATE_POOL_min 1
|
|
|
|
|
2023-07-11 00:25:23 +02:00
|
|
|
#define NEXT_HALVING_EVENT 840000
|
|
|
|
#define HALVING_BLOCKS 210000
|
2023-06-07 17:07:30 +02:00
|
|
|
|
2023-08-27 11:21:26 +02:00
|
|
|
enum NMState {
|
|
|
|
NM_waitingConfig,
|
|
|
|
NM_Connecting,
|
|
|
|
NM_hashing
|
|
|
|
};
|
|
|
|
|
2023-06-07 10:51:46 +02:00
|
|
|
typedef struct{
|
|
|
|
uint8_t screen;
|
|
|
|
bool rotation;
|
2023-08-27 11:21:26 +02:00
|
|
|
NMState NerdStatus;
|
2023-06-07 10:51:46 +02:00
|
|
|
}monitor_data;
|
|
|
|
|
2023-06-08 01:11:47 +02:00
|
|
|
typedef struct{
|
|
|
|
String globalHash; //hexahashes
|
2023-07-11 00:25:23 +02:00
|
|
|
String currentBlock;
|
2023-06-08 01:11:47 +02:00
|
|
|
String difficulty;
|
|
|
|
String blocksHalving;
|
|
|
|
float progressPercent;
|
|
|
|
int remainingBlocks;
|
|
|
|
int halfHourFee;
|
|
|
|
}global_data;
|
|
|
|
|
2023-08-28 22:54:13 +02:00
|
|
|
typedef struct {
|
|
|
|
String completedShares;
|
|
|
|
String totalMHashes;
|
|
|
|
String totalKHashes;
|
|
|
|
String currentHashRate;
|
|
|
|
String templates;
|
|
|
|
String bestDiff;
|
|
|
|
String timeMining;
|
|
|
|
String valids;
|
|
|
|
String temp;
|
|
|
|
String currentTime;
|
|
|
|
}mining_data;
|
2023-08-27 11:21:26 +02:00
|
|
|
|
2023-08-28 22:54:13 +02:00
|
|
|
typedef struct {
|
|
|
|
String completedShares;
|
|
|
|
String totalKHashes;
|
|
|
|
String currentHashRate;
|
|
|
|
String btcPrice;
|
|
|
|
String blockHeight;
|
|
|
|
String currentTime;
|
|
|
|
}clock_data;
|
|
|
|
|
2023-09-08 17:48:10 +02:00
|
|
|
typedef struct {
|
|
|
|
String currentHashRate;
|
|
|
|
String valids;
|
|
|
|
unsigned long currentHours;
|
|
|
|
unsigned long currentMinutes;
|
|
|
|
unsigned long currentSeconds;
|
|
|
|
}clock_data_t;
|
|
|
|
|
2023-08-28 22:54:13 +02:00
|
|
|
typedef struct {
|
|
|
|
String completedShares;
|
|
|
|
String totalKHashes;
|
|
|
|
String currentHashRate;
|
|
|
|
String btcPrice;
|
|
|
|
String currentTime;
|
|
|
|
String halfHourFee;
|
|
|
|
String netwrokDifficulty;
|
|
|
|
String globalHashRate;
|
|
|
|
String blockHeight;
|
|
|
|
float progressPercent;
|
|
|
|
String remainingBlocks;
|
|
|
|
}coin_data;
|
2023-08-27 11:21:26 +02:00
|
|
|
|
2023-09-11 00:48:09 +02:00
|
|
|
typedef struct{
|
|
|
|
int workersCount; // Workers count, how many nerdminers using your address
|
|
|
|
String workersHash; // Workers Total Hash Rate
|
|
|
|
String bestDifficulty; // Your miners best difficulty
|
|
|
|
}pool_data;
|
|
|
|
|
2023-06-07 14:12:45 +02:00
|
|
|
void setup_monitor(void);
|
2023-06-07 10:51:46 +02:00
|
|
|
|
2023-08-28 22:54:13 +02:00
|
|
|
mining_data getMiningData(unsigned long mElapsed);
|
|
|
|
clock_data getClockData(unsigned long mElapsed);
|
|
|
|
coin_data getCoinData(unsigned long mElapsed);
|
2023-09-11 00:48:09 +02:00
|
|
|
pool_data updatePoolData(void);
|
2023-09-12 12:43:10 +02:00
|
|
|
|
2023-09-08 17:48:10 +02:00
|
|
|
clock_data_t getClockData_t(unsigned long mElapsed);
|
2023-08-28 22:54:13 +02:00
|
|
|
|
2023-09-12 12:43:10 +02:00
|
|
|
|
2023-06-07 10:51:46 +02:00
|
|
|
#endif //MONITOR_API_H
|