aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorjust-another-jxliu <just-another-jxliu@users.noreply.github.com>2021-10-29 13:11:48 -0700
committerGitHub <noreply@github.com>2021-10-29 13:11:48 -0700
commit736d9fa5384977159abf55b72251c93a5dba8356 (patch)
tree2b2a75dd512cffcd8c7d74da95777c7c120cabf0 /tmk_core
parent55fb468d7453eb31bc1793772938e2d28881fcaa (diff)
downloadqmk_firmware-736d9fa5384977159abf55b72251c93a5dba8356.tar.gz
qmk_firmware-736d9fa5384977159abf55b72251c93a5dba8356.zip
Stop-gap forward-port Drop LED features for CTRL and ALT (#14967)
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix.c48
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix.h21
2 files changed, 65 insertions, 4 deletions
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
index 98967aac8..43d9f2ee6 100644
--- a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c
@@ -341,6 +341,10 @@ uint8_t led_lighting_mode = LED_MODE_NORMAL;
341uint8_t led_enabled = 1; 341uint8_t led_enabled = 1;
342uint8_t led_animation_breathe_cur = BREATHE_MIN_STEP; 342uint8_t led_animation_breathe_cur = BREATHE_MIN_STEP;
343uint8_t breathe_dir = 1; 343uint8_t breathe_dir = 1;
344uint8_t led_animation_circular = 0;
345float led_edge_brightness = 1.0f;
346float led_ratio_brightness = 1.0f;
347uint8_t led_edge_mode = LED_EDGE_MODE_ALL;
344 348
345static void led_run_pattern(led_setup_t* f, float* ro, float* go, float* bo, float pos) { 349static void led_run_pattern(led_setup_t* f, float* ro, float* go, float* bo, float pos) {
346 float po; 350 float po;
@@ -398,16 +402,32 @@ static void led_run_pattern(led_setup_t* f, float* ro, float* go, float* bo, flo
398 } 402 }
399} 403}
400 404
405# define RGB_MAX_DISTANCE 232.9635f
406
401static void md_rgb_matrix_config_override(int i) { 407static void md_rgb_matrix_config_override(int i) {
402 float ro = 0; 408 float ro = 0;
403 float go = 0; 409 float go = 0;
404 float bo = 0; 410 float bo = 0;
405 411 float po;
406 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;
407 412
408 uint8_t highest_active_layer = biton32(layer_state); 413 uint8_t highest_active_layer = biton32(layer_state);
409 414
410 if (led_lighting_mode == LED_MODE_KEYS_ONLY && HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) { 415 if (led_animation_circular) {
416 // TODO: should use min/max values from LED configuration instead of
417 // hard-coded 224, 64
418 // 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;
419 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;
420 } else {
421 if (led_animation_orientation) {
422 po = (float)g_led_config.point[i].y / 64.f * 100;
423 } else {
424 po = (float)g_led_config.point[i].x / 224.f * 100;
425 }
426 }
427
428 if (led_edge_mode == LED_EDGE_MODE_ALTERNATE && LED_IS_EDGE_ALT(led_map[i].scan)) {
429 // Do not act on this LED (Edge alternate lighting mode)
430 } else if (led_lighting_mode == LED_MODE_KEYS_ONLY && HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) {
411 // Do not act on this LED 431 // Do not act on this LED
412 } else if (led_lighting_mode == LED_MODE_NON_KEYS_ONLY && !HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) { 432 } else if (led_lighting_mode == LED_MODE_NON_KEYS_ONLY && !HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) {
413 // Do not act on this LED 433 // Do not act on this LED
@@ -465,10 +485,30 @@ static void md_rgb_matrix_config_override(int i) {
465 } 485 }
466 } 486 }
467 487
488 // Adjust edge LED brightness
489 if (led_edge_brightness != 1 && LED_IS_EDGE(led_map[i].scan)) {
490 ro *= led_edge_brightness;
491 go *= led_edge_brightness;
492 bo *= led_edge_brightness;
493 }
494
495 // Adjust ratio of key vs. underglow (edge) LED brightness
496 if (LED_IS_EDGE(led_map[i].scan) && led_ratio_brightness > 1.0) {
497 // Decrease edge (underglow) LEDs
498 ro *= (2.0 - led_ratio_brightness);
499 go *= (2.0 - led_ratio_brightness);
500 bo *= (2.0 - led_ratio_brightness);
501 } else if (LED_IS_KEY(led_map[i].scan) && led_ratio_brightness < 1.0) {
502 // Decrease KEY LEDs
503 ro *= led_ratio_brightness;
504 go *= led_ratio_brightness;
505 bo *= led_ratio_brightness;
506 }
507
468 led_buffer[i].r = (uint8_t)ro; 508 led_buffer[i].r = (uint8_t)ro;
469 led_buffer[i].g = (uint8_t)go; 509 led_buffer[i].g = (uint8_t)go;
470 led_buffer[i].b = (uint8_t)bo; 510 led_buffer[i].b = (uint8_t)bo;
471} 511}
472 512
473# endif // USE_MASSDROP_CONFIGURATOR 513# endif // USE_MASSDROP_CONFIGURATOR
474#endif // RGB_MATRIX_ENABLE \ No newline at end of file 514#endif // RGB_MATRIX_ENABLE
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix.h b/tmk_core/protocol/arm_atsam/md_rgb_matrix.h
index 76ccaa678..f72dca298 100644
--- a/tmk_core/protocol/arm_atsam/md_rgb_matrix.h
+++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.h
@@ -128,6 +128,8 @@ typedef struct led_instruction_s {
128 uint32_t id1; // Bitwise id, IDs 32-63 128 uint32_t id1; // Bitwise id, IDs 32-63
129 uint32_t id2; // Bitwise id, IDs 64-95 129 uint32_t id2; // Bitwise id, IDs 64-95
130 uint32_t id3; // Bitwise id, IDs 96-127 130 uint32_t id3; // Bitwise id, IDs 96-127
131 uint32_t id4; // Bitwise id, IDs 128-159
132 uint32_t id5; // Bitwise id, IDs 160-191
131 uint8_t layer; 133 uint8_t layer;
132 uint8_t r; 134 uint8_t r;
133 uint8_t g; 135 uint8_t g;
@@ -146,6 +148,11 @@ extern uint8_t led_enabled;
146extern uint8_t led_animation_breathe_cur; 148extern uint8_t led_animation_breathe_cur;
147extern uint8_t led_animation_direction; 149extern uint8_t led_animation_direction;
148extern uint8_t breathe_dir; 150extern uint8_t breathe_dir;
151extern uint8_t led_animation_orientation;
152extern uint8_t led_animation_circular;
153extern float led_edge_brightness;
154extern float led_ratio_brightness;
155extern uint8_t led_edge_mode;
149 156
150# define LED_MODE_NORMAL 0 // Must be 0 157# define LED_MODE_NORMAL 0 // Must be 0
151# define LED_MODE_KEYS_ONLY 1 158# define LED_MODE_KEYS_ONLY 1
@@ -153,6 +160,20 @@ extern uint8_t breathe_dir;
153# define LED_MODE_INDICATORS_ONLY 3 160# define LED_MODE_INDICATORS_ONLY 3
154# define LED_MODE_MAX_INDEX LED_MODE_INDICATORS_ONLY // Must be highest value 161# define LED_MODE_MAX_INDEX LED_MODE_INDICATORS_ONLY // Must be highest value
155 162
163# define LED_EDGE_MODE_ALL 0 // All edge LEDs are active (Must be 0)
164# define LED_EDGE_MODE_ALTERNATE 1 // Alternate mode of edge LEDs are active (Intention is for 'only every other edge LED' to be active)
165# define LED_EDGE_MODE_MAX LED_EDGE_MODE_ALTERNATE // Must be the highest valued LED edge mode
166
167# define LED_EDGE_FULL_MODE 255 // LEDs configured with this scan code will always be on for edge lighting modes
168# define LED_EDGE_ALT_MODE 254 // LEDs configured with this scan code will turn off in edge alternating mode
169# define LED_EDGE_MIN_SCAN 254 // LEDs configured with scan code >= to this are assigned as edge LEDs
170# define LED_INDICATOR_SCAN 253 // LEDs configured as dedicated indicators
171
172# define LED_IS_KEY(scan) (scan < LED_INDICATOR_SCAN) // Return true if an LED's scan value indicates it is a key LED
173# define LED_IS_EDGE(scan) (scan >= LED_EDGE_MIN_SCAN) // Return true if an LED's scan value indicates an edge LED
174# 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
175# define LED_IS_INDICATOR(scan) (scan == LED_INDICATOR_SCAN) // Return true if an LED's scan value indicates it is a dedicated Indicator
176
156#endif // USE_MASSDROP_CONFIGURATOR 177#endif // USE_MASSDROP_CONFIGURATOR
157 178
158#endif //_LED_MATRIX_H_ 179#endif //_LED_MATRIX_H_