Propagate the lessons from tron-room-demo's hardware bring-up back into the canonical template, so demos are hardware-testable from day one: - Contract change: the sketch renders into emuGfx::fb565 (320x240 uint16_t, RGB565 in PANEL WIRE ORDER - big-endian, the byte sequence the ST7789 receives over SPI, the same convention TFT_eSprite's primitives use). The host expands 565 to 8888 for SDL only. Native little-endian writes look right in the emulator but show byte-swapped on the panel (seen on hardware: BG 0x0002 -> green, fogged floor 0x0882 -> pink) - the new contract makes that bug impossible. - Recommended sketch structure: examples/APP/Core.h holds all rendering/logic device-agnostically (demoInit/demoInput/demoFrame); the .cpp is a thin emulator shell. Bundled sample demonstrates it. - New fw/ scaffold: standalone PlatformIO project (shared boards/lib, T-Deck pin map) with DemoHW.ino driving the same core through a TFT_eSprite frameBuffer() and reporting true fps + render/push split over USB serial every 2 s. -O2 explicitly (pio default -Os skews benchmarks). - shim.h gains rgb565()/wire565() helpers; Makefile deps now include the sketch's headers; --dump now also fires on safety-hatch exit (a long --frames run was silently losing its dump before). Verified: template builds + smoke renders correct 565 colors; DemoHW builds clean for ESP32-S3 (328 KB flash).
60 lines
2.0 KiB
Makefile
60 lines
2.0 KiB
Makefile
# Minimal Makefile for the T-Deck emulator-only template.
|
|
# Build & run: make run (from this directory)
|
|
# Smoke test: make smoke
|
|
#
|
|
# This Makefile is self-contained: all sources (shim, main, sketch)
|
|
# are relative to this Makefile's directory. Copy the whole folder
|
|
# for a new project — no path adjustments needed.
|
|
#
|
|
# The sketch lives in examples/$(APP)/$(APP).cpp and provides setup()/loop().
|
|
# Default is the bundled sample demo; replace it to make your own.
|
|
|
|
APP ?= Demo
|
|
APP_DIR := examples/$(APP)
|
|
|
|
# SDL3 flags via pkg-config
|
|
SDLFLAGS := $(shell pkg-config --cflags sdl3 sdl3-ttf)
|
|
LIBS := $(shell pkg-config --libs sdl3 sdl3-ttf)
|
|
|
|
CXX ?= g++
|
|
CXXFLAGS ?= -std=gnu++17 -O2 -Wall -Wextra
|
|
|
|
# Include current directory for shim.h, and the sketch directory
|
|
INC := -I . -I $(APP_DIR)
|
|
|
|
# Preprocessor definitions: app name, .ino filename, and the sketch source
|
|
# path. main.cpp does `#include APP_SRC`, so switching APP is enough.
|
|
DEFS += -DAPP_INO='"$(APP).ino"' -DAPP_NAME='"$(APP)"' \
|
|
-DAPP_SRC='"$(APP_DIR)/$(APP).cpp"'
|
|
|
|
# Source files — the sketch .cpp is included by main.cpp via #include,
|
|
# so they compile as a single translation unit.
|
|
SHIMS := $(wildcard *.h) # picks up shim.h at template root
|
|
|
|
# Main entry point for this template (standalone, no HW deps)
|
|
# main.cpp includes examples/$(APP)/$(APP).cpp forming one TU.
|
|
EMU_MAIN := src/main.cpp
|
|
|
|
EMU := $(APP)-emu
|
|
|
|
all: $(EMU)
|
|
|
|
# Compile + link: main.cpp includes the sketch .cpp, forming one TU.
|
|
# -DAPP_INO makes the sketch's .ino filename available to #ifdef EMULATOR.
|
|
# Depend on the sketch AND its headers too (e.g. the device-agnostic
|
|
# $(APP)Core.h), or core edits won't trigger a rebuild.
|
|
SKETCH := $(APP_DIR)/$(APP).cpp
|
|
$(EMU): $(EMU_MAIN) $(SHIMS) $(SKETCH) $(wildcard $(APP_DIR)/*.h)
|
|
$(CXX) $(CXXFLAGS) $(SDLFLAGS) $(INC) $(DEFS) \
|
|
$(EMU_MAIN) -o $@ $(LIBS)
|
|
|
|
run: $(EMU)
|
|
./$(EMU)
|
|
|
|
smoke: $(EMU)
|
|
./$(EMU) --frames 240 --dump smoke_frame.bmp
|
|
|
|
clean:
|
|
rm -f $(EMU)
|
|
|
|
.PHONY: all run smoke clean |