led matrix programs now basically function
This commit is contained in:
parent
c060bcc236
commit
83fb171fbf
|
@ -112,6 +112,22 @@ void userconf_load()
|
|||
|
||||
userconf.checksum = checksum();
|
||||
userconf.checkval = CHECKVAL;
|
||||
|
||||
// default program connfigs
|
||||
|
||||
// program 0: flashing
|
||||
userconf.pep_conf[0][0] = 0x80; // brightness
|
||||
userconf.pep_conf[0][1] = 200; // flash rate
|
||||
|
||||
// program 2: loops
|
||||
userconf.pep_conf[2][0] = 0xc0; // brightness
|
||||
userconf.pep_conf[2][1] = 0; // looping rate
|
||||
userconf.pep_conf[2][3] = 3; // decay rate
|
||||
|
||||
// program 4: alternating
|
||||
userconf.pep_conf[4][0] = 0x80; // brightness
|
||||
userconf.pep_conf[4][1] = 8; // flash rate
|
||||
userconf.pep_conf[4][3] = 0x0b; // lower brightness on alternate
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ static void pep_0_flash(uint8_t tick)
|
|||
{
|
||||
uint8_t i;
|
||||
|
||||
uint16_t out = userconf.pep_conf[PEP_0][PEP_0_CONF_BRIGHTNESS] ^ 0xff;
|
||||
uint16_t out = userconf.pep_conf[PEP_0][PEP_0_CONF_BRIGHTNESS];
|
||||
uint8_t flash = userconf.pep_conf[PEP_0][PEP_0_CONF_FLASH_RATE];
|
||||
|
||||
if (!flash) {
|
||||
|
@ -56,9 +56,12 @@ static void pep_0_flash(uint8_t tick)
|
|||
if (!pep_work[0]) {
|
||||
pep_work[1] ^= 0x1;
|
||||
if (pep_work[1] & 1) {
|
||||
for (i = 0; i < LED_PEP_COUNT; i++) {
|
||||
for (i = 0; i < LED_PEP_NOTOP; i++) {
|
||||
led.section.pep[i] = out;
|
||||
}
|
||||
for (i = LED_PEP_NOTOP; i < LED_PEP_COUNT; i++) {
|
||||
led.section.pep[i] = out >> 1;
|
||||
}
|
||||
for (i = 0; i < LED_HAT_COUNT; i++) {
|
||||
led.section.hat[i] = out;
|
||||
}
|
||||
|
@ -141,27 +144,49 @@ static void pep_1_sizzle(uint8_t tick)
|
|||
* work global:
|
||||
* 0: loop state
|
||||
*/
|
||||
#define PEP_2_CONF_BRIGHTNESS 0
|
||||
#define PEP_2_CONF_LOOP_RATE 1
|
||||
#define PEP_2_CONF_DECAY_RATE 3
|
||||
|
||||
static void pep_2_loops(uint8_t tick)
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t top, bot;
|
||||
|
||||
pep_work[0]++;
|
||||
uint8_t brite = userconf.pep_conf[PEP_2][PEP_2_CONF_BRIGHTNESS];
|
||||
uint8_t rate = userconf.pep_conf[PEP_2][PEP_2_CONF_LOOP_RATE];
|
||||
uint8_t decay = userconf.pep_conf[PEP_2][PEP_2_CONF_DECAY_RATE];
|
||||
|
||||
top = pep_work[0] * LED_PEP_COUNT;
|
||||
top >>= 8;
|
||||
if (pep_work[0]) {
|
||||
pep_work[0]--;
|
||||
} else {
|
||||
pep_work[0] = rate;
|
||||
pep_work[1]++;
|
||||
}
|
||||
|
||||
bot = pep_work[0] * LED_HAT_COUNT;
|
||||
bot = pep_work[1] * LED_PEP_COUNT;
|
||||
bot >>= 8;
|
||||
|
||||
for (i = 0; i < LED_PEP_COUNT; i++) {
|
||||
if (i == bot) led.section.pep[i] = 255;
|
||||
else if (led.section.pep[i]) led.section.pep[i]--;
|
||||
if (i == bot) led.section.pep[i] = brite;
|
||||
else {
|
||||
if (led.section.pep[i] >= decay) led.section.pep[i] -= decay;
|
||||
else led.section.pep[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
top = pep_work[1] * LED_HAT_COUNT;
|
||||
top >>= 8;
|
||||
|
||||
for (i = 0; i < LED_HAT_COUNT; i++) {
|
||||
if (i == top) led.section.hat[i] = 255;
|
||||
else if (led.section.hat[i]) led.section.hat[i]--;
|
||||
if (i == top) led.section.hat[i] = brite;
|
||||
else {
|
||||
if (led.section.hat[i] >= decay) led.section.hat[i] -= decay;
|
||||
else led.section.hat[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
led_matrix_is_updated();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -175,11 +200,12 @@ static void pep_3_neon_sign(uint8_t tick)
|
|||
uint8_t i;
|
||||
|
||||
// todo: implement flickering on/off
|
||||
// like a flourescent tube warming up or failing
|
||||
for (i = 0; i < LED_PEP_COUNT; i++) {
|
||||
led.section.pep[i] = (tick & 1) ? 255 : 200;
|
||||
led.section.pep[i] = (tick & 2) ? 0x40 : 16;
|
||||
}
|
||||
for (i = 0; i < LED_HAT_COUNT; i++) {
|
||||
led.section.hat[i] = (tick & 1) ? 255 : 200;
|
||||
led.section.hat[i] = (tick & 2) ? 0x80 : 24;
|
||||
}
|
||||
|
||||
led_matrix_is_updated();
|
||||
|
@ -208,6 +234,10 @@ static void pep_4_alternate(uint8_t tick)
|
|||
led.section.hat[i] = (pep_work[1] & 1) ? lo : hi;
|
||||
}
|
||||
|
||||
pep_work[1] ^= 0x1;
|
||||
|
||||
led_matrix_is_updated();
|
||||
|
||||
pep_work[0] = userconf.pep_conf[PEP_4][PEP_4_CONF_FLASH_RATE];
|
||||
} else {
|
||||
pep_work[0]--;
|
||||
|
@ -224,9 +254,9 @@ static void pep_4_alternate(uint8_t tick)
|
|||
* 2: delay step
|
||||
*/
|
||||
static const uint8_t nom_map[5][2] = {
|
||||
{15, 21},
|
||||
{13, 23},
|
||||
{ 6, 24},
|
||||
{14, 21},
|
||||
{12, 23},
|
||||
{ 9, 24},
|
||||
{ 5, 27},
|
||||
{ 2, 29}
|
||||
};
|
||||
|
@ -234,10 +264,6 @@ static const uint8_t nom_map[5][2] = {
|
|||
static void pep_5_nom(uint8_t tick)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
i = nom_map[0][0];
|
||||
i = (uint8_t)i;
|
||||
|
||||
uint8_t start, end;
|
||||
|
||||
switch (pep_work[0]) {
|
||||
|
@ -245,8 +271,7 @@ static void pep_5_nom(uint8_t tick)
|
|||
case 2: { // wait a while
|
||||
if (!pep_work[2]) {
|
||||
// just got here; set a new random timeout
|
||||
i = prng_get8() >> 2;
|
||||
pep_work[2] = (0xff - 64) + i;
|
||||
pep_work[2] = 0xff - (prng_get8() >> 2);
|
||||
} else {
|
||||
// wait around for a little while
|
||||
pep_work[2]--;
|
||||
|
@ -254,6 +279,7 @@ static void pep_5_nom(uint8_t tick)
|
|||
// done here
|
||||
pep_work[1] = 0;
|
||||
pep_work[0]++;
|
||||
pep_work[0] &= 0x3;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,31 +288,31 @@ static void pep_5_nom(uint8_t tick)
|
|||
|
||||
case 1: { // eat the pepper
|
||||
// eat at about one bite per second
|
||||
if ((tick & 0x7f) != 0) break;
|
||||
if ((tick & 0x3f) != 0) break;
|
||||
|
||||
start = 0;
|
||||
|
||||
if (!pep_work[1]) {
|
||||
end = LED_PEP_NOTOP;
|
||||
} else if (pep_work[1] < 6) {
|
||||
start = nom_map[pep_work[i] - 1][0];
|
||||
end = nom_map[pep_work[i] - 1][1];
|
||||
} else {
|
||||
end = 0;
|
||||
} else if (pep_work[1] < 6) {
|
||||
start = nom_map[pep_work[1] - 1][0] - 1;
|
||||
end = nom_map[pep_work[1] - 1][1] - 1;
|
||||
} else {
|
||||
end = LED_PEP_NOTOP - 1;
|
||||
}
|
||||
|
||||
// set pepper body LEDs to initial on state (or off if pepper is fully eated)
|
||||
for (i = 0; i < LED_PEP_NOTOP; i++) {
|
||||
led.section.pep[i] = end ? 255 : 0;
|
||||
led.section.pep[i] = (pep_work[1] < 6) ? 0x80 : 0;
|
||||
}
|
||||
// in this mode we need to light up the top pepper line
|
||||
for (i = LED_PEP_NOTOP; i < LED_PEP_COUNT; i++) {
|
||||
led.section.pep[i] = 200;
|
||||
// in this mode we need to light up the top pepper line as well as the hat
|
||||
for (i = LED_PEP_NOTOP; i < 64; i++) {
|
||||
led.all[i] = 0x60;
|
||||
}
|
||||
|
||||
// clear eated pepper portions, gonna cry
|
||||
if (end) {
|
||||
for (i = start; i < end; i++) {
|
||||
for (i = start; i <= end; i++) {
|
||||
led.section.pep[i] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -301,15 +327,15 @@ static void pep_5_nom(uint8_t tick)
|
|||
}
|
||||
|
||||
case 3: { // regen the pepper
|
||||
if (led.section.pep[pep_work[1]] >= 0xfe) {
|
||||
if (led.section.pep[pep_work[1]] >= (0x80 - 4)) {
|
||||
// next segment
|
||||
pep_work[1]++;
|
||||
if (pep_work[i] >= (LED_PEP_NOTOP - pep_work[i])) {
|
||||
if (pep_work[1] > (LED_PEP_NOTOP - pep_work[1])) {
|
||||
// we're done regenerating
|
||||
pep_work[0] = 0;
|
||||
}
|
||||
} else {
|
||||
led.section.pep[pep_work[1]] += 2;
|
||||
led.section.pep[pep_work[1]] += 4;
|
||||
if (pep_work[1]) {
|
||||
led.section.pep[LED_PEP_NOTOP - pep_work[1]] = led.section.pep[pep_work[1]];
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ void ui_init()
|
|||
}
|
||||
|
||||
uint8_t tmp;
|
||||
volatile uint8_t prog_run = 5;
|
||||
|
||||
void ui_render()
|
||||
{
|
||||
|
@ -80,7 +81,8 @@ void ui_render()
|
|||
}
|
||||
|
||||
// temporary: testing
|
||||
ledprog_pep[1](tick);
|
||||
|
||||
ledprog_pep[prog_run](tick);
|
||||
/*
|
||||
if ((tick & 3) == 3) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue