Skip to content

Instantly share code, notes, and snippets.

@noahbliss
Created November 22, 2023 19:07
Show Gist options
  • Save noahbliss/494267ad7bc78cd9183b4d3a1d2863a2 to your computer and use it in GitHub Desktop.
Save noahbliss/494267ad7bc78cd9183b4d3a1d2863a2 to your computer and use it in GitHub Desktop.
cleaned up a bit
use async_executor::Executor;
//use async_executor::LocalExecutor;
//use edge_executor::Executor;
use futures_lite::future;
use hal::{gpio::*, peripherals::Peripherals, prelude::*, task::*, timer::*};
use std::thread;
use std::time;
fn main() -> anyhow::Result<()> {
hal::sys::link_patches();
println!("Init!");
let exe = Executor::new();
let peripherals = Peripherals::take()?;
//let timer_group0 = hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks);
// GPIO 0 as input
//Buttons
let b1 = PinDriver::input(peripherals.pins.gpio0.downgrade_input())?;
//LEDs
let l1 = PinDriver::output(peripherals.pins.gpio3.downgrade_output())?;
//let timer = TimerDriver::new(peripherals.timer00, &TimerConfig::new())?;
//let iowatch = thread::spawn(run(b1, l1));
//spawner.spawn(run(b1, l1)).ok();
//exe.spawn(run(b1, l1));
let test = exe.spawn(test());
//block_on(exe.run(core::future:pending::<()>()));
block_on(exe.run(test));
//iowatch = futures_util::task:: (run(b1, l1))
loop {
println!("nom");
thread::sleep(time::Duration::from_secs(1)); //This is probably a problem.
}
//Ok(());
}
async fn test() {
loop {
println!("test from async!!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment