Beyond 2048
A project about mixing classic 2D games in a single one on Raspberry Pico, having 2048 in the main stage.
Author: Nenciu George-Robert
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-robertnen
Description
The objective of the project is to show the knowledge gained throughout the semester by making functional hardware that runs games written in Rust. Starting with a 2048 games, it can be very fast changed to Tetris, creating more fun for the player.
Motivation
For many years I loved playing games, even it is not in a computer. While trying to prove what I learn this semester about Rust and hardware, I wanted to show that anyone can create a game on anything that has electricity.
Arhitecture
Log
Week 28 April - 4 May
Forked the project and started the documentation. Added the bill of materials and the software most likely used.
Week 5 May - 11 May
Most time spend testing each component to be working and fixing small typos. I should not forget that I started to code and to add small functions.
Week 12 April - 18 May
Created basic logic after finishing with the hardware part. Everything is working very well and testing was taken more serious. Added logic for the SPI LCD module and for the buttons. Holding a button will execute it's command only one time. To do it more, the player has to press multiple times
Week 19 May - 25 May
Implemented a mechanic that prevents executing the same command when holding a button. It will happen only one time, after it will stop until a new button is pressed (or the same). The game is was created using a struct and an impl. There are tiles with numbers until 2^14 and it can go beyond it without any problem. The grid can be changed between 4x4, 5x5 and 6x6.
Hardware
This project is using the following components:
- 2x Raspberry Pi Pico 2W for controlling the display and the results intended while pressing the buttons;
- 1x 1.8" SPI LCD Module (128 x 160) to display the game;
- 5x push buttons (4 for movements, 1 to change / reset a game).
Schematics
Photos
Bill of materials
Name | Quantity | Usage | Price |
---|---|---|---|
Raspberry Pi Pico 2W | 2 | One for debugging (UART), the other for controlling the architecture | 39,66 lei |
1.8" SPI LCD Module (128 x 160) | 1 | Display for game status, score etc. | 28,99 lei |
Breadboard Jumper Wires Set | 66 | Connections between components (picos, buttons, LCD, etc.) | 7,99 lei |
0.25 W 10K Ω Resistor | 10 | Pull-down resistors for buttons | 1 leu |
2.54 mm Red Pin Headers | 3 | Headers for connecting Picos and LCD to the breadboard | 2.97 lei |
Breadboard HQ (830 Points) | 2 | Main breadboard for connecting the buttons | 19,96 lei |
400p HQ Breadboard | 1 | Auxiliary breadboard, likely for GPIO and others | 4,56 lei |
6 x 6 x 6 Push Button | 8 | 4 for movement, 1 for reset / game switch, others as spares | 2,88 lei |
Micro USB 1 m Black Cable | 1 | Power and programming for a Pico | 6,95 lei |
Software
This is not final. This is most likely what I'll use after I get the last order of components which are missing.
Crate | Description | Usage |
---|---|---|
rp2035-hal | Hardware Abstraction Layer for the RP2035 microcontroller | Direct access to GPIOs, UART, SPI, I2C, timers, PWM, etc., on the Pico |
embedded-hal | Standard traits for embedded peripherals (e.g., digital I/O, SPI, I2C) | Foundation for cross-platform driver development and HALs |
panic-halt (or) defmt | panic-halt: minimal panic handler; defmt: logging and debug output | Handling panics or enabling real-time logging/debugging |
embedded-graphics | 2D graphics primitives for displays (no-std) | Drawing shapes, text, images on the LCD |
st7735-lcd | Driver for ST7735-based SPI displays | Communicating with and rendering to the 1.8" SPI LCD module |
heapless | Fixed-capacity data structures with no heap allocation | Queues, buffers, or hash maps without dynamic memory |
cortex-m | Low-level access to ARM Cortex-M processor features | Accessing special registers, enabling interrupts, etc. |
cortex-m-rt | Runtime support for Cortex-M processors | Defines the entry point, vector table, and startup code |
usb-device | USB device stack for embedded systems | Creating USB peripherals (e.g., serial communication over USB) |
Links
I got inspiered from the links mentioned below: