• Home page
  • About Us
  • Services
    • Microsoft Azure
  • Technologies
    • Yocto
    • LoRa
    • LWM2M
      • LWM2M Fundamentals
  • Case Study
  • Careers
  • Blog
  • Contact
  • Home page
  • About Us
  • Services
    • Microsoft Azure
  • Technologies
    • Yocto
    • LoRa
    • LWM2M
      • LWM2M Fundamentals
  • Case Study
  • Careers
  • Blog
  • Contact

A Classic Snake Game in Rust

  • Posted by Thaumatec
  • On 2 December 2019
  • In IoT
  • 0

The goal of this project was to experiment with Rust bare metal programming by implementing a simple game. The chosen hardware platform was STM32F4DISCOVERY. It is similar to F3 DISCOVERY from the official embedded Rust tutorial however, it has some additional features like analog-digital converter required for the snake to be controlled with a joystick. The game is displayed on a 96×64 OLED screen using SSD1331 controller and SPI interface. In the process of development and debugging two additional versions of the game were created: one with text based UI for running the game in a terminal and the other one using a game engine called Quicksilver. Quicksilver is capable of targeting WebAssembly, which means the same game can be played both on the microcontroller and in a web browser. Implemenation of the game. Embedded HAL  hides a lot of details and allows us to interact with the hardware on a relatively high level of abstraction.
Some remarkable issues are:

* Development without OS and allocator requires #![no_std] flag but Rust’s native test framework depends on standard library facilities. In order to keep unit tests in the same file as the source code (which is Rust’s convention), a conditional compilation was required.

* Lack of dynamic memory allocation makes it difficult to parameterize application code with the size of “things” – everything has to be set at compile time. It is a problem when unit testing or targeting different screen sizes. The easy solution for this would be to use a feature named “const generics“ which, unfortunately, is not yet fully implemented in Rust. Luckily there is a workaround in the form of crate generic_array, but overall Rust still has to catch up with C++ in this subject.

* Important thing one has to remember when developing with Rust is that the difference in performance between debug and release versions is huge. In the case of this game and microcontroller, the debug version was literally unusable.

For more information follow the link below:

https://github.com/g-bartoszek/snake
Share:

Previous Post

RustFest: Barcelona
0 comments on A Classic Snake Game in Rust

Post a comment Cancel reply

Your email address will not be published. Required fields are marked *

Latest posts
  • A Classic Snake Game in Rust
  • RustFest: Barcelona
  • Ignite 2019 Reveals new Azure Synapse
  • Top 100 Smartest-Cities in the World: Wroclaw Ranks in #95
  • Akademickie Targi Pracy Campus Recruitment 2019 : Meet Thaumatec @ Wroclaw University of Science and Technology
Categories
  • Company
  • Development
  • Events
  • IoT
  • Knowledge base
  • Partnerships
  • Social responsibility
  • Team
Scroll

Introduction
  • Home page
  • About Us
  • Services
    • Microsoft Azure
  • Technologies
    • Yocto
    • LoRa
    • LWM2M
      • LWM2M Fundamentals
  • Case Study
  • Careers
  • Blog
  • Contact
Latest Posts
  • A Classic Snake Game in Rust
  • RustFest: Barcelona
  • Ignite 2019 Reveals new Azure Synapse
Address

Thaumatec Sp. z o.o.
ul. Mickiewicza 20c
51-619 Wroclaw
Poland
Phone: +48 698 632 801
Mail: office@thaumatec.com
VAT-ID/NIP: PL897-179-80-51

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy

Necessary Always Enabled