]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add ability to animate arm_atsam led matrix from the center of a circle
authorIan O'Dea <ianodea@gmail.com>
Mon, 7 Jan 2019 15:36:28 +0000 (09:36 -0600)
committerIan O'Dea <ianodea@gmail.com>
Mon, 7 Jan 2019 15:36:28 +0000 (09:36 -0600)
tmk_core/protocol/arm_atsam/led_matrix.c
tmk_core/protocol/arm_atsam/led_matrix.h

index e914fc80ea5940cd44507a94a149781ab5fc4510..3e07fbe6c3d72f105029f18a128d43c10b6c9d7f 100644 (file)
@@ -18,6 +18,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "arm_atsam_protocol.h"
 #include "tmk_core/common/led.h"
 #include <string.h>
+#include <math.h>
 
 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;
index cedea8a856dcaff2cd5b94c162a33f2cc4ec0d96..f0d45283484f23992aad2c0a5a757ad7bbaadfe4 100644 (file)
@@ -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[];