]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Make arm_atsam led matrix circular animation circular rather than obloid
authorIan O'Dea <ianodea@gmail.com>
Mon, 7 Jan 2019 16:20:15 +0000 (10:20 -0600)
committerIan O'Dea <ianodea@gmail.com>
Mon, 7 Jan 2019 16:20:15 +0000 (10:20 -0600)
tmk_core/protocol/arm_atsam/led_matrix.c
tmk_core/protocol/arm_atsam/led_matrix.h

index 3e07fbe6c3d72f105029f18a128d43c10b6c9d7f..af49db28dd786c4214bab7c2d22b03478cc6de2c 100644 (file)
@@ -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)
index f0d45283484f23992aad2c0a5a757ad7bbaadfe4..4513234e7f37cd040465d3dfbd76e805f22b877c 100644 (file)
@@ -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);