distinguish between change and notify commands
This commit is contained in:
@ -1,15 +1,13 @@
|
||||
const BUTTON_HOLD_TIME_MS: u64 = 500;
|
||||
const STOP_SAFETY_TIME_MS: u64 = 2000;
|
||||
|
||||
// Debug crates
|
||||
//use esp_idf_svc::timer::EspTaskTimerService;
|
||||
//use core::time::Duration;
|
||||
|
||||
// Crates used in release
|
||||
use log::*; //{trace, debug, info, warn, error}
|
||||
use anyhow::Result;
|
||||
use async_executor::Executor;
|
||||
use futures_lite::future;
|
||||
use std::panic;
|
||||
use std::ops::Deref;
|
||||
|
||||
// Debug modules
|
||||
mod test_console;
|
||||
@ -28,7 +26,6 @@ use crate::commands::Commands;
|
||||
|
||||
//TODO: limit switch driver, would be good in long run if it checked limit switches periodically (every 1s?) to ensure they are still functioning
|
||||
|
||||
|
||||
fn main() {
|
||||
// Do basic initialization
|
||||
esp_idf_svc::sys::link_patches();
|
||||
@ -36,6 +33,22 @@ fn main() {
|
||||
log::set_max_level(log::LevelFilter::Trace);
|
||||
//log::set_max_level(log::LevelFilter::Info);
|
||||
|
||||
// Set panic to use error! instead of write! (as we will potentially log errors)
|
||||
panic::set_hook(Box::new(|panic_info| {
|
||||
let (filename, line) =
|
||||
panic_info.location().map(|loc| (loc.file(), loc.line()))
|
||||
.unwrap_or(("<unknown>", 0));
|
||||
|
||||
let cause = panic_info.payload().downcast_ref::<String>().map(String::deref);
|
||||
|
||||
let cause = cause.unwrap_or_else(||
|
||||
panic_info.payload().downcast_ref::<&str>().map(|s| *s)
|
||||
.unwrap_or("<cause unknown>")
|
||||
);
|
||||
|
||||
error!("A panic occurred at {}:{}: {}", filename, line, cause);
|
||||
}));
|
||||
|
||||
match future::block_on(main_loop()) {
|
||||
Ok(_) => {error!("Exited main loop with no errors, but this should not happen."); panic!();}
|
||||
Err(e) => {error!("Exited main loop with error {}", e); panic!();}
|
||||
|
||||
Reference in New Issue
Block a user