de
Close Menu
Pong on Microcontroller with Rust

Pong on Microcontroller with Rust

Published on 2018-04-13

In the last two weeks I took a practical course at university. We got an introduction into Rust and then were split up into teams to write something for the STM32F746G discovery microcontroller. A fellow student and I decided to create a simple pong clone with networked multiplayer.

This was my first contact with Rust and the first time using a microcontroller, so that already created a few challenges. To improve draw speed, I used two L8 framebuffers (one byte per pixel containing just the luminacity) which I allocated on the heap in SRAM instead of the SDRAM as in the given example. For the communication between devices we send the whole gamestate (19 bytes) in an UDP packet in every frame to the client and the client just sends the touched y position in every frame. We also added a local multiplayer mode to test the game when only one microcontroller is available.

If you happen to have this microcontroller you could install the rust nightly-2018-04-12, download our source code from GitHub and run cargo run --release after installing the necessary tools described in the library project.

Although the two weeks were really exhausting I really learned a lot in this course. Learning a new programming language was quite fun, especially as there are a few concepts that work a little different than in programming languages I already knew. But I’m also happy to get back to higher level programming in the next time.