RGB Matrix Overhaul (#5372)
* RGB Matrix overhaul Breakout of animations to separate files Integration of optimized int based math lib Overhaul of rgb_matrix.c and animations for performance * Updating effect function api for future extensions * Combined the keypresses || keyreleases define checks into a single define so I stop forgetting it where necessary * Moving define RGB_MATRIX_KEYREACTIVE_ENABLED earlier in the include chain
This commit is contained in:
parent
68d8bb2b3f
commit
c98247e3dd
37 changed files with 3879 additions and 1010 deletions
|
@ -78,9 +78,11 @@ RGB hsv_to_rgb( HSV hsv )
|
|||
break;
|
||||
}
|
||||
|
||||
#ifdef USE_CIE1931_CURVE
|
||||
rgb.r = pgm_read_byte( &CIE1931_CURVE[rgb.r] );
|
||||
rgb.g = pgm_read_byte( &CIE1931_CURVE[rgb.g] );
|
||||
rgb.b = pgm_read_byte( &CIE1931_CURVE[rgb.b] );
|
||||
#endif
|
||||
|
||||
return rgb;
|
||||
}
|
||||
|
|
|
@ -274,10 +274,10 @@ bool process_record_quantum(keyrecord_t *record) {
|
|||
#ifdef HAPTIC_ENABLE
|
||||
process_haptic(keycode, record) &&
|
||||
#endif //HAPTIC_ENABLE
|
||||
process_record_kb(keycode, record) &&
|
||||
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYPRESSES)
|
||||
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
|
||||
process_rgb_matrix(keycode, record) &&
|
||||
#endif
|
||||
process_record_kb(keycode, record) &&
|
||||
#if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
|
||||
process_midi(keycode, record) &&
|
||||
#endif
|
||||
|
@ -1049,12 +1049,6 @@ void matrix_init_quantum() {
|
|||
matrix_init_kb();
|
||||
}
|
||||
|
||||
uint8_t rgb_matrix_task_counter = 0;
|
||||
|
||||
#ifndef RGB_MATRIX_SKIP_FRAMES
|
||||
#define RGB_MATRIX_SKIP_FRAMES 1
|
||||
#endif
|
||||
|
||||
void matrix_scan_quantum() {
|
||||
#if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
|
||||
matrix_scan_music();
|
||||
|
@ -1078,10 +1072,6 @@ void matrix_scan_quantum() {
|
|||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
rgb_matrix_task();
|
||||
if (rgb_matrix_task_counter == 0) {
|
||||
rgb_matrix_update_pwm_buffers();
|
||||
}
|
||||
rgb_matrix_task_counter = ((rgb_matrix_task_counter + 1) % (RGB_MATRIX_SKIP_FRAMES + 1));
|
||||
#endif
|
||||
|
||||
#ifdef ENCODER_ENABLE
|
||||
|
|
1175
quantum/rgb_matrix.c
1175
quantum/rgb_matrix.c
File diff suppressed because it is too large
Load diff
|
@ -21,32 +21,33 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "rgb_matrix_types.h"
|
||||
#include "color.h"
|
||||
#include "quantum.h"
|
||||
|
||||
#ifdef IS31FL3731
|
||||
#include "is31fl3731.h"
|
||||
#include "is31fl3731.h"
|
||||
#elif defined (IS31FL3733)
|
||||
#include "is31fl3733.h"
|
||||
#include "is31fl3733.h"
|
||||
#endif
|
||||
|
||||
typedef struct Point {
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
} __attribute__((packed)) Point;
|
||||
#ifndef RGB_MATRIX_LED_FLUSH_LIMIT
|
||||
#define RGB_MATRIX_LED_FLUSH_LIMIT 16
|
||||
#endif
|
||||
|
||||
typedef struct rgb_led {
|
||||
union {
|
||||
uint8_t raw;
|
||||
struct {
|
||||
uint8_t row:4; // 16 max
|
||||
uint8_t col:4; // 16 max
|
||||
};
|
||||
} matrix_co;
|
||||
Point point;
|
||||
uint8_t modifier:1;
|
||||
} __attribute__((packed)) rgb_led;
|
||||
#ifndef RGB_MATRIX_LED_PROCESS_LIMIT
|
||||
#define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5
|
||||
#endif
|
||||
|
||||
#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL
|
||||
#define RGB_MATRIX_USE_LIMITS(min, max) uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \
|
||||
uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
|
||||
if (max > DRIVER_LED_TOTAL) \
|
||||
max = DRIVER_LED_TOTAL;
|
||||
#else
|
||||
#define RGB_MATRIX_USE_LIMITS(min, max) uint8_t min = 0; \
|
||||
uint8_t max = DRIVER_LED_TOTAL;
|
||||
#endif
|
||||
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
|
||||
|
@ -56,79 +57,73 @@ typedef struct
|
|||
uint8_t index;
|
||||
} rgb_indicator;
|
||||
|
||||
typedef union {
|
||||
uint32_t raw;
|
||||
struct {
|
||||
bool enable :1;
|
||||
uint8_t mode :6;
|
||||
uint16_t hue :9;
|
||||
uint8_t sat :8;
|
||||
uint8_t val :8;
|
||||
uint8_t speed :8;//EECONFIG needs to be increased to support this
|
||||
};
|
||||
} rgb_config_t;
|
||||
|
||||
enum rgb_matrix_effects {
|
||||
RGB_MATRIX_NONE = 0,
|
||||
RGB_MATRIX_SOLID_COLOR = 1,
|
||||
#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
|
||||
RGB_MATRIX_ALPHAS_MODS,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
|
||||
RGB_MATRIX_DUAL_BEACON,
|
||||
#endif
|
||||
RGB_MATRIX_ALPHAS_MODS,
|
||||
#endif // DISABLE_RGB_MATRIX_ALPHAS_MODS
|
||||
#ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
|
||||
RGB_MATRIX_GRADIENT_UP_DOWN,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINDROPS
|
||||
RGB_MATRIX_RAINDROPS,
|
||||
#endif
|
||||
RGB_MATRIX_GRADIENT_UP_DOWN,
|
||||
#endif // DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
|
||||
#ifndef DISABLE_RGB_MATRIX_BREATHING
|
||||
RGB_MATRIX_BREATHING,
|
||||
#endif // DISABLE_RGB_MATRIX_BREATHING
|
||||
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
|
||||
RGB_MATRIX_CYCLE_ALL,
|
||||
#endif
|
||||
RGB_MATRIX_CYCLE_ALL,
|
||||
#endif // DISABLE_RGB_MATRIX_CYCLE_ALL
|
||||
#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
|
||||
RGB_MATRIX_CYCLE_LEFT_RIGHT,
|
||||
#endif
|
||||
RGB_MATRIX_CYCLE_LEFT_RIGHT,
|
||||
#endif // DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
|
||||
#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
|
||||
RGB_MATRIX_CYCLE_UP_DOWN,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
|
||||
RGB_MATRIX_RAINBOW_BEACON,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
|
||||
RGB_MATRIX_RAINBOW_PINWHEELS,
|
||||
#endif
|
||||
RGB_MATRIX_CYCLE_UP_DOWN,
|
||||
#endif // DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
|
||||
RGB_MATRIX_RAINBOW_MOVING_CHEVRON,
|
||||
#endif
|
||||
RGB_MATRIX_RAINBOW_MOVING_CHEVRON,
|
||||
#endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
|
||||
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
|
||||
RGB_MATRIX_DUAL_BEACON,
|
||||
#endif // DISABLE_RGB_MATRIX_DUAL_BEACON
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
|
||||
RGB_MATRIX_RAINBOW_BEACON,
|
||||
#endif // DISABLE_RGB_MATRIX_RAINBOW_BEACON
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
|
||||
RGB_MATRIX_RAINBOW_PINWHEELS,
|
||||
#endif // DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINDROPS
|
||||
RGB_MATRIX_RAINDROPS,
|
||||
#endif // DISABLE_RGB_MATRIX_RAINDROPS
|
||||
#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
|
||||
RGB_MATRIX_JELLYBEAN_RAINDROPS,
|
||||
#endif
|
||||
RGB_MATRIX_JELLYBEAN_RAINDROPS,
|
||||
#endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
|
||||
#ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN
|
||||
RGB_MATRIX_DIGITAL_RAIN,
|
||||
#endif
|
||||
#ifdef RGB_MATRIX_KEYPRESSES
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
|
||||
RGB_MATRIX_SOLID_REACTIVE,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
|
||||
RGB_MATRIX_SOLID_REACTIVE_SIMPLE,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_SPLASH
|
||||
RGB_MATRIX_SPLASH,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_MULTISPLASH
|
||||
RGB_MATRIX_MULTISPLASH,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
|
||||
RGB_MATRIX_SOLID_SPLASH,
|
||||
#endif
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||
RGB_MATRIX_SOLID_MULTISPLASH,
|
||||
#endif
|
||||
#endif
|
||||
RGB_MATRIX_EFFECT_MAX
|
||||
RGB_MATRIX_DIGITAL_RAIN,
|
||||
#endif // DISABLE_RGB_MATRIX_DIGITAL_RAIN
|
||||
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
|
||||
RGB_MATRIX_SOLID_REACTIVE_SIMPLE,
|
||||
#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
|
||||
RGB_MATRIX_SOLID_REACTIVE,
|
||||
#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE
|
||||
#ifndef DISABLE_RGB_MATRIX_SPLASH
|
||||
RGB_MATRIX_SPLASH,
|
||||
#endif // DISABLE_RGB_MATRIX_SPLASH
|
||||
#ifndef DISABLE_RGB_MATRIX_MULTISPLASH
|
||||
RGB_MATRIX_MULTISPLASH,
|
||||
#endif // DISABLE_RGB_MATRIX_MULTISPLASH
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
|
||||
RGB_MATRIX_SOLID_SPLASH,
|
||||
#endif // DISABLE_RGB_MATRIX_SOLID_SPLASH
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||
RGB_MATRIX_SOLID_MULTISPLASH,
|
||||
#endif // DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
RGB_MATRIX_EFFECT_MAX
|
||||
};
|
||||
|
||||
uint8_t rgb_matrix_map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led_i);
|
||||
|
||||
void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
|
||||
void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
|
||||
|
||||
|
@ -162,8 +157,6 @@ void rgb_matrix_decrease(void);
|
|||
// void backlight_get_key_color( uint8_t led, HSV *hsv );
|
||||
// void backlight_set_key_color( uint8_t row, uint8_t column, HSV hsv );
|
||||
|
||||
uint32_t rgb_matrix_get_tick(void);
|
||||
|
||||
void rgb_matrix_toggle(void);
|
||||
void rgb_matrix_enable(void);
|
||||
void rgb_matrix_enable_noeeprom(void);
|
||||
|
@ -212,7 +205,6 @@ uint8_t rgb_matrix_get_mode(void);
|
|||
typedef struct {
|
||||
/* Perform any initialisation required for the other driver functions to work. */
|
||||
void (*init)(void);
|
||||
|
||||
/* Set the colour of a single LED in the buffer. */
|
||||
void (*set_color)(int index, uint8_t r, uint8_t g, uint8_t b);
|
||||
/* Set the colour of all LEDS on the keyboard in the buffer. */
|
||||
|
|
26
quantum/rgb_matrix_animations/alpha_mods_anim.h
Normal file
26
quantum/rgb_matrix_animations/alpha_mods_anim.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
|
||||
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
// alphas = color1, mods = color2
|
||||
bool rgb_matrix_alphas_mods(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
RGB rgb1 = hsv_to_rgb(hsv);
|
||||
hsv.h += rgb_matrix_config.speed;
|
||||
RGB rgb2 = hsv_to_rgb(hsv);
|
||||
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
if (g_rgb_leds[i].modifier) {
|
||||
rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b);
|
||||
} else {
|
||||
rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b);
|
||||
}
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_ALPHAS_MODS
|
19
quantum/rgb_matrix_animations/breathing_anim.h
Normal file
19
quantum/rgb_matrix_animations/breathing_anim.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_BREATHING
|
||||
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_breathing(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8);
|
||||
uint8_t val = scale8(abs8(sin8(time) - 128) * 2, rgb_matrix_config.val);
|
||||
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, val };
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_BREATHING
|
21
quantum/rgb_matrix_animations/cycle_all_anim.h
Normal file
21
quantum/rgb_matrix_animations/cycle_all_anim.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
|
||||
|
||||
extern rgb_counters_t g_rgb_counters;
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_cycle_all(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
hsv.h = time;
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_CYCLE_ALL
|
22
quantum/rgb_matrix_animations/cycle_left_right_anim.h
Normal file
22
quantum/rgb_matrix_animations/cycle_left_right_anim.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
|
||||
|
||||
extern rgb_counters_t g_rgb_counters;
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_cycle_left_right(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
point_t point = g_rgb_leds[i].point;
|
||||
hsv.h = point.x - time;
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
|
22
quantum/rgb_matrix_animations/cycle_up_down_anim.h
Normal file
22
quantum/rgb_matrix_animations/cycle_up_down_anim.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
|
||||
|
||||
extern rgb_counters_t g_rgb_counters;
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_cycle_up_down(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
point_t point = g_rgb_leds[i].point;
|
||||
hsv.h = point.y - time;
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
|
74
quantum/rgb_matrix_animations/digital_rain_anim.h
Normal file
74
quantum/rgb_matrix_animations/digital_rain_anim.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN
|
||||
|
||||
#ifndef RGB_DIGITAL_RAIN_DROPS
|
||||
// lower the number for denser effect/wider keyboard
|
||||
#define RGB_DIGITAL_RAIN_DROPS 24
|
||||
#endif
|
||||
|
||||
bool rgb_matrix_digital_rain(effect_params_t* params) {
|
||||
// algorithm ported from https://github.com/tremby/Kaleidoscope-LEDEffect-DigitalRain
|
||||
const uint8_t drop_ticks = 28;
|
||||
const uint8_t pure_green_intensity = 0xd0;
|
||||
const uint8_t max_brightness_boost = 0xc0;
|
||||
const uint8_t max_intensity = 0xff;
|
||||
|
||||
static uint8_t map[MATRIX_COLS][MATRIX_ROWS] = {{0}};
|
||||
static uint8_t drop = 0;
|
||||
|
||||
if (params->init) {
|
||||
rgb_matrix_set_color_all(0, 0, 0);
|
||||
memset(map, 0, sizeof map);
|
||||
drop = 0;
|
||||
}
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
if (row == 0 && drop == 0 && rand() < RAND_MAX / RGB_DIGITAL_RAIN_DROPS) {
|
||||
// top row, pixels have just fallen and we're
|
||||
// making a new rain drop in this column
|
||||
map[col][row] = max_intensity;
|
||||
}
|
||||
else if (map[col][row] > 0 && map[col][row] < max_intensity) {
|
||||
// neither fully bright nor dark, decay it
|
||||
map[col][row]--;
|
||||
}
|
||||
// set the pixel colour
|
||||
uint8_t led[LED_HITS_TO_REMEMBER];
|
||||
uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led);
|
||||
|
||||
// TODO: multiple leds are supported mapped to the same row/column
|
||||
if (led_count > 0) {
|
||||
if (map[col][row] > pure_green_intensity) {
|
||||
const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost * (map[col][row] - pure_green_intensity) / (max_intensity - pure_green_intensity));
|
||||
rgb_matrix_set_color(led[0], boost, max_intensity, boost);
|
||||
}
|
||||
else {
|
||||
const uint8_t green = (uint8_t) ((uint16_t) max_intensity * map[col][row] / pure_green_intensity);
|
||||
rgb_matrix_set_color(led[0], 0, green, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (++drop > drop_ticks) {
|
||||
// reset drop timer
|
||||
drop = 0;
|
||||
for (uint8_t row = MATRIX_ROWS - 1; row > 0; row--) {
|
||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
|
||||
// if ths is on the bottom row and bright allow decay
|
||||
if (row == MATRIX_ROWS - 1 && map[col][row] == max_intensity) {
|
||||
map[col][row]--;
|
||||
}
|
||||
// check if the pixel above is bright
|
||||
if (map[col][row - 1] == max_intensity) {
|
||||
// allow old bright pixel to decay
|
||||
map[col][row - 1]--;
|
||||
// make this pixel bright
|
||||
map[col][row] = max_intensity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_DIGITAL_RAIN
|
24
quantum/rgb_matrix_animations/dual_beacon_anim.h
Normal file
24
quantum/rgb_matrix_animations/dual_beacon_anim.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
|
||||
|
||||
extern rgb_counters_t g_rgb_counters;
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_dual_beacon(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
|
||||
int8_t cos_value = cos8(time) - 128;
|
||||
int8_t sin_value = sin8(time) - 128;
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
point_t point = g_rgb_leds[i].point;
|
||||
hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue;
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_DUAL_BEACON
|
22
quantum/rgb_matrix_animations/gradient_up_down_anim.h
Normal file
22
quantum/rgb_matrix_animations/gradient_up_down_anim.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
|
||||
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_gradient_up_down(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
uint8_t scale = scale8(64, rgb_matrix_config.speed);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
point_t point = g_rgb_leds[i].point;
|
||||
// The y range will be 0..64, map this to 0..4
|
||||
// Relies on hue being 8-bit and wrapping
|
||||
hsv.h = rgb_matrix_config.hue + scale * (point.y >> 4);
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
#endif // DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
|
30
quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
Normal file
30
quantum/rgb_matrix_animations/jellybean_raindrops_anim.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
|
||||
|
||||
extern rgb_counters_t g_rgb_counters;
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
static void jellybean_raindrops_set_color(int i) {
|
||||
HSV hsv = { rand() & 0xFF , rand() & 0xFF, rgb_matrix_config.val };
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
|
||||
bool rgb_matrix_jellybean_raindrops(effect_params_t* params) {
|
||||
if (!params->init) {
|
||||
// Change one LED every tick, make sure speed is not 0
|
||||
if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) {
|
||||
jellybean_raindrops_set_color(rand() % DRIVER_LED_TOTAL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
for (int i = led_min; i < led_max; i++) {
|
||||
jellybean_raindrops_set_color(i);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
|
24
quantum/rgb_matrix_animations/rainbow_beacon_anim.h
Normal file
24
quantum/rgb_matrix_animations/rainbow_beacon_anim.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
|
||||
|
||||
extern rgb_counters_t g_rgb_counters;
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_rainbow_beacon(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
|
||||
int16_t cos_value = 2 * (cos8(time) - 128);
|
||||
int16_t sin_value = 2 * (sin8(time) - 128);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
point_t point = g_rgb_leds[i].point;
|
||||
hsv.h = ((point.y - 32) * cos_value + (point.x - 112) * sin_value) / 128 + rgb_matrix_config.hue;
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_RAINBOW_BEACON
|
22
quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
Normal file
22
quantum/rgb_matrix_animations/rainbow_moving_chevron_anim.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
|
||||
|
||||
extern rgb_counters_t g_rgb_counters;
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_rainbow_moving_chevron(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
uint8_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
point_t point = g_rgb_leds[i].point;
|
||||
hsv.h = abs8(point.y - 32) + (point.x - time) + rgb_matrix_config.hue;
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
|
24
quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
Normal file
24
quantum/rgb_matrix_animations/rainbow_pinwheels_anim.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
|
||||
|
||||
extern rgb_counters_t g_rgb_counters;
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_rainbow_pinwheels(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 4);
|
||||
int16_t cos_value = 3 * (cos8(time) - 128);
|
||||
int16_t sin_value = 3 * (sin8(time) - 128);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
point_t point = g_rgb_leds[i].point;
|
||||
hsv.h = ((point.y - 32) * cos_value + (56 - abs8(point.x - 112)) * sin_value) / 128 + rgb_matrix_config.hue;
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
|
40
quantum/rgb_matrix_animations/raindrops_anim.h
Normal file
40
quantum/rgb_matrix_animations/raindrops_anim.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
#pragma once
|
||||
#ifndef DISABLE_RGB_MATRIX_RAINDROPS
|
||||
#include "rgb_matrix_types.h"
|
||||
|
||||
extern rgb_counters_t g_rgb_counters;
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
static void raindrops_set_color(int i) {
|
||||
HSV hsv = { 0 , rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
|
||||
// Take the shortest path between hues
|
||||
int16_t deltaH = ((rgb_matrix_config.hue + 180) % 360 - rgb_matrix_config.hue) / 4;
|
||||
if (deltaH > 127) {
|
||||
deltaH -= 256;
|
||||
} else if (deltaH < -127) {
|
||||
deltaH += 256;
|
||||
}
|
||||
|
||||
hsv.h = rgb_matrix_config.hue + (deltaH * (rand() & 0x03));
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
|
||||
bool rgb_matrix_raindrops(effect_params_t* params) {
|
||||
if (!params->init) {
|
||||
// Change one LED every tick, make sure speed is not 0
|
||||
if (scale16by8(g_rgb_counters.tick, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
|
||||
raindrops_set_color(rand() % DRIVER_LED_TOTAL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
for (int i = led_min; i < led_max; i++) {
|
||||
raindrops_set_color(i);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_RAINDROPS
|
14
quantum/rgb_matrix_animations/solid_color_anim.h
Normal file
14
quantum/rgb_matrix_animations/solid_color_anim.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
|
||||
bool rgb_matrix_solid_color(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
33
quantum/rgb_matrix_animations/solid_reactive_anim.h
Normal file
33
quantum/rgb_matrix_animations/solid_reactive_anim.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
|
||||
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
extern last_hit_t g_last_hit_tracker;
|
||||
|
||||
bool rgb_matrix_solid_reactive(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { rgb_matrix_config.hue, 255, rgb_matrix_config.val };
|
||||
// Max tick based on speed scale ensures results from scale16by8 with rgb_matrix_config.speed are no greater than 255
|
||||
uint16_t max_tick = 65535 / rgb_matrix_config.speed;
|
||||
// Relies on hue being 8-bit and wrapping
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
uint16_t tick = max_tick;
|
||||
for(uint8_t j = 0; j < g_last_hit_tracker.count; j++) {
|
||||
if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
|
||||
tick = g_last_hit_tracker.tick[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t offset = scale16by8(tick, rgb_matrix_config.speed);
|
||||
hsv.h = rgb_matrix_config.hue + qsub8(130, offset);
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
|
||||
#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
|
32
quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
Normal file
32
quantum/rgb_matrix_animations/solid_reactive_simple_anim.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
|
||||
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
extern last_hit_t g_last_hit_tracker;
|
||||
|
||||
bool rgb_matrix_solid_reactive_simple(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
|
||||
// Max tick based on speed scale ensures results from scale16by8 with rgb_matrix_config.speed are no greater than 255
|
||||
uint16_t max_tick = 65535 / rgb_matrix_config.speed;
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
uint16_t tick = max_tick;
|
||||
for(uint8_t j = 0; j < g_last_hit_tracker.count; j++) {
|
||||
if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) {
|
||||
tick = g_last_hit_tracker.tick[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t offset = scale16by8(tick, rgb_matrix_config.speed);
|
||||
hsv.v = scale8(255 - offset, rgb_matrix_config.val);
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
|
||||
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
|
42
quantum/rgb_matrix_animations/solid_splash_anim.h
Normal file
42
quantum/rgb_matrix_animations/solid_splash_anim.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
#if !defined(DISABLE_RGB_MATRIX_SOLID_SPLASH) || !defined(DISABLE_RGB_MATRIX_SOLID_MULTISPLASH)
|
||||
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
extern last_hit_t g_last_hit_tracker;
|
||||
|
||||
static bool rgb_matrix_solid_multisplash_range(uint8_t start, effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, 0 };
|
||||
uint8_t count = g_last_hit_tracker.count;
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
hsv.v = 0;
|
||||
point_t point = g_rgb_leds[i].point;
|
||||
for (uint8_t j = start; j < count; j++) {
|
||||
int16_t dx = point.x - g_last_hit_tracker.x[j];
|
||||
int16_t dy = point.y - g_last_hit_tracker.y[j];
|
||||
uint8_t dist = sqrt16(dx * dx + dy * dy);
|
||||
uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist;
|
||||
if (effect > 255)
|
||||
effect = 255;
|
||||
hsv.v = qadd8(hsv.v, 255 - effect);
|
||||
}
|
||||
hsv.v = scale8(hsv.v, rgb_matrix_config.val);
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
bool rgb_matrix_solid_multisplash(effect_params_t* params) {
|
||||
return rgb_matrix_solid_multisplash_range(0, params);
|
||||
}
|
||||
|
||||
bool rgb_matrix_solid_splash(effect_params_t* params) {
|
||||
return rgb_matrix_solid_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params);
|
||||
}
|
||||
|
||||
#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) && !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
|
||||
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
|
44
quantum/rgb_matrix_animations/splash_anim.h
Normal file
44
quantum/rgb_matrix_animations/splash_anim.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#pragma once
|
||||
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
#if !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
|
||||
|
||||
extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
|
||||
extern rgb_config_t rgb_matrix_config;
|
||||
extern last_hit_t g_last_hit_tracker;
|
||||
|
||||
static bool rgb_matrix_multisplash_range(uint8_t start, effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { 0, rgb_matrix_config.sat, 0 };
|
||||
uint8_t count = g_last_hit_tracker.count;
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
hsv.h = rgb_matrix_config.hue;
|
||||
hsv.v = 0;
|
||||
point_t point = g_rgb_leds[i].point;
|
||||
for (uint8_t j = start; j < count; j++) {
|
||||
int16_t dx = point.x - g_last_hit_tracker.x[j];
|
||||
int16_t dy = point.y - g_last_hit_tracker.y[j];
|
||||
uint8_t dist = sqrt16(dx * dx + dy * dy);
|
||||
uint16_t effect = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed) - dist;
|
||||
if (effect > 255)
|
||||
effect = 255;
|
||||
hsv.h += effect;
|
||||
hsv.v = qadd8(hsv.v, 255 - effect);
|
||||
}
|
||||
hsv.v = scale8(hsv.v, rgb_matrix_config.val);
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
}
|
||||
|
||||
bool rgb_matrix_multisplash(effect_params_t* params) {
|
||||
return rgb_matrix_multisplash_range(0, params);
|
||||
}
|
||||
|
||||
bool rgb_matrix_splash(effect_params_t* params) {
|
||||
return rgb_matrix_multisplash_range(qsub8(g_last_hit_tracker.count, 1), params);
|
||||
}
|
||||
|
||||
#endif // !defined(DISABLE_RGB_MATRIX_SPLASH) || !defined(DISABLE_RGB_MATRIX_MULTISPLASH)
|
||||
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
|
90
quantum/rgb_matrix_types.h
Normal file
90
quantum/rgb_matrix_types.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define PACKED __attribute__ ((__packed__))
|
||||
#else
|
||||
#define PACKED
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack( push, 1 )
|
||||
#endif
|
||||
|
||||
#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES)
|
||||
#define RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
#endif
|
||||
|
||||
// Last led hit
|
||||
#ifndef LED_HITS_TO_REMEMBER
|
||||
#define LED_HITS_TO_REMEMBER 8
|
||||
#endif // LED_HITS_TO_REMEMBER
|
||||
|
||||
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
typedef struct PACKED {
|
||||
uint8_t count;
|
||||
uint8_t x[LED_HITS_TO_REMEMBER];
|
||||
uint8_t y[LED_HITS_TO_REMEMBER];
|
||||
uint8_t index[LED_HITS_TO_REMEMBER];
|
||||
uint16_t tick[LED_HITS_TO_REMEMBER];
|
||||
} last_hit_t;
|
||||
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||
|
||||
typedef enum rgb_task_states {
|
||||
STARTING,
|
||||
RENDERING,
|
||||
FLUSHING,
|
||||
SYNCING
|
||||
} rgb_task_states;
|
||||
|
||||
typedef uint8_t led_flags_t;
|
||||
|
||||
typedef struct PACKED {
|
||||
uint8_t iter;
|
||||
led_flags_t flags;
|
||||
bool init;
|
||||
} effect_params_t;
|
||||
|
||||
typedef struct PACKED {
|
||||
// Global tick at 20 Hz
|
||||
uint32_t tick;
|
||||
// Ticks since this key was last hit.
|
||||
uint32_t any_key_hit;
|
||||
} rgb_counters_t;
|
||||
|
||||
typedef struct PACKED {
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
} point_t;
|
||||
|
||||
typedef union {
|
||||
uint8_t raw;
|
||||
struct {
|
||||
uint8_t row:4; // 16 max
|
||||
uint8_t col:4; // 16 max
|
||||
};
|
||||
} matrix_co_t;
|
||||
|
||||
typedef struct PACKED {
|
||||
matrix_co_t matrix_co;
|
||||
point_t point;
|
||||
uint8_t modifier:1;
|
||||
} rgb_led;
|
||||
|
||||
typedef union {
|
||||
uint32_t raw;
|
||||
struct PACKED {
|
||||
bool enable :1;
|
||||
uint8_t mode :7;
|
||||
uint8_t hue :8;
|
||||
uint8_t sat :8;
|
||||
uint8_t val :8;
|
||||
uint8_t speed :8;//EECONFIG needs to be increased to support this
|
||||
};
|
||||
} rgb_config_t;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack( pop )
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue