[MERGE][Core] Add dirty chunk checking for all RGB and LED drivers (24872)
This commit is contained in:
parent
0324612c37
commit
4a138dd93c
28 changed files with 690 additions and 286 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <util/delay.h>
|
||||
#include "ws2812.h"
|
||||
#include "pin_defs.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define pinmask(pin) (_BV((pin)&0xF))
|
||||
|
||||
|
@ -152,6 +153,7 @@ static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t
|
|||
}
|
||||
|
||||
ws2812_led_t ws2812_leds[WS2812_LED_COUNT];
|
||||
bool ws2812_dirty = false;
|
||||
|
||||
void ws2812_init(void) {
|
||||
DDRx_ADDRESS(WS2812_DI_PIN) |= pinmask(WS2812_DI_PIN);
|
||||
|
@ -161,6 +163,7 @@ void ws2812_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
|||
ws2812_leds[index].r = red;
|
||||
ws2812_leds[index].g = green;
|
||||
ws2812_leds[index].b = blue;
|
||||
ws2812_dirty = true;
|
||||
#if defined(WS2812_RGBW)
|
||||
ws2812_rgb_to_rgbw(&ws2812_leds[index]);
|
||||
#endif
|
||||
|
@ -173,6 +176,8 @@ void ws2812_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
|||
}
|
||||
|
||||
void ws2812_flush(void) {
|
||||
if (!ws2812_dirty) return;
|
||||
ws2812_dirty = false;
|
||||
uint8_t masklo = ~(pinmask(WS2812_DI_PIN)) & PORTx_ADDRESS(WS2812_DI_PIN);
|
||||
uint8_t maskhi = pinmask(WS2812_DI_PIN) | PORTx_ADDRESS(WS2812_DI_PIN);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2024 QMK
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "ws2812.h"
|
||||
#include "i2c_master.h"
|
||||
|
||||
|
@ -17,6 +18,7 @@
|
|||
#endif
|
||||
|
||||
ws2812_led_t ws2812_leds[WS2812_LED_COUNT];
|
||||
bool ws2812_dirty = false;
|
||||
|
||||
void ws2812_init(void) {
|
||||
i2c_init();
|
||||
|
@ -26,6 +28,7 @@ void ws2812_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
|
|||
ws2812_leds[index].r = red;
|
||||
ws2812_leds[index].g = green;
|
||||
ws2812_leds[index].b = blue;
|
||||
ws2812_dirty = true;
|
||||
}
|
||||
|
||||
void ws2812_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
|
@ -35,5 +38,7 @@ void ws2812_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
|
|||
}
|
||||
|
||||
void ws2812_flush(void) {
|
||||
if (!ws2812_dirty) return;
|
||||
ws2812_dirty = false;
|
||||
i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ws2812_leds, WS2812_LED_COUNT * sizeof(ws2812_led_t), WS2812_I2C_TIMEOUT);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue