Prevent crash when failing to send ddc command

This commit is contained in:
Sam W 2022-08-18 09:28:19 +00:00
parent 1fccc92bce
commit 7aab7f726c
1 changed files with 5 additions and 3 deletions

View File

@ -51,10 +51,12 @@ fn run_i2c(idx: usize, mut dev: I2cDeviceDdc, command_channel: Receiver<MonitorC
}
}
event!(Level::INFO, monitor_index = idx, ?cmd, "Sending DDC comand");
match cmd {
MonitorCommand::Brightness(b) => dev.set_vcp_feature(cmd.vcp(), b.into()).unwrap(),
if let Err(e) = match cmd {
MonitorCommand::Brightness(b) => dev.set_vcp_feature(cmd.vcp(), b.into()),
// Hack - add 15 to align with DELL monitors
MonitorCommand::Input(i) => dev.set_vcp_feature(cmd.vcp(), (i + 15).into()).unwrap(),
MonitorCommand::Input(i) => dev.set_vcp_feature(cmd.vcp(), (i + 15).into()),
} {
event!(Level::WARN, err = %e, "Error sending DDC command");
}
last_sent_command.insert(cmd.cmd_str(), Some(Instant::now()));
}