Test debouncing

This commit is contained in:
~erin 2023-07-02 09:50:00 -04:00
parent 55794a6188
commit b80ad9da65
1 changed files with 13 additions and 3 deletions

View File

@ -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;