/pico-game-of-light

Ledstrip based matrix to light your room, made alive by using a simple Game Of Life algorithm.Toy project to play with embassy-rs and rust on raspberry-pi Pico, use with appropriate care.

Primary LanguageRustGNU General Public License v3.0GPL-3.0

pico-game-of-light : Mathematically alive lighting

⚠️ 🚧 Toy project to play with embassy-rs and rust on raspberry-pi Pico, use with appropriate care.

nice_gif_here

1.2. Hardware

1.2.1. BOM (bill of material)

1.2.2. Schematics

                           β”Œβ”€β”€RP2040───┐
                      β”Œβ”€β”€β”€β”€β”€VSYS       β”‚
                      β”‚    β”‚           β”‚
                      β”‚  β”Œβ”€β”€GND    IO8 β”‚
                      β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”˜
  β”Œβ”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”    β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”
  β”‚  +5Vβ”œβ”€>── C1 β”œβ”€β”€β”¬β”€β”΄β”€β”€β”Όβ”€β”€           β”œβ”€β”€+3.3V β”‚
──►     β”‚   β”‚100 β”‚  β”‚    β”‚ β”‚ TTL LLV   β”‚ β”‚      ◄──
  β”‚  GNDβ”œβ”€>──ùF  β”œβ”€β”€β”Όβ”€β”€β”€β”¬β”΄β”€β”€ 3.3 -> 5V β”œβ”€β”€GND   β”‚
  β””β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”˜  β”‚   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜
                    β”‚   β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”Œβ”€β”΄β”€β”¬β”€β”΄β”€β”¬β”€β”΄β”€β”
                  β”‚+5Vβ”‚GNDβ”‚Dinβ”‚
        β”Œβ”€β”¬β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”
        β”‚ │┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼─▼│
        β”‚β–Όβ”œβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”‚ β”‚
        β”‚ │┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼─▼│
        β”‚β–Όβ”œβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”‚ β”‚
        β”‚ β”‚β”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”‚LEDβ”‚STRIP│┼┼┼┼┼┼┼┼─▼│
        β”‚β–Όβ”œβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”‚ β”‚
        β”‚ │┼┼┼┼┼┼┼┼────┼┼┼┼┼┼┼┼┼┼┼┼┼─▼│
        β”‚β–Όβ”œβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”‚8*18β”‚β”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”Όβ”‚ β”‚
        β”‚ │┼┼┼┼┼┼┼┼────┼┼┼┼┼┼┼┼┼┼┼┼┼│ β”‚
        β””β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”˜

1.3. Software

1.3.1. Requirements

source : rp-rs github project requirements

  • The standard Rust tooling (cargo, rustup) : eg. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • Toolchain support for the cortex-m0+ processors in the rp2040 (thumbv6m-none-eabi) : eg. rustup target add thumbv6m-none-eabi
  • flip-link - this allows you to detect stack-overflows on the first core, which is the only supported target for now. : eg. cargo install flip-link
  • probe-run. Upstream support for RP2040 was added with version 0.3.1. eg. cargo install probe-run
  • A CMSIS-DAP probe. (J-Link and other probes will not work with probe-run)
    • I use a second Pico as a CMSIS-DAP debug probe.

To develop with async (embedded) Rust πŸ¦€ with embassy framwework

1.3.2. GOL rules

graph TD
    loop{{for each cell}}--> living_or_not{{is cell alive ?}}
    living_or_not-->|yes|should_survive{{if N < 2 or N >3}}
    should_survive--> |yes|cell_die[cell die <br/><i>loneliness or overpopulation]
    should_survive--> |no|cell_live[cell stay alive]
    living_or_not-->|no|should_born{{if N == 3}}
    should_born-->|yes|born[living cell born]
    should_born-->|no|dead[cell still dead]
Loading

1.3.3. Notes for future me

  • The boilerplate to develop on RP2040 is here : https://github.com/SupImDos/embassy-rp-skeleton

  • Section about how to use a second Pico as probe : https://github.com/SupImDos/embassy-rp-skeleton#hardware-setup

  • Write tests. See below discussion about how to ...

  • Use nightly : rustup override set nightly

  • Me

    ...would you tell me how do you implement test (mainly unit testing, but why not integ too) in your embassy based projects?

  • dirbaio

    if it's hardware-independent logic, so you can run the tests in the host, it's easiest to separate that code into its own crate, and use regular Rust tests if it's hardware-dependent then there's defmt-test. defmt-test has some limitations though (can't have tests in multiple modules, can't reinitialize hardware between tests) so for some I've ended up doing one binary for each test, and scripting something to flash+run them in succession