add click, short, and long press handling / detection
This commit is contained in:
parent
2d8e2ce6ee
commit
5aa56a244d
2 changed files with 37 additions and 8 deletions
|
|
@ -396,6 +396,19 @@ impl App {
|
||||||
// TODO
|
// TODO
|
||||||
#[cfg(feature = "enable_print")]
|
#[cfg(feature = "enable_print")]
|
||||||
println!("main button release");
|
println!("main button release");
|
||||||
|
match (
|
||||||
|
self.timers.sp_timer.is_enabled(),
|
||||||
|
self.timers.lp_timer.is_enabled(),
|
||||||
|
) {
|
||||||
|
// click
|
||||||
|
(true, true) => self.main_button_click(),
|
||||||
|
// short press
|
||||||
|
(false, true) => self.main_button_short_press(),
|
||||||
|
// long press
|
||||||
|
(false, false) => self.main_button_long_press(),
|
||||||
|
// anything else is not possible
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
self.timers.sp_timer.reset();
|
self.timers.sp_timer.reset();
|
||||||
self.timers.lp_timer.reset();
|
self.timers.lp_timer.reset();
|
||||||
}
|
}
|
||||||
|
|
@ -406,6 +419,25 @@ impl App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Events
|
||||||
|
impl App {
|
||||||
|
fn main_button_click(&self) {
|
||||||
|
// TODO
|
||||||
|
#[cfg(feature = "enable_print")]
|
||||||
|
println!("click");
|
||||||
|
}
|
||||||
|
fn main_button_short_press(&self) {
|
||||||
|
// TODO
|
||||||
|
#[cfg(feature = "enable_print")]
|
||||||
|
println!("short press");
|
||||||
|
}
|
||||||
|
fn main_button_long_press(&self) {
|
||||||
|
// TODO
|
||||||
|
#[cfg(feature = "enable_print")]
|
||||||
|
println!("long press");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO LIST
|
// TODO LIST
|
||||||
//
|
//
|
||||||
// AUDIO:
|
// AUDIO:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::insert_coin::services::{TickServiceData, TickService};
|
use crate::insert_coin::services::{TickService, TickServiceData};
|
||||||
|
|
||||||
pub struct TickTimerService {
|
pub struct TickTimerService {
|
||||||
service_data: core::cell::RefCell<TickServiceData>,
|
service_data: core::cell::RefCell<TickServiceData>,
|
||||||
|
|
@ -15,9 +15,9 @@ impl TickTimerService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn is_enabled(&self) -> bool {
|
pub fn is_enabled(&self) -> bool {
|
||||||
// self.enabled
|
self.enabled
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
let mut sd = self.service_data.borrow_mut();
|
let mut sd = self.service_data.borrow_mut();
|
||||||
|
|
@ -30,7 +30,6 @@ impl TickTimerService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl TickService for TickTimerService {
|
impl TickService for TickTimerService {
|
||||||
fn tick(&self) {
|
fn tick(&self) {
|
||||||
if self.enabled {
|
if self.enabled {
|
||||||
|
|
@ -48,5 +47,3 @@ impl TickService for TickTimerService {
|
||||||
tc.ticks_remaining = tc.ticks_per_service;
|
tc.ticks_remaining = tc.ticks_per_service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue