A PlatformIO/Arduino project for ESP32 for Lua Game Engine lge, TFT display rendering (TFT_eSPI), and resistive touch input (XPT2046). Lua scripting is integrated for game logic. Core source is in /src/ and /include/.
ESP32-LuaGameConsole-Demo-GH.mp4
- TFT display via TFT_eSPI
- Resistive touch via XPT2046_Touchscreen
- Lua scripting for game logic (see
src/lua_driver.cpp/src/lua_driver.hpp) - Single binary: Arduino-style
setup()andloop() - Pin and hardware config via
platformio.inibuild flags
/src/ # Main application code (entry: main.cpp, Lua bridge, game logic)
/include/ # Project headers
/platformio.ini # Build configuration, pin macros, dependencies
/lua/ # Example Lua scripts and applications
/lua/api/ # Lua API documentation
/data/runtime.luac # Example of compiled runtime
- Install PlatformIO (VSCode recommended)
- Clone this repo
- Configure pins in
platformio.ini(build_flagssection). Current configuration based on CYD - Load Games:
To load a 10 examples to the device, use:
This will create an
lua/luaToConst.sh -m header lua/bouncingBalls.lua lua/touchSequence.lua lua/sideShooter.lua lua/rotatingBox.lua lua/bouncingRotatingCubes.lua lua/flappyBird.lua lua/3dApiDemo.lua lua/3dApiDemoBounce.lua lua/orbit.lua lua/gemfall.lua
hfile with the entire code for all 10 examples, once compiled the games will be available. - Build:
platformio run
- Upload:
platformio run -t upload
- Monitor serial output:
platformio device monitor --port COMx --baud 115200
- ESP32 (tested with
esp32devboard, based on CYD) - TFT and touch share SPI bus; touch uses a separate
SPIClassinstance - Pin assignments: Set in
platformio.ini(do not hardcode in source) - Touch calibration: Adjust
TS_MIN_X_CONST,TS_MAX_X_CONST,TS_MIN_Y_CONST,TS_MAX_Y_CONSTinsrc/luaDriver.cppif needed
- Display/touch/game loop: Edit
src/main.cpp - Lua integration: See
src/luaDriver.cppandsrc/luaDriver.hpp - Pin changes: Edit
platformio.iniand rebuild - Example Lua scripts: See the lua/ directory
- Lua API documentation: See the lua/api/ directory
- Touch not working? Check pin macros and calibration constants
- Display issues? Confirm SPI wiring and
platformio.inisettings
See LICENSE.