|
|
@@ -37,34 +37,36 @@ void virtual_portal_tick(void* ctx) {
|
|
|
if (elapsed < led->delay) {
|
|
|
float t_phase = fminf((float)elapsed / (float)led->delay, 1);
|
|
|
if (led->current_phase == 0) {
|
|
|
- if (led->last_r < led->r) {
|
|
|
- furi_hal_light_set(LightRed, lerp(led->last_r, led->r, t_phase));
|
|
|
+ if (led->last_r < led->target_r) {
|
|
|
+ led->r = lerp(led->last_r, led->target_r, t_phase);
|
|
|
}
|
|
|
- if (led->last_g < led->g) {
|
|
|
- furi_hal_light_set(LightGreen, lerp(led->last_g, led->g, t_phase));
|
|
|
+ if (led->last_g < led->target_g) {
|
|
|
+ led->g = lerp(led->last_g, led->target_g, t_phase);
|
|
|
}
|
|
|
- if (led->last_b < led->b) {
|
|
|
- furi_hal_light_set(LightBlue, lerp(led->last_b, led->b, t_phase));
|
|
|
+ if (led->last_b < led->target_b) {
|
|
|
+ led->b = lerp(led->last_b, led->target_b, t_phase);
|
|
|
}
|
|
|
} else {
|
|
|
- if (led->last_r > led->r) {
|
|
|
- furi_hal_light_set(LightRed, lerp(led->last_r, led->r, t_phase));
|
|
|
+ if (led->last_r > led->target_r) {
|
|
|
+ led->r = lerp(led->last_r, led->target_r, t_phase);
|
|
|
}
|
|
|
- if (led->last_g > led->g) {
|
|
|
- furi_hal_light_set(LightGreen, lerp(led->last_g, led->g, t_phase));
|
|
|
+ if (led->last_g > led->target_g) {
|
|
|
+ led->g = lerp(led->last_g, led->target_g, t_phase);
|
|
|
}
|
|
|
- if (led->last_b > led->b) {
|
|
|
- furi_hal_light_set(LightBlue, lerp(led->last_b, led->b, t_phase));
|
|
|
+ if (led->last_b > led->target_b) {
|
|
|
+ led->b = lerp(led->last_b, led->target_b, t_phase);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ furi_hal_light_set(LightRed, led->r);
|
|
|
+ furi_hal_light_set(LightGreen, led->g);
|
|
|
+ furi_hal_light_set(LightBlue, led->b);
|
|
|
} else if (led->two_phase && led->current_phase == 0) {
|
|
|
led->start_time = furi_get_tick();
|
|
|
led->current_phase++;
|
|
|
} else {
|
|
|
- led->last_r = led->r;
|
|
|
- led->last_g = led->g;
|
|
|
- led->last_b = led->b;
|
|
|
+ led->r = led->target_r;
|
|
|
+ led->g = led->target_g;
|
|
|
+ led->b = led->target_b;
|
|
|
furi_hal_light_set(LightRed, led->r);
|
|
|
furi_hal_light_set(LightGreen, led->g);
|
|
|
furi_hal_light_set(LightBlue, led->b);
|
|
|
@@ -85,28 +87,29 @@ void queue_led_command(VirtualPortal* virtual_portal, int side, uint8_t r, uint8
|
|
|
led = &virtual_portal->left;
|
|
|
break;
|
|
|
}
|
|
|
+ led->running = false;
|
|
|
led->last_r = led->r;
|
|
|
led->last_g = led->g;
|
|
|
led->last_b = led->b;
|
|
|
- led->r = r;
|
|
|
- led->g = g;
|
|
|
- led->b = b;
|
|
|
+ led->target_r = r;
|
|
|
+ led->target_g = g;
|
|
|
+ led->target_b = b;
|
|
|
if (duration) {
|
|
|
led->start_time = furi_get_tick();
|
|
|
led->delay = duration;
|
|
|
- led->running = true;
|
|
|
- bool increasing = r > led->last_r || g > led->last_g || b > led->last_b;
|
|
|
- bool decreasing = r < led->last_r || g < led->last_g || b < led->last_b;
|
|
|
+ bool increasing = r > led->r || g > led->g || b > led->b;
|
|
|
+ bool decreasing = r < led->r || g < led->g || b < led->b;
|
|
|
led->two_phase = increasing && decreasing;
|
|
|
led->current_phase = increasing ? 0 : 1;
|
|
|
if (increasing && decreasing) {
|
|
|
duration /= 2;
|
|
|
}
|
|
|
+ led->running = true;
|
|
|
} else {
|
|
|
if (side == PORTAL_SIDE_RIGHT) {
|
|
|
- furi_hal_light_set(LightRed, led->r);
|
|
|
- furi_hal_light_set(LightGreen, led->g);
|
|
|
- furi_hal_light_set(LightBlue, led->b);
|
|
|
+ furi_hal_light_set(LightRed, r);
|
|
|
+ furi_hal_light_set(LightGreen, g);
|
|
|
+ furi_hal_light_set(LightBlue, b);
|
|
|
}
|
|
|
led->running = false;
|
|
|
}
|