From d55dc9b8168dc4582751b4d7ee4b2de3f5b4e3ab Mon Sep 17 00:00:00 2001 From: Ian O'Dea Date: Mon, 7 Jan 2019 09:36:28 -0600 Subject: [PATCH 1/3] Add ability to animate arm_atsam led matrix from the center of a circle --- tmk_core/protocol/arm_atsam/led_matrix.c | 20 ++++++++++++++------ tmk_core/protocol/arm_atsam/led_matrix.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index e914fc80ea..3e07fbe6c3 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.c +++ b/tmk_core/protocol/arm_atsam/led_matrix.c @@ -18,6 +18,7 @@ along with this program. If not, see . #include "arm_atsam_protocol.h" #include "tmk_core/common/led.h" #include +#include void SERCOM1_0_Handler( void ) { @@ -249,6 +250,7 @@ uint8_t led_animation_breathing; uint8_t led_animation_breathe_cur; uint8_t breathe_step; uint8_t breathe_dir; +uint8_t led_animation_circular; uint64_t led_next_run; uint8_t led_animation_id; @@ -327,13 +329,18 @@ void led_matrix_run(void) for (fcur = 0; fcur < fmax; fcur++) { - if (led_animation_orientation) - { - po = led_cur->py; + if (led_animation_circular) { + po = sqrtf((powf(fabsf(50 - led_cur->py), 2) + powf(fabsf(50 - led_cur->px), 2))); } - else - { - po = led_cur->px; + else { + if (led_animation_orientation) + { + po = led_cur->py; + } + else + { + po = led_cur->px; + } } float pomod; @@ -466,6 +473,7 @@ uint8_t led_matrix_init(void) led_animation_breathe_cur = BREATHE_MIN_STEP; breathe_step = 1; breathe_dir = 1; + led_animation_circular = 0; gcr_min_counter = 0; v_5v_cat_hit = 0; diff --git a/tmk_core/protocol/arm_atsam/led_matrix.h b/tmk_core/protocol/arm_atsam/led_matrix.h index cedea8a856..f0d4528348 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.h +++ b/tmk_core/protocol/arm_atsam/led_matrix.h @@ -129,6 +129,7 @@ extern uint8_t led_animation_orientation; extern uint8_t led_animation_breathing; extern uint8_t led_animation_breathe_cur; extern uint8_t breathe_dir; +extern uint8_t led_animation_circular; extern const uint8_t led_setups_count; extern void *led_setups[]; From 9f3afae5d12e7847639666b30f3239580dafed28 Mon Sep 17 00:00:00 2001 From: Ian O'Dea Date: Mon, 7 Jan 2019 10:20:15 -0600 Subject: [PATCH 2/3] Make arm_atsam led matrix circular animation circular rather than obloid --- tmk_core/protocol/arm_atsam/led_matrix.c | 4 +++- tmk_core/protocol/arm_atsam/led_matrix.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index 3e07fbe6c3..af49db28dd 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.c +++ b/tmk_core/protocol/arm_atsam/led_matrix.c @@ -218,6 +218,7 @@ void disp_calc_extents(void) disp.width = disp.right - disp.left; disp.height = disp.top - disp.bottom; + disp.max_distance = sqrtf(powf(disp.width, 2) + powf(disp.height, 2)); } void disp_pixel_setup(void) @@ -267,6 +268,7 @@ void led_matrix_run(void) float go; float bo; float po; + uint8_t led_this_run = 0; led_setup_t *f = (led_setup_t*)led_setups[led_animation_id]; @@ -330,7 +332,7 @@ void led_matrix_run(void) { if (led_animation_circular) { - po = sqrtf((powf(fabsf(50 - led_cur->py), 2) + powf(fabsf(50 - led_cur->px), 2))); + 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; } else { if (led_animation_orientation) diff --git a/tmk_core/protocol/arm_atsam/led_matrix.h b/tmk_core/protocol/arm_atsam/led_matrix.h index f0d4528348..4513234e7f 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.h +++ b/tmk_core/protocol/arm_atsam/led_matrix.h @@ -83,6 +83,7 @@ typedef struct led_disp_s { float bottom; float width; float height; + float max_distance; } led_disp_t; uint8_t led_matrix_init(void); From 6ca52c9d571659463a526fdeabb86af10c8e1665 Mon Sep 17 00:00:00 2001 From: Ian O'Dea Date: Mon, 7 Jan 2019 10:22:47 -0600 Subject: [PATCH 3/3] Fix indentation in tmk_core led_matrix.c --- tmk_core/protocol/arm_atsam/led_matrix.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index af49db28dd..9b76d8bbc8 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.c +++ b/tmk_core/protocol/arm_atsam/led_matrix.c @@ -332,17 +332,17 @@ void led_matrix_run(void) { if (led_animation_circular) { - 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((disp.width / 2) - (led_cur->x - disp.left)), 2) + powf(fabsf((disp.height / 2) - (led_cur->y - disp.bottom)), 2))) / disp.max_distance * 100; } else { - if (led_animation_orientation) - { - po = led_cur->py; - } - else - { - po = led_cur->px; - } + if (led_animation_orientation) + { + po = led_cur->py; + } + else + { + po = led_cur->px; + } } float pomod;