mirror of
https://codeberg.org/Fl1tzi/microdeck.git
synced 2024-05-20 03:21:04 +00:00
Compare commits
2 commits
3cf4d1cd7a
...
b26a8834c6
Author | SHA1 | Date | |
---|---|---|---|
Fl1tzi | b26a8834c6 | ||
Fl1tzi | 305d0ea93e |
|
@ -35,6 +35,12 @@ impl Display for DeviceError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for Device {
|
||||||
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
write!(formatter, "{}", self.serial)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Handles everything related to a single device
|
/// Handles everything related to a single device
|
||||||
pub struct Device {
|
pub struct Device {
|
||||||
modules: HashMap<u8, ModuleController>,
|
modules: HashMap<u8, ModuleController>,
|
||||||
|
@ -162,8 +168,9 @@ impl Device {
|
||||||
/// listener for button press changes on the device
|
/// listener for button press changes on the device
|
||||||
#[tracing::instrument(skip_all, fields(serial = self.serial))]
|
#[tracing::instrument(skip_all, fields(serial = self.serial))]
|
||||||
pub async fn key_listener(&mut self) {
|
pub async fn key_listener(&mut self) {
|
||||||
|
let reader = self.device.get_reader();
|
||||||
loop {
|
loop {
|
||||||
match self.device.get_reader().read(7.0).await {
|
match reader.read(7.0).await {
|
||||||
Ok(v) => {
|
Ok(v) => {
|
||||||
trace!("{:?}", v);
|
trace!("{:?}", v);
|
||||||
for update in v {
|
for update in v {
|
||||||
|
@ -238,9 +245,9 @@ impl Device {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn execute_sh(command: &str) {
|
pub async fn execute_sh(command: &str) {
|
||||||
match Command::new("sh").arg(command).output().await {
|
match Command::new("sh").arg("-c").arg(command).spawn() {
|
||||||
Ok(o) => debug!("Command \'{}\' returned: {}", command, o.status),
|
Ok(_) => debug!("Command \'{}\' returned", command),
|
||||||
Err(e) => error!("Command \'{}\' failed: {}", command, e),
|
Err(_) => error!("Command \'{}\' failed", command),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,9 +170,6 @@ pub async fn start_device(
|
||||||
info!("Connected");
|
info!("Connected");
|
||||||
device.init_modules().await;
|
device.init_modules().await;
|
||||||
device.key_listener().await;
|
device.key_listener().await;
|
||||||
if !device.has_modules() {
|
|
||||||
warn!("All modules have failed to start");
|
|
||||||
}
|
|
||||||
Some(device)
|
Some(device)
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
Loading…
Reference in a new issue