Initial commit: Base Project for Kode Dot (ESP32-S3)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+11975
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+19705
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,85 @@
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
|
||||
#define LV_USE_DEV_VERSION 1
|
||||
|
||||
/* Color settings */
|
||||
#define LV_COLOR_DEPTH 16
|
||||
#define LV_COLOR_16_SWAP 0
|
||||
|
||||
/* Memory settings */
|
||||
#define LV_MEM_CUSTOM 0
|
||||
#define LV_MEM_SIZE (64U * 1024U)
|
||||
|
||||
/* HAL settings */
|
||||
#define LV_DISP_DEF_REFR_PERIOD 30
|
||||
#define LV_INDEV_DEF_READ_PERIOD 30
|
||||
|
||||
/* Feature usage */
|
||||
#define LV_USE_ANIMATION 1
|
||||
#define LV_USE_SHADOW 1
|
||||
#define LV_USE_BLEND_MODES 1
|
||||
#define LV_USE_OPA_SCALE 1
|
||||
#define LV_USE_IMG_TRANSFORM 1
|
||||
|
||||
/* Widget usage */
|
||||
#define LV_USE_ARC 1
|
||||
#define LV_USE_ANIMIMG 1
|
||||
#define LV_USE_BAR 1
|
||||
#define LV_USE_BTN 1
|
||||
#define LV_USE_BTNMATRIX 1
|
||||
#define LV_USE_CANVAS 1
|
||||
#define LV_USE_CHECKBOX 1
|
||||
#define LV_USE_DROPDOWN 1
|
||||
#define LV_USE_IMG 1
|
||||
#define LV_USE_LABEL 1
|
||||
#define LV_USE_LINE 1
|
||||
#define LV_USE_LIST 1
|
||||
#define LV_USE_METER 1
|
||||
#define LV_USE_MSGBOX 1
|
||||
#define LV_USE_ROLLER 1
|
||||
#define LV_USE_SLIDER 1
|
||||
#define LV_USE_SPAN 1
|
||||
#define LV_USE_SPINBOX 1
|
||||
#define LV_USE_SPINNER 1
|
||||
#define LV_USE_SWITCH 1
|
||||
#define LV_USE_TEXTAREA 1
|
||||
#define LV_USE_TABLE 1
|
||||
#define LV_USE_TABVIEW 1
|
||||
#define LV_USE_TILEVIEW 1
|
||||
#define LV_USE_WIN 1
|
||||
|
||||
/* Themes */
|
||||
#define LV_USE_THEME_DEFAULT 1
|
||||
#define LV_USE_THEME_BASIC 1
|
||||
|
||||
/* Font usage */
|
||||
#define LV_FONT_MONTSERRAT_14 1
|
||||
#define LV_FONT_MONTSERRAT_18 1
|
||||
#define LV_FONT_MONTSERRAT_22 1
|
||||
#define LV_FONT_MONTSERRAT_26 1
|
||||
#define LV_FONT_MONTSERRAT_30 1
|
||||
#define LV_FONT_MONTSERRAT_34 1
|
||||
#define LV_FONT_MONTSERRAT_38 1
|
||||
#define LV_FONT_MONTSERRAT_42 1
|
||||
#define LV_FONT_MONTSERRAT_46 1
|
||||
#define LV_FONT_MONTSERRAT_48 1
|
||||
|
||||
/* Others */
|
||||
#define LV_USE_PERF_MONITOR 0
|
||||
#define LV_USE_MEM_MONITOR 0
|
||||
#define LV_USE_REFR_DEBUG 0
|
||||
|
||||
/* Compiler settings */
|
||||
#define LV_ATTRIBUTE_TICK_INC
|
||||
#define LV_ATTRIBUTE_TIMER_HANDLER
|
||||
#define LV_ATTRIBUTE_FLUSH_READY
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||
#define LV_ATTRIBUTE_LARGE_CONST
|
||||
#define LV_ATTRIBUTE_LARGE_RAM_ARRAY
|
||||
|
||||
/* HAL settings */
|
||||
#define LV_TICK_CUSTOM 0
|
||||
#define LV_DPI_DEF 130
|
||||
|
||||
#endif /*LV_CONF_H*/
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
#include <Arduino.h>
|
||||
#include <lvgl.h>
|
||||
#include <kodedot/display_manager.h>
|
||||
#include <TCA9555.h>
|
||||
#include <kodedot/pin_config.h>
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
// Display manager instance
|
||||
DisplayManager display;
|
||||
|
||||
// UI labels
|
||||
static lv_obj_t *touch_label;
|
||||
static lv_obj_t *button_label;
|
||||
|
||||
// IO Expander
|
||||
static TCA9555 ioexp(IOEXP_I2C_ADDR);
|
||||
|
||||
// NeoPixel
|
||||
static Adafruit_NeoPixel pixel(NEO_PIXEL_COUNT, NEO_PIXEL_PIN, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
// Forward declarations
|
||||
void createUserInterface();
|
||||
void createFontExamples(lv_obj_t *parent);
|
||||
void updateTouchDisplay();
|
||||
void updateButtonDisplay();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("Starting Base Project with LVGL...");
|
||||
|
||||
// Initialize display subsystem
|
||||
if (!display.init()) {
|
||||
Serial.println("Error: Failed to initialize display");
|
||||
while(1) {
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
// Create the UI
|
||||
createUserInterface();
|
||||
|
||||
// Initialize IO Expander (inputs)
|
||||
if (!ioexp.begin(INPUT)) {
|
||||
Serial.println("Warning: IO Expander not connected");
|
||||
}
|
||||
|
||||
// Configure TOP button (GPIO with external pull-up)
|
||||
pinMode(BUTTON_TOP, INPUT);
|
||||
|
||||
// Initialize NeoPixel
|
||||
pixel.begin();
|
||||
pixel.setBrightness(64);
|
||||
pixel.clear();
|
||||
pixel.show();
|
||||
|
||||
Serial.println("System ready!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Pump display subsystem
|
||||
display.update();
|
||||
|
||||
// Update touch coordinates on the UI
|
||||
updateTouchDisplay();
|
||||
updateButtonDisplay();
|
||||
|
||||
delay(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create the main user interface
|
||||
*/
|
||||
void createUserInterface() {
|
||||
lv_obj_t * scr = lv_scr_act();
|
||||
lv_obj_set_style_bg_color(scr, lv_color_hex(0x111111), 0);
|
||||
|
||||
// Title
|
||||
lv_obj_t * title = lv_label_create(scr);
|
||||
lv_obj_set_style_text_font(title, &lv_font_montserrat_30, 0);
|
||||
lv_label_set_text(title, "Base Project");
|
||||
lv_obj_set_style_text_color(title, lv_color_hex(0xFFFFFF), 0);
|
||||
lv_obj_align(title, LV_ALIGN_TOP_MID, 0, 30);
|
||||
|
||||
// Label for touch coordinates
|
||||
touch_label = lv_label_create(scr);
|
||||
lv_obj_set_style_text_font(touch_label, &lv_font_montserrat_22, 0);
|
||||
lv_label_set_text(touch_label, "Touch: (-, -)");
|
||||
lv_obj_set_style_text_color(touch_label, lv_color_hex(0x00FF00), 0);
|
||||
lv_obj_align(touch_label, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
// Label for buttons state (expander)
|
||||
button_label = lv_label_create(scr);
|
||||
lv_obj_set_style_text_font(button_label, &lv_font_montserrat_18, 0);
|
||||
lv_label_set_text(button_label, "Button: none");
|
||||
lv_obj_set_style_text_color(button_label, lv_color_hex(0x66CCFF), 0);
|
||||
lv_obj_align(button_label, LV_ALIGN_BOTTOM_MID, 0, -10);
|
||||
|
||||
// Ejemplos de diferentes fuentes
|
||||
createFontExamples(scr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create sample labels using different font sizes
|
||||
*/
|
||||
void createFontExamples(lv_obj_t *parent) {
|
||||
// Small font
|
||||
lv_obj_t * font_small = lv_label_create(parent);
|
||||
lv_obj_set_style_text_font(font_small, &lv_font_montserrat_14, 0);
|
||||
lv_label_set_text(font_small, "Montserrat 14px");
|
||||
lv_obj_set_style_text_color(font_small, lv_color_hex(0xCCCCCC), 0);
|
||||
lv_obj_align(font_small, LV_ALIGN_BOTTOM_LEFT, 20, -80);
|
||||
|
||||
// Medium font
|
||||
lv_obj_t * font_medium = lv_label_create(parent);
|
||||
lv_obj_set_style_text_font(font_medium, &lv_font_montserrat_18, 0);
|
||||
lv_label_set_text(font_medium, "Montserrat 18px");
|
||||
lv_obj_set_style_text_color(font_medium, lv_color_hex(0xCCCCCC), 0);
|
||||
lv_obj_align(font_medium, LV_ALIGN_BOTTOM_LEFT, 20, -50);
|
||||
|
||||
// Large font
|
||||
lv_obj_t * font_large = lv_label_create(parent);
|
||||
lv_obj_set_style_text_font(font_large, &lv_font_montserrat_42, 0);
|
||||
lv_label_set_text(font_large, "42");
|
||||
lv_obj_set_style_text_color(font_large, lv_color_hex(0x999999), 0);
|
||||
lv_obj_align(font_large, LV_ALIGN_BOTTOM_RIGHT, -30, -30);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update the touch coordinates label
|
||||
*/
|
||||
void updateTouchDisplay() {
|
||||
if (!touch_label) return;
|
||||
|
||||
int16_t x, y;
|
||||
if (display.getTouchCoordinates(x, y)) {
|
||||
lv_label_set_text_fmt(touch_label, "Touch: (%d, %d)", x, y);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool isPressed(uint8_t pinIndex) {
|
||||
// Entradas con pull-up externa: activo en LOW
|
||||
int v = ioexp.read1(pinIndex);
|
||||
return (v != TCA9555_INVALID_READ) && (v == LOW);
|
||||
}
|
||||
|
||||
static inline bool isGpioPressed(int gpio) {
|
||||
return digitalRead(gpio) == LOW; // activo en LOW por pull-up externa
|
||||
}
|
||||
|
||||
void updateButtonDisplay() {
|
||||
if (!button_label) return;
|
||||
|
||||
const char* status = "none";
|
||||
|
||||
if (isGpioPressed(BUTTON_TOP)) {
|
||||
status = "BUTTON_TOP";
|
||||
} else if (isPressed(EXPANDER_BUTTON_BOTTOM)) {
|
||||
status = "BUTTON_BOTTOM";
|
||||
} else if (isPressed(EXPANDER_PAD_TOP)) {
|
||||
status = "PAD_TOP";
|
||||
} else if (isPressed(EXPANDER_PAD_BOTTOM)) {
|
||||
status = "PAD_BOTTOM";
|
||||
} else if (isPressed(EXPANDER_PAD_LEFT)) {
|
||||
status = "PAD_LEFT";
|
||||
} else if (isPressed(EXPANDER_PAD_RIGHT)) {
|
||||
status = "PAD_RIGHT";
|
||||
}
|
||||
|
||||
lv_label_set_text_fmt(button_label, "Button: %s", status);
|
||||
|
||||
// Actualizar NeoPixel según botón
|
||||
uint32_t color = pixel.Color(0, 0, 0);
|
||||
if (status == (const char*)"BUTTON_TOP") {
|
||||
color = pixel.Color(255, 0, 0); // rojo
|
||||
} else if (status == (const char*)"BOTON_INFERIOR") {
|
||||
color = pixel.Color(0, 0, 255); // azul
|
||||
} else if (status == (const char*)"PAD_TOP") {
|
||||
color = pixel.Color(255, 255, 0); // amarillo
|
||||
} else if (status == (const char*)"PAD_BOTTOM") {
|
||||
color = pixel.Color(255, 0, 255); // magenta
|
||||
} else if (status == (const char*)"PAD_LEFT") {
|
||||
color = pixel.Color(0, 255, 0); // verde
|
||||
} else if (status == (const char*)"PAD_RIGHT") {
|
||||
color = pixel.Color(0, 255, 255); // cian
|
||||
}
|
||||
pixel.setPixelColor(0, color);
|
||||
pixel.show();
|
||||
}
|
||||
Reference in New Issue
Block a user