diff --git a/src/main.rs b/src/main.rs index cfd6502..bae4541 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,13 +63,23 @@ fn main() -> ! { let mut switchSmoothed: f32 = 0.0; let mut switchPrev: f32 = 0.0; + let mut switch_count = 0.0; loop { - let val = match switch.is_low() { + /* Get Input */ + switch_count = match switch.is_low() { true => 1.0, - false => 0.0, + false => switch_count - 0.2, }; - switchSmoothed = (val * 0.05) + (switchPrev * 0.95); + + let val; + if switch_count > 0.0 { + val = 1.0; + } else { + val = 0.0; + } + + switchSmoothed = (switch_count * 0.05) + (switchPrev * 0.95); switchPrev = switchSmoothed; let deg = (190.0 * switchSmoothed) + 25.0;