btclock_v3/src/lib/shared.hpp

40 lines
1.1 KiB
C++
Raw Normal View History

2023-11-07 00:11:12 +00:00
#pragma once
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
2023-11-07 00:11:12 +00:00
#include <Adafruit_MCP23X17.h>
2023-11-07 20:26:15 +00:00
#include <ArduinoJson.h>
2023-11-07 00:11:12 +00:00
#include <Preferences.h>
2023-11-08 11:18:59 +00:00
#include "utils.hpp"
2023-11-07 00:11:12 +00:00
extern Adafruit_MCP23X17 mcp;
extern Preferences preferences;
2023-11-07 20:26:15 +00: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;
const PROGMEM int SCREEN_MARKET_CAP = 5;
2023-11-07 20:26:15 +00:00
const PROGMEM int SCREEN_COUNTDOWN = 98;
const PROGMEM int SCREEN_CUSTOM = 99;
const int SCREEN_COUNT = 6;
const PROGMEM int screens[SCREEN_COUNT] = { SCREEN_BLOCK_HEIGHT, SCREEN_MSCW_TIME, SCREEN_BTC_TICKER, SCREEN_TIME, SCREEN_HALVING_COUNTDOWN, SCREEN_MARKET_CAP };
2023-11-07 20:26:15 +00:00
struct SpiRamAllocator {
void* allocate(size_t size) {
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM);
}
void deallocate(void* pointer) {
heap_caps_free(pointer);
}
void* reallocate(void* ptr, size_t new_size) {
return heap_caps_realloc(ptr, new_size, MALLOC_CAP_SPIRAM);
}
};
using SpiRamJsonDocument = BasicJsonDocument<SpiRamAllocator>;