This project lets you build and preview LVGL interfaces on macOS (via SDL2) and flash the same code directly to an M5Stack Core2 device.
Write your UI code once in src/ui.cpp - it automatically works on both platforms!
# 1. Develop and test on macOS (fast iteration)
pio run -e pc_sim && ./.pio/build/pc_sim/program
# 2. Deploy to M5Stack Core2 when ready
pio run -e m5stack-core2 --target uploadbrew install sdl2
pip install platformio- M5Stack Core2
- USB-C cable
- Edit
src/ui.cpp- All your UI code goes here - Test on macOS - See changes instantly in SDL2 window
- Deploy to M5Stack Core2 - Same code, no changes needed
- ✅ Single codebase for both platforms
- ✅ Platform-agnostic UI code in
src/ui.cpp - ✅ Automatic screen dimensions via
SCREEN_WIDTHandSCREEN_HEIGHT - ✅ Touch/mouse input works transparently on both
- ✅ Rapid iteration on macOS, deploy to hardware when ready
See UI_GUIDE.md for detailed examples and best practices.
Simulate on Mac:
pio run -e pc_sim
./.pio/build/pc_sim/programFlash to M5Stack Core2:
pio run -e m5stack-core2 --target uploadMonitor serial output (M5Stack Core2):
pio device monitor -e m5stack-core2src/
├── main.cpp # Platform-specific initialization (don't modify)
├── ui.h # UI header
└── ui.cpp # Your UI code (edit this!)
Edit src/ui.cpp:
#include "ui.h"
void ui_init() {
lv_obj_t *label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "Hello from both platforms!");
lv_obj_center(label);
}Build and run - it works on both macOS and M5Stack Core2!