Add main application logic and touch handling functionality
- Implemented main application entry point in main.cpp, initializing queues and event groups. - Created TouchHandler and EInkTouchHandler classes for handling touch events. - Added a minimal event loop for touch processing in touch.cpp. - Introduced unit tests for the hello world application in pytest_hello_world.py. - Added configuration files for CI and Wokwi support. - Created empty header files for network and UI modules.
This commit is contained in:
62
main/display/display.cpp
Normal file
62
main/display/display.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#include "display.h"
|
||||
#include "common/constants.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
// TODO: implement actual display functionality
|
||||
|
||||
DisplayHandler::DisplayHandler(QueueHandle_t touch_queue, SemaphoreHandle_t lvgl_mutex) {
|
||||
(void)touch_queue;
|
||||
(void)lvgl_mutex;
|
||||
}
|
||||
|
||||
DisplayHandler::~DisplayHandler() { }
|
||||
|
||||
EInkDisplayHandler::EInkDisplayHandler(QueueHandle_t touch_queue, SemaphoreHandle_t lvgl_mutex)
|
||||
: DisplayHandler(touch_queue, lvgl_mutex) { }
|
||||
|
||||
EInkDisplayHandler::~EInkDisplayHandler() { }
|
||||
|
||||
void EInkDisplayHandler::init(EventGroupHandle_t system_event_group) {
|
||||
if (system_event_group != NULL) {
|
||||
xEventGroupSetBits(system_event_group, DISPLAY_READY_BIT);
|
||||
}
|
||||
}
|
||||
void EInkDisplayHandler::start_event_loop() {
|
||||
// Minimal background task to represent display processing
|
||||
xTaskCreate(
|
||||
// use the static adapter and pass `this` as the task parameter
|
||||
EInkDisplayHandler::task_adapter,
|
||||
"display_task",
|
||||
2048,
|
||||
this,
|
||||
tskIDLE_PRIORITY + 1,
|
||||
nullptr
|
||||
);
|
||||
}
|
||||
|
||||
// static
|
||||
void EInkDisplayHandler::task_adapter(void* arg) {
|
||||
EInkDisplayHandler* self = static_cast<EInkDisplayHandler*>(arg);
|
||||
if (self) {
|
||||
self->run_event_loop();
|
||||
} else {
|
||||
printf("EInkDisplayHandler::task_adapter received null pointer\n");
|
||||
}
|
||||
// If run_event_loop ever returns, delete the task.
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void EInkDisplayHandler::run_event_loop() {
|
||||
for (;;) {
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
}
|
||||
}
|
||||
|
||||
shutdown_display_handlerFunc EInkDisplayHandler::get_shutdown_display_handler() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
restart_display_handlerFunc EInkDisplayHandler::get_restart_display_handler() {
|
||||
return nullptr;
|
||||
}
|
||||
42
main/display/display.h
Normal file
42
main/display/display.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "info/info.h"
|
||||
|
||||
typedef void (*shutdown_display_handlerFunc)(void);
|
||||
typedef void (*restart_display_handlerFunc)(void);
|
||||
|
||||
class DisplayHandler {
|
||||
public:
|
||||
DisplayHandler(QueueHandle_t touch_queue, SemaphoreHandle_t lvgl_mutex);
|
||||
// the system_event_group is used to set display-ready bit
|
||||
virtual void init(EventGroupHandle_t system_event_group) = 0;
|
||||
virtual void start_event_loop() = 0;
|
||||
// get a handler to perform display shutdown cleanup, this is called after event loop ends and DisplayHandler is deleted
|
||||
virtual shutdown_display_handlerFunc get_shutdown_display_handler() = 0;
|
||||
virtual restart_display_handlerFunc get_restart_display_handler() = 0;
|
||||
virtual ~DisplayHandler() = 0;
|
||||
|
||||
private:
|
||||
DisplayHandler(const DisplayHandler&) = delete;
|
||||
DisplayHandler& operator=(const DisplayHandler&) = delete;
|
||||
};
|
||||
|
||||
class EInkDisplayHandler : public DisplayHandler {
|
||||
public:
|
||||
EInkDisplayHandler(QueueHandle_t touch_queue, SemaphoreHandle_t lvgl_mutex);
|
||||
void init(EventGroupHandle_t system_event_group) override;
|
||||
void start_event_loop() override;
|
||||
shutdown_display_handlerFunc get_shutdown_display_handler() override;
|
||||
restart_display_handlerFunc get_restart_display_handler() override;
|
||||
~EInkDisplayHandler() override;
|
||||
|
||||
private:
|
||||
// Task adapter used for FreeRTOS task creation. It forwards to the
|
||||
// instance `run_event_loop()` method using the `this` pointer passed
|
||||
// as the task parameter.
|
||||
static void task_adapter(void* arg);
|
||||
|
||||
// Instance method that implements the display task loop.
|
||||
void run_event_loop();
|
||||
// prevent copying
|
||||
EInkDisplayHandler(const EInkDisplayHandler&) = delete;
|
||||
EInkDisplayHandler& operator=(const EInkDisplayHandler&) = delete;
|
||||
};
|
||||
Reference in New Issue
Block a user