diff options
Diffstat (limited to 'quantum/light_ws2812.c')
| -rwxr-xr-x | quantum/light_ws2812.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c index 497543339..6edbc0f2b 100755 --- a/quantum/light_ws2812.c +++ b/quantum/light_ws2812.c | |||
| @@ -133,13 +133,13 @@ unsigned char I2C_Write(unsigned char c) | |||
| 133 | #endif | 133 | #endif |
| 134 | 134 | ||
| 135 | // Setleds for standard RGB | 135 | // Setleds for standard RGB |
| 136 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) | 136 | void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) |
| 137 | { | 137 | { |
| 138 | // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); | 138 | // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); |
| 139 | ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF)); | 139 | ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF)); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pinmask) | 142 | void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask) |
| 143 | { | 143 | { |
| 144 | // ws2812_DDRREG |= pinmask; // Enable DDR | 144 | // ws2812_DDRREG |= pinmask; // Enable DDR |
| 145 | // new universal format (DDR) | 145 | // new universal format (DDR) |
| @@ -150,12 +150,15 @@ void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pin | |||
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | // Setleds for SK6812RGBW | 152 | // Setleds for SK6812RGBW |
| 153 | void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) | 153 | void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) |
| 154 | { | 154 | { |
| 155 | 155 | ||
| 156 | #ifdef RGBW_BB_TWI | 156 | #ifdef RGBW_BB_TWI |
| 157 | uint8_t sreg_prev, twcr_prev; | ||
| 158 | sreg_prev=SREG; | ||
| 159 | twcr_prev=TWCR; | ||
| 157 | cli(); | 160 | cli(); |
| 158 | TWCR = 0; | 161 | TWCR &= ~(1<<TWEN); |
| 159 | I2C_Init(); | 162 | I2C_Init(); |
| 160 | I2C_Start(); | 163 | I2C_Start(); |
| 161 | I2C_Write(0x84); | 164 | I2C_Write(0x84); |
| @@ -167,9 +170,9 @@ void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) | |||
| 167 | I2C_Write(curbyte); | 170 | I2C_Write(curbyte); |
| 168 | } | 171 | } |
| 169 | I2C_Stop(); | 172 | I2C_Stop(); |
| 170 | sei(); | 173 | SREG=sreg_prev; |
| 171 | #else | 174 | // TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN); |
| 172 | _delay_us(80); | 175 | TWCR=twcr_prev; |
| 173 | #endif | 176 | #endif |
| 174 | 177 | ||
| 175 | 178 | ||
| @@ -180,7 +183,9 @@ void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) | |||
| 180 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); | 183 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); |
| 181 | 184 | ||
| 182 | 185 | ||
| 183 | 186 | #ifndef RGBW_BB_TWI | |
| 187 | _delay_us(80); | ||
| 188 | #endif | ||
| 184 | } | 189 | } |
| 185 | 190 | ||
| 186 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) | 191 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) |
