diff --git a/src/lib.rs b/src/lib.rs index 569b25304..9d156965d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -255,6 +255,28 @@ fn set_led_all(state: bool) { with_navigator!().set_led_all(state) } +#[cpy_fn_c] +#[comment = "Set the color brightnesses of a connected RGBW NeoPixel LED array."] +fn set_neopixel_rgbw_c(rgbw_array: *const [u8; 4], length: usize) { + let array = unsafe { + assert!(!rgbw_array.is_null()); + std::slice::from_raw_parts(rgbw_array, length) + }; + with_navigator!().set_neopixel_rgbw(array); +} + +#[cpy_fn_py] +#[comment = "Set the color brightnesses of a connected RGBW NeoPixel LED array.\n + Args:\n + state ([[uint8, uint8, uint8, uint8], ...]): A 2D array containing RGBW values for each LED.\n + Set the Red, Green, Blue and White components independently, with values from 0-255.\n + Examples:\n + >>> import bluerobotics_navigator as navigator\n + >>> navigator.set_neopixel_rgbw([[100,0,0,100]])"] +fn set_neopixel_rgbw_py(rgbw_array: Vec<[u8; 4]>) { + with_navigator!().set_neopixel_rgbw(&rgbw_array) +} + #[cpy_fn_c] #[comment = "Set the color brightnesses of a connected NeoPixel LED array."] fn set_neopixel_c(rgb_array: *const [u8; 3], length: usize) {