Initial commit: Base Project for Kode Dot (ESP32-S3)
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Arduino_GFX_Library.h>
|
||||
#include <lvgl.h>
|
||||
#include <kodedot/pin_config.h>
|
||||
#include <bb_captouch.h>
|
||||
|
||||
/**
|
||||
* @brief High-level manager that initializes and wires up the display, LVGL, and touch input.
|
||||
*
|
||||
* Responsibilities:
|
||||
* - Bring up the panel using Arduino_GFX
|
||||
* - Allocate LVGL draw buffers (prefer PSRAM, fallback to SRAM)
|
||||
* - Register LVGL display and input drivers
|
||||
* - Provide simple helpers for brightness and touch reading
|
||||
*/
|
||||
class DisplayManager {
|
||||
private:
|
||||
// Hardware interfaces
|
||||
Arduino_DataBus *bus;
|
||||
Arduino_CO5300 *gfx;
|
||||
BBCapTouch bbct;
|
||||
|
||||
// LVGL draw buffer and driver handles
|
||||
lv_disp_draw_buf_t draw_buf;
|
||||
lv_color_t *buf;
|
||||
lv_color_t *buf2;
|
||||
lv_disp_drv_t disp_drv;
|
||||
|
||||
// Static callbacks required by LVGL
|
||||
static void disp_flush_callback(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);
|
||||
static void touchpad_read_callback(lv_indev_drv_t *indev_drv, lv_indev_data_t *data);
|
||||
|
||||
// Singleton-like back-reference used by static callbacks
|
||||
static DisplayManager* instance;
|
||||
|
||||
public:
|
||||
DisplayManager();
|
||||
~DisplayManager();
|
||||
|
||||
/**
|
||||
* @brief Fully initialize display, LVGL, and touch.
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool init();
|
||||
|
||||
/**
|
||||
* @brief Get the underlying Arduino_GFX panel instance.
|
||||
*/
|
||||
Arduino_CO5300* getGfx() { return gfx; }
|
||||
|
||||
/**
|
||||
* @brief Get the touch controller instance.
|
||||
*/
|
||||
BBCapTouch* getTouch() { return &bbct; }
|
||||
|
||||
/**
|
||||
* @brief Pump LVGL timers and tick. Call frequently in loop().
|
||||
*/
|
||||
void update();
|
||||
|
||||
/**
|
||||
* @brief Set backlight brightness.
|
||||
* @param brightness Range 0-255
|
||||
*/
|
||||
void setBrightness(uint8_t brightness);
|
||||
|
||||
/**
|
||||
* @brief Read current touch coordinates.
|
||||
* @param x Output X coordinate
|
||||
* @param y Output Y coordinate
|
||||
* @return true if there is an active touch
|
||||
*/
|
||||
bool getTouchCoordinates(int16_t &x, int16_t &y);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user