remove keyboard fifo

This commit is contained in:
2025-07-02 20:23:21 -06:00
parent 65ad7bab48
commit a0fb1a0da5
3 changed files with 14 additions and 29 deletions

View File

@@ -25,7 +25,7 @@ use embedded_sdmmc::asynchronous::{File, SdCard, ShortFileName, VolumeIdx, Volum
use static_cell::StaticCell;
mod peripherals;
use peripherals::{keyboard::KeyEvent, peripherals_task};
use peripherals::{conf_peripherals, keyboard::KeyEvent};
mod display;
use display::display_task;
@@ -37,16 +37,11 @@ embassy_rp::bind_interrupts!(struct Irqs {
async fn main(spawner: Spawner) {
let p = embassy_rp::init(Default::default());
static KEYBOARD_EVENTS: StaticCell<Channel<NoopRawMutex, KeyEvent, 10>> = StaticCell::new();
let keyboard_events = KEYBOARD_EVENTS.init(Channel::new());
// // configure keyboard event handler
// let mut config = i2c::Config::default();
// config.frequency = 100_000;
// let i2c1 = I2c::new_async(p.I2C1, p.PIN_7, p.PIN_6, Irqs, config);
// spawner
// .spawn(peripherals_task(i2c1, keyboard_events.sender()))
// .unwrap();
// configure keyboard event handler
let mut config = i2c::Config::default();
config.frequency = 100_000;
let i2c1 = I2c::new_async(p.I2C1, p.PIN_7, p.PIN_6, Irqs, config);
conf_peripherals(i2c1).await;
// configure display handler
let mut config = spi::Config::default();

View File

@@ -17,7 +17,7 @@ const KEY_CAPSLOCK: u8 = 1 << 5;
const KEY_NUMLOCK: u8 = 1 << 6;
const KEY_COUNT_MASK: u8 = 0x1F; // 0x1F == 31
pub async fn read_keyboard_fifo(channel: &mut Sender<'static, NoopRawMutex, KeyEvent, 10>) {
pub async fn read_keyboard_fifo() -> Option<KeyEvent> {
let mut i2c = PERIPHERAL_BUS.get().lock().await;
let i2c = i2c.as_mut().unwrap();
@@ -40,16 +40,15 @@ pub async fn read_keyboard_fifo(channel: &mut Sender<'static, NoopRawMutex, KeyE
.await
.is_ok()
{
channel
.try_send(KeyEvent {
return Some(KeyEvent {
state: KeyState::from(event[0]),
key: KeyCode::from(event[1]),
mods: Modifiers::NONE,
})
.expect("Failed to push key");
});
}
}
}
None
}
const REG_ID_DEB: u8 = 0x06;

View File

@@ -25,11 +25,7 @@ const REG_ID_VER: u8 = 0x01;
const REG_ID_RST: u8 = 0x08;
const REG_ID_INT: u8 = 0x03;
#[embassy_executor::task]
pub async fn peripherals_task(
i2c: I2CBUS,
mut keyboard_channel: Sender<'static, NoopRawMutex, KeyEvent, 10>,
) {
pub async fn conf_peripherals(i2c: I2CBUS) {
Timer::after(embassy_time::Duration::from_millis(100)).await;
PERIPHERAL_BUS.get().lock().await.replace(i2c);
@@ -37,11 +33,6 @@ pub async fn peripherals_task(
configure_keyboard(200, 100).await;
set_lcd_backlight(255).await;
set_key_backlight(0).await;
loop {
Timer::after(Duration::from_millis(200)).await;
read_keyboard_fifo(&mut keyboard_channel).await;
}
}
/// return major & minor mcu version