mirror of
https://github.com/whowechina/aic_pico.git
synced 2024-11-27 23:10:48 +01:00
Improve light brightness control
This commit is contained in:
parent
7aa1c83f58
commit
5863d20be1
@ -378,14 +378,15 @@ static void rainbow_control(uint32_t delta_ms)
|
||||
}
|
||||
|
||||
/* non linear speed change for better visual */
|
||||
|
||||
int range = rainbow.speed.to - rainbow.speed.from;
|
||||
int progress = fast_sqrt(rainbow.elapsed * 10000 / rainbow.smooth_ms);
|
||||
rainbow.speed.current = rainbow.speed.from + range * progress / 100;
|
||||
|
||||
range = rainbow.level.to - rainbow.level.from;
|
||||
progress = fast_sqrt(rainbow.elapsed * 10000 / rainbow.smooth_ms);
|
||||
progress = rainbow.elapsed * 100 / rainbow.smooth_ms;
|
||||
rainbow.level.current = rainbow.level.from + range * progress / 100;
|
||||
|
||||
printf("\nlevel: %d", rainbow.level.current);
|
||||
}
|
||||
|
||||
#define RAINBOW_PITCH 37
|
||||
|
@ -115,9 +115,12 @@ static void light_mode_update()
|
||||
{
|
||||
static bool was_cardio = true;
|
||||
bool cardio = !reader_is_active() && !hid_is_active();
|
||||
static uint8_t last_level;
|
||||
bool level_changed = (last_level != aic_cfg->light.level_idle);
|
||||
|
||||
if (cardio && !was_cardio) {
|
||||
light_rainbow(1, 1, aic_cfg->light.level_idle);
|
||||
if (cardio && (!was_cardio || level_changed)) {
|
||||
light_rainbow(1, 1000, aic_cfg->light.level_idle);
|
||||
last_level = aic_cfg->light.level_idle;
|
||||
}
|
||||
|
||||
was_cardio = cardio;
|
||||
|
Loading…
Reference in New Issue
Block a user