RustBox
RustBox - The Rust Gaming Box
Author: Frimu Aurel-Viorel
GitHub Project Link: https://github.com/AurasV/RustBox-The-Rust-Gaming-Box
Description
Using the power of two screens, two joysticks and a few buttons, RustBox is a (mini) gaming console that can run several Singleplayer and Multiplayer (1v1) games:
Singleplayer games:
- Brick Breaker
- Snake
Multiplayer games:
- Tic Tac Toe
- Snake battle
- Pong
Motivation
I have always wanted to create some portable gaming devices since I've first seen them on YouTube and other websites. Wanting to one up my roommate that made something similar - Rogue Rust
Architecture
The STM32 Board is the whole gaming station and it connects to the rest of the components like so:
- To the 1602 LCD Display using I2C;
- To the Two Axis HW-504 Joysticks using ADC for the X and Y movements and using GPIO for the push button they each have;
- To the built in button using GPIO
- To the (Fake) Arduino using Serial
Log
Week 1
Got the rough outline of the components and planned what games I want to implement, ordered the components and started researching.
Week 2
Got the components and started doing the wiring and some tests, couldn't figure out how to get the STM32 to play nicely with the TFT screen. Started going insane trying different things / libraries to make it work.
Week 3
Tested TFT screen with an Arduino that I had from a previous purchase, it worked so switched to using the Arduino as a GPU and communicating between STM32 and Arduino via Serial. Finished the wiring and started work on the code, successfully making Tic Tac Toe work with the controllers and the screens.
Week 4
Made a main menu, struggled to find a decent enough speed that the Arduino could keep up with (text wouldn't appear / wouldn't be formatted if speed was too high, games would be too slow if the speed was too low)
Hardware
The hardware used is:
NUCLEO-U545RE-Q - STM32 Board - 1x
(Fake) Arduino from Plusivo - ATMEGA328 microcontroller - 1x
TFT IPS Display - GMT130-V1.0 with Driver IC - ST7789 using SPI - 1x
LCD 1602 Text Display - using I2C - 1x
HW-504 Joystick - 2x \
Schematics
KiCAD schematic:
Bill of Materials
| Device | Usage | Price |
|---|---|---|
| NUCLEO-U545RE-Q - STM32 Board | The Microcontroller | Loaned from Class - 0 RON |
| (Fake) Arduino from Plusivo - ATMEGA328 microcontroller | To control the TFT display | Got as Part of a Kit, Standalone Price - 47.47 |
| Ecran LCD - 1602 IIC/I2C | To Display Simple Text | 21.04 RON |
| TFT Color Display - GMT130-V1.0 ST7789 | Showing the Actual Game | 40.99 RON |
| Two Axis Joystick - HW-504 | Used for Playing the Games | 5.35 RON x 2 |
| Push Button - for Breadboard | Reset Button | 1 RON |
| Breadboard HQ - 830 Points | Connecting Everything | Got as Part of a Kit, Standalone Price - 9.98 RON |
| Female to Male Wires - 20 cm | Wires | 7.99 RON |
| Male to Male Wires - Various Sizes | Wires | Got as part of a Kit, standalone price - 7.99 RON |
| Total | If Hardware Obtained From Kits Are Accounted | 147.16 RON |
Software
| Library | Description | Usage |
|---|---|---|
| embassy-stm32 | Hardware Abstraction Layer for STM32 microcontrollers | Used for GPIO, ADC, I2C, UART, and peripheral configuration on the STM32U545 |
| embassy-executor | Async/await executor for embedded systems | Used to run the async main function and manage tasks |
| embassy-time | Timekeeping, delays and timeouts | Used for Timer::after_millis() delays throughout the game logic |
| embedded-hal-async | Async traits for embedded HAL | Used for I2C trait bounds in LCD helper functions |
| embedded-io-async | Async traits for embedded I/O | Used for UART Write trait bounds in TFT display functions |
| heapless | Static-friendly data structures that don't require dynamic memory | Used for String used in UART |
| defmt | Efficient, deferred formatting for logging on embedded systems | Used for debug logging with info!() macro |
| defmt-rtt | RTT transport for defmt | Used to transport defmt logs over RTT to the debugger |
| cortex-m | Low-level access to Cortex-M processors | Required for Cortex-M CPU features and critical sections |
| cortex-m-rt | Minimal runtime for Cortex-M microcontrollers | Provides the startup code and interrupt vector table |
| panic-probe | Panic handler for probe-run | Handles panics by printing via defmt and halting execution |