Giter VIP home page Giter VIP logo

esp32-rust-multi-target-template's Introduction

ESP32 Rust Multi Target Template

Template project for creating interactive apps with Rust Bare Metal (no_std) on ESP32. The template contains also WASM and Desktop version which could help with faster implementation of concepts. Each target HW is in separate directory. Shared code is stored in engine.

Version of espflash

Use espflash 2.x which supports also targets like ESP32-C6.

Installation:

cargo install espflash --git https://github.com/esp-rs/espflash.git

Generate new project

cargo generate https://github.com/georgik/esp32-rust-multi-target-template.git
cd project-name

Build and flash

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.

Build for ESP32-S3-BOX with ILI9486

Control: IMU

  • tilt the board to move the character
  • move quickly up to perform the first action
  • move quickly down to perform second action
cd esp32-s3-box
cargo espflash flash --release --monitor

Build for ESP32-C6-DevKitM-1 with ILI9341

Control: Not implemented

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

Build for ESP32-C3-DeviKit-RUST with ILI9341

Control: IMU

  • tilt board to move character
cd esp32-c3-devkit-rust
cargo espflash flash --release --monitor

Features

  • Embedded Graphics
  • Framebuffer
  • Random maze generator
  • IMU Accelerometer control

Build for dekstop

Control: keyboard

  • press arrows or W,A,S,D to move the character

  • press Enter to perform action

  • macOS prerequisites:

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

Build for ESP32-S3-USB-OTG with ST7789

Control: buttons

  • press button to move the character
  • press up & down to perform the first action
  • press ok & menu to perform the secomnd action
cd esp32-s3-usb-otg
cargo espflash flash --release --monitor

Build for ESP32-S2-USB-OTG with ST7789

Control: buttons

  • press button to move the character
  • press up & down to perform the first action
  • press ok & menu to perform the second action
cd esp32-s2-usb-otg
cargo espflash flash --release --monitor

Build for M5STACK-FIRE with ESP32 and ILI9341

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

Control: MPU-9250, buttons

  • tilt the board to move the character
  • move quickly up or press button C to perform the first action
  • move quickly down or press button B to perform the second action
cd m5stack-fire
cargo espflash flash --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

  • Navigate to GitHub repository
  • Click Open, select Codespaces tab, click Create Codespace
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

Control: MPU6886

cd m5stack-core2
cargo espflash flash --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 espflash flash --release --monitor

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

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: limited, only one button available

  • it's not possible to move the character
  • press button Boot to to perform the first action
cd esp-wrover-kit
cargo espflash flash --release --monitor

Build for ESP32-S2 with ILI9341

See tag v0.1.0.

cargo espflash flash --release --target xtensa-esp32s2-none-elf --features esp32s2_ili9341 --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.

esp32-rust-multi-target-template's People

Contributors

georgik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

filagyuri

esp32-rust-multi-target-template's Issues

m5stack_fire/m5stack_core2 tested and core-dumped

While trying the template, I connected my m5stack_fire / m5stack_core2 and tried it with real HW.
Unfortunately, both core dumped.

My devices have both gyros of mpu6886 soldered. While initialization with mpu6050 driver, the device type is checked and therefore an exception is thrown.

I modified the mpu6050 library to fit for mpu6886 [https://github.com/oldsheep68/mpu6886.git].
I uploaded it also to crates.io. [https://crates.io/crates/mpu6886]
After that, the little game started to work with m5stack_fire. I didn't try the core2 device.

I do not know, if there are m5stack_fire with different accel/gyro chips soldered out there. The documentation clearly states MPU9250, but on my device, there is the mpu6886 mentioned.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.