32 lines
723 B
C++
32 lines
723 B
C++
#include "fifo.h"
|
|
#include "spiclass.h"
|
|
#include "system.h"
|
|
#include "gpio.h"
|
|
extern "C" {
|
|
extern const unsigned table [];
|
|
};
|
|
|
|
static FIFO<uint32_t, NUMLEDS> ring;
|
|
static ws2812b driver(ring);
|
|
static SpiClass spi (driver);
|
|
static GpioClass led (GPIOB, 8);
|
|
static constexpr unsigned timeout = 5'000u;
|
|
|
|
int main () {
|
|
led << true;
|
|
delay_init();
|
|
spi.Init();
|
|
unsigned counter = 0u;
|
|
for (;;) {
|
|
delay_us(timeout);
|
|
const bool b = counter & 0x100u;
|
|
led << b;
|
|
counter += 1u;
|
|
for (unsigned n=0u; n<NUMLEDS; n++) {
|
|
unsigned cmd = ((counter + 64u * n) & 0xFFu);
|
|
cmd = table [cmd] | (n << 24);
|
|
ring.Write (cmd);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|