feat: add tokio runtime and make adync gpio interups on seperate thread
This commit is contained in:
parent
19862ecf70
commit
716153b1b6
4 changed files with 19 additions and 12 deletions
|
|
@ -27,11 +27,14 @@ async fn main() -> Result<()> {
|
|||
Duration::from_secs(DEFAULT_DEBOUNCE_DELAY_SECS)
|
||||
)?;
|
||||
|
||||
// Get a handle to the current runtime
|
||||
let runtime = tokio::runtime::Handle::current();
|
||||
|
||||
// Set up the callback for state changes
|
||||
let callback = move |event: gpio::CircuitEvent| {
|
||||
info!("Circuit state changed to: {:?}", event);
|
||||
let discord_client = discord_client.clone();
|
||||
tokio::spawn(async move {
|
||||
runtime.spawn(async move {
|
||||
let space_event = match event {
|
||||
gpio::CircuitEvent::Open => discord::SpaceEvent::Open,
|
||||
gpio::CircuitEvent::Closed => discord::SpaceEvent::Closed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue