diff options
| author | Drashna Jaelre <drashna@live.com> | 2019-01-25 16:04:21 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-25 16:04:21 -0800 |
| commit | 0306e487e2cd6a77ad840d0a441b478747b7ccd0 (patch) | |
| tree | 52d34a051c1c9195b68ae4179b06777f387996b6 /tmk_core | |
| parent | 1d3b9eea940908d02b6c2deda5d744a73cd838da (diff) | |
| parent | 6ca52c9d571659463a526fdeabb86af10c8e1665 (diff) | |
| download | qmk_firmware-0306e487e2cd6a77ad840d0a441b478747b7ccd0.tar.gz qmk_firmware-0306e487e2cd6a77ad840d0a441b478747b7ccd0.zip | |
Circular animation (#4796)
* Add ability to animate arm_atsam led matrix from the center of a circle
* Make arm_atsam led matrix circular animation circular rather than obloid
* Fix indentation in tmk_core led_matrix.c
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/protocol/arm_atsam/led_matrix.c | 22 | ||||
| -rw-r--r-- | tmk_core/protocol/arm_atsam/led_matrix.h | 2 |
2 files changed, 18 insertions, 6 deletions
diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c index 9ef7393a2..04d05af6d 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 <http://www.gnu.org/licenses/>. | |||
| 18 | #include "arm_atsam_protocol.h" | 18 | #include "arm_atsam_protocol.h" |
| 19 | #include "tmk_core/common/led.h" | 19 | #include "tmk_core/common/led.h" |
| 20 | #include <string.h> | 20 | #include <string.h> |
| 21 | #include <math.h> | ||
| 21 | 22 | ||
| 22 | void SERCOM1_0_Handler( void ) | 23 | void SERCOM1_0_Handler( void ) |
| 23 | { | 24 | { |
| @@ -217,6 +218,7 @@ void disp_calc_extents(void) | |||
| 217 | 218 | ||
| 218 | disp.width = disp.right - disp.left; | 219 | disp.width = disp.right - disp.left; |
| 219 | disp.height = disp.top - disp.bottom; | 220 | disp.height = disp.top - disp.bottom; |
| 221 | disp.max_distance = sqrtf(powf(disp.width, 2) + powf(disp.height, 2)); | ||
| 220 | } | 222 | } |
| 221 | 223 | ||
| 222 | void disp_pixel_setup(void) | 224 | void disp_pixel_setup(void) |
| @@ -249,6 +251,7 @@ uint8_t led_animation_breathing; | |||
| 249 | uint8_t led_animation_breathe_cur; | 251 | uint8_t led_animation_breathe_cur; |
| 250 | uint8_t breathe_step; | 252 | uint8_t breathe_step; |
| 251 | uint8_t breathe_dir; | 253 | uint8_t breathe_dir; |
| 254 | uint8_t led_animation_circular; | ||
| 252 | uint64_t led_next_run; | 255 | uint64_t led_next_run; |
| 253 | 256 | ||
| 254 | uint8_t led_animation_id; | 257 | uint8_t led_animation_id; |
| @@ -265,6 +268,7 @@ void led_matrix_run(void) | |||
| 265 | float go; | 268 | float go; |
| 266 | float bo; | 269 | float bo; |
| 267 | float po; | 270 | float po; |
| 271 | |||
| 268 | uint8_t led_this_run = 0; | 272 | uint8_t led_this_run = 0; |
| 269 | led_setup_t *f = (led_setup_t*)led_setups[led_animation_id]; | 273 | led_setup_t *f = (led_setup_t*)led_setups[led_animation_id]; |
| 270 | 274 | ||
| @@ -327,13 +331,18 @@ void led_matrix_run(void) | |||
| 327 | for (fcur = 0; fcur < fmax; fcur++) | 331 | for (fcur = 0; fcur < fmax; fcur++) |
| 328 | { | 332 | { |
| 329 | 333 | ||
| 330 | if (led_animation_orientation) | 334 | if (led_animation_circular) { |
| 331 | { | 335 | 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; |
| 332 | po = led_cur->py; | ||
| 333 | } | 336 | } |
| 334 | else | 337 | else { |
| 335 | { | 338 | if (led_animation_orientation) |
| 336 | po = led_cur->px; | 339 | { |
| 340 | po = led_cur->py; | ||
| 341 | } | ||
| 342 | else | ||
| 343 | { | ||
| 344 | po = led_cur->px; | ||
| 345 | } | ||
| 337 | } | 346 | } |
| 338 | 347 | ||
| 339 | float pomod; | 348 | float pomod; |
| @@ -466,6 +475,7 @@ uint8_t led_matrix_init(void) | |||
| 466 | led_animation_breathe_cur = BREATHE_MIN_STEP; | 475 | led_animation_breathe_cur = BREATHE_MIN_STEP; |
| 467 | breathe_step = 1; | 476 | breathe_step = 1; |
| 468 | breathe_dir = 1; | 477 | breathe_dir = 1; |
| 478 | led_animation_circular = 0; | ||
| 469 | 479 | ||
| 470 | gcr_min_counter = 0; | 480 | gcr_min_counter = 0; |
| 471 | v_5v_cat_hit = 0; | 481 | 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 cedea8a85..4513234e7 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 { | |||
| 83 | float bottom; | 83 | float bottom; |
| 84 | float width; | 84 | float width; |
| 85 | float height; | 85 | float height; |
| 86 | float max_distance; | ||
| 86 | } led_disp_t; | 87 | } led_disp_t; |
| 87 | 88 | ||
| 88 | uint8_t led_matrix_init(void); | 89 | uint8_t led_matrix_init(void); |
| @@ -129,6 +130,7 @@ extern uint8_t led_animation_orientation; | |||
| 129 | extern uint8_t led_animation_breathing; | 130 | extern uint8_t led_animation_breathing; |
| 130 | extern uint8_t led_animation_breathe_cur; | 131 | extern uint8_t led_animation_breathe_cur; |
| 131 | extern uint8_t breathe_dir; | 132 | extern uint8_t breathe_dir; |
| 133 | extern uint8_t led_animation_circular; | ||
| 132 | extern const uint8_t led_setups_count; | 134 | extern const uint8_t led_setups_count; |
| 133 | 135 | ||
| 134 | extern void *led_setups[]; | 136 | extern void *led_setups[]; |
