remove keyboard fifo
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -25,7 +25,7 @@ use embedded_sdmmc::asynchronous::{File, SdCard, ShortFileName, VolumeIdx, Volum
|
|||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
|
|
||||||
mod peripherals;
|
mod peripherals;
|
||||||
use peripherals::{keyboard::KeyEvent, peripherals_task};
|
use peripherals::{conf_peripherals, keyboard::KeyEvent};
|
||||||
mod display;
|
mod display;
|
||||||
use display::display_task;
|
use display::display_task;
|
||||||
|
|
||||||
@@ -37,16 +37,11 @@ embassy_rp::bind_interrupts!(struct Irqs {
|
|||||||
async fn main(spawner: Spawner) {
|
async fn main(spawner: Spawner) {
|
||||||
let p = embassy_rp::init(Default::default());
|
let p = embassy_rp::init(Default::default());
|
||||||
|
|
||||||
static KEYBOARD_EVENTS: StaticCell<Channel<NoopRawMutex, KeyEvent, 10>> = StaticCell::new();
|
// configure keyboard event handler
|
||||||
let keyboard_events = KEYBOARD_EVENTS.init(Channel::new());
|
let mut config = i2c::Config::default();
|
||||||
|
config.frequency = 100_000;
|
||||||
// // configure keyboard event handler
|
let i2c1 = I2c::new_async(p.I2C1, p.PIN_7, p.PIN_6, Irqs, config);
|
||||||
// let mut config = i2c::Config::default();
|
conf_peripherals(i2c1).await;
|
||||||
// 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 display handler
|
// configure display handler
|
||||||
let mut config = spi::Config::default();
|
let mut config = spi::Config::default();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const KEY_CAPSLOCK: u8 = 1 << 5;
|
|||||||
const KEY_NUMLOCK: u8 = 1 << 6;
|
const KEY_NUMLOCK: u8 = 1 << 6;
|
||||||
const KEY_COUNT_MASK: u8 = 0x1F; // 0x1F == 31
|
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 mut i2c = PERIPHERAL_BUS.get().lock().await;
|
||||||
let i2c = i2c.as_mut().unwrap();
|
let i2c = i2c.as_mut().unwrap();
|
||||||
|
|
||||||
@@ -40,16 +40,15 @@ pub async fn read_keyboard_fifo(channel: &mut Sender<'static, NoopRawMutex, KeyE
|
|||||||
.await
|
.await
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
channel
|
return Some(KeyEvent {
|
||||||
.try_send(KeyEvent {
|
state: KeyState::from(event[0]),
|
||||||
state: KeyState::from(event[0]),
|
key: KeyCode::from(event[1]),
|
||||||
key: KeyCode::from(event[1]),
|
mods: Modifiers::NONE,
|
||||||
mods: Modifiers::NONE,
|
});
|
||||||
})
|
|
||||||
.expect("Failed to push key");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
const REG_ID_DEB: u8 = 0x06;
|
const REG_ID_DEB: u8 = 0x06;
|
||||||
|
|||||||
@@ -25,11 +25,7 @@ const REG_ID_VER: u8 = 0x01;
|
|||||||
const REG_ID_RST: u8 = 0x08;
|
const REG_ID_RST: u8 = 0x08;
|
||||||
const REG_ID_INT: u8 = 0x03;
|
const REG_ID_INT: u8 = 0x03;
|
||||||
|
|
||||||
#[embassy_executor::task]
|
pub async fn conf_peripherals(i2c: I2CBUS) {
|
||||||
pub async fn peripherals_task(
|
|
||||||
i2c: I2CBUS,
|
|
||||||
mut keyboard_channel: Sender<'static, NoopRawMutex, KeyEvent, 10>,
|
|
||||||
) {
|
|
||||||
Timer::after(embassy_time::Duration::from_millis(100)).await;
|
Timer::after(embassy_time::Duration::from_millis(100)).await;
|
||||||
|
|
||||||
PERIPHERAL_BUS.get().lock().await.replace(i2c);
|
PERIPHERAL_BUS.get().lock().await.replace(i2c);
|
||||||
@@ -37,11 +33,6 @@ pub async fn peripherals_task(
|
|||||||
configure_keyboard(200, 100).await;
|
configure_keyboard(200, 100).await;
|
||||||
set_lcd_backlight(255).await;
|
set_lcd_backlight(255).await;
|
||||||
set_key_backlight(0).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
|
/// return major & minor mcu version
|
||||||
|
|||||||
Reference in New Issue
Block a user