Compare commits

...

2 Commits

Author SHA1 Message Date
Sylvain Munaut 4eb2ed52d2 firmware/main: For candle mode, make max brightness random
This makes it look a bit smoother and also reduces the average
current, saving a bit of power.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2023-03-20 15:26:13 +01:00
Sylvain Munaut 2277549293 firmware/main: For breathe mode, allow earlier OverBright re-use
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2023-03-20 15:20:07 +01:00
1 changed files with 8 additions and 5 deletions

View File

@ -174,6 +174,7 @@ static const struct led_anim la_sparkle2 = {
struct la_candle_state {
struct candle_state cdl[N_LEDS];
uint8_t brg[N_LEDS];
};
static void
@ -181,8 +182,10 @@ la_candle_init(void *state)
{
struct la_candle_state *s = state;
for (int i=0; i<N_LEDS; i++)
for (int i=0; i<N_LEDS; i++) {
candle_init(&s->cdl[i]);
s->brg[i] = 128 + (rand16() & 127);
}
}
static void
@ -192,7 +195,7 @@ la_candle_render(void *state, uint16_t *leds,
struct la_candle_state *s = state;
for (int i=0; i<N_LEDS; i++)
leds[i] = (3750 * conf->dim * candle_exec(&s->cdl[i], conf->speed)) >> 8;
leds[i] = (3750UL * s->brg[i] * conf->dim * candle_exec(&s->cdl[i], conf->speed)) >> 16;
}
static const struct led_anim la_candle = {
@ -277,9 +280,9 @@ la_breathe_render(void *state, uint16_t *leds,
s->leds[i].pha = pha;
/* Early OverBright release */
/* After pha >= 40000, we're not overbright anyway, so
* allow another led to use it early */
if (s->leds[i].ob && (s->leds[i].pha > 40000)) {
/* After pha >= 28000, we know that it's safe to allow a new overbright led
* because we'll be past the peak by the time they start needing overbright */
if (s->leds[i].ob && (s->leds[i].pha > 28000)) {
s->leds[i].ob = false;
s->n_ob--;
}