From f44887d477606ac17f5aa7072162c87bc548dd3e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Mare=C5=A1?= Date: Wed, 24 Dec 2025 16:18:18 +0100 Subject: [PATCH] X-mas: WIP as always --- xmas-lights/firmware/interface.h | 2 +- xmas-lights/firmware/main.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/xmas-lights/firmware/interface.h b/xmas-lights/firmware/interface.h index 7068e16..09a2533 100644 --- a/xmas-lights/firmware/interface.h +++ b/xmas-lights/firmware/interface.h @@ -8,4 +8,4 @@ #define NPIX_USB_PRODUCT 0x0015 #define NPIX_USB_VERSION 0x0100 -#define NPIX_NUM_LEDS 150 +#define NPIX_NUM_LEDS 131 diff --git a/xmas-lights/firmware/main.c b/xmas-lights/firmware/main.c index 3c69751..5e12ba7 100644 --- a/xmas-lights/firmware/main.c +++ b/xmas-lights/firmware/main.c @@ -95,9 +95,9 @@ static void delay_ms(uint ms) /*** 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]; @@ -169,10 +169,10 @@ static inline void next_led(byte *buf) 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 { @@ -396,7 +396,7 @@ static void usb_init(void) /*** Effects ***/ -#if 1 +#if 0 static void effect(void) { @@ -423,7 +423,7 @@ 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; @@ -432,8 +432,8 @@ static void effect(void) 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