Create AniMe device only if physical device exists

The call to create the device handler will return with an error if
the physical device doesn't exist, the device (if exists) is stored
in an option already so just keep that as `None` if errored.

Addresses issue #14
This commit is contained in:
Luke
2020-06-08 19:54:07 +12:00
parent 9ddd7da1c2
commit cb8032c7c2
3 changed files with 9 additions and 3 deletions

View File

@@ -69,8 +69,10 @@ pub async fn start_daemon() -> Result<(), Box<dyn Error>> {
// Possible Animatrix
let mut animatrix_writer = None;
if laptop.support_animatrix() {
animatrix_writer = Some(AniMeWriter::new()?);
info!("Device has an AniMe Matrix display");
if let Ok(dev) = AniMeWriter::new() {
animatrix_writer = Some(dev);
info!("Device has an AniMe Matrix display");
}
}
// Set up the mutexes