98 lines
2.1 KiB
C++
98 lines
2.1 KiB
C++
#pragma once
|
|
#include "program.h"
|
|
#include "shell.h"
|
|
#include "tft_handler.h"
|
|
#include <Arduino.h>
|
|
|
|
// Example Program 1: Simple counter
|
|
class CounterProgram : public Program {
|
|
private:
|
|
int counter = 0;
|
|
|
|
public:
|
|
void run() override {
|
|
Serial.println("Counter program started!");
|
|
|
|
WindowContentText text;
|
|
|
|
text.x = _window->x + 10;
|
|
text.y = _window->y + 50;
|
|
|
|
_window->window_content_text.push_back(text);
|
|
|
|
while (_running) {
|
|
counter++;
|
|
Serial.printf("Counter: %d\n", counter);
|
|
|
|
// You can modify the window title
|
|
if (_window) {
|
|
if (!_window->minimized) {
|
|
_window->title = "Counter: " + std::to_string(counter);
|
|
|
|
for (int i = 0; i < _window->window_content_text.size(); i++) {
|
|
_window->window_content_text[i].text = std::to_string(counter);
|
|
}
|
|
|
|
_display_state->update_display.store(true);
|
|
}
|
|
}
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
}
|
|
}
|
|
};
|
|
|
|
// Example Program 2: Text editor
|
|
class TextEditorProgram : public Program {
|
|
public:
|
|
void run() override {
|
|
Serial.println("Text editor started!");
|
|
|
|
// You have full access to the window and can draw to it
|
|
while (_running) {
|
|
// Handle text editing logic here
|
|
// Draw to the window content area using _tft
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(100));
|
|
}
|
|
}
|
|
};
|
|
|
|
// Example Program 3: Calculator
|
|
class CalculatorProgram : public Program {
|
|
public:
|
|
void run() override {
|
|
Serial.println("Calculator started!");
|
|
|
|
while (_running) {
|
|
// Calculator logic here
|
|
vTaskDelay(pdMS_TO_TICKS(100));
|
|
}
|
|
}
|
|
};
|
|
|
|
// Example Program 4: Game
|
|
class GameProgram : public Program {
|
|
public:
|
|
void run() override {
|
|
Serial.println("Game started!");
|
|
|
|
while (_running) {
|
|
// Game logic and rendering
|
|
vTaskDelay(pdMS_TO_TICKS(50)); // 20 FPS
|
|
}
|
|
}
|
|
};
|
|
|
|
// Example Program 5: Settings
|
|
class SettingsProgram : public Program {
|
|
public:
|
|
void run() override {
|
|
Serial.println("Settings started!");
|
|
|
|
while (_running) {
|
|
// Settings UI logic
|
|
vTaskDelay(pdMS_TO_TICKS(100));
|
|
}
|
|
}
|
|
}; |