Skip to content

Commit

Permalink
lib: Add: New method to support Neopixel RGBW
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulTrombin committed Jul 8, 2024
1 parent b28d0bf commit fcc45ce
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,28 @@ fn set_neopixel_py(rgb_array: Vec<[u8; 3]>) {
with_navigator!().set_neopixel(&rgb_array)
}

#[cpy_fn_c]
#[comment = "Set the color brightnesses of a connected NeoPixel LED array."]
fn set_neopixel_rgbw_c(rgb_array: *const [u8; 4], length: usize) {
let array = unsafe {
assert!(!rgb_array.is_null());
std::slice::from_raw_parts(rgb_array, length)
};
with_navigator!().set_neopixel_rgbw(array);
}

#[cpy_fn_py]
#[comment = "Set the color brightnesses of a connected NeoPixel LED array.\n
Args:\n
state ([[uint8, uint8, uint8, uint8], ...]): A 2D array containing RGB 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([[100,0,0,128]])"]
fn set_neopixel_rgbw_py(rgb_array: Vec<[u8; 4]>) {
with_navigator!().set_neopixel_rgbw(&rgb_array)
}

#[cpy_fn]
#[comment_c = "Reads the ADC channel values (from the ADS1115 chip)."]
#[comment_py = "Reads the ADC channel values (from the ADS1115 chip).\n
Expand Down Expand Up @@ -612,6 +634,7 @@ cpy_module!(
set_led_toggle,
set_led_all,
set_neopixel,
set_neopixel_rgbw,
read_adc_all,
read_adc,
read_pressure,
Expand Down

0 comments on commit fcc45ce

Please sign in to comment.