#include "ws2812b.h" enum WS2812B_SPI : uint32_t { BIT_LOW = 1u, BIT_HIGH = 3u, }; OneColor::OneColor(const uint8_t color) noexcept { b0 = (color & 0x80u) ? BIT_HIGH : BIT_LOW; b1 = (color & 0x40u) ? BIT_HIGH : BIT_LOW; b2 = (color & 0x20u) ? BIT_HIGH : BIT_LOW; b3 = (color & 0x10u) ? BIT_HIGH : BIT_LOW; b4 = (color & 0x08u) ? BIT_HIGH : BIT_LOW; b5 = (color & 0x04u) ? BIT_HIGH : BIT_LOW; b6 = (color & 0x02u) ? BIT_HIGH : BIT_LOW; b7 = (color & 0x01u) ? BIT_HIGH : BIT_LOW; } unsigned OneColor::to_string(char * ptr, const int m) { auto f = [=](const uint32_t x, char * buf) -> unsigned { unsigned i = 0; for (int k=0; k & r) noexcept : OneWay (), ring(r) { } unsigned int ws2812b::Send (uint8_t * const ptr, const unsigned int len) { uint32_t cmd; while (ring.Read(cmd)) { const Entry ne (cmd); if (ne.ws.order < NUMLEDS) { Color * cptr = reinterpret_cast(ptr); Color & c = cptr [ne.ws.order]; const OneColor cb (ne.ws.b), cg (ne.ws.g), cr (ne.ws.r); c.b = cb; c.g = cg; c.r = cr; } } return len; }