Stop-gap forward-port Drop LED features for CTRL and ALT (#14967)
This commit is contained in:
parent
55fb468d74
commit
736d9fa538
8 changed files with 430 additions and 62 deletions
|
@ -341,6 +341,10 @@ uint8_t led_lighting_mode = LED_MODE_NORMAL;
|
|||
uint8_t led_enabled = 1;
|
||||
uint8_t led_animation_breathe_cur = BREATHE_MIN_STEP;
|
||||
uint8_t breathe_dir = 1;
|
||||
uint8_t led_animation_circular = 0;
|
||||
float led_edge_brightness = 1.0f;
|
||||
float led_ratio_brightness = 1.0f;
|
||||
uint8_t led_edge_mode = LED_EDGE_MODE_ALL;
|
||||
|
||||
static void led_run_pattern(led_setup_t* f, float* ro, float* go, float* bo, float pos) {
|
||||
float po;
|
||||
|
@ -398,16 +402,32 @@ static void led_run_pattern(led_setup_t* f, float* ro, float* go, float* bo, flo
|
|||
}
|
||||
}
|
||||
|
||||
# define RGB_MAX_DISTANCE 232.9635f
|
||||
|
||||
static void md_rgb_matrix_config_override(int i) {
|
||||
float ro = 0;
|
||||
float go = 0;
|
||||
float bo = 0;
|
||||
|
||||
float po = (led_animation_orientation) ? (float)g_led_config.point[i].y / 64.f * 100 : (float)g_led_config.point[i].x / 224.f * 100;
|
||||
float po;
|
||||
|
||||
uint8_t highest_active_layer = biton32(layer_state);
|
||||
|
||||
if (led_lighting_mode == LED_MODE_KEYS_ONLY && HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) {
|
||||
if (led_animation_circular) {
|
||||
// TODO: should use min/max values from LED configuration instead of
|
||||
// hard-coded 224, 64
|
||||
// po = sqrtf((powf(fabsf((disp.width / 2) - (led_cur->x - disp.left)), 2) + powf(fabsf((disp.height / 2) - (led_cur->y - disp.bottom)), 2))) / disp.max_distance * 100;
|
||||
po = sqrtf((powf(fabsf((224 / 2) - (float)g_led_config.point[i].x), 2) + powf(fabsf((64 / 2) - (float)g_led_config.point[i].y), 2))) / RGB_MAX_DISTANCE * 100;
|
||||
} else {
|
||||
if (led_animation_orientation) {
|
||||
po = (float)g_led_config.point[i].y / 64.f * 100;
|
||||
} else {
|
||||
po = (float)g_led_config.point[i].x / 224.f * 100;
|
||||
}
|
||||
}
|
||||
|
||||
if (led_edge_mode == LED_EDGE_MODE_ALTERNATE && LED_IS_EDGE_ALT(led_map[i].scan)) {
|
||||
// Do not act on this LED (Edge alternate lighting mode)
|
||||
} else if (led_lighting_mode == LED_MODE_KEYS_ONLY && HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) {
|
||||
// Do not act on this LED
|
||||
} else if (led_lighting_mode == LED_MODE_NON_KEYS_ONLY && !HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) {
|
||||
// Do not act on this LED
|
||||
|
@ -465,10 +485,30 @@ static void md_rgb_matrix_config_override(int i) {
|
|||
}
|
||||
}
|
||||
|
||||
// Adjust edge LED brightness
|
||||
if (led_edge_brightness != 1 && LED_IS_EDGE(led_map[i].scan)) {
|
||||
ro *= led_edge_brightness;
|
||||
go *= led_edge_brightness;
|
||||
bo *= led_edge_brightness;
|
||||
}
|
||||
|
||||
// Adjust ratio of key vs. underglow (edge) LED brightness
|
||||
if (LED_IS_EDGE(led_map[i].scan) && led_ratio_brightness > 1.0) {
|
||||
// Decrease edge (underglow) LEDs
|
||||
ro *= (2.0 - led_ratio_brightness);
|
||||
go *= (2.0 - led_ratio_brightness);
|
||||
bo *= (2.0 - led_ratio_brightness);
|
||||
} else if (LED_IS_KEY(led_map[i].scan) && led_ratio_brightness < 1.0) {
|
||||
// Decrease KEY LEDs
|
||||
ro *= led_ratio_brightness;
|
||||
go *= led_ratio_brightness;
|
||||
bo *= led_ratio_brightness;
|
||||
}
|
||||
|
||||
led_buffer[i].r = (uint8_t)ro;
|
||||
led_buffer[i].g = (uint8_t)go;
|
||||
led_buffer[i].b = (uint8_t)bo;
|
||||
}
|
||||
|
||||
# endif // USE_MASSDROP_CONFIGURATOR
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
#endif // RGB_MATRIX_ENABLE
|
||||
|
|
|
@ -128,6 +128,8 @@ typedef struct led_instruction_s {
|
|||
uint32_t id1; // Bitwise id, IDs 32-63
|
||||
uint32_t id2; // Bitwise id, IDs 64-95
|
||||
uint32_t id3; // Bitwise id, IDs 96-127
|
||||
uint32_t id4; // Bitwise id, IDs 128-159
|
||||
uint32_t id5; // Bitwise id, IDs 160-191
|
||||
uint8_t layer;
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
|
@ -146,6 +148,11 @@ extern uint8_t led_enabled;
|
|||
extern uint8_t led_animation_breathe_cur;
|
||||
extern uint8_t led_animation_direction;
|
||||
extern uint8_t breathe_dir;
|
||||
extern uint8_t led_animation_orientation;
|
||||
extern uint8_t led_animation_circular;
|
||||
extern float led_edge_brightness;
|
||||
extern float led_ratio_brightness;
|
||||
extern uint8_t led_edge_mode;
|
||||
|
||||
# define LED_MODE_NORMAL 0 // Must be 0
|
||||
# define LED_MODE_KEYS_ONLY 1
|
||||
|
@ -153,6 +160,20 @@ extern uint8_t breathe_dir;
|
|||
# define LED_MODE_INDICATORS_ONLY 3
|
||||
# define LED_MODE_MAX_INDEX LED_MODE_INDICATORS_ONLY // Must be highest value
|
||||
|
||||
# define LED_EDGE_MODE_ALL 0 // All edge LEDs are active (Must be 0)
|
||||
# define LED_EDGE_MODE_ALTERNATE 1 // Alternate mode of edge LEDs are active (Intention is for 'only every other edge LED' to be active)
|
||||
# define LED_EDGE_MODE_MAX LED_EDGE_MODE_ALTERNATE // Must be the highest valued LED edge mode
|
||||
|
||||
# define LED_EDGE_FULL_MODE 255 // LEDs configured with this scan code will always be on for edge lighting modes
|
||||
# define LED_EDGE_ALT_MODE 254 // LEDs configured with this scan code will turn off in edge alternating mode
|
||||
# define LED_EDGE_MIN_SCAN 254 // LEDs configured with scan code >= to this are assigned as edge LEDs
|
||||
# define LED_INDICATOR_SCAN 253 // LEDs configured as dedicated indicators
|
||||
|
||||
# define LED_IS_KEY(scan) (scan < LED_INDICATOR_SCAN) // Return true if an LED's scan value indicates it is a key LED
|
||||
# define LED_IS_EDGE(scan) (scan >= LED_EDGE_MIN_SCAN) // Return true if an LED's scan value indicates an edge LED
|
||||
# define LED_IS_EDGE_ALT(scan) (scan == LED_EDGE_ALT_MODE) // Return true if an LED's scan value indicates an alternate edge mode LED
|
||||
# define LED_IS_INDICATOR(scan) (scan == LED_INDICATOR_SCAN) // Return true if an LED's scan value indicates it is a dedicated Indicator
|
||||
|
||||
#endif // USE_MASSDROP_CONFIGURATOR
|
||||
|
||||
#endif //_LED_MATRIX_H_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue