Skip to content

Rust Bare Metal implementation of Conway's Game of Life

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

georgik/esp32-conways-game-of-life-rs

Repository files navigation

ESP32 Conway's Game of Life in Rust

Implementation of Conway's Game of Life Rust Bare Metal.

Wokwi

ESP32 Conways Game of Life in Rust

Supported boards

ESP32-S3-BOX-3 Minimal Implementation

The implementation is based on Rust no_std, using mipidsi crate.

cd esp32-s3-box-3-minimal
cargo run --release

ESP32-C6-LCD-1.47 Waveshare

Rust Bare Metal no_std with Bevy ECS no_std on 1.47 inch ESP32-C6 LCD Waheshare with DMA and framebuffer - Conway's Game of Life:

2025-03-bevy-no_std.mp4

The implementation is based on Rust no_std and Bevy 0.15 no_std, plus mipidsi crate

cd esp32-c6-waveshare-1_47
cargo run --release

M5Stack Atom-S3

ESP32 Conways Game of Life in Rust - M5Stack Atom-S3 with Bevy ECS

Controls: Press button under display to reset the game state (GPIO 41).

The implementation is based on Rust no_std, using mipidsi crate and Bevy ECS. It requires es-rs toolchain for ESP32-S3 version at least 1.85, because of edition 2024.

Installation of the toolchain:

cargo install espup
espup install --toolchain-version 1.85.0.0
source ~/export-esp.sh

Build:

cd m5stack-atom-s3
cargo run --release

M5Stack CoreS3

ESP32 Conways Game of Life in Rust - M5Stack CoreS3 with Bevy ECS

Controls: Press the button under display to reset the game state.

Note: Press Boot button and reset to enter download mode.

The implementation is based on Rust no_std, using mipidsi crate and Bevy ECS.

Installation of the toolchain:

espup install --toolchain-version 1.85.0.0
source ~/export-esp.sh

Build:

cd m5stack-cores3
cargo run --release

ESP32-S3-BOX-3

ESP32 Conways Game of Life in Rust - ESP32-S3-BOX-3 with Bevy ECS

The implementation is based on Rust no_std, using mipidsi crate and Bevy ECS. It requires es-rs toolchain for ESP32-S3 version at least 1.85, because of edition 2024.

Installation of the toolchain:

cargo install espup
espup install --toolchain-version 1.85.0.0
source ~/export-esp.sh

Build:

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

ESP32-S3-LCD-Ev-Board

ESP32 Conways Game of Life in Rust - ESP32-S3-LCD-Ev-Board with Bevy ECS

ESP32-S3-LCD-Ev-Board is more complex when it comes to the display. Initialization sequence for the display is:

  • initialize I2C
  • tunnel SPI commands via I2C bus
  • configure 16 GPIOs to transfer data
  • all data must be transferred in one transaction (requires PSRAM)

The timing of the display must be precise, otherwise incorrect data will be displayed.

Working configuration of timing:

    // Configure the RGB display
    let config = Config::default()
        .with_clock_mode(ClockMode {
            polarity: Polarity::IdleLow,
            phase: Phase::ShiftLow,
        })
        .with_frequency(Rate::from_mhz(10))
        .with_format(Format {
            enable_2byte_mode: true,
            ..Default::default()
        })
        .with_timing(FrameTiming {
            // active region
            horizontal_active_width: 480,
            vertical_active_height: 480,
            // extend total timings for larger porch intervals
            horizontal_total_width: 600, // allow long back/front porch
            horizontal_blank_front_porch: 80,
            vertical_total_height: 600,  // allow longer vertical blank
            vertical_blank_front_porch: 80,
            // maintain sync widths
            hsync_width: 10,
            vsync_width: 4,
            // place HSYNC pulse well before active data
            hsync_position: 10,
        })
        .with_vsync_idle_level(Level::High)
        .with_hsync_idle_level(Level::High)
        .with_de_idle_level(Level::Low)
        .with_disable_black_region(false);

This is only bare metal implementation, does not contain Bevy ECS in this version.

cargo install espup
espup install --toolchain-version 1.85.0.0
source ~/export-esp.sh

Build:

cd esp32-s3-lcd-ev-board
cargo run --release

ESP32-C3-LCDKit

ESP32 Conways Game of Life in Rust - ESP32-C3-LCDkit with Bevy ECS

Controls: Press button rotary button to reset the game state (GPIO 9).

cd esp32-c3-lcdkit
cargo run --release

WASM

This is experimental implementation for WASM.

cd wasm
wasm-pack build --target web
wasm-bindgen --target web --out-dir pkg target/wasm32-unknown-unknown/release/conways_wasm.wasm
python3 -m http.server

ESP32-WROVER-KIT

This board is no longer in production, yet it's still used by many developers.

ESP32 Conways Game of Life in Rust - ESP-WROVER-KIT with Bevy ECS

The implementation is based on Rust no_std, using mipidsi crate and Bevy ECS. It requires es-rs toolchain for ESP32-S3 version at least 1.85, because of edition 2024.

Installation of the toolchain:

cargo install espup
espup install --toolchain-version 1.85.0.0
source ~/export-esp.sh

Build:

cd esp32-wrover-kit
cargo run --release