Skip to content

Commit 5ee90a2

Browse files
committed
lib: Add: New method to support Neopixel RGBW
1 parent fe0e2c1 commit 5ee90a2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,28 @@ fn set_neopixel_py(rgb_array: Vec<[u8; 3]>) {
246246
with_navigator!().set_neopixel(&rgb_array)
247247
}
248248

249+
#[cpy_fn_c]
250+
#[comment = "Set the color brightnesses of a connected NeoPixel LED array."]
251+
fn set_neopixel_rgbw_c(rgb_array: *const [u8; 4], length: usize) {
252+
let array = unsafe {
253+
assert!(!rgb_array.is_null());
254+
std::slice::from_raw_parts(rgb_array, length)
255+
};
256+
with_navigator!().set_neopixel_rgbw(array);
257+
}
258+
259+
#[cpy_fn_py]
260+
#[comment = "Set the color brightnesses of a connected NeoPixel LED array.\n
261+
Args:\n
262+
state ([[uint8, uint8, uint8, uint8], ...]): A 2D array containing RGB values for each LED.\n
263+
Set the Red, Green, Blue and White components independently, with values from 0-255.\n
264+
Examples:\n
265+
>>> import bluerobotics_navigator as navigator\n
266+
>>> navigator.set_neopixel([[100,0,0,128]])"]
267+
fn set_neopixel_rgbw_py(rgb_array: Vec<[u8; 4]>) {
268+
with_navigator!().set_neopixel_rgbw(&rgb_array)
269+
}
270+
249271
#[cpy_fn]
250272
#[comment_c = "Reads the ADC channel values (from the ADS1115 chip)."]
251273
#[comment_py = "Reads the ADC channel values (from the ADS1115 chip).\n
@@ -612,6 +634,7 @@ cpy_module!(
612634
set_led_toggle,
613635
set_led_all,
614636
set_neopixel,
637+
set_neopixel_rgbw,
615638
read_adc_all,
616639
read_adc,
617640
read_pressure,

0 commit comments

Comments
 (0)