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> {
|
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)
|
// coin debounce timer (100ms)
|
||||||
Self {
|
Self {
|
||||||
input: Input::new(pin, Pull::None),
|
input: Input::new(pin, pull),
|
||||||
value: false,
|
value: false,
|
||||||
ready: false,
|
ready: false,
|
||||||
active: 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) };
|
unsafe { system::init_gpio_irq(main_btn_pin.pin(), main_btn_pin.port(), true, true) };
|
||||||
|
|
||||||
// coin debouncer (100ms)
|
// coin debouncer (100ms)
|
||||||
let mut sense_coin_input =
|
let mut sense_coin_input = DebouncedGPIO::new(
|
||||||
DebouncedGPIO::new(sense_coin_pin.degrade(), core_config.tick_rate_hz, 20);
|
sense_coin_pin.degrade(),
|
||||||
|
Pull::None,
|
||||||
|
core_config.tick_rate_hz,
|
||||||
|
20,
|
||||||
|
);
|
||||||
// main button debouncer (100ms)
|
// main button debouncer (100ms)
|
||||||
let mut main_btn_input =
|
let mut main_btn_input = DebouncedGPIO::new(
|
||||||
DebouncedGPIO::new(main_btn_pin.degrade(), core_config.tick_rate_hz, 20);
|
main_btn_pin.degrade(),
|
||||||
|
Pull::None,
|
||||||
|
core_config.tick_rate_hz,
|
||||||
|
20,
|
||||||
|
);
|
||||||
// button debouncer (100ms)
|
// button debouncer (100ms)
|
||||||
let mut volume_btn_input =
|
let mut volume_btn_input = DebouncedGPIO::new(
|
||||||
DebouncedGPIO::new(volume_btn_pin.degrade(), core_config.tick_rate_hz, 100);
|
volume_btn_pin.degrade(),
|
||||||
|
Pull::Down,
|
||||||
|
core_config.tick_rate_hz,
|
||||||
|
100,
|
||||||
|
);
|
||||||
// button debouncer (100ms)
|
// button debouncer (100ms)
|
||||||
let mut light_ctrl_btn_input =
|
let mut light_ctrl_btn_input = DebouncedGPIO::new(
|
||||||
DebouncedGPIO::new(light_ctrl_btn_pin.degrade(), core_config.tick_rate_hz, 100);
|
light_ctrl_btn_pin.degrade(),
|
||||||
|
Pull::Down,
|
||||||
|
core_config.tick_rate_hz,
|
||||||
|
100,
|
||||||
|
);
|
||||||
|
|
||||||
let timer_config = TimerConfig {
|
let timer_config = TimerConfig {
|
||||||
sp_timer_ms: 1000,
|
sp_timer_ms: 1000,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue