From 7ad00a55b76a2b39319423532e76f8d56e6c21dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Tue, 10 Dec 2024 13:48:17 -0300 Subject: [PATCH] examples: Add led-custom-builder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- examples/led-custom-builder.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 examples/led-custom-builder.rs diff --git a/examples/led-custom-builder.rs b/examples/led-custom-builder.rs new file mode 100644 index 000000000..6f6c40398 --- /dev/null +++ b/examples/led-custom-builder.rs @@ -0,0 +1,29 @@ +use navigator_rs::{Navigator, UserLed}; +use std::thread::sleep; +use std::time::Duration; + +use rand::seq::SliceRandom; + +fn main() { + let mut nav = Navigator::create().build_navigator_v2_pi5(); + + let colors = [ + [40u8, 0, 0], + [0, 40, 0], + [0, 0, 40], + [40, 40, 0], + [0, 40, 40], + [40, 0, 40], + ]; + + println!("LED show started!"); + loop { + nav.set_neopixel(&[*colors.choose(&mut rand::thread_rng()).unwrap()]); + for led in [UserLed::Led1, UserLed::Led2, UserLed::Led3] { + nav.set_led_toggle(led); + sleep(Duration::from_millis(300)); + } + + println!("{:?}", nav.read_all()); + } +}