From d55dc9b8168dc4582751b4d7ee4b2de3f5b4e3ab Mon Sep 17 00:00:00 2001 From: Ian O'Dea Date: Mon, 7 Jan 2019 09:36:28 -0600 Subject: Add ability to animate arm_atsam led matrix from the center of a circle --- tmk_core/protocol/arm_atsam/led_matrix.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'tmk_core/protocol/arm_atsam/led_matrix.c') diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index e914fc80e..3e07fbe6c 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; -- cgit v1.2.3-24-g4f1b From 9f3afae5d12e7847639666b30f3239580dafed28 Mon Sep 17 00:00:00 2001 From: Ian O'Dea Date: Mon, 7 Jan 2019 10:20:15 -0600 Subject: Make arm_atsam led matrix circular animation circular rather than obloid --- tmk_core/protocol/arm_atsam/led_matrix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tmk_core/protocol/arm_atsam/led_matrix.c') diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index 3e07fbe6c..af49db28d 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) -- cgit v1.2.3-24-g4f1b From 6ca52c9d571659463a526fdeabb86af10c8e1665 Mon Sep 17 00:00:00 2001 From: Ian O'Dea Date: Mon, 7 Jan 2019 10:22:47 -0600 Subject: Fix indentation in tmk_core led_matrix.c --- tmk_core/protocol/arm_atsam/led_matrix.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tmk_core/protocol/arm_atsam/led_matrix.c') diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index af49db28d..9b76d8bbc 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; -- cgit v1.2.3-24-g4f1b From 6e984a8b5e34ba181b0893a929af569a1faef2b6 Mon Sep 17 00:00:00 2001 From: patrickmt <40182064+patrickmt@users.noreply.github.com> Date: Tue, 18 Dec 2018 15:21:25 -0500 Subject: Update to arm_atsam wait and timer routines Microsecond (us) delays are now handled by a busy wait loop according to MCU frequency. This replaces the system counter method which had an overhead of around 12us. TC5 device and supporting routines removed as it was the old us delay counter. wait_ms is now properly a macro to CLK_delay_ms. wait_us is now properly a macro to CLK_delay_us. Removed CLK_get_us as it has no use. All calls to CLK_get_ms() have been replaced by timer_read64() with corrected typing. All calls to CLK_delay_ms() have been replaced by wait_ms(). All calls to CLK_delay_us() have been replaced by wait_us() and timings verified or updated as needed after review on scope. Corrected typing of variables using 64bit ms timer readings if needed. --- tmk_core/protocol/arm_atsam/led_matrix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tmk_core/protocol/arm_atsam/led_matrix.c') diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index e914fc80e..9ef7393a2 100644 --- a/tmk_core/protocol/arm_atsam/led_matrix.c +++ b/tmk_core/protocol/arm_atsam/led_matrix.c @@ -494,11 +494,11 @@ void led_matrix_task(void) if (led_enabled) { //If an update may run and frame processing has completed - if (CLK_get_ms() >= led_next_run && led_cur == lede) + if (timer_read64() >= led_next_run && led_cur == lede) { uint8_t drvid; - led_next_run = CLK_get_ms() + LED_UPDATE_RATE; //Set next frame update time + led_next_run = timer_read64() + LED_UPDATE_RATE; //Set next frame update time //NOTE: GCR does not need to be timed with LED processing, but there is really no harm if (gcr_actual != gcr_actual_last) -- cgit v1.2.3-24-g4f1b