/*** Neopixels ***/
#define NPIX_PERIOD 90 // timer runs on 72 MHz, so 90 periods = 1250 ns
-#define NPIX_RESET 10 // length of reset pulse in LED slots
+#define NPIX_RESET 19 // length of reset pulse in LED slots (24 periods)
// The chip needs longer reset pulse than documented.
-#define B0 30
+#define B0 30 // Right length should be 32 and 64
#define B1 60
static byte neopixel_leds[NPIX_NUM_LEDS][3];
if (neopixel_index < NPIX_NUM_LEDS) {
byte *led = neopixel_leds[neopixel_index++];
byte r = led[0], g = led[1], b = led[2];
- for (uint m=0x80; m; m >>= 1)
- *buf++ = (g & m) ? B1 : B0;
for (uint m=0x80; m; m >>= 1)
*buf++ = (r & m) ? B1 : B0;
+ for (uint m=0x80; m; m >>= 1)
+ *buf++ = (g & m) ? B1 : B0;
for (uint m=0x80; m; m >>= 1)
*buf++ = (b & m) ? B1 : B0;
} else {
/*** Effects ***/
-#if 1
+#if 0
static void effect(void)
{
static u32 last_update = 0;
static byte b = 0;
- if (ms_ticks - last_update < 60)
+ if (ms_ticks - last_update < 40)
return;
last_update = ms_ticks;
for (uint j=0; j < NPIX_NUM_LEDS; j++)
neopixel_set(j, neopixel_leds[j][0]*DIM, neopixel_leds[j][1]*DIM, neopixel_leds[j][2]*DIM);
- for (uint k=0; k<NPIX_NUM_LEDS/3; k++) {
- neopixel_set((b + 30*k) % NPIX_NUM_LEDS, 255, 3*k, k/5);
+ for (uint k=0; k<NPIX_NUM_LEDS/30; k++) {
+ neopixel_set((b + 30*k) % NPIX_NUM_LEDS, k/5, 3*k, 255);
}
b = (b + 1) % NPIX_NUM_LEDS;
}
static uint i;
neopixel_set(i, 0, 0, 7);
i = (i+1) % NPIX_NUM_LEDS;
- neopixel_set(i, 0, 255, 0);
+ neopixel_set(i, 255, 0, 0);
}
#endif
}