Checkpoint

This commit is contained in:
Luke Jones
2025-02-08 23:06:02 +13:00
parent 377bb4d6ad
commit 663f87d5e2
24 changed files with 131 additions and 93 deletions

View File

@@ -8,6 +8,7 @@ use std::sync::Arc;
use std::thread::sleep;
use config_traits::StdConfig;
use futures_util::lock::Mutex;
use log::{debug, error, info, warn};
use rog_anime::usb::{
pkt_flush, pkt_set_brightness, pkt_set_enable_display, pkt_set_enable_powersave_anim,
@@ -16,7 +17,6 @@ use rog_anime::usb::{
use rog_anime::{ActionData, AnimeDataBuffer, AnimePacketType};
use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw;
use tokio::sync::Mutex;
use self::config::{AniMeConfig, AniMeConfigCached};
use crate::error::RogError;
@@ -51,7 +51,7 @@ impl AniMe {
/// Will fail if something is already holding the config lock
async fn do_init_cache(&mut self) {
if let Ok(mut config) = self.config.try_lock() {
if let Some(mut config) = self.config.try_lock() {
if let Err(e) = self.cache.init_from_config(&config, config.anime_type) {
error!(
"Trying to cache the Anime Config failed, will reset to default config: {e:?}"

View File

@@ -81,7 +81,7 @@ impl AniMeZbus {
/// Set base brightness level
#[zbus(property)]
async fn brightness(&self) -> Brightness {
if let Ok(config) = self.0.config.try_lock() {
if let Some(config) = self.0.config.try_lock() {
return config.display_brightness;
}
Brightness::Off
@@ -113,7 +113,7 @@ impl AniMeZbus {
#[zbus(property)]
async fn builtins_enabled(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() {
if let Some(config) = self.0.config.try_lock() {
return config.builtin_anims_enabled;
}
false
@@ -158,7 +158,7 @@ impl AniMeZbus {
#[zbus(property)]
async fn builtin_animations(&self) -> Animations {
if let Ok(config) = self.0.config.try_lock() {
if let Some(config) = self.0.config.try_lock() {
return config.builtin_anims;
}
Animations::default()
@@ -191,7 +191,7 @@ impl AniMeZbus {
#[zbus(property)]
async fn enable_display(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() {
if let Some(config) = self.0.config.try_lock() {
return config.display_enabled;
}
false
@@ -214,7 +214,7 @@ impl AniMeZbus {
#[zbus(property)]
async fn off_when_unplugged(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() {
if let Some(config) = self.0.config.try_lock() {
return config.off_when_unplugged;
}
false
@@ -241,7 +241,7 @@ impl AniMeZbus {
#[zbus(property)]
async fn off_when_suspended(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() {
if let Some(config) = self.0.config.try_lock() {
return config.off_when_suspended;
}
false
@@ -257,7 +257,7 @@ impl AniMeZbus {
#[zbus(property)]
async fn off_when_lid_closed(&self) -> bool {
if let Ok(config) = self.0.config.try_lock() {
if let Some(config) = self.0.config.try_lock() {
return config.off_when_lid_closed;
}
false