Skip to content

Commit

Permalink
lib: Add support to RGBW neopixel
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Jul 29, 2024
1 parent 0417ea5 commit 8481b8f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8481b8f

Please sign in to comment.