Skip to content

Commit

Permalink
fix: revert led not working properly
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgomesdev committed Dec 24, 2023
1 parent bb7bcec commit f1215b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions server/src/ps_move/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ impl PsMoveController {
self.last_led_effect = current_effect;
self.setting.last_led = current_led;

let last_led_effect = &mut self.last_led_effect;

if last_led_effect.duration.is_some() {
let duration = last_led_effect.duration.unwrap();

if last_led_effect.start.elapsed() >= duration {
info!("Last led effect '{}' of '{}' has already expired, setting to off", last_led_effect, self.bt_address);
let off_effect = LedEffect::off();

self.led_effect = off_effect;
self.setting.led = off_effect.kind.get_initial_hsv()
}
}

info!("Reverted '{:?}' to '{}'", self.bt_address, self.led_effect);
}

Expand Down Expand Up @@ -185,20 +199,6 @@ impl PsMoveController {
}

pub fn transform_led(&mut self) {
let last_led_effect = &mut self.last_led_effect;

if last_led_effect.duration.is_some() {
let duration = last_led_effect.duration.unwrap();

if last_led_effect.start.elapsed() >= duration {
info!("Last led effect '{}' of '{}' expired", last_led_effect, self.bt_address);
let off_effect = LedEffect::off();

self.last_led_effect = off_effect;
self.setting.last_led = off_effect.kind.get_initial_hsv()
}
};

let led_effect = &mut self.led_effect;
let current_hsv = self.setting.led;

Expand Down
2 changes: 1 addition & 1 deletion server/src/tasks/controllers_list_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub async fn run(
get_on_connected_effect()
} else {
tracing::info!(
"Setting current initial effect on '{}'. ({initial_effect})",
"Setting current effect on '{}'. ({initial_effect})",
controller.bt_address
);
initial_effect
Expand Down

0 comments on commit f1215b4

Please sign in to comment.