summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tmk_core/protocol/arm_atsam/led_matrix.c73
-rw-r--r--tmk_core/protocol/arm_atsam/led_matrix.h1
2 files changed, 43 insertions, 31 deletions
diff --git a/tmk_core/protocol/arm_atsam/led_matrix.c b/tmk_core/protocol/arm_atsam/led_matrix.c
index c328fdc4ce..729e042a6e 100644
--- a/tmk_core/protocol/arm_atsam/led_matrix.c
+++ b/tmk_core/protocol/arm_atsam/led_matrix.c
@@ -226,7 +226,7 @@ void disp_pixel_setup(void)
while (cur < lede)
{
cur->px = (cur->x - disp.left) / disp.width * 100;
- cur->py = (cur->y - disp.top) / disp.height * 100;
+ cur->py = (cur->y - disp.bottom) / disp.height * 100;
*cur->rgb.r = 0;
*cur->rgb.g = 0;
*cur->rgb.b = 0;
@@ -244,6 +244,7 @@ void led_matrix_prepare(void)
uint8_t led_enabled;
float led_animation_speed;
uint8_t led_animation_direction;
+uint8_t led_animation_orientation;
uint8_t led_animation_breathing;
uint8_t led_animation_breathe_cur;
uint8_t breathe_step;
@@ -263,7 +264,7 @@ void led_matrix_run(void)
float ro;
float go;
float bo;
- float px;
+ float po;
uint8_t led_this_run = 0;
led_setup_t *f = (led_setup_t*)led_setups[led_animation_id];
@@ -325,59 +326,68 @@ void led_matrix_run(void)
//Act on LED
for (fcur = 0; fcur < fmax; fcur++)
{
- px = led_cur->px;
- float pxmod;
- pxmod = (float)(disp.frame % (uint32_t)(1000.0f / led_animation_speed)) / 10.0f * led_animation_speed;
+
+ if (led_animation_orientation)
+ {
+ po = led_cur->py;
+ }
+ else
+ {
+ po = led_cur->px;
+ }
+
+ float pomod;
+ pomod = (float)(disp.frame % (uint32_t)(1000.0f / led_animation_speed)) / 10.0f * led_animation_speed;
//Add in any moving effects
if ((!led_animation_direction && f[fcur].ef & EF_SCR_R) || (led_animation_direction && (f[fcur].ef & EF_SCR_L)))
{
- pxmod *= 100.0f;
- pxmod = (uint32_t)pxmod % 10000;
- pxmod /= 100.0f;
+ pomod *= 100.0f;
+ pomod = (uint32_t)pomod % 10000;
+ pomod /= 100.0f;
- px -= pxmod;
+ po -= pomod;
- if (px > 100) px -= 100;
- else if (px < 0) px += 100;
+ if (po > 100) po -= 100;
+ else if (po < 0) po += 100;
}
else if ((!led_animation_direction && f[fcur].ef & EF_SCR_L) || (led_animation_direction && (f[fcur].ef & EF_SCR_R)))
{
- pxmod *= 100.0f;
- pxmod = (uint32_t)pxmod % 10000;
- pxmod /= 100.0f;
- px += pxmod;
+ pomod *= 100.0f;
+ pomod = (uint32_t)pomod % 10000;
+ pomod /= 100.0f;
+ po += pomod;
- if (px > 100) px -= 100;
- else if (px < 0) px += 100;
+ if (po > 100) po -= 100;
+ else if (po < 0) po += 100;
}
- //Check if LED's px is in current frame
- if (px < f[fcur].hs) continue;
- if (px > f[fcur].he) continue;
+ //Check if LED's po is in current frame
+ if (po < f[fcur].hs) continue;
+ if (po > f[fcur].he) continue;
//note: < 0 or > 100 continue
- //Calculate the px within the start-stop percentage for color blending
- px = (px - f[fcur].hs) / (f[fcur].he - f[fcur].hs);
+ //Calculate the po within the start-stop percentage for color blending
+ po = (po - f[fcur].hs) / (f[fcur].he - f[fcur].hs);
//Add in any color effects
if (f[fcur].ef & EF_OVER)
{
- ro = (px * (f[fcur].re - f[fcur].rs)) + f[fcur].rs;// + 0.5;
- go = (px * (f[fcur].ge - f[fcur].gs)) + f[fcur].gs;// + 0.5;
- bo = (px * (f[fcur].be - f[fcur].bs)) + f[fcur].bs;// + 0.5;
+ ro = (po * (f[fcur].re - f[fcur].rs)) + f[fcur].rs;// + 0.5;
+ go = (po * (f[fcur].ge - f[fcur].gs)) + f[fcur].gs;// + 0.5;
+ bo = (po * (f[fcur].be - f[fcur].bs)) + f[fcur].bs;// + 0.5;
}
else if (f[fcur].ef & EF_SUBTRACT)
{
- ro -= (px * (f[fcur].re - f[fcur].rs)) + f[fcur].rs;// + 0.5;
- go -= (px * (f[fcur].ge - f[fcur].gs)) + f[fcur].gs;// + 0.5;
- bo -= (px * (f[fcur].be - f[fcur].bs)) + f[fcur].bs;// + 0.5;
+ ro -= (po * (f[fcur].re - f[fcur].rs)) + f[fcur].rs;// + 0.5;
+ go -= (po * (f[fcur].ge - f[fcur].gs)) + f[fcur].gs;// + 0.5;
+ bo -= (po * (f[fcur].be - f[fcur].bs)) + f[fcur].bs;// + 0.5;
}
else
{
- ro += (px * (f[fcur].re - f[fcur].rs)) + f[fcur].rs;// + 0.5;
- go += (px * (f[fcur].ge - f[fcur].gs)) + f[fcur].gs;// + 0.5;
- bo += (px * (f[fcur].be - f[fcur].bs)) + f[fcur].bs;// + 0.5;
+ ro += (po * (f[fcur].re - f[fcur].rs)) + f[fcur].rs;// + 0.5;
+ go += (po * (f[fcur].ge - f[fcur].gs)) + f[fcur].gs;// + 0.5;
+ bo += (po * (f[fcur].be - f[fcur].bs)) + f[fcur].bs;// + 0.5;
}
}
}
@@ -451,6 +461,7 @@ uint8_t led_matrix_init(void)
led_lighting_mode = LED_MODE_NORMAL;
led_animation_speed = 4.0f;
led_animation_direction = 0;
+ led_animation_orientation = 0;
led_animation_breathing = 0;
led_animation_breathe_cur = BREATHE_MIN_STEP;
breathe_step = 1;
diff --git a/tmk_core/protocol/arm_atsam/led_matrix.h b/tmk_core/protocol/arm_atsam/led_matrix.h
index 3f2b9cdb86..cedea8a856 100644
--- a/tmk_core/protocol/arm_atsam/led_matrix.h
+++ b/tmk_core/protocol/arm_atsam/led_matrix.h
@@ -125,6 +125,7 @@ extern uint8_t led_enabled;
extern float led_animation_speed;
extern uint8_t led_lighting_mode;
extern uint8_t led_animation_direction;
+extern uint8_t led_animation_orientation;
extern uint8_t led_animation_breathing;
extern uint8_t led_animation_breathe_cur;
extern uint8_t breathe_dir;