Skip to content

Commit c57ca3f

Browse files
authored
Week 14 Documentation Update (#1406)
* Add project description for RustShips * docs: add inspiration and resource links * added: image paths in index.md * updated: architecture scheme in index.md * docs: optimize 3D PCB render images to webp format * fix: resize and compress images to pass repo size limits * fix: deleted identifier files * chore: update and optimize hardware images * Week 14: simulator complete, all game logic implemented and tested * Fix MDX link syntax on line 8 * Add WebP compressed prototype photo * Final tweaks to docs and image
1 parent 08de223 commit c57ca3f

8 files changed

Lines changed: 40 additions & 20 deletions

File tree

107 KB
Loading
141 KB
Loading

website/versioned_docs/version-fils_en/project/2026/daniel.mirza/images/pcb_2d.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.
52.7 KB
Loading
49.6 KB
Loading
Binary file not shown.
Binary file not shown.

website/versioned_docs/version-fils_en/project/2026/daniel.mirza/index.md

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A two-player Battleship game running on devices having a 4" touchscreen display and wireless peer-to-peer communication.
44

5-
:::info
5+
:::info
66

77
**Author**: Mîrza Daniel \
88
**GitHub Project Link**: https://github.com/UPB-PMRust-Students/fils-project-2026-Danum1z
@@ -11,18 +11,18 @@ A two-player Battleship game running on devices having a 4" touchscreen display
1111

1212
## Description
1313

14-
RustShips is a fully embedded, wireless two-player Battleship game. Each player owns a dedicated device consisting of an STM32U545RE Nucleo-64 board connected to a 4" TFT touchscreen (ST7796S, 320×480) wtih action buttons and a passive buzzer. The two devices communicate wirelessly via NRF24L01+ radio modules over SPI.
14+
RustShips is a fully embedded, wireless two-player Battleship game. Each player owns a dedicated device consisting of an STM32U545RE Nucleo-64 board connected to a 4" TFT touchscreen (ST7796S, 320×480) with action buttons and a passive buzzer. The two devices communicate wirelessly via NRF24L01+ radio modules over SPI.
1515

1616
Each player places a fleet of 5 ships on a 10×10 grid, then takes turns firing at the opponent's grid. The game tracks two matrices per device: `my_fleet` (own ships and incoming hits) and `enemy_radar` (shots fired and confirmed results). A dedicated button toggles between the two views.
1717

1818
The game features three special mechanics, each usable once per game:
19-
- **Sonar Scan**: hold the action button for 3 seconds to reveal a 3×3 area of the enemy grid for 2 seconds
20-
- **Airstrike**: double-press the action button to instantly sink an entire enemy ship
19+
20+
- **Sonar Scan**: hold the action button for 1.5 seconds to reveal a 3×3 area of the enemy grid for 1 second
21+
- **Airstrike**: double-press the action button within a 300 ms window to instantly sink an entire enemy ship
2122
- **Ferris Repair**: named after Ferris the Rust mascot — fully repair a damaged ship and move it to a new position
2223

2324
The entire game logic is written as a `no_std` Rust library (`game-core`) that compiles for both the real MCU and a desktop simulator built with `embedded-graphics-simulator`.
2425

25-
2626
## Motivation
2727

2828
The choice of this project comes from a long-standing interest in classical strategy games like Battleships and a desire to translate tactile, paper-based mechanics into a robust digital embedded system. Beyond the childhood nostalgia, this project serves as a comprehensive learning platform for several reasons:
@@ -31,7 +31,7 @@ The choice of this project comes from a long-standing interest in classical stra
3131
- **Hardware Integration**: The project offers hands-on experience with SPI bus sharing between high-resolution displays, touch controllers, and wireless radio modules.
3232
- **Future Potential**: This handheld terminal is designed as a versatile gaming platform. Its low energy consumption and independent peer-to-peer wireless link make it ideal for offline use (trains, planes, or remote trips). It establishes a foundation for a suite of offline multiplayer games like or Connect 4, Tic-Tac-Toe, or even singleplayer Sudoku.
3333

34-
## Architecture
34+
## Architecture
3535

3636
The project is split into three crates inside a Cargo workspace:
3737

@@ -42,6 +42,7 @@ The project is split into three crates inside a Cargo workspace:
4242
**`embassy-app`**`no_std` Embassy application for the real hardware. Spawns independent async tasks that communicate via Embassy channels and signals.
4343

4444
**Game State Machine (per device):**
45+
4546
```text
4647
Placement ──► WaitingForOpponent ──► Battle ──► GameOver
4748
├── Aiming
@@ -135,63 +136,83 @@ graph TD
135136

136137
### Week 12 - 13
137138

138-
- _to be continued..._
139+
- Sent the PCB files for production to JLCPCB
140+
- Updated the KiCAD images for the web documentation page
141+
- PCB files sent to JLCPCB for production
142+
- Implemented the full simulator game loop `main.rs` with two-player local split-screen
143+
- Built `display.rs` which renders both player panels, grids, ships, hit/miss markers, specials
144+
- Implemented `input.rs` with keyboard-to-InputEvent mapping with timing logic
145+
- Implemented `fake_network.rs` to simulate the NRF24L01+ link between two players as in-process channel pair
146+
- Wired all three special abilities end-to-end in the simulator: Sonar Scan, Airstrike, and Ferris Repair
147+
- Fixed numerous game logic bugs across `game-core` (placement validation, cursor and key press behavior, view toggle, Ferris Repair, Airstrike, Sonar Scan, radar sync, game states)
148+
- Playtested full games including all specials, edge cases, and win conditions
149+
- Still waiting for the PCB to arrive
150+
151+
### Week 14
152+
153+
- Finally received the long-awaited PCB
139154

140155
## Hardware
141156

142157
Each player's device consists of:
143158

144159
- **STM32U545RE-Q Nucleo-64**: Arm Cortex-M33 microcontroller running at up to 160 MHz, 512 KB flash, 274 KB SRAM. Runs the Embassy async runtime with multiple concurrent tasks.
160+
- **Power Management Subsystem**: Powered by a 3.7V LiPo battery. Includes a TP4056 module for USB-C charging, a custom P-Channel MOSFET auto-power latch circuit for software-controlled shutdown, and a 3.3V Buck-Boost converter to provide stable voltage to the MCU and peripherals.
145161
- **4.0" TFT LCD (ST7796S, 320×480)**: Connected via SPI. Displays both game grids, ship positions, hit/miss markers, and special ability highlights. Driven by the `mipidsi` crate with `embedded-graphics`.
146162
- **XPT2046 resistive touch controller**: Shares the SPI bus with the display (separate CS pin). Used for cell selection on the touchscreen.
147163
- **NRF24L01+ radio module**: Connected via SPI. Provides 2.4 GHz peer-to-peer wireless communication between the two devices. No server or router required.
148164
- **Passive buzzer**: Driven via PWM. Provides audio feedback for shots, hits, sinks, special abilities, and win/lose outcomes.
149165
- **Navigation buttons**: Arrow buttons (up/down/left/right) for cursor movement and ship placement, plus Action, View-Toggle, and Rotate buttons.
150166

167+
### Prototype
168+
169+
![Hardware Prototype](./images/hardware-prototype.webp)
170+
151171
### Schematics
152172

153173
#### 1. Schematic Design
154174

155175
The schematic integrates the STM32 Nucleo, nRF24L01+ transceiver, SPI TFT Display, and a custom P-Channel MOSFET auto-power latch circuit for battery management.
156176

157177
![System Schematic](./images/schematic.svg)
158-
*Figure 1: Full system schematic including power management, MCU, and peripherals.*
178+
_Figure 1: Full system schematic including power management, MCU, and peripherals._
159179

160180
#### 2. PCB Layout and Routing (2D)
161181

162182
The board has been floorplanned to accommodate a comfortable handheld form factor. Critical components (like the nRF24 decoupling capacitors) have been placed as close to their target pins as possible.
163183

164-
![2D PCB Routing](./images/pcb_2d.svg)
165-
*Figure 2: Current 2-layer copper routing (Front: Red, Back: Blue).*
184+
![2D PCB Routing](./images/pcb_2d-routing.webp)
185+
_Figure 2: Current 2-layer copper routing (Front: Red, Back: Blue)._
166186

167187
#### 3. 3D Render
168188

169-
This is the physical representation of the board, which will be used to design the 3D-printed enclosure.
189+
This is the physical representation of the board, which will be used to design the 3D-printed enclosure.
170190

171-
![3D PCB Render - Front](./images/pcb_3d_f.webp)
172-
![3D PCB Render - Back](./images/pcb_3d_b.webp)
173-
*Figure 3: 3D visualization of the assembled PCB (front and back).*
191+
![3D PCB Render - Front](./images/pcb_3d-render_f.webp)
192+
![3D PCB Render - Back](./images/pcb_3d-render_b.webp)
193+
_Figure 3: 3D visualization of the assembled PCB (front and back)._
174194

175195
### Bill of Materials
176196

177197
| Device | Usage | Price |
178-
|--------|--------|-------|
198+
| ------ | ----- | ----- |
179199
| [STM32U545RE Nucleo-64](https://www.st.com/en/evaluation-tools/nucleo-u545re-q.html#overview) | Main microcontroller board (×2) | [130 RON](https://ro.mouser.com/ProductDetail/STMicroelectronics/NUCLEO-U545RE-Q?qs=mELouGlnn3cp3Tn45zRmFA%3D%3D&countryCode=RO&currencyCode=RON) × 2 |
180200
| [4.0" TFT LCD ST7796S 320×480](https://www.lcdwiki.com/4.0inch_SPI_Module_ST7796) | Touchscreen display (×2) | [130 RON](https://www.amazon.es/-/en/gp/product/B0CQ87KN3Q/ref=ox_sc_act_title_1?smid=A3E5QOOXTLF93M&th=1) × 2 |
181201
| [NRF24L01+ module](https://www.handsontec.com/dataspecs/module/NRF24L01+.pdf) | 2.4GHz wireless link (×2) | [7 RON](https://www.optimusdigital.ro/ro/ism-24-ghz/48-modul-tranceiver-nrf24l01-24-ghz.html?search_query=NRF24L01++module&results=5) × 2 |
182202
| [TP4056 Charger module]() | Charger module (x2) | [4 Ron](https://www.optimusdigital.ro/ro/electronica-de-putere-incarcatoare/7534-incarcator-tp4056-cu-micro-usb-pt-baterie-lipo-1a-cu-protectie-pentru-circuite.html?search_query=TP4056+&results=4) × 2 |
183203
| [Buck-Boost 3V3]() | Constant and regulated 3.3V voltage (x2) | [15 Ron](https://www.emag.ro/convertor-buck-boost-elektroweb-3v-15v-la-3-3v-rosu-3-h-051/pd/D8HNPBYBM/) × 2 |
184-
| [Tantalum Capacitors]() | Help the radio transmission | [4 RON]() × 6 |
204+
| [Tantalum Capacitors]() | Help the radio transmission (x6) | [4 RON]() × 6 |
185205
| [LEDs]() | Illumination + feedback | [4 Ron](https://www.optimusdigital.ro/ro/optoelectronice-led-uri/11629-led-portocaliu-0603.html?search_query=0104110000072290&results=1) × 3 |
186-
| [Resisistors]() | Leds and power management | [20 RON](https://www.optimusdigital.ro/ro/componente-electronice-rezistoare/638-set-de-rezistoare-smd-0805.html?search_query=0104110000003560&results=1) |
206+
| [Resisistors]() | For leds and power management | [20 RON](https://www.optimusdigital.ro/ro/componente-electronice-rezistoare/638-set-de-rezistoare-smd-0805.html?search_query=0104110000003560&results=1) |
187207
| [Push buttons]() | Navigation + action input (×2 sets) | [0.36 RON](https://www.optimusdigital.ro/en/buttons-and-switches/1119-6x6x6-push-button.html?search_query=button&results=379) × 20 |
188208
| [Jumper wires]() + [breadboard](https://www.optimusdigital.ro/en/breadboards/13244-breadboard-175-x-67-x-9-mm.html) | Prototyping connections | [~12 RON]() |
189-
| **Total (estimated)** | | **~ 650 RON** |
209+
| [PCB]() | Circuit board (x5) | [~ 50 RON](https://cart.jlcpcb.com/quote) |
210+
| **Total (approximated)** | | **~ 700 RON** |
190211

191212
## Software
192213

193214
| Library | Description | Usage |
194-
|---------|-------------|-------|
215+
| ------- | ----------- | ----- |
195216
| [embassy](https://github.com/embassy-rs/embassy) | Async embedded framework | Task scheduler, async SPI/GPIO/PWM drivers for STM32U5 |
196217
| [mipidsi](https://github.com/almindor/mipidsi) | MIPI display driver | Drives the ST7796S TFT display over SPI |
197218
| [embedded-graphics](https://github.com/embedded-graphics/embedded-graphics) | 2D graphics library | Draws grids, ships, cursors, highlights, text |

0 commit comments

Comments
 (0)