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 45ef1f2
Showing 1 changed file with 14 additions and 14 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 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

0 comments on commit 45ef1f2

Please sign in to comment.