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:
53
main/touch/touch.cpp
Normal file
53
main/touch/touch.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "touch.h"
|
||||
#include "common/constants.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
// TODO: implement actual touch functionality
|
||||
|
||||
TouchHandler::TouchHandler(QueueHandle_t touch_queue) {
|
||||
(void)touch_queue;
|
||||
}
|
||||
|
||||
TouchHandler::~TouchHandler() { }
|
||||
|
||||
EInkTouchHandler::EInkTouchHandler(QueueHandle_t touch_queue)
|
||||
: TouchHandler(touch_queue) { }
|
||||
|
||||
EInkTouchHandler::~EInkTouchHandler() { }
|
||||
|
||||
void EInkTouchHandler::init(EventGroupHandle_t system_event_group) {
|
||||
if (system_event_group != NULL) {
|
||||
xEventGroupSetBits(system_event_group, TOUCH_CALIBRATED_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
void EInkTouchHandler::start_event_loop() {
|
||||
// Minimal background task to represent touch processing
|
||||
xTaskCreate(
|
||||
// use static adapter and pass `this` as task parameter
|
||||
EInkTouchHandler::task_adapter,
|
||||
"touch_task",
|
||||
2048,
|
||||
this,
|
||||
tskIDLE_PRIORITY + 1,
|
||||
nullptr
|
||||
);
|
||||
}
|
||||
|
||||
// static
|
||||
void EInkTouchHandler::task_adapter(void* arg) {
|
||||
EInkTouchHandler* self = static_cast<EInkTouchHandler*>(arg);
|
||||
if (self) {
|
||||
self->run_event_loop();
|
||||
} else {
|
||||
printf("EInkTouchHandler::task_adapter received null pointer\n");
|
||||
}
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void EInkTouchHandler::run_event_loop() {
|
||||
for (;;) {
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
}
|
||||
}
|
||||
32
main/touch/touch.h
Normal file
32
main/touch/touch.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "info/info.h"
|
||||
|
||||
class TouchHandler {
|
||||
public:
|
||||
TouchHandler(QueueHandle_t touch_queue);
|
||||
// the system_event_group is used to set touch-calibrated bit
|
||||
virtual void init(EventGroupHandle_t system_event_group) = 0;
|
||||
virtual void start_event_loop() = 0;
|
||||
virtual ~TouchHandler() = 0;
|
||||
private:
|
||||
TouchHandler(const TouchHandler&) = delete;
|
||||
TouchHandler& operator=(const TouchHandler&) = delete;
|
||||
};
|
||||
|
||||
class EInkTouchHandler : public TouchHandler {
|
||||
public:
|
||||
EInkTouchHandler(QueueHandle_t touch_queue);
|
||||
void init(EventGroupHandle_t system_event_group) override;
|
||||
void start_event_loop() override;
|
||||
~EInkTouchHandler() override;
|
||||
|
||||
private:
|
||||
// Task adapter used for FreeRTOS task creation. Forwards to
|
||||
// `run_event_loop()` using the `this` pointer passed as the task param.
|
||||
static void task_adapter(void* arg);
|
||||
|
||||
// Instance method implementing the touch event loop.
|
||||
void run_event_loop();
|
||||
// prevent copying
|
||||
EInkTouchHandler(const EInkTouchHandler&) = delete;
|
||||
EInkTouchHandler& operator=(const EInkTouchHandler&) = delete;
|
||||
};
|
||||
Reference in New Issue
Block a user