Home

Awesome

esp32-spooky-maze-game

Wokwi

Spooky Maze is simple game where ghost is located in the maze. The goal is to collect 100 coins. The ghost can find artifact "Walker" which allows him to pass throght the wall for limited period of time. The ghost can use dynamite to clear wall in the vicinity. The ghost can use also Teleport spell to move to random place in the maze. The Teleport spell requires some time to recharge. There are some not friendly spirits running around the maze, when collision occurs the ghost is teleported and loses five coins which are then send randomly back to the maze.

Spooky on ESP32-S2-Kaluga

Flashing binary from Releases

Binaries are available in GitHub Releases.

Binaries can be flashed by:

IDE support

CLion

Recommendation: Open only sub-directory with specific target with specific toolchain in CLion, because only one toolchain is supported for resolving code dependencies. Opening whole workspace works, just some code dependencies might not be resolved. This is also limitation of cargo, which supports only one toolchain per build.

Build and flash

Install espflash which is required to flash and monitor the app on Embedded Device:

cargo install espflash
cargo install cargo-espflash

Enter the directory with project and build it:

cd esp-wrover-kit
cargo build --release

Build binaries for all targets

The script builds all possible targets: support/ci/build-esp32-firmware.sh

Wokwi simulation in VS Code

Open subdirectory with target in VS Code with installed Wokwi Extension. Select Wokwi: Start Simulator.

Build WASM version

cd wasm
npm install
npm run serve

Open in web browser: https://localhost:8443.

Note: https is required for access to accelerometer data - https://w3c.github.io/deviceorientation/#security-and-privacy . It's possible to run the app without accelerometer on http.

Implemented technologies

Each directory contains implementation specific for the HW.

Overview:

NameChipDisplayControlsPMUGPIO Expander
esp-wrover-kitesp32ili93416 push-button controls, separate PINs
esp32-c3-devkit-rustesp32-c3st7789icm42670 accelerometer
esp32-c3-lcdkitesp32-c3gc9a01rotary encoder
esp32-c6-devkitesp32-c6ili9341resistor ladder with push buttons
esp32-s2-kalugaesp32-s2ili9341resistor ladder with push buttons
esp32-s3-boxesp32-s3ili9342cicm42670 accelerometer
esp32-s3-box-liteesp32-s3st7789no controls
esp32-s3-usb-otgesp32-s3st77895 push-buttons on the board
m5stack-core2esp32ili9341mpu6886 accelerometeraxp192
m5stack-cores32esp32-s3ili9342cbmi279 accelerometeraxp2101aw9523
m5stack-fireesp32ili9342cmpu9250 accelerometer

Build for ESP32-S3-BOX with ILI9486

Control: IMU

cd esp32-s3-box
cargo run --release --monitor

Build for ESP32-C3-DeviKit-RUST with ILI9341

Control: IMU

cd esp32-c3-devkit-rust
cargo run --release --monitor

Features

Build for desktop

Control: keyboard

brew install SDL2
export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib"
sudo zypper install SDL2-devel
cd desktop
cargo run

Build for ESP32-S3-USB-OTG with ST7789

Spooky on ESP32-S3-USB-OTG

Control: buttons

cd esp32-s3-usb-otg
cargo run --release --monitor

Build for M5Stack-FIRE with ESP32 and ILI9341

HW: https://docs.makerfactory.io/m5stack/core/fire/

Control: MPU-9250, buttons

cd m5stack-fire
cargo run --release --monitor

Build M5Stack-FIRE using GitPod.io and run with Wokwi

cd m5stack-fire
./run-wokwi.sh

Build M5Stack-FIRE using Codespaces and run with Wokwi

cd m5stack-fire
./run-wokwi.sh

Build M5Stack-FIRE and run Wokwi in local VS Code

Preview: install VS Code Wokwi plugin (private beta available on request)

cd m5stack-fire
cargo build --release --no-default-features --features "wokwi"

Press F1, select Wokwi: Start simulation

Build for M5Stack-Core2 with ESP32 and ILI9342C

HW: https://shop.m5stack.com/products/m5stack-core2-esp32-iot-development-kit?variant=35960244109476

Control: MPU6886

cd m5stack-core2
cargo run --release --monitor

Build for ESP32-S2-Kaluga v1.3

HW: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-wrover-kit.html

Control: buttons (partialy implemented based on of https://github.com/espressif/esp-bsp/blob/master/esp32_s2_kaluga_kit/esp32_s2_kaluga_kit.c#L59)

cd esp32-s2-kaluga
cargo run --release --monitor

Note for older version 1.2 - GPIO6 is used to control backlight.

Build for ESP32-C6-DevKitM-1

HW: https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html

Important: Requires espflash 2.x - install with cargo install espflash --git https://github.com/esp-rs/espflash.git

Controls: not implemented

cd esp32-c6-devkit
cargo espflash flash --release --monitor

Build for ESP Wrover Kit

HW: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-wrover-kit.html

Control: 6 push buttons

cd esp-wrover-kit
cargo run --release --monitor

Development

Following steps are useful for IDE integration, so that IDE can recognize which is your current target and fature set.

Check target configurad in the file .cargo/config.toml. It should be one of following values:

target = "xtensa-esp32-none-elf"
target = "xtensa-esp32s2-none-elf"
target = "xtensa-esp32s3-none-elf"
target = "riscv32imac-unknown-none-elf"

If no value is selected, make sure to specify target on command line.

Check default features in Cargo.toml. Make sure that default set contains your board and display combinations.

If no value is selected, make sure to specify features on command line.