pages-tui working
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
// TODO WARNING core 1 should be logic, core 0 wifi, its flipped now
|
||||
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_futures::select::{select3, Either3};
|
||||
use embassy_futures::select::{select, Either, select3, Either3};
|
||||
use embassy_net::{Runner, StackResources};
|
||||
use embassy_sync::signal::Signal;
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
@@ -20,7 +20,9 @@ use esp_alloc as _;
|
||||
use esp_backtrace as _;
|
||||
|
||||
use esp_hal::{
|
||||
gpio::InputConfig,
|
||||
clock::CpuClock,
|
||||
gpio::{Input, Pull},
|
||||
i2c::master::{Config as I2cConfig, I2c},
|
||||
rng::Rng,
|
||||
system::{CpuControl, Stack},
|
||||
@@ -31,6 +33,7 @@ use esp_wifi::{
|
||||
EspWifiController,
|
||||
};
|
||||
|
||||
use pages_tui::input::Key;
|
||||
use log::info;
|
||||
use rust_mqtt::packet::v5::publish_packet::QualityOfService;
|
||||
use static_cell::StaticCell;
|
||||
@@ -122,6 +125,11 @@ async fn main(spawner: Spawner) -> ! {
|
||||
NETWORK_READY.wait().await;
|
||||
info!("Network ready, starting core 0 tasks");
|
||||
|
||||
let config = InputConfig::default().with_pull(Pull::Down);
|
||||
let button_select = Input::new(peripherals.GPIO32, config);
|
||||
let button_next = Input::new(peripherals.GPIO35, config);
|
||||
spawner.spawn(button_detection_task(button_select, button_next)).unwrap();
|
||||
|
||||
// Core 0: display and MPU tasks
|
||||
spawner.spawn(display::task::display_task(display_i2c)).expect("spawn display_task");
|
||||
spawner.spawn(mpu::task::mpu_task(mpu_i2c)).expect("spawn mpu_task");
|
||||
@@ -248,3 +256,25 @@ async fn connection_task(mut controller: WifiController<'static>) {
|
||||
async fn net_task(mut runner: Runner<'static, WifiDevice<'static>>) {
|
||||
runner.run().await
|
||||
}
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn button_detection_task(mut select_btn: Input<'static>, mut next_btn: Input<'static>) {
|
||||
use embassy_futures::select::Either;
|
||||
loop {
|
||||
match select(
|
||||
select_btn.wait_for_rising_edge(),
|
||||
next_btn.wait_for_rising_edge(),
|
||||
).await {
|
||||
Either::First(_) => {
|
||||
info!("Detection: GPIO 32 (Select) triggered!");
|
||||
display::api::push_key(Key::enter()).await;
|
||||
}
|
||||
Either::Second(_) => {
|
||||
info!("Detection: GPIO 35 (Next) triggered!");
|
||||
display::api::push_key(Key::tab()).await
|
||||
}
|
||||
}
|
||||
// Debounce: prevent mechanical bouncing from double-triggering
|
||||
embassy_time::Timer::after(embassy_time::Duration::from_millis(200)).await;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user