crosspoint-reader/src/screens/SettingsScreen.h

52 lines
1.6 KiB
C
Raw Normal View History

#pragma once
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>
#include <freertos/task.h>
2025-12-15 23:17:23 +11:00
#include <cstdint>
2025-12-15 20:56:09 -05:00
#include <functional>
#include <string>
#include <vector>
#include "Screen.h"
class CrossPointSettings;
2025-12-15 20:56:09 -05:00
// Enum to distinguish setting types
enum class SettingType { TOGGLE, ACTION };
// Structure to hold setting information
struct SettingInfo {
2025-12-15 20:56:09 -05:00
const char* name; // Display name of the setting
SettingType type; // Type of setting
uint8_t CrossPointSettings::* valuePtr; // Pointer to member in CrossPointSettings (for TOGGLE)
};
class SettingsScreen final : public Screen {
TaskHandle_t displayTaskHandle = nullptr;
SemaphoreHandle_t renderingMutex = nullptr;
bool updateRequired = false;
int selectedSettingIndex = 0; // Currently selected setting
const std::function<void()> onGoHome;
2025-12-15 20:56:09 -05:00
const std::function<void()> onGoWifi;
// Static settings list
2025-12-15 20:56:09 -05:00
static constexpr int settingsCount = 3; // Number of settings
static const SettingInfo settingsList[settingsCount];
static void taskTrampoline(void* param);
[[noreturn]] void displayTaskLoop();
void render() const;
void toggleCurrentSetting();
2025-12-15 20:56:09 -05:00
void activateCurrentSetting();
public:
2025-12-15 20:56:09 -05:00
explicit SettingsScreen(GfxRenderer& renderer, InputManager& inputManager,
const std::function<void()>& onGoHome,
const std::function<void()>& onGoWifi)
: Screen(renderer, inputManager), onGoHome(onGoHome), onGoWifi(onGoWifi) {}
void onEnter() override;
void onExit() override;
void handleInput() override;
};