2023-11-07 01:11:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Adafruit_MCP23X17.h>
|
2023-11-07 21:26:15 +01:00
|
|
|
#include <ArduinoJson.h>
|
2023-11-07 01:11:12 +01:00
|
|
|
#include <Preferences.h>
|
2023-11-30 22:38:01 +01:00
|
|
|
#include <freertos/FreeRTOS.h>
|
|
|
|
#include <freertos/task.h>
|
2024-03-18 19:32:34 +01:00
|
|
|
#include <GxEPD2.h>
|
|
|
|
#include <GxEPD2_BW.h>
|
2023-11-13 20:02:58 +01:00
|
|
|
|
2023-11-30 22:56:50 +01:00
|
|
|
#include <mutex>
|
2023-11-30 22:38:01 +01:00
|
|
|
#include <utils.hpp>
|
2023-11-07 01:11:12 +01:00
|
|
|
|
2024-07-11 14:08:37 +02:00
|
|
|
#include "defaults.hpp"
|
|
|
|
|
2023-11-26 00:51:54 +01:00
|
|
|
extern Adafruit_MCP23X17 mcp1;
|
|
|
|
#ifdef IS_BTCLOCK_S3
|
|
|
|
extern Adafruit_MCP23X17 mcp2;
|
|
|
|
#endif
|
2023-11-07 01:11:12 +01:00
|
|
|
extern Preferences preferences;
|
2023-11-13 20:02:58 +01:00
|
|
|
extern std::mutex mcpMutex;
|
2023-11-07 21:26:15 +01:00
|
|
|
|
2024-03-18 19:32:34 +01:00
|
|
|
#ifdef VERSION_EPD_2_13
|
|
|
|
#define EPD_CLASS GxEPD2_213_B74
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VERSION_EPD_2_9
|
|
|
|
#define EPD_CLASS GxEPD2_290_T94
|
|
|
|
#endif
|
|
|
|
|
2023-11-07 21:26:15 +01:00
|
|
|
const PROGMEM int SCREEN_BLOCK_HEIGHT = 0;
|
|
|
|
const PROGMEM int SCREEN_MSCW_TIME = 1;
|
|
|
|
const PROGMEM int SCREEN_BTC_TICKER = 2;
|
|
|
|
const PROGMEM int SCREEN_TIME = 3;
|
|
|
|
const PROGMEM int SCREEN_HALVING_COUNTDOWN = 4;
|
2023-11-10 19:52:06 +01:00
|
|
|
const PROGMEM int SCREEN_MARKET_CAP = 5;
|
2024-03-10 20:24:55 +01:00
|
|
|
const PROGMEM int SCREEN_BLOCK_FEE_RATE = 6;
|
2023-11-10 19:52:06 +01:00
|
|
|
|
2023-11-07 21:26:15 +01:00
|
|
|
const PROGMEM int SCREEN_COUNTDOWN = 98;
|
|
|
|
const PROGMEM int SCREEN_CUSTOM = 99;
|
2024-03-10 20:24:55 +01:00
|
|
|
const int SCREEN_COUNT = 7;
|
2023-11-30 22:38:01 +01:00
|
|
|
const PROGMEM int screens[SCREEN_COUNT] = {
|
|
|
|
SCREEN_BLOCK_HEIGHT, SCREEN_MSCW_TIME, SCREEN_BTC_TICKER,
|
2024-03-10 20:24:55 +01:00
|
|
|
SCREEN_TIME, SCREEN_HALVING_COUNTDOWN, SCREEN_MARKET_CAP,
|
|
|
|
SCREEN_BLOCK_FEE_RATE};
|
2023-11-13 12:27:34 +01:00
|
|
|
const int usPerSecond = 1000000;
|
|
|
|
const int usPerMinute = 60 * usPerSecond;
|
2023-11-07 21:26:15 +01:00
|
|
|
|
2024-03-10 20:24:55 +01:00
|
|
|
struct SpiRamAllocator : ArduinoJson::Allocator {
|
|
|
|
void* allocate(size_t size) override {
|
2023-11-07 21:26:15 +01:00
|
|
|
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM);
|
|
|
|
}
|
|
|
|
|
2024-03-10 20:24:55 +01:00
|
|
|
void deallocate(void* pointer) override {
|
|
|
|
heap_caps_free(pointer);
|
|
|
|
}
|
2023-11-07 21:26:15 +01:00
|
|
|
|
2024-03-10 20:24:55 +01:00
|
|
|
void* reallocate(void* ptr, size_t new_size) override {
|
2023-11-07 21:26:15 +01:00
|
|
|
return heap_caps_realloc(ptr, new_size, MALLOC_CAP_SPIRAM);
|
|
|
|
}
|
2024-03-10 20:24:55 +01:00
|
|
|
};
|