2023-11-07 01:11:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
2023-11-07 21:26:15 +01:00
|
|
|
#include <esp_timer.h>
|
2023-11-07 01:11:12 +01:00
|
|
|
#include <freertos/FreeRTOS.h>
|
|
|
|
#include <freertos/task.h>
|
|
|
|
|
2023-11-30 22:56:50 +01:00
|
|
|
#include <data_handler.hpp>
|
2024-07-29 20:49:46 +02:00
|
|
|
#include <bitaxe_handler.hpp>
|
2024-12-20 04:00:09 +01:00
|
|
|
#include "lib/mining_pool/mining_pool_stats_handler.hpp"
|
2023-11-30 22:56:50 +01:00
|
|
|
|
2023-11-07 01:11:12 +01:00
|
|
|
#include "lib/epd.hpp"
|
2023-11-30 22:38:01 +01:00
|
|
|
#include "lib/shared.hpp"
|
2023-11-07 01:11:12 +01:00
|
|
|
|
2024-12-26 23:08:46 +01:00
|
|
|
#define WORK_QUEUE_SIZE 10
|
|
|
|
|
2023-11-12 12:38:28 +01:00
|
|
|
extern TaskHandle_t workerTaskHandle;
|
2023-11-07 21:26:15 +01:00
|
|
|
extern TaskHandle_t taskScreenRotateTaskHandle;
|
2023-11-12 12:38:28 +01:00
|
|
|
extern QueueHandle_t workQueue;
|
2023-11-10 23:18:14 +01:00
|
|
|
|
2023-11-30 22:38:01 +01:00
|
|
|
typedef enum {
|
|
|
|
TASK_PRICE_UPDATE,
|
|
|
|
TASK_BLOCK_UPDATE,
|
2024-03-10 20:24:55 +01:00
|
|
|
TASK_FEE_UPDATE,
|
2024-07-29 20:49:46 +02:00
|
|
|
TASK_TIME_UPDATE,
|
2024-12-17 20:17:21 -06:00
|
|
|
TASK_BITAXE_UPDATE,
|
|
|
|
TASK_MINING_POOL_STATS_UPDATE
|
2023-11-12 12:38:28 +01:00
|
|
|
} TaskType;
|
|
|
|
|
2023-11-30 22:38:01 +01:00
|
|
|
typedef struct {
|
|
|
|
TaskType type;
|
|
|
|
char data;
|
2023-11-12 12:38:28 +01:00
|
|
|
} WorkItem;
|
|
|
|
|
2024-12-26 23:08:46 +01:00
|
|
|
class ScreenHandler {
|
|
|
|
private:
|
|
|
|
static uint currentScreen;
|
|
|
|
static uint currentCurrency;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static uint getCurrentScreen() { return currentScreen; }
|
|
|
|
static uint getCurrentCurrency() { return currentCurrency; }
|
|
|
|
static void setCurrentScreen(uint newScreen);
|
|
|
|
static void setCurrentCurrency(char currency);
|
|
|
|
static void nextScreen();
|
|
|
|
static void previousScreen();
|
|
|
|
static void showSystemStatusScreen();
|
|
|
|
static bool isCurrencySpecific(uint screen);
|
|
|
|
static bool handleCurrencyRotation(bool forward);
|
|
|
|
static int findNextVisibleScreen(int currentScreen, bool forward);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Keep as free functions since they deal with FreeRTOS tasks
|
2023-11-12 12:38:28 +01:00
|
|
|
void workerTask(void *pvParameters);
|
2023-11-07 21:26:15 +01:00
|
|
|
void taskScreenRotate(void *pvParameters);
|
|
|
|
void setupTasks();
|
2024-12-26 23:08:46 +01:00
|
|
|
void cleanup();
|