Test debouncing
This commit is contained in:
parent
55794a6188
commit
b80ad9da65
16
src/main.rs
16
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue