use if syntax instead of match
This commit is contained in:
parent
475dffe6b2
commit
52c918cf1f
1 changed files with 15 additions and 21 deletions
|
|
@ -81,8 +81,7 @@ fn main() -> Result<()> {
|
||||||
// when we receive button event, button interrupt will be automatically disabled until we enable it manually
|
// when we receive button event, button interrupt will be automatically disabled until we enable it manually
|
||||||
// so we use this feature to "debounce" our button by enabling interrupt only after some time passes
|
// so we use this feature to "debounce" our button by enabling interrupt only after some time passes
|
||||||
let not = btn1.button.wait_event(esp_idf_svc::hal::delay::NON_BLOCK);
|
let not = btn1.button.wait_event(esp_idf_svc::hal::delay::NON_BLOCK);
|
||||||
match not {
|
if not.is_some() {
|
||||||
Some(n) => {
|
|
||||||
println!("Button 1 pressed!");
|
println!("Button 1 pressed!");
|
||||||
|
|
||||||
if heater_drv_pin.is_set_high() {
|
if heater_drv_pin.is_set_high() {
|
||||||
|
|
@ -94,19 +93,14 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
input_time = Option::from(Instant::now());
|
input_time = Option::from(Instant::now());
|
||||||
},
|
|
||||||
None => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable button interrupt again after 300ms from last click
|
// enable button interrupt again after 300ms from last click
|
||||||
match input_time {
|
if let Some(time) = input_time {
|
||||||
Some(time) => {
|
|
||||||
if time.elapsed().as_millis() >= 300 {
|
if time.elapsed().as_millis() >= 300 {
|
||||||
btn1.button.enable_interrupt()?;
|
btn1.button.enable_interrupt()?;
|
||||||
input_time.take();
|
input_time.take();
|
||||||
}
|
}
|
||||||
},
|
|
||||||
None => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if measure_time.elapsed().as_millis() >= 10 {
|
if measure_time.elapsed().as_millis() >= 10 {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue