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

@@ -99,6 +99,10 @@ sudo systemctl enable rog-core.service
Thanks to @aspann you can grab it here [sys-power/rog-core](https://lab.retarded.farm/zappel/zGentoo/-/tree/master/sys-power/rog-core)
### Arch AUR
You can find the thingimajig [here](https://aur.archlinux.org/packages/rog-core/)
## Updating
Occasionally I might break things for you by tweaking or changing the config file layout. Usually this will mean you

View File

@@ -33,7 +33,7 @@ impl AniMeWriter {
pub fn new() -> Result<AniMeWriter, Box<dyn Error>> {
// We don't expect this ID to ever change
let mut dev_handle = AniMeWriter::get_device(0x0b05, 0x193b).map_err(|err| {
error!("Could not get device handle: {:?}", err);
error!("Could not get AniMe display handle: {:?}", err);
err
})?;
// This config seems to be the required device config for writing

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