From bf390f0fbf209482b65c143af9919a5abc42cfd4 Mon Sep 17 00:00:00 2001 From: Krzysztof Mazur Date: Mon, 4 Dec 2023 08:38:28 +0100 Subject: [PATCH] Improve documentation --- Cargo.lock | 2 +- Cargo.toml | 3 ++- README.md | 43 ++++++++++++++++++++++++++++++++++++------- src/ws2812.rs | 2 +- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b073b5..e8e4365 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1120,7 +1120,7 @@ dependencies = [ [[package]] name = "pico-w-neopixel-server" -version = "0.1.0" +version = "0.2.0" dependencies = [ "cortex-m", "cortex-m-rt", diff --git a/Cargo.toml b/Cargo.toml index d8969d9..eafe600 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,9 @@ [package] edition = "2021" name = "pico-w-neopixel-server" -version = "0.1.0" +version = "0.2.0" license = "MIT OR Apache-2.0" +default-run = "tcp" [dependencies] diff --git a/README.md b/README.md index badbff8..ad9a716 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,50 @@ # pico-w-neopixel-server -# **!WIP!** Rust migration in progress! +Simple webserver aiming to be a thin remote controller for neopixel lights. + +Developed to work with https://github.com/mrozycki/rustmas project. + +## Setup +### Dependencies +You will need to use [picotool](https://github.com/raspberrypi/picotool) or [elf2uf2-rs](https://github.com/JoNil/elf2uf2-rs) to flash the compiled binary onto your pico. +Choose whichever you want and set the runner in `.cargo/config.toml` accordingly + +We recommend using `picotool`, as it let's you read the binary information from a flashed pico as well. + +On MacOS and Linux you can install it with [brew](https://brew.sh/): + +```sh +brew install picotool +``` +### WiFi credentials +You will need to make a copy of the `src/secret.rs.example` file and name it `src/secret.rs`. +In that file fill you the SSID and password of the WiFi network you want the pico to connect to. + + +## Flashing + +This repo contains both TCP and UDP versions of the neopixel server. The TCP one is used by default. + To flash it to pico just put the pico in bootsel mode and run ```sh cargo run --release ``` -> [!TIP] +> [!NOTE] > Some lights have their red and green colors swapped, if you don't want to compensate for that in each frame sent to pico, you can compensate in the firmware: ```sh cargo run --release --features grb ``` +### UDP +To use the UDP version you just need to add `--bin udp` to your flash command: +```sh +cargo run --release --bin udp +``` +> [!IMPORTANT] +> Make sure that the UDP packets length doesn't exceed the MTU in your network. +> For a default MTU of 1500 bytes, you won't be able to drive 500 LEDs due to the protocol overhead. -Simple webserver aiming to be a thin remote controller for neopixel lights. - -Developed to work with https://github.com/mrozycki/rustmas project. - -The C++ SDK version using Pico SDK can be found here: https://github.com/krzmaz/pico-w-neopixel-server-cpp +--- +The legacy version of this project using Pico C++ SDK can be found here: https://github.com/krzmaz/pico-w-neopixel-server-cpp diff --git a/src/ws2812.rs b/src/ws2812.rs index aef996d..10884cd 100644 --- a/src/ws2812.rs +++ b/src/ws2812.rs @@ -97,7 +97,7 @@ impl<'d, P: Instance, const S: usize> Ws2812<'d, P, S> { } pub fn write(&mut self, r: u8, g: u8, b: u8) { - let word = convert_colors_to_word(r,g,b); + let word = convert_colors_to_word(r, g, b); // we need to watch out not to overflow the FIFO, see: // https://github.com/rp-rs/ws2812-pio-rs/blob/944494ca9dad73933f700408c3054c8f14c78998/src/lib.rs#L177-L179 while !self.sm.tx().try_push(word) {