hsc26-artemis2/firmware/app/led/ledprog.c
true d95af918fa initial WIP
lots of code copied over, things filled in to hopefully get the LED matrix lighting up. untested.
2026-05-08 11:54:12 -07:00

81 lines
1.4 KiB
C

/*
* ledprog.c: led programs
*/
#include "matrix.h"
static uint32_t s[8] = {0};
//static uint32_t t[8] = {0};
//static uint32_t l[8] = {0};
void lp_ribbon_init()
{
uint8_t i;
for (i = 0; i < 8; i++) {
s[i] = 0;
}
}
void lp_ribbon_upward(uint16_t wait, uint16_t rate, uint8_t fade)
{
uint32_t i;
uint32_t x;
/*
0: state
1: timeout
2: index
*/
switch (s[0]) {
case 0: { // timeout
if (!s[1]) {
s[0]++;
s[2] = 0;
return;
}
s[1]--;
break;
}
case 1: { // upward trails
// rate delay
if (!s[1]) {
s[1] = rate;
} else {
s[1]--;
break;
}
x = s[2]++;
// are we done?
if (x > sizeof(led_set.ribbon)) {
s[0] = 0;
s[1] = wait;
break;
}
// fade in and up
led_set.ribbon[x] = 0x40;
if (x) led_set.ribbon[x - 1] = 0x70;
if (x > 1) led_set.ribbon[x - 2] = 0xff;
}
}
// fade out LEDs
for (i = 0; i < sizeof(led_set.ribbon); i++) {
if (led_set.ribbon[i] >= fade) {
led_set.ribbon[i] -= fade;
} else {
led_set.ribbon[i] = 0;
}
}
matrix_flag_update();
}