2025-12-04 00:07:25 +11:00
|
|
|
#pragma once
|
|
|
|
|
#include <freertos/FreeRTOS.h>
|
2025-12-06 03:02:52 +11:00
|
|
|
#include <freertos/semphr.h>
|
2025-12-06 04:20:03 +11:00
|
|
|
#include <freertos/task.h>
|
2025-12-04 00:07:25 +11:00
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2025-12-17 23:32:18 +11:00
|
|
|
#include "../Activity.h"
|
2025-12-04 00:07:25 +11:00
|
|
|
|
2025-12-17 23:32:18 +11:00
|
|
|
class FileSelectionActivity final : public Activity {
|
2025-12-04 00:07:25 +11:00
|
|
|
TaskHandle_t displayTaskHandle = nullptr;
|
2025-12-06 03:02:52 +11:00
|
|
|
SemaphoreHandle_t renderingMutex = nullptr;
|
2025-12-05 22:12:28 +11:00
|
|
|
std::string basepath = "/";
|
2025-12-04 00:07:25 +11:00
|
|
|
std::vector<std::string> files;
|
|
|
|
|
int selectorIndex = 0;
|
|
|
|
|
bool updateRequired = false;
|
|
|
|
|
const std::function<void(const std::string&)> onSelect;
|
2025-12-17 20:47:43 +11:00
|
|
|
const std::function<void()> onGoHome;
|
2025-12-04 00:07:25 +11:00
|
|
|
|
|
|
|
|
static void taskTrampoline(void* param);
|
|
|
|
|
[[noreturn]] void displayTaskLoop();
|
|
|
|
|
void render() const;
|
2025-12-05 22:12:28 +11:00
|
|
|
void loadFiles();
|
2025-12-04 00:07:25 +11:00
|
|
|
|
2025-12-06 00:34:16 +11:00
|
|
|
public:
|
2025-12-17 23:32:18 +11:00
|
|
|
explicit FileSelectionActivity(GfxRenderer& renderer, InputManager& inputManager,
|
|
|
|
|
const std::function<void(const std::string&)>& onSelect,
|
|
|
|
|
const std::function<void()>& onGoHome)
|
|
|
|
|
: Activity(renderer, inputManager), onSelect(onSelect), onGoHome(onGoHome) {}
|
2025-12-04 00:07:25 +11:00
|
|
|
void onEnter() override;
|
|
|
|
|
void onExit() override;
|
2025-12-17 23:32:18 +11:00
|
|
|
void loop() override;
|
2025-12-04 00:07:25 +11:00
|
|
|
};
|