#include "ws2812.h" WS2812::WS2812(uint gpio, PIO pio, uint sm) : m_pio{pio}, m_sm{sm} { uint offset = pio_add_program(m_pio, &ws2812_program); ws2812_program_init(m_pio, m_sm, offset, gpio, 800000, true); switchColor(Color::OFF); } void WS2812::switchColor(Color color) { putPixel(static_cast(color)); } void WS2812::blinkReady() { for (int i = 0; i < 2; i++) { switchColor(Color::WHITE); sleep_ms(250); switchColor(Color::OFF); sleep_ms(250); } } void WS2812::putPixel(uint32_t pixel_grb) { pio_sm_put_blocking(m_pio, m_sm, pixel_grb << 8u); }