1
0
Fork 0
forked from forks/qmk_firmware

Clean up RGB LED type (#21859)

This commit is contained in:
Ryan 2023-09-04 10:19:59 +10:00 committed by GitHub
parent 1e3095f9cc
commit 41bd4e35a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
63 changed files with 222 additions and 243 deletions

View file

@ -370,9 +370,9 @@ If you need to change your RGB lighting in code, for example in a macro to chang
Example:
```c
sethsv(HSV_WHITE, (LED_TYPE *)&led[0]); // led 0
sethsv(HSV_RED, (LED_TYPE *)&led[1]); // led 1
sethsv(HSV_GREEN, (LED_TYPE *)&led[2]); // led 2
sethsv(HSV_WHITE, (rgb_led_t *)&led[0]); // led 0
sethsv(HSV_RED, (rgb_led_t *)&led[1]); // led 1
sethsv(HSV_GREEN, (rgb_led_t *)&led[2]); // led 2
rgblight_set(); // Utility functions do not call rgblight_set() automatically, so they need to be called explicitly.
```

View file

@ -61,18 +61,18 @@ void static apa102_end_frame(uint16_t num_leds);
void static apa102_send_frame(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness);
void static apa102_send_byte(uint8_t byte);
void apa102_setleds(LED_TYPE *start_led, uint16_t num_leds) {
LED_TYPE *end = start_led + num_leds;
void apa102_setleds(rgb_led_t *start_led, uint16_t num_leds) {
rgb_led_t *end = start_led + num_leds;
apa102_start_frame();
for (LED_TYPE *led = start_led; led < end; led++) {
for (rgb_led_t *led = start_led; led < end; led++) {
apa102_send_frame(led->r, led->g, led->b, apa102_led_brightness);
}
apa102_end_frame(num_leds);
}
// Overwrite the default rgblight_call_driver to use apa102 driver
void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) {
void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds) {
apa102_setleds(start_led, num_leds);
}

View file

@ -37,5 +37,5 @@ extern uint8_t apa102_led_brightness;
* - Set the data-out pin as output
* - Send out the LED data
*/
void apa102_setleds(LED_TYPE *start_led, uint16_t num_leds);
void apa102_setleds(rgb_led_t *start_led, uint16_t num_leds);
void apa102_set_brightness(uint8_t brightness);

View file

@ -73,4 +73,4 @@
* - Send out the LED data
* - Wait 50us to reset the LEDs
*/
void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
void ws2812_setleds(rgb_led_t *ledarray, uint16_t number_of_leds);

View file

@ -7,7 +7,7 @@
#include "color.h"
static inline void rgblite_setrgb(RGB rgb) {
LED_TYPE leds[RGBLED_NUM] = {{.r = rgb.r, .g = rgb.g, .b = rgb.b}};
rgb_led_t leds[RGBLED_NUM] = {{.r = rgb.r, .g = rgb.g, .b = rgb.b}};
ws2812_setleds(leds, RGBLED_NUM);
}

View file

@ -7,7 +7,7 @@
#include "color.h"
static inline void rgblite_setrgb(RGB rgb) {
LED_TYPE leds[RGBLED_NUM] = {{.r = rgb.r, .g = rgb.g, .b = rgb.b}};
rgb_led_t leds[RGBLED_NUM] = {{.r = rgb.r, .g = rgb.g, .b = rgb.b}};
ws2812_setleds(leds, RGBLED_NUM);
}

View file

@ -85,7 +85,7 @@ uint8_t remap[16] = {
void refresh_leds(void) {
for (uint8_t index = 0; index < 16; ++index) {
uint8_t tile = tiles[index];
setrgb(r[tile], g[tile], b[tile], (LED_TYPE *)&led[remap[index]]);
setrgb(r[tile], g[tile], b[tile], (rgb_led_t *)&led[remap[index]]);
}
rgblight_set();
}

View file

@ -341,10 +341,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
//キー毎に時間差で色が変化していく
if (aqours_next_color_timer_count % NEXT_CHANGE_TARGET_TIME == 0) {
if (target_col < MATRIX_COLS) {
sethsv(aqours_h[aqours_num], aqours_s[aqours_num], aqours_v[aqours_num], (LED_TYPE *)&led[target_col]);
sethsv(aqours_h[aqours_num], aqours_s[aqours_num], aqours_v[aqours_num], (LED_TYPE *)&led[11 - target_col]);
sethsv(aqours_h[aqours_num], aqours_s[aqours_num], aqours_v[aqours_num], (LED_TYPE *)&led[12 + target_col]);
sethsv(aqours_h[aqours_num], aqours_s[aqours_num], aqours_v[aqours_num], (LED_TYPE *)&led[23 - target_col]);
sethsv(aqours_h[aqours_num], aqours_s[aqours_num], aqours_v[aqours_num], (rgb_led_t *)&led[target_col]);
sethsv(aqours_h[aqours_num], aqours_s[aqours_num], aqours_v[aqours_num], (rgb_led_t *)&led[11 - target_col]);
sethsv(aqours_h[aqours_num], aqours_s[aqours_num], aqours_v[aqours_num], (rgb_led_t *)&led[12 + target_col]);
sethsv(aqours_h[aqours_num], aqours_s[aqours_num], aqours_v[aqours_num], (rgb_led_t *)&led[23 - target_col]);
target_col++;
rgblight_set();
}

View file

@ -172,7 +172,7 @@ void clueboard_set_midi_led(uint8_t base_oct, uint8_t val)
uint8_t sat = 255;
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
sethsv(oct_hues[base_oct], sat, val, (LED_TYPE *)&led[i]);
sethsv(oct_hues[base_oct], sat, val, (rgb_led_t *)&led[i]);
}
uint8_t next_oct = base_oct < MAX_OCT ? base_oct + 1 : base_oct;
@ -183,11 +183,11 @@ void clueboard_set_midi_led(uint8_t base_oct, uint8_t val)
for (uint8_t i = 0; i < 3; i++) {
sethsv(next_hue, next_sat, next_val, (LED_TYPE *)&led[i]);
sethsv(next_hue, next_sat, next_val, (rgb_led_t *)&led[i]);
}
for (uint8_t i = 11; i < 14; i++) {
sethsv(next_hue, next_sat, next_val, (LED_TYPE *)&led[i]);
sethsv(next_hue, next_sat, next_val, (rgb_led_t *)&led[i]);
}
rgblight_set();

View file

@ -70,9 +70,9 @@ void keyboard_post_init_user(void) {
extern rgblight_config_t rgblight_config;
extern void rgblight_layers_write(void);
extern void indicator_write(LED_TYPE *start_led, uint8_t num_leds);
extern void indicator_write(rgb_led_t *start_led, uint8_t num_leds);
void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds)
void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds)
{
ws2812_setleds(start_led, RGBLED_NUM-RGB_INDICATOR_NUM);

View file

@ -20,7 +20,7 @@
#define ws2812_setleds_pin indicator_setleds_pin
#include "ws2812_bitbang.c"
void indicator_write(LED_TYPE *start_led, uint8_t num_leds)
void indicator_write(rgb_led_t *start_led, uint8_t num_leds)
{
indicator_setleds(start_led, num_leds);
}

View file

@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "ergodox_ez.h"
void rgblight_call_driver(LED_TYPE *led, uint8_t led_num) {
void rgblight_call_driver(rgb_led_t *led, uint8_t led_num) {
i2c_init();
i2c_start(0x84, ERGODOX_EZ_I2C_TIMEOUT);
int i = 0;

View file

@ -154,15 +154,15 @@ int aqours_color_v[] = {255, 255, 255, 255, 255, 255, 200, 255, 255};
void LED_default_set(void) {
sethsv(aqours_color_h[2], aqours_color_s[2], aqours_color_v[2], (LED_TYPE *)&led[0]);
sethsv(aqours_color_h[7], aqours_color_s[7], aqours_color_v[7], (LED_TYPE *)&led[1]);
sethsv(aqours_color_h[1], aqours_color_s[1], aqours_color_v[1], (LED_TYPE *)&led[2]);
sethsv(aqours_color_h[5], aqours_color_s[5], aqours_color_v[5], (LED_TYPE *)&led[3]);
sethsv(aqours_color_h[8], aqours_color_s[8], aqours_color_v[8], (LED_TYPE *)&led[4]);
sethsv(aqours_color_h[6], aqours_color_s[6], aqours_color_v[6], (LED_TYPE *)&led[5]);
sethsv(aqours_color_h[0], aqours_color_s[0], aqours_color_v[0], (LED_TYPE *)&led[6]);
sethsv(aqours_color_h[4], aqours_color_s[4], aqours_color_v[4], (LED_TYPE *)&led[7]);
sethsv(aqours_color_h[3], aqours_color_s[3], aqours_color_v[3], (LED_TYPE *)&led[8]);
sethsv(aqours_color_h[2], aqours_color_s[2], aqours_color_v[2], (rgb_led_t *)&led[0]);
sethsv(aqours_color_h[7], aqours_color_s[7], aqours_color_v[7], (rgb_led_t *)&led[1]);
sethsv(aqours_color_h[1], aqours_color_s[1], aqours_color_v[1], (rgb_led_t *)&led[2]);
sethsv(aqours_color_h[5], aqours_color_s[5], aqours_color_v[5], (rgb_led_t *)&led[3]);
sethsv(aqours_color_h[8], aqours_color_s[8], aqours_color_v[8], (rgb_led_t *)&led[4]);
sethsv(aqours_color_h[6], aqours_color_s[6], aqours_color_v[6], (rgb_led_t *)&led[5]);
sethsv(aqours_color_h[0], aqours_color_s[0], aqours_color_v[0], (rgb_led_t *)&led[6]);
sethsv(aqours_color_h[4], aqours_color_s[4], aqours_color_v[4], (rgb_led_t *)&led[7]);
sethsv(aqours_color_h[3], aqours_color_s[3], aqours_color_v[3], (rgb_led_t *)&led[8]);
rgblight_set();
@ -171,7 +171,7 @@ void LED_default_set(void) {
void LED_layer_set(int aqours_index) {
for (int c = 0; c < 9; c++) {
sethsv(aqours_color_h[aqours_index], aqours_color_s[aqours_index], aqours_color_v[aqours_index], (LED_TYPE *)&led[c]);
sethsv(aqours_color_h[aqours_index], aqours_color_s[aqours_index], aqours_color_v[aqours_index], (rgb_led_t *)&led[c]);
}
rgblight_set();
}

View file

@ -1,7 +1,7 @@
#include "ws2812.h"
#include "rgbsps.h"
cRGB led[RGBSPS_NUM];
rgb_led_t led[RGBSPS_NUM];
void rgbsps_set(uint8_t index, uint8_t r, uint8_t g, uint8_t b) {
led[index].r = r;

View file

@ -49,19 +49,19 @@ bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if (res) {
if (led_state.caps_lock) {
sethsv_raw(HSV_CAPS, (LED_TYPE *)&led[0]);
sethsv_raw(HSV_CAPS, (rgb_led_t *)&led[0]);
} else {
sethsv(HSV_BLACK, (LED_TYPE *)&led[0]);
sethsv(HSV_BLACK, (rgb_led_t *)&led[0]);
}
if (led_state.num_lock) {
sethsv_raw(HSV_NLCK, (LED_TYPE *)&led[1]);
sethsv_raw(HSV_NLCK, (rgb_led_t *)&led[1]);
} else {
sethsv(HSV_BLACK, (LED_TYPE *)&led[1]);
sethsv(HSV_BLACK, (rgb_led_t *)&led[1]);
}
if (led_state.scroll_lock) {
sethsv_raw(HSV_SCRL, (LED_TYPE *)&led[2]);
sethsv_raw(HSV_SCRL, (rgb_led_t *)&led[2]);
} else {
sethsv(HSV_BLACK, (LED_TYPE *)&led[2]);
sethsv(HSV_BLACK, (rgb_led_t *)&led[2]);
}
rgblight_set();
}
@ -83,7 +83,7 @@ void keyboard_post_init_user(void) {
__attribute__ ((weak))
void hbcp_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) {
LED_TYPE tmp_led;
rgb_led_t tmp_led;
sethsv_raw(hue, sat, val, &tmp_led);
for (uint8_t i = start; i < end; i++) {
led[i] = tmp_led;

View file

@ -79,19 +79,19 @@ void matrix_scan_user(void) {
// The first three LEDs are used as indicators for CAPS_LOCK, NUM_LOCK and SCROLL_LOCK.
bool led_update_user(led_t led_state) {
if (led_state.caps_lock) {
sethsv_raw(HSV_SOFT_RED, (LED_TYPE *)&led[0]);
sethsv_raw(HSV_SOFT_RED, (rgb_led_t *)&led[0]);
} else {
sethsv(HSV_BLACK, (LED_TYPE *)&led[0]);
sethsv(HSV_BLACK, (rgb_led_t *)&led[0]);
}
if (led_state.num_lock) {
sethsv_raw(HSV_WARM_WHITE, (LED_TYPE *)&led[1]);
sethsv_raw(HSV_WARM_WHITE, (rgb_led_t *)&led[1]);
} else {
sethsv(HSV_BLACK, (LED_TYPE *)&led[1]);
sethsv(HSV_BLACK, (rgb_led_t *)&led[1]);
}
if (led_state.scroll_lock) {
sethsv_raw(HSV_SOFT_BLUE, (LED_TYPE *)&led[2]);
sethsv_raw(HSV_SOFT_BLUE, (rgb_led_t *)&led[2]);
} else {
sethsv(HSV_BLACK, (LED_TYPE *)&led[2]);
sethsv(HSV_BLACK, (rgb_led_t *)&led[2]);
}
rgblight_set();
return false;

View file

@ -39,26 +39,26 @@ static uint8_t isRecording = 0;
# if RGBLED_NUM < 3
# error we need at least 3 RGB LEDs!
# endif
static cRGB led[RGBLED_NUM] = {{255, 255, 255}, {255, 255, 255}, {255, 255, 255}};
static rgb_led_t led[RGBLED_NUM] = {{255, 255, 255}, {255, 255, 255}, {255, 255, 255}};
# define BRIGHT 32
# define DIM 6
static const cRGB black = {.r = 0, .g = 0, .b = 0};
static const rgb_led_t black = {.r = 0, .g = 0, .b = 0};
static const __attribute__((unused)) cRGB green = {.r = 0, .g = BRIGHT, .b = 0};
static const __attribute__((unused)) cRGB lgreen = {.r = 0, .g = DIM, .b = 0};
static const __attribute__((unused)) rgb_led_t green = {.r = 0, .g = BRIGHT, .b = 0};
static const __attribute__((unused)) rgb_led_t lgreen = {.r = 0, .g = DIM, .b = 0};
static const __attribute__((unused)) cRGB red = {.r = BRIGHT, .g = 0, .b = 0};
static const __attribute__((unused)) cRGB lred = {.r = DIM, .g = 0, .b = 0};
static const __attribute__((unused)) rgb_led_t red = {.r = BRIGHT, .g = 0, .b = 0};
static const __attribute__((unused)) rgb_led_t lred = {.r = DIM, .g = 0, .b = 0};
static const __attribute__((unused)) cRGB blue = {.r = 0, .g = 0, .b = BRIGHT};
static const __attribute__((unused)) cRGB lblue = {.r = 0, .g = 0, .b = DIM};
static const __attribute__((unused)) rgb_led_t blue = {.r = 0, .g = 0, .b = BRIGHT};
static const __attribute__((unused)) rgb_led_t lblue = {.r = 0, .g = 0, .b = DIM};
static const __attribute__((unused)) cRGB turq = {.r = 0, .g = BRIGHT, .b = BRIGHT};
static const __attribute__((unused)) cRGB lturq = {.r = 0, .g = DIM, .b = DIM};
static const __attribute__((unused)) rgb_led_t turq = {.r = 0, .g = BRIGHT, .b = BRIGHT};
static const __attribute__((unused)) rgb_led_t lturq = {.r = 0, .g = DIM, .b = DIM};
static const __attribute__((unused)) cRGB white = {.r = BRIGHT, .g = BRIGHT, .b = BRIGHT};
static const __attribute__((unused)) rgb_led_t white = {.r = BRIGHT, .g = BRIGHT, .b = BRIGHT};
static led_t led_state;
static uint8_t layer;

View file

@ -162,7 +162,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/** Set just 4 LEDs closest to the user. Slightly less annoying to bystanders.*/
void rgbflag(uint8_t r, uint8_t g, uint8_t b, uint8_t rr, uint8_t gg, uint8_t bb) {
LED_TYPE *target_led = user_rgb_mode ? shadowed_led : led;
rgb_led_t *target_led = user_rgb_mode ? shadowed_led : led;
for (int i = 0; i < RGBLED_NUM; i++) {
switch (i) {
case 12: case 13:

View file

@ -157,7 +157,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
#define C_ORG 0xFF, 0x93, 0x00
void rgbflag(uint8_t r, uint8_t g, uint8_t b, uint8_t rr, uint8_t gg, uint8_t bb) {
LED_TYPE *target_led = user_rgb_mode ? shadowed_led : led;
rgb_led_t *target_led = user_rgb_mode ? shadowed_led : led;
for (int i = 0; i < RGBLED_NUM; i++) {
switch (i) {
case 10: case 11:

View file

@ -217,7 +217,7 @@ void keyboard_post_init_user(void) {
rgblight_sethsv_noeeprom(50, 255, 100);
rgblight_mode_noeeprom(RGBLIGHT_EFFECT_BREATHING + 2);
// Init the second LED to a static color:
setrgb(225, 185, 0, (LED_TYPE *)&led[1]);
setrgb(225, 185, 0, (rgb_led_t *)&led[1]);
rgblight_set();
#endif // RGBLIGHT_ENABLE
}
@ -232,7 +232,7 @@ layer_state_t layer_state_set_user(layer_state_t state){
if (layer_state_cmp(state, 3)) {
led1r = 200;
}
setrgb(led1r, led1g, led1b, (LED_TYPE *)&led[1]);
setrgb(led1r, led1g, led1b, (rgb_led_t *)&led[1]);
rgblight_set();
#endif //RGBLIGHT_ENABLE
return state;

View file

@ -217,7 +217,7 @@ void keyboard_post_init_user(void) {
rgblight_sethsv_noeeprom(50, 255, 100);
rgblight_mode_noeeprom(RGBLIGHT_EFFECT_BREATHING + 2);
// Init the second LED to a static color:
setrgb(225, 185, 0, (LED_TYPE *)&led[1]);
setrgb(225, 185, 0, (rgb_led_t *)&led[1]);
rgblight_set();
#endif // RGBLIGHT_ENABLE
}
@ -232,7 +232,7 @@ layer_state_t layer_state_set_user(layer_state_t state){
if (layer_state_cmp(state, 3)) {
led1r = 200;
}
setrgb(led1r, led1g, led1b, (LED_TYPE *)&led[1]);
setrgb(led1r, led1g, led1b, (rgb_led_t *)&led[1]);
rgblight_set();
#endif //RGBLIGHT_ENABLE
return state;

View file

@ -148,7 +148,7 @@ bool rgb_matrix_indicators_kb(void) {
// ==========================================================================
# if WS2812_LED_TOTAL > 0
LED_TYPE rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
# endif
static void rgb_matrix_driver_init(void) {

View file

@ -148,7 +148,7 @@ bool rgb_matrix_indicators_kb(void) {
// ==========================================================================
# if WS2812_LED_TOTAL > 0
LED_TYPE rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
# endif
static void rgb_matrix_driver_init(void) {

View file

@ -144,7 +144,7 @@ bool rgb_matrix_indicators_kb(void) {
// ==========================================================================
# if WS2812_LED_TOTAL > 0
LED_TYPE rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
# endif
static void rgb_matrix_driver_init(void) {

View file

@ -41,15 +41,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case 0:
sethsv(HSV_WHITE, (LED_TYPE *)&led[0]);
sethsv(HSV_WHITE, (rgb_led_t *)&led[0]);
rgblight_set();
break;
case 1:
sethsv(HSV_GREEN, (LED_TYPE *)&led[0]);
sethsv(HSV_GREEN, (rgb_led_t *)&led[0]);
rgblight_set();
break;
case 2:
sethsv(HSV_BLUE, (LED_TYPE *)&led[0]);
sethsv(HSV_BLUE, (rgb_led_t *)&led[0]);
rgblight_set();
break;
}

View file

@ -41,15 +41,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case 0:
sethsv(HSV_WHITE, (LED_TYPE *)&led[0]);
sethsv(HSV_WHITE, (rgb_led_t *)&led[0]);
rgblight_set();
break;
case 1:
sethsv(HSV_GREEN, (LED_TYPE *)&led[0]);
sethsv(HSV_GREEN, (rgb_led_t *)&led[0]);
rgblight_set();
break;
case 2:
sethsv(HSV_BLUE, (LED_TYPE *)&led[0]);
sethsv(HSV_BLUE, (rgb_led_t *)&led[0]);
rgblight_set();
break;
}

View file

@ -66,7 +66,7 @@ const aw9523b_led g_aw9523b_leds[AW9523B_RGB_NUM] = {
{AW9523B_P07_PWM, AW9523B_P06_PWM, AW9523B_P05_PWM},
};
void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds)
void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds)
{
uint8_t num = num_leds < AW9523B_RGB_NUM ? num_leds : AW9523B_RGB_NUM;

View file

@ -357,7 +357,7 @@ static void custom_effects(void)
effect_funcs[rgb_ring.effect]();
}
void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds)
void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds)
{
if (rgb_ring.state != RING_STATE_QMK) {
return;

View file

@ -20,7 +20,7 @@ extern rgblight_config_t rgblight_config;
#if RGBLED_NUM < 7
#error "MUST set the RGBLED_NUM bigger than 7"
#endif
LED_TYPE noah_leds[RGBLED_NUM];
rgb_led_t noah_leds[RGBLED_NUM];
static bool noah_led_mode = false;
void rgblight_set(void) {
memset(&noah_leds[0], 0, sizeof(noah_leds));

View file

@ -25,7 +25,7 @@
// Variables for controlling front LED application
uint8_t fled_mode; // Mode for front LEDs
uint8_t fled_val; // Brightness for front leds (0 - 255)
LED_TYPE fleds[2]; // Front LED rgb values for indicator mode use
rgb_led_t fleds[2]; // Front LED rgb values for indicator mode use
// Layer indicator colors
__attribute__ ((weak))

View file

@ -98,7 +98,7 @@ animation_status_t animation_status = {};
#endif
#ifndef LED_ARRAY
LED_TYPE led[RGBLED_NUM];
rgb_led_t led[RGBLED_NUM];
# define LED_ARRAY led
#endif
@ -111,10 +111,10 @@ rgblight_ranges_t rgblight_ranges = {0, RGBLED_NUM, 0, RGBLED_NUM, RGBLED_NUM};
// MxSS custom
extern uint8_t fled_mode;
extern uint8_t fled_val;
extern LED_TYPE fleds[2];
extern rgb_led_t fleds[2];
hs_set fled_hs[2];
void copyrgb(LED_TYPE *src, LED_TYPE *dst) {
void copyrgb(rgb_led_t *src, rgb_led_t *dst) {
dst->r = src->r;
dst->g = src->g;
dst->b = src->b;
@ -135,7 +135,7 @@ void rgblight_set_effect_range(uint8_t start_pos, uint8_t num_leds) {
__attribute__((weak)) RGB rgblight_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv); }
void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1) {
HSV hsv = {hue, sat, val};
// MxSS custom
// if led is front leds, cache the hue and sat values
@ -150,9 +150,9 @@ void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
setrgb(rgb.r, rgb.g, rgb.b, led1);
}
void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { sethsv_raw(hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val, led1); }
void sethsv(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1) { sethsv_raw(hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val, led1); }
void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) {
void setrgb(uint8_t r, uint8_t g, uint8_t b, rgb_led_t *led1) {
led1->r = r;
led1->g = g;
led1->b = b;
@ -454,7 +454,7 @@ void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) {
fled_hs[0].hue = fled_hs[1].hue = hue;
fled_hs[0].sat = fled_hs[1].sat = sat;
LED_TYPE tmp_led;
rgb_led_t tmp_led;
sethsv(hue, sat, val, &tmp_led);
rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
}
@ -465,7 +465,7 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w
rgblight_status.base_mode = mode_base_table[rgblight_config.mode];
if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) {
// same static color
LED_TYPE tmp_led;
rgb_led_t tmp_led;
sethsv(hue, sat, val, &tmp_led);
// MxSS custom
@ -515,7 +515,7 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w
_hue = hue - _hue;
}
dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range);
sethsv(_hue, sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]);
sethsv(_hue, sat, val, (rgb_led_t *)&led[i + rgblight_ranges.effect_start_pos]);
}
rgblight_set();
}
@ -601,7 +601,7 @@ void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index) {
return;
}
LED_TYPE tmp_led;
rgb_led_t tmp_led;
sethsv(hue, sat, val, &tmp_led);
rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index);
}
@ -640,7 +640,7 @@ void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start,
return;
}
LED_TYPE tmp_led;
rgb_led_t tmp_led;
sethsv(hue, sat, val, &tmp_led);
rgblight_setrgb_range(tmp_led.r, tmp_led.g, tmp_led.b, start, end);
}
@ -702,8 +702,8 @@ static void rgblight_layers_write(void) {
break; // No more segments
}
// Write segment.count LEDs
LED_TYPE *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)];
for (LED_TYPE *led_ptr = &led[segment.index]; led_ptr < limit; led_ptr++) {
rgb_led_t *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)];
for (rgb_led_t *led_ptr = &led[segment.index]; led_ptr < limit; led_ptr++) {
sethsv(segment.hue, segment.sat, segment.val, led_ptr);
}
segment_ptr++;
@ -737,11 +737,11 @@ void rgblight_unblink_layers(void) {
#endif
__attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); }
__attribute__((weak)) void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds) { ws2812_setleds(start_led, num_leds); }
#ifndef RGBLIGHT_CUSTOM_DRIVER
void rgblight_set(void) {
LED_TYPE *start_led;
rgb_led_t *start_led;
uint8_t num_leds = rgblight_ranges.clipping_num_leds;
if (!rgblight_config.enable) {
@ -769,7 +769,7 @@ void rgblight_set(void) {
# endif
# ifdef RGBLIGHT_LED_MAP
LED_TYPE led0[RGBLED_NUM];
rgb_led_t led0[RGBLED_NUM];
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
led0[i] = led[pgm_read_byte(&led_map[i])];
}
@ -1089,7 +1089,7 @@ void rgblight_effect_rainbow_swirl(animation_status_t *anim) {
for (i = 0; i < rgblight_ranges.effect_num_leds; i++) {
hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / rgblight_ranges.effect_num_leds * i + anim->current_hue);
sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]);
sethsv(hue, rgblight_config.sat, rgblight_config.val, (rgb_led_t *)&led[i + rgblight_ranges.effect_start_pos]);
}
rgblight_set();
@ -1130,7 +1130,7 @@ void rgblight_effect_snake(animation_status_t *anim) {
fled_hs[0].sat = fled_hs[1].sat = 0;
for (i = 0; i < rgblight_ranges.effect_num_leds; i++) {
LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos;
rgb_led_t *ledp = led + i + rgblight_ranges.effect_start_pos;
ledp->r = 0;
ledp->g = 0;
ledp->b = 0;
@ -1203,7 +1203,7 @@ void rgblight_effect_knight(animation_status_t *anim) {
cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % rgblight_ranges.effect_num_leds + rgblight_ranges.effect_start_pos;
if (i >= low_bound && i <= high_bound) {
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]);
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (rgb_led_t *)&led[cur]);
} else {
// MxSS custom code
if (cur == RGBLIGHT_FLED1) {
@ -1262,7 +1262,7 @@ void rgblight_effect_christmas(animation_status_t *anim) {
for (i = 0; i < rgblight_ranges.effect_num_leds; i++) {
uint8_t local_hue = (i / RGBLIGHT_EFFECT_CHRISTMAS_STEP) % 2 ? hue : hue_green - hue;
sethsv(local_hue, rgblight_config.sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]);
sethsv(local_hue, rgblight_config.sat, val, (rgb_led_t *)&led[i + rgblight_ranges.effect_start_pos]);
}
rgblight_set();
@ -1285,7 +1285,7 @@ void rgblight_effect_rgbtest(animation_status_t *anim) {
uint8_t b;
if (maxval == 0) {
LED_TYPE tmp_led;
rgb_led_t tmp_led;
sethsv(0, 255, RGBLIGHT_LIMIT_VAL, &tmp_led);
maxval = tmp_led.r;
}
@ -1322,7 +1322,7 @@ void rgblight_effect_rgbtest(animation_status_t *anim) {
#ifdef RGBLIGHT_EFFECT_ALTERNATING
void rgblight_effect_alternating(animation_status_t *anim) {
for (int i = 0; i < rgblight_ranges.effect_num_leds; i++) {
LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos;
rgb_led_t *ledp = led + i + rgblight_ranges.effect_start_pos;
if (i < rgblight_ranges.effect_num_leds / 2 && anim->pos) {
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, ledp);
} else if (i >= rgblight_ranges.effect_num_leds / 2 && !anim->pos) {
@ -1383,7 +1383,7 @@ void rgblight_effect_twinkle(animation_status_t *anim) {
// This LED is off, and was NOT selected to start brightening
}
LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos;
rgb_led_t *ledp = led + i + rgblight_ranges.effect_start_pos;
sethsv(c->h, c->s, c->v, ledp);
}

View file

@ -322,7 +322,7 @@ void housekeeping_task_kb(void)
} else if (rgb_state.state == CAPS_ALERT) {
if (rgb_state.alert) {
is31fl3731_set_color_all(ALERM_LED_R, ALERM_LED_G, ALERM_LED_B);
LED_TYPE leds[4];
rgb_led_t leds[4];
for (int i = 0; i < 4; i++) {
leds[i].r = ALERM_LED_G;
leds[i].g = ALERM_LED_R;
@ -331,7 +331,7 @@ void housekeeping_task_kb(void)
ws2812_setleds(leds, 4);
} else {
is31fl3731_set_color_all(0, 0, 0);
LED_TYPE leds[4] = {0};
rgb_led_t leds[4] = {0};
ws2812_setleds(leds, 4);
}
@ -349,14 +349,14 @@ void housekeeping_task_kb(void)
housekeeping_task_user();
}
void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds)
void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds)
{
if (rgb_state.state != NORMAL) return;
for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
is31fl3731_set_color(i, start_led[i].r, start_led[i].g, start_led[i].b);
}
LED_TYPE leds[4];
rgb_led_t leds[4];
for (int i = 0; i < 4; i++) {
leds[i].r = start_led[RGB_MATRIX_LED_COUNT+i].g;
leds[i].g = start_led[RGB_MATRIX_LED_COUNT+i].r;

View file

@ -320,7 +320,7 @@ void housekeeping_task_kb(void)
self_testing();
} else if (rgb_state.state == CAPS_ALERT) {
//gold 0xFF, 0xD9, 0x00
LED_TYPE led = {
rgb_led_t led = {
.r = 0xFF,
//.g = 0xD9,
.g = 0xA5,
@ -351,7 +351,7 @@ void housekeeping_task_kb(void)
housekeeping_task_user();
}
void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds)
void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds)
{
if (rgb_state.state != NORMAL) return;

View file

@ -22,7 +22,7 @@
static bool alert = false;
static bool backup = false;
static LED_TYPE caps_led;
static rgb_led_t caps_led;
static uint16_t last_ticks = 0;
#define ALERT_INTERVAL 500
@ -66,7 +66,7 @@ void housekeeping_task_kb(void)
housekeeping_task_user();
}
void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds)
void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds)
{
start_led[2].r = start_led[0].r;
start_led[2].g = start_led[0].g;

View file

@ -22,13 +22,13 @@ void ws2812_init(void) {
}
// Setleds for standard RGB
void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) {
static bool s_init = false;
if (!s_init) {
ws2812_init();
s_init = true;
}
i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * (leds >> 1), WS2812_I2C_TIMEOUT);
i2c_transmit(WS2812_I2C_ADDRESS_RIGHT, (uint8_t *)ledarray+(sizeof(LED_TYPE) * (leds >> 1)), sizeof(LED_TYPE) * (leds - (leds >> 1)), WS2812_I2C_TIMEOUT);
i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(rgb_led_t) * (leds >> 1), WS2812_I2C_TIMEOUT);
i2c_transmit(WS2812_I2C_ADDRESS_RIGHT, (uint8_t *)ledarray+(sizeof(rgb_led_t) * (leds >> 1)), sizeof(rgb_led_t) * (leds - (leds >> 1)), WS2812_I2C_TIMEOUT);
}

View file

@ -22,7 +22,7 @@
# include "ws2812.h"
// LED color buffer
LED_TYPE rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
rgb_led_t rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
static void init(void) {}

View file

@ -94,40 +94,40 @@ void matrix_scan_user(void) {
uint16_t kc = keymap_key_to_keycode(layer, (keypos_t) {.row = 0, .col = i
});
if (kc == KC_TRNS) {
setrgb(5, 5, 5, (LED_TYPE * ) & led[j]); /* TRNS color 0-255*/
setrgb(5, 5, 5, (rgb_led_t * ) & led[j]); /* TRNS color 0-255*/
} else if (kc == KC_NO) {
setrgb(0, 0, 0, (LED_TYPE * ) & led[j]); /* NO color 0-255*/
setrgb(0, 0, 0, (rgb_led_t * ) & led[j]); /* NO color 0-255*/
} else {
if (layer == 1) {
setrgb(128, 64, 0, (LED_TYPE * ) & led[j]); /* 1 layer 0-255*/
setrgb(128, 64, 0, (rgb_led_t * ) & led[j]); /* 1 layer 0-255*/
} else if (layer == 2) {
setrgb(0, 64, 128, (LED_TYPE * ) & led[j]); /* 2*/
setrgb(0, 64, 128, (rgb_led_t * ) & led[j]); /* 2*/
} else if (layer == 3) {
setrgb(64, 128, 0, (LED_TYPE * ) & led[j]); /* 3*/
setrgb(64, 128, 0, (rgb_led_t * ) & led[j]); /* 3*/
} else if (layer == 4) {
setrgb(0, 128, 64, (LED_TYPE * ) & led[j]); /* 4*/
setrgb(0, 128, 64, (rgb_led_t * ) & led[j]); /* 4*/
} else if (layer == 5) {
setrgb(128, 0, 128, (LED_TYPE * ) & led[j]); /* 5*/
setrgb(128, 0, 128, (rgb_led_t * ) & led[j]); /* 5*/
} else if (layer == 6) {
setrgb(128, 0, 128, (LED_TYPE * ) & led[j]); /* 6*/
setrgb(128, 0, 128, (rgb_led_t * ) & led[j]); /* 6*/
} else if (layer == 7) {
setrgb(128, 128, 0, (LED_TYPE * ) & led[j]); /* 7*/
setrgb(128, 128, 0, (rgb_led_t * ) & led[j]); /* 7*/
} else if (layer == 8) {
setrgb(0, 128, 128, (LED_TYPE * ) & led[j]); /* 8*/
setrgb(0, 128, 128, (rgb_led_t * ) & led[j]); /* 8*/
} else if (layer == 9) {
setrgb(128, 192, 64, (LED_TYPE * ) & led[j]); /* 9*/
setrgb(128, 192, 64, (rgb_led_t * ) & led[j]); /* 9*/
} else if (layer == 10) {
setrgb(64, 192, 128, (LED_TYPE * ) & led[j]); /* 10*/
setrgb(64, 192, 128, (rgb_led_t * ) & led[j]); /* 10*/
} else if (layer == 11) {
setrgb(128, 64, 192, (LED_TYPE * ) & led[j]); /* 11*/
setrgb(128, 64, 192, (rgb_led_t * ) & led[j]); /* 11*/
} else if (layer == 12) {
setrgb(64, 128, 192, (LED_TYPE * ) & led[j]); /* 12*/
setrgb(64, 128, 192, (rgb_led_t * ) & led[j]); /* 12*/
} else if (layer == 13) {
setrgb(128, 192, 0, (LED_TYPE * ) & led[j]); /* 13*/
setrgb(128, 192, 0, (rgb_led_t * ) & led[j]); /* 13*/
} else if (layer == 14) {
setrgb(192, 0, 128, (LED_TYPE * ) & led[j]); /* 14*/
setrgb(192, 0, 128, (rgb_led_t * ) & led[j]); /* 14*/
} else if (layer == 15) {
setrgb(0, 192, 128, (LED_TYPE * ) & led[j]); /* 15*/
setrgb(0, 192, 128, (rgb_led_t * ) & led[j]); /* 15*/
}
}
}

View file

@ -180,8 +180,8 @@ void keyboard_post_init_user(void) {
rgblight_mode_noeeprom(RGBLIGHT_EFFECT_BREATHING + 2);
// set other led's to off
setrgb(0, 0, 0, (LED_TYPE *)&led[0]);
setrgb(0, 0, 0, (LED_TYPE *)&led[1]);
setrgb(0, 0, 0, (rgb_led_t *)&led[0]);
setrgb(0, 0, 0, (rgb_led_t *)&led[1]);
rgblight_set();
#endif
}
@ -190,23 +190,23 @@ layer_state_t layer_state_set_user(layer_state_t state) {
state = update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
#ifdef RGBLIGHT_ENABLE
if (layer_state_cmp(state, _ADJUST)) {
setrgb(70, 255, 200, (LED_TYPE *)&led[0]);
setrgb(255, 70, 100, (LED_TYPE *)&led[1]);
setrgb(70, 255, 200, (rgb_led_t *)&led[0]);
setrgb(255, 70, 100, (rgb_led_t *)&led[1]);
} else if (layer_state_cmp(state, _LOWER)) {
setrgb(70, 255, 200, (LED_TYPE *)&led[0]);
setrgb(0, 0, 0, (LED_TYPE *)&led[1]);
setrgb(70, 255, 200, (rgb_led_t *)&led[0]);
setrgb(0, 0, 0, (rgb_led_t *)&led[1]);
} else if (layer_state_cmp(state, _RAISE)) {
setrgb(0, 0, 0, (LED_TYPE *)&led[0]);
setrgb(255, 70, 100, (LED_TYPE *)&led[1]);
setrgb(0, 0, 0, (rgb_led_t *)&led[0]);
setrgb(255, 70, 100, (rgb_led_t *)&led[1]);
} else if (layer_state_cmp(state, _UTIL)) {
setrgb(200, 70, 225, (LED_TYPE *)&led[0]);
setrgb(200, 70, 225, (LED_TYPE *)&led[1]);
setrgb(200, 70, 225, (rgb_led_t *)&led[0]);
setrgb(200, 70, 225, (rgb_led_t *)&led[1]);
} else if (layer_state_cmp(state, _MOUSE)) {
setrgb(255, 145, 5, (LED_TYPE *)&led[0]);
setrgb(255, 145, 5, (LED_TYPE *)&led[1]);
setrgb(255, 145, 5, (rgb_led_t *)&led[0]);
setrgb(255, 145, 5, (rgb_led_t *)&led[1]);
} else {
setrgb(0, 0, 0, (LED_TYPE *)&led[0]);
setrgb(0, 0, 0, (LED_TYPE *)&led[1]);
setrgb(0, 0, 0, (rgb_led_t *)&led[0]);
setrgb(0, 0, 0, (rgb_led_t *)&led[1]);
}
rgblight_set();

View file

@ -50,8 +50,8 @@ void keyboard_post_init_user(void) {
rgblight_mode_noeeprom(RGBLIGHT_EFFECT_BREATHING + 2);
// Init the first two LEDs to a static color
setrgb(0, 0, 0, (LED_TYPE *)&led[0]);
setrgb(0, 0, 0, (LED_TYPE *)&led[1]);
setrgb(0, 0, 0, (rgb_led_t *)&led[0]);
setrgb(0, 0, 0, (rgb_led_t *)&led[1]);
rgblight_set();
#endif //RGBLIGHT_ENABLE
}
@ -75,8 +75,8 @@ layer_state_t layer_state_set_user(layer_state_t state){
led1r = 255;
}
setrgb(led0r, led0g, led0b, (LED_TYPE *)&led[0]);
setrgb(led1r, led1g, led1b, (LED_TYPE *)&led[1]);
setrgb(led0r, led0g, led0b, (rgb_led_t *)&led[0]);
setrgb(led1r, led1g, led1b, (rgb_led_t *)&led[1]);
rgblight_set();
#endif //RGBLIGHT_ENABLE
return state;

View file

@ -192,8 +192,8 @@ void keyboard_post_init_user (void) {
rgblight_mode_noeeprom (RGBLIGHT_EFFECT_BREATHING + 2);
// Init the first and last LEDs to a static color.
setrgb (0, 0, 0, (LED_TYPE *)&led[0]); // Led[0] is led 0
setrgb (0, 0, 0, (LED_TYPE *)&led[2]); // 2nd led
setrgb (0, 0, 0, (rgb_led_t *)&led[0]); // Led[0] is led 0
setrgb (0, 0, 0, (rgb_led_t *)&led[2]); // 2nd led
// The logic seems to be to establish the effect first, and then toggle it on/off.
# ifdef STARTUP_MID_LED_OFF
@ -301,8 +301,8 @@ void isolate_rgblight_set (void) {
led2r = 0;
led2g = 0;
led2b = 0;
setrgb(led0r, led0g, led0b, (LED_TYPE *)&led[0]); // Led 0
setrgb(led2r, led2g, led2b, (LED_TYPE *)&led[2]); // Led 2
setrgb(led0r, led0g, led0b, (rgb_led_t *)&led[0]); // Led 0
setrgb(led2r, led2g, led2b, (rgb_led_t *)&led[2]); // Led 2
}
rgblight_set ();
# endif
@ -326,8 +326,8 @@ void indicate_fun_stay (void) {
led0g = 50; //
led2r = 255; // red
}
setrgb(led0r, led0g, led0b, (LED_TYPE *)&led[0]); // Led 0
setrgb(led2r, led2g, led2b, (LED_TYPE *)&led[2]); // Led 2
setrgb(led0r, led0g, led0b, (rgb_led_t *)&led[0]); // Led 0
setrgb(led2r, led2g, led2b, (rgb_led_t *)&led[2]); // Led 2
isolate_rgblight_set ();
# endif //RGBLIGHT_ENABLE
@ -369,8 +369,8 @@ void indicate_base (void) {
led2g = 255;
led2b = 255;
}
setrgb(led0r, led0g, led0b, (LED_TYPE *)&led[0]); // Led 0
setrgb(led2r, led2g, led2b, (LED_TYPE *)&led[2]); // Led 2
setrgb(led0r, led0g, led0b, (rgb_led_t *)&led[0]); // Led 0
setrgb(led2r, led2g, led2b, (rgb_led_t *)&led[2]); // Led 2
isolate_rgblight_set ();
# endif //RGBLIGHT_ENABLE
@ -535,8 +535,8 @@ void set_led_colors_ (layer_state_t state) {
//---
// pushes the configuration
setrgb (led0r, led0g, led0b, (LED_TYPE *)&led[0]); // Led 0
setrgb (led2r, led2g, led2b, (LED_TYPE *)&led[2]); // Led 2
setrgb (led0r, led0g, led0b, (rgb_led_t *)&led[0]); // Led 0
setrgb (led2r, led2g, led2b, (rgb_led_t *)&led[2]); // Led 2
isolate_rgblight_set (); // Activates the led color change, after on/off check.

View file

@ -97,7 +97,7 @@ float rgb_brightness = 1.0;
void rgbflag(uint8_t r, uint8_t g, uint8_t b) {
float rgb_brightness = ((float)rgblight_get_val())/256;
if(rgb_brightness == 0) rgb_brightness = 0.05;
LED_TYPE *target_led = user_rgb_mode ? shadowed_led : led;
rgb_led_t *target_led = user_rgb_mode ? shadowed_led : led;
target_led[0].r = (uint8_t)(r*rgb_brightness);
target_led[0].g = (uint8_t)(g*rgb_brightness);
target_led[0].b = (uint8_t)(b*rgb_brightness);

View file

@ -64,7 +64,7 @@
#if defined(RGB_BACKLIGHT_DAWN60)
#include "ws2812.h"
LED_TYPE g_ws2812_leds[WS2812_LED_TOTAL];
rgb_led_t g_ws2812_leds[WS2812_LED_TOTAL];
#endif
#include "progmem.h"

View file

@ -24,7 +24,7 @@
#include "ws2812_bitbang.c"
void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) {
void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds) {
ws2812_setleds(start_led, num_leds);
}
#endif

View file

@ -23,7 +23,7 @@
#include "ws2812.h"
#ifdef RGB_MATRIX_ENABLE
LED_TYPE rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
const is31_led PROGMEM g_is31_leds[RGB_MATRIX_LED_COUNT] = {
/* Refer to IS31 manual for these locations

View file

@ -4,6 +4,6 @@
#include "color.h"
static inline void rgblite_setrgb(uint8_t _r, uint8_t _g, uint8_t _b) {
LED_TYPE leds[RGBLED_NUM] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}};
rgb_led_t leds[RGBLED_NUM] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}};
ws2812_setleds(leds, RGBLED_NUM);
}

View file

@ -4,7 +4,7 @@
#include "color.h"
static inline void rgblite_setrgb(uint8_t _r, uint8_t _g, uint8_t _b) {
LED_TYPE leds[RGBLED_NUM] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}};
rgb_led_t leds[RGBLED_NUM] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}};
ws2812_setleds(leds, RGBLED_NUM);
}

View file

@ -49,7 +49,7 @@ int speed = 300;
void set_colors(int r, int g, int b) {
for(int i = 0; i<6; i++) {
sethsv(r, g, b, (LED_TYPE *)&led[i]);
sethsv(r, g, b, (rgb_led_t *)&led[i]);
}
rgblight_set();
}
@ -213,7 +213,7 @@ void matrix_scan_user(void) {
if (rc == 0) {
rc = speed;
for(int i = 0; i<6; i++) {
sethsv(42*((t+i)%6), 255, 255, (LED_TYPE *)&led[i]);
sethsv(42*((t+i)%6), 255, 255, (rgb_led_t *)&led[i]);
}
rgblight_set();
t++; t = t % 6;
@ -224,9 +224,9 @@ void matrix_scan_user(void) {
col = (col + 1) % 36;
for (int i = 0; i<6; i++) {
if (i==t)
sethsv(42*(((col-1)/6)%6), 255, 255, (LED_TYPE *)&led[(right ? t : 5-t)]);
sethsv(42*(((col-1)/6)%6), 255, 255, (rgb_led_t *)&led[(right ? t : 5-t)]);
else
sethsv(0, 0, 0, (LED_TYPE *)&led[right ? i : 5-i]);
sethsv(0, 0, 0, (rgb_led_t *)&led[right ? i : 5-i]);
}
rgblight_set();
t++; t = t % 6;

View file

@ -106,7 +106,7 @@ bool rgb_matrix_indicators_user(void) {
#if defined(RGB_MATRIX_ENABLE)
#define INDICATOR_RGB_DIVISOR 4
extern LED_TYPE rgb_matrix_ws2812_array[DRIVER_LED_TOTAL];
extern rgb_led_t rgb_matrix_ws2812_array[DRIVER_LED_TOTAL];
bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
for (uint8_t i = led_min; i < led_max; i++) {
if (g_led_config.flags[i] & LED_FLAG_INDICATOR) {

View file

@ -37,13 +37,13 @@
static inline void ws2812_sendarray_mask(uint8_t *data, uint16_t datlen, uint8_t masklo, uint8_t maskhi);
void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds) {
void ws2812_setleds(rgb_led_t *ledarray, uint16_t number_of_leds) {
DDRx_ADDRESS(WS2812_DI_PIN) |= pinmask(WS2812_DI_PIN);
uint8_t masklo = ~(pinmask(WS2812_DI_PIN)) & PORTx_ADDRESS(WS2812_DI_PIN);
uint8_t maskhi = pinmask(WS2812_DI_PIN) | PORTx_ADDRESS(WS2812_DI_PIN);
ws2812_sendarray_mask((uint8_t *)ledarray, number_of_leds * sizeof(LED_TYPE), masklo, maskhi);
ws2812_sendarray_mask((uint8_t *)ledarray, number_of_leds * sizeof(rgb_led_t), masklo, maskhi);
_delay_us(WS2812_TRST_US);
}

View file

@ -18,12 +18,12 @@ void ws2812_init(void) {
}
// Setleds for standard RGB
void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) {
static bool s_init = false;
if (!s_init) {
ws2812_init();
s_init = true;
}
i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_I2C_TIMEOUT);
i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(rgb_led_t) * leds, WS2812_I2C_TIMEOUT);
}

View file

@ -268,7 +268,7 @@ static inline void sync_ws2812_transfer(void) {
busy_wait_until(LAST_TRANSFER);
}
void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) {
void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) {
static bool is_initialized = false;
if (unlikely(!is_initialized)) {
is_initialized = ws2812_init();

View file

@ -72,7 +72,7 @@ void ws2812_init(void) {
}
// Setleds for standard RGB
void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) {
static bool s_init = false;
if (!s_init) {
ws2812_init();

View file

@ -379,7 +379,7 @@ void ws2812_write_led_rgbw(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b,
}
// Setleds for standard RGB
void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) {
void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) {
static bool s_init = false;
if (!s_init) {
ws2812_init();

View file

@ -106,7 +106,7 @@ static uint8_t get_protocol_eq(uint8_t data, int pos) {
return eq;
}
static void set_led_color_rgb(LED_TYPE color, int pos) {
static void set_led_color_rgb(rgb_led_t color, int pos) {
uint8_t* tx_start = &txbuf[PREAMBLE_SIZE];
#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB)
@ -187,7 +187,7 @@ void ws2812_init(void) {
#endif
}
void ws2812_setleds(LED_TYPE* ledarray, uint16_t leds) {
void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) {
static bool s_init = false;
if (!s_init) {
ws2812_init();

View file

@ -110,7 +110,7 @@ RGB hsv_to_rgb_nocie(HSV hsv) {
}
#ifdef RGBW
void convert_rgb_to_rgbw(LED_TYPE *led) {
void convert_rgb_to_rgbw(rgb_led_t *led) {
// Determine lowest value in all three colors, put that into
// the white channel and then shift all colors by that amount
led->w = MIN(led->r, MIN(led->g, led->b));

View file

@ -83,12 +83,6 @@
# pragma pack(push, 1)
#endif
#ifdef RGBW
# define LED_TYPE cRGBW
#else
# define LED_TYPE RGB
#endif
#define WS2812_BYTE_ORDER_RGB 0
#define WS2812_BYTE_ORDER_GRB 1
#define WS2812_BYTE_ORDER_BGR 2
@ -97,26 +91,7 @@
# define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_GRB
#endif
typedef struct PACKED {
#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB)
uint8_t g;
uint8_t r;
uint8_t b;
#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB)
uint8_t r;
uint8_t g;
uint8_t b;
#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_BGR)
uint8_t b;
uint8_t g;
uint8_t r;
#endif
} cRGB;
typedef cRGB RGB;
// WS2812 specific layout
typedef struct PACKED {
typedef struct PACKED rgb_led_t {
#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB)
uint8_t g;
uint8_t r;
@ -130,10 +105,14 @@ typedef struct PACKED {
uint8_t g;
uint8_t r;
#endif
#ifdef RGBW
uint8_t w;
} cRGBW;
#endif
} rgb_led_t;
typedef struct PACKED {
typedef rgb_led_t RGB;
typedef struct PACKED HSV {
uint8_t h;
uint8_t s;
uint8_t v;
@ -146,5 +125,5 @@ typedef struct PACKED {
RGB hsv_to_rgb(HSV hsv);
RGB hsv_to_rgb_nocie(HSV hsv);
#ifdef RGBW
void convert_rgb_to_rgbw(LED_TYPE *led);
void convert_rgb_to_rgbw(rgb_led_t *led);
#endif

View file

@ -426,8 +426,8 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
# endif
// LED color buffer
LED_TYPE rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
bool ws2812_dirty = false;
rgb_led_t rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
bool ws2812_dirty = false;
static void init(void) {
ws2812_dirty = false;

View file

@ -115,7 +115,7 @@ animation_status_t animation_status = {};
#endif
#ifndef LED_ARRAY
LED_TYPE led[RGBLED_NUM];
rgb_led_t led[RGBLED_NUM];
# define LED_ARRAY led
#endif
@ -144,17 +144,17 @@ __attribute__((weak)) RGB rgblight_hsv_to_rgb(HSV hsv) {
return hsv_to_rgb(hsv);
}
void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1) {
HSV hsv = {hue, sat, val};
RGB rgb = rgblight_hsv_to_rgb(hsv);
setrgb(rgb.r, rgb.g, rgb.b, led1);
}
void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
void sethsv(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1) {
sethsv_raw(hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val, led1);
}
void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) {
void setrgb(uint8_t r, uint8_t g, uint8_t b, rgb_led_t *led1) {
led1->r = r;
led1->g = g;
led1->b = b;
@ -516,7 +516,7 @@ void rgblight_decrease_speed_noeeprom(void) {
void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) {
if (rgblight_config.enable) {
LED_TYPE tmp_led;
rgb_led_t tmp_led;
sethsv(hue, sat, val, &tmp_led);
rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
}
@ -532,7 +532,7 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w
rgblight_status.base_mode = mode_base_table[rgblight_config.mode];
if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) {
// same static color
LED_TYPE tmp_led;
rgb_led_t tmp_led;
#ifdef RGBLIGHT_LAYERS_RETAIN_VAL
// needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val
rgblight_config.val = val;
@ -576,7 +576,7 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w
_hue = hue - _hue;
}
dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range);
sethsv(_hue, sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]);
sethsv(_hue, sat, val, (rgb_led_t *)&led[i + rgblight_ranges.effect_start_pos]);
}
# ifdef RGBLIGHT_LAYERS_RETAIN_VAL
// needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val
@ -679,7 +679,7 @@ void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index) {
return;
}
LED_TYPE tmp_led;
rgb_led_t tmp_led;
sethsv(hue, sat, val, &tmp_led);
rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index);
}
@ -717,7 +717,7 @@ void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start,
return;
}
LED_TYPE tmp_led;
rgb_led_t tmp_led;
sethsv(hue, sat, val, &tmp_led);
rgblight_setrgb_range(tmp_led.r, tmp_led.g, tmp_led.b, start, end);
}
@ -786,8 +786,8 @@ static void rgblight_layers_write(void) {
break; // No more segments
}
// Write segment.count LEDs
LED_TYPE *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)];
for (LED_TYPE *led_ptr = &led[segment.index]; led_ptr < limit; led_ptr++) {
rgb_led_t *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)];
for (rgb_led_t *led_ptr = &led[segment.index]; led_ptr < limit; led_ptr++) {
# ifdef RGBLIGHT_LAYERS_RETAIN_VAL
sethsv(segment.hue, segment.sat, current_val, led_ptr);
# else
@ -897,15 +897,15 @@ void rgblight_wakeup(void) {
#endif
__attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) {
__attribute__((weak)) void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds) {
ws2812_setleds(start_led, num_leds);
}
#ifndef RGBLIGHT_CUSTOM_DRIVER
void rgblight_set(void) {
LED_TYPE *start_led;
uint8_t num_leds = rgblight_ranges.clipping_num_leds;
rgb_led_t *start_led;
uint8_t num_leds = rgblight_ranges.clipping_num_leds;
if (!rgblight_config.enable) {
for (uint8_t i = rgblight_ranges.effect_start_pos; i < rgblight_ranges.effect_end_pos; i++) {
@ -931,7 +931,7 @@ void rgblight_set(void) {
# endif
# ifdef RGBLIGHT_LED_MAP
LED_TYPE led0[RGBLED_NUM];
rgb_led_t led0[RGBLED_NUM];
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
led0[i] = led[pgm_read_byte(&led_map[i])];
}
@ -1230,7 +1230,7 @@ void rgblight_effect_rainbow_swirl(animation_status_t *anim) {
for (i = 0; i < rgblight_ranges.effect_num_leds; i++) {
hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / rgblight_ranges.effect_num_leds * i + anim->current_hue);
sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]);
sethsv(hue, rgblight_config.sat, rgblight_config.val, (rgb_led_t *)&led[i + rgblight_ranges.effect_start_pos]);
}
rgblight_set();
@ -1267,10 +1267,10 @@ void rgblight_effect_snake(animation_status_t *anim) {
# endif
for (i = 0; i < rgblight_ranges.effect_num_leds; i++) {
LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos;
ledp->r = 0;
ledp->g = 0;
ledp->b = 0;
rgb_led_t *ledp = led + i + rgblight_ranges.effect_start_pos;
ledp->r = 0;
ledp->g = 0;
ledp->b = 0;
# ifdef RGBW
ledp->w = 0;
# endif
@ -1340,7 +1340,7 @@ void rgblight_effect_knight(animation_status_t *anim) {
cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % rgblight_ranges.effect_num_leds + rgblight_ranges.effect_start_pos;
if (i >= low_bound && i <= high_bound) {
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]);
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (rgb_led_t *)&led[cur]);
} else {
led[cur].r = 0;
led[cur].g = 0;
@ -1392,7 +1392,7 @@ void rgblight_effect_christmas(animation_status_t *anim) {
for (i = 0; i < rgblight_ranges.effect_num_leds; i++) {
uint8_t local_hue = (i / RGBLIGHT_EFFECT_CHRISTMAS_STEP) % 2 ? hue : hue_green - hue;
sethsv(local_hue, rgblight_config.sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]);
sethsv(local_hue, rgblight_config.sat, val, (rgb_led_t *)&led[i + rgblight_ranges.effect_start_pos]);
}
rgblight_set();
@ -1415,7 +1415,7 @@ void rgblight_effect_rgbtest(animation_status_t *anim) {
uint8_t b;
if (maxval == 0) {
LED_TYPE tmp_led;
rgb_led_t tmp_led;
sethsv(0, 255, RGBLIGHT_LIMIT_VAL, &tmp_led);
maxval = tmp_led.r;
}
@ -1439,7 +1439,7 @@ void rgblight_effect_rgbtest(animation_status_t *anim) {
#ifdef RGBLIGHT_EFFECT_ALTERNATING
void rgblight_effect_alternating(animation_status_t *anim) {
for (int i = 0; i < rgblight_ranges.effect_num_leds; i++) {
LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos;
rgb_led_t *ledp = led + i + rgblight_ranges.effect_start_pos;
if (i < rgblight_ranges.effect_num_leds / 2 && anim->pos) {
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, ledp);
} else if (i >= rgblight_ranges.effect_num_leds / 2 && !anim->pos) {
@ -1512,7 +1512,7 @@ void rgblight_effect_twinkle(animation_status_t *anim) {
// This LED is off, and was NOT selected to start brightening
}
LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos;
rgb_led_t *ledp = led + i + rgblight_ranges.effect_start_pos;
sethsv(c->h, c->s, c->v, ledp);
}

View file

@ -233,7 +233,7 @@ void rgblight_unblink_all_but_layer(uint8_t layer);
#endif
extern LED_TYPE led[RGBLED_NUM];
extern rgb_led_t led[RGBLED_NUM];
extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM;
extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM;
@ -283,9 +283,9 @@ typedef struct _rgblight_ranges_t {
extern rgblight_ranges_t rgblight_ranges;
/* === Utility Functions ===*/
void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1);
void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); // without RGBLIGHT_LIMIT_VAL check
void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1);
void sethsv(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1);
void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1); // without RGBLIGHT_LIMIT_VAL check
void setrgb(uint8_t r, uint8_t g, uint8_t b, rgb_led_t *led1);
/* === Low level Functions === */
void rgblight_set(void);

View file

@ -142,7 +142,7 @@ void scan_rgblight_fadeout(void) { // Don't effing change this function .... rg
if (light->life) {
light->life -= 1;
if (get_highest_layer(layer_state) == 0) {
sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]);
sethsv(light->hue + rand() % 0xF, 255, light->life, (rgb_led_t *)&led[light_index]);
}
light->timer = timer_read();
} else {

View file

@ -45,7 +45,7 @@ void matrix_scan_keymap(void) {
uint16_t effect_start_timer = 0;
uint8_t user_rgb_mode = 0;
LED_TYPE shadowed_led[RGBLED_NUM] = {{0}};
rgb_led_t shadowed_led[RGBLED_NUM] = {{0}};
void start_firey_return(void) {
user_rgb_mode = BREATH_FIRE;
@ -79,7 +79,7 @@ void set_color_for_offsets(uint16_t time_offset, uint16_t space_offset, uint8_t
float alpha = (time_progress + 0.1) * 7.0 - space_progress;
alpha = fmin(1.0, alpha*alpha);
LED_TYPE px[1] = {{0}};
rgb_led_t px[1] = {{0}};
sethsv((uint16_t)(fmod(time_progress * 1.5 + space_progress,1.0)*360), 255, (uint8_t)(progress*255),&px[0]);
led[idx].r = alpha * px[0].r + ( 1.0 - alpha) * shadowed_led[idx].r;
led[idx].g = alpha * px[0].g + ( 1.0 - alpha) * shadowed_led[idx].g;

View file

@ -22,7 +22,7 @@
extern uint8_t user_rgb_mode;
extern LED_TYPE shadowed_led[];
extern rgb_led_t shadowed_led[];
#endif //RGBLIGHT_ENABLE

View file

@ -9,7 +9,7 @@
#define EECONFIG_LED_DIM_LVL (uint8_t *)15
#define SET_LED_RGB(r, g, b, led_dim, pos) \
setrgb(r >> led_dim, g >> led_dim, b >> led_dim, (LED_TYPE *)&led[pos])
setrgb(r >> led_dim, g >> led_dim, b >> led_dim, (rgb_led_t *)&led[pos])
typedef enum {
DEFAULT,