diff options
Diffstat (limited to 'quantum/light_ws2812.c')
| -rwxr-xr-x | quantum/light_ws2812.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c index f20043067..401845e85 100755 --- a/quantum/light_ws2812.c +++ b/quantum/light_ws2812.c | |||
| @@ -19,12 +19,16 @@ | |||
| 19 | // Setleds for standard RGB | 19 | // Setleds for standard RGB |
| 20 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) | 20 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) |
| 21 | { | 21 | { |
| 22 | ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); | 22 | // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); |
| 23 | ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF)); | ||
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pinmask) | 26 | void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pinmask) |
| 26 | { | 27 | { |
| 27 | ws2812_DDRREG |= pinmask; // Enable DDR | 28 | // ws2812_DDRREG |= pinmask; // Enable DDR |
| 29 | // new universal format (DDR) | ||
| 30 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask; | ||
| 31 | |||
| 28 | ws2812_sendarray_mask((uint8_t*)ledarray,leds+leds+leds,pinmask); | 32 | ws2812_sendarray_mask((uint8_t*)ledarray,leds+leds+leds,pinmask); |
| 29 | _delay_us(50); | 33 | _delay_us(50); |
| 30 | } | 34 | } |
| @@ -32,14 +36,17 @@ void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pin | |||
| 32 | // Setleds for SK6812RGBW | 36 | // Setleds for SK6812RGBW |
| 33 | void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) | 37 | void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) |
| 34 | { | 38 | { |
| 35 | ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR | 39 | // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR |
| 36 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(ws2812_pin)); | 40 | // new universal format (DDR) |
| 41 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF); | ||
| 42 | |||
| 43 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); | ||
| 37 | _delay_us(80); | 44 | _delay_us(80); |
| 38 | } | 45 | } |
| 39 | 46 | ||
| 40 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) | 47 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) |
| 41 | { | 48 | { |
| 42 | ws2812_sendarray_mask(data,datlen,_BV(ws2812_pin)); | 49 | ws2812_sendarray_mask(data,datlen,_BV(RGB_DI_PIN & 0xF)); |
| 43 | } | 50 | } |
| 44 | 51 | ||
| 45 | /* | 52 | /* |
| @@ -108,8 +115,10 @@ void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi) | |||
| 108 | uint8_t curbyte,ctr,masklo; | 115 | uint8_t curbyte,ctr,masklo; |
| 109 | uint8_t sreg_prev; | 116 | uint8_t sreg_prev; |
| 110 | 117 | ||
| 111 | masklo =~maskhi&ws2812_PORTREG; | 118 | // masklo =~maskhi&ws2812_PORTREG; |
| 112 | maskhi |= ws2812_PORTREG; | 119 | // maskhi |= ws2812_PORTREG; |
| 120 | masklo =~maskhi&_SFR_IO8((RGB_DI_PIN >> 4) + 2); | ||
| 121 | maskhi |= _SFR_IO8((RGB_DI_PIN >> 4) + 2); | ||
| 113 | sreg_prev=SREG; | 122 | sreg_prev=SREG; |
| 114 | cli(); | 123 | cli(); |
| 115 | 124 | ||
| @@ -173,7 +182,7 @@ w_nop16 | |||
| 173 | " dec %0 \n\t" // '1' [+2] '0' [+2] | 182 | " dec %0 \n\t" // '1' [+2] '0' [+2] |
| 174 | " brne loop%=\n\t" // '1' [+3] '0' [+4] | 183 | " brne loop%=\n\t" // '1' [+3] '0' [+4] |
| 175 | : "=&d" (ctr) | 184 | : "=&d" (ctr) |
| 176 | : "r" (curbyte), "I" (_SFR_IO_ADDR(ws2812_PORTREG)), "r" (maskhi), "r" (masklo) | 185 | : "r" (curbyte), "I" (_SFR_IO_ADDR(_SFR_IO8((RGB_DI_PIN >> 4) + 2))), "r" (maskhi), "r" (masklo) |
| 177 | ); | 186 | ); |
| 178 | } | 187 | } |
| 179 | 188 | ||
