Skip to content

Commit e9bc1c8

Browse files
committed
codal_app/microbithal: Add microbit_hal_pin_write_ws2812 function.
1 parent 18eb9de commit e9bc1c8

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/codal_app/microbithal.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "main.h"
2828
#include "MicroBitDevice.h"
29+
#include "neopixel.h"
2930

3031
extern "C" {
3132

@@ -162,6 +163,10 @@ int microbit_hal_pin_is_touched(int pin) {
162163
return pin_obj[pin]->isTouched();
163164
}
164165

166+
void microbit_hal_pin_write_ws2812(int pin, const uint8_t *buf, size_t len) {
167+
neopixel_send_buffer(*pin_obj[pin], buf, len);
168+
}
169+
165170
int microbit_hal_i2c_init(int scl, int sda, int freq) {
166171
// TODO set pins
167172
int ret = uBit.i2c.setFrequency(freq);

src/codal_app/microbithal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ void microbit_hal_pin_write(int pin, int value);
9393
int microbit_hal_pin_read_analog_u10(int pin);
9494
void microbit_hal_pin_write_analog_u10(int pin, int value);
9595
int microbit_hal_pin_is_touched(int pin);
96+
void microbit_hal_pin_write_ws2812(int pin, const uint8_t *buf, size_t len);
9697

9798
int microbit_hal_i2c_init(int scl, int sda, int freq);
9899
int microbit_hal_i2c_readfrom(uint8_t addr, uint8_t *buf, size_t len, int stop);

0 commit comments

Comments
 (0)