Skip to content

reneodlt/lvgl_mac_and_arduino_dual

Repository files navigation

LVGL + M5Stack Core2 Dual Environment (macOS Simulator + Hardware)

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!

🚀 Quick Start

# 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 upload

🧩 Requirements

macOS

brew install sdl2
pip install platformio

ESP32

  • M5Stack Core2
  • USB-C cable

📝 Development Workflow

  1. Edit src/ui.cpp - All your UI code goes here
  2. Test on macOS - See changes instantly in SDL2 window
  3. Deploy to M5Stack Core2 - Same code, no changes needed

🎯 Key Features

  • Single codebase for both platforms
  • Platform-agnostic UI code in src/ui.cpp
  • Automatic screen dimensions via SCREEN_WIDTH and SCREEN_HEIGHT
  • Touch/mouse input works transparently on both
  • Rapid iteration on macOS, deploy to hardware when ready

📚 Documentation

See UI_GUIDE.md for detailed examples and best practices.

⚙️ Build Commands

Simulate on Mac:

pio run -e pc_sim
./.pio/build/pc_sim/program

Flash to M5Stack Core2:

pio run -e m5stack-core2 --target upload

Monitor serial output (M5Stack Core2):

pio device monitor -e m5stack-core2

🏗️ Project Structure

src/
├── main.cpp    # Platform-specific initialization (don't modify)
├── ui.h        # UI header
└── ui.cpp      # Your UI code (edit this!)

💡 Example

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!

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published