Compare commits
1 commit
main
...
on-chip-pu
| Author | SHA1 | Date | |
|---|---|---|---|
| d115f4e848 |
2 changed files with 31 additions and 10 deletions
|
|
@ -14,10 +14,15 @@ pub struct DebouncedGPIO<'a> {
|
|||
}
|
||||
|
||||
impl<'a> DebouncedGPIO<'a> {
|
||||
pub fn new(pin: AnyPin, system_tick_rate_hz: usize, debounce_time_ms: usize) -> Self {
|
||||
pub fn new(
|
||||
pin: AnyPin,
|
||||
pull: Pull,
|
||||
system_tick_rate_hz: usize,
|
||||
debounce_time_ms: usize,
|
||||
) -> Self {
|
||||
// coin debounce timer (100ms)
|
||||
Self {
|
||||
input: Input::new(pin, Pull::None),
|
||||
input: Input::new(pin, pull),
|
||||
value: false,
|
||||
ready: false,
|
||||
active: false,
|
||||
|
|
|
|||
|
|
@ -343,17 +343,33 @@ fn app_main(mut p: hal::Peripherals, app_settings: Settings) -> Settings {
|
|||
unsafe { system::init_gpio_irq(main_btn_pin.pin(), main_btn_pin.port(), true, true) };
|
||||
|
||||
// coin debouncer (100ms)
|
||||
let mut sense_coin_input =
|
||||
DebouncedGPIO::new(sense_coin_pin.degrade(), core_config.tick_rate_hz, 20);
|
||||
let mut sense_coin_input = DebouncedGPIO::new(
|
||||
sense_coin_pin.degrade(),
|
||||
Pull::None,
|
||||
core_config.tick_rate_hz,
|
||||
20,
|
||||
);
|
||||
// main button debouncer (100ms)
|
||||
let mut main_btn_input =
|
||||
DebouncedGPIO::new(main_btn_pin.degrade(), core_config.tick_rate_hz, 20);
|
||||
let mut main_btn_input = DebouncedGPIO::new(
|
||||
main_btn_pin.degrade(),
|
||||
Pull::None,
|
||||
core_config.tick_rate_hz,
|
||||
20,
|
||||
);
|
||||
// button debouncer (100ms)
|
||||
let mut volume_btn_input =
|
||||
DebouncedGPIO::new(volume_btn_pin.degrade(), core_config.tick_rate_hz, 100);
|
||||
let mut volume_btn_input = DebouncedGPIO::new(
|
||||
volume_btn_pin.degrade(),
|
||||
Pull::Down,
|
||||
core_config.tick_rate_hz,
|
||||
100,
|
||||
);
|
||||
// button debouncer (100ms)
|
||||
let mut light_ctrl_btn_input =
|
||||
DebouncedGPIO::new(light_ctrl_btn_pin.degrade(), core_config.tick_rate_hz, 100);
|
||||
let mut light_ctrl_btn_input = DebouncedGPIO::new(
|
||||
light_ctrl_btn_pin.degrade(),
|
||||
Pull::Down,
|
||||
core_config.tick_rate_hz,
|
||||
100,
|
||||
);
|
||||
|
||||
let timer_config = TimerConfig {
|
||||
sp_timer_ms: 1000,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue