mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae8ce83583 | ||
|
|
5c3348a9f5 | ||
|
|
f299ffeb6e | ||
|
|
21c468cf02 | ||
|
|
7f12f62ad5 | ||
|
|
5fb0e26331 | ||
|
|
4dd29952c8 | ||
|
|
2c006699f2 | ||
|
|
0bdf0474c9 | ||
|
|
66196ceb17 | ||
|
|
b2726f3a67 | ||
|
|
663f87d5e2 | ||
|
|
377bb4d6ad | ||
|
|
98e60db2da |
34
CHANGELOG.md
34
CHANGELOG.md
@@ -2,8 +2,42 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [v6.1.7]
|
||||
|
||||
### Changed
|
||||
- Fix Slash display enable
|
||||
|
||||
## [v6.1.6]
|
||||
|
||||
### Changed
|
||||
- Disable skia bindings for UI again. It causes failures in build pipelines and requires extra dependencies.
|
||||
|
||||
## [v6.1.5]
|
||||
|
||||
### Changed
|
||||
- Update dependencies
|
||||
- Fix fan-curve proxy type signatures
|
||||
|
||||
## [v6.1.4]
|
||||
|
||||
### Changed
|
||||
- Fix git doing me a dirty
|
||||
|
||||
## [v6.1.3]
|
||||
|
||||
### Changed
|
||||
- Many small bugfixes such as for platform profile switching
|
||||
|
||||
## [v6.1.2]
|
||||
|
||||
### Changed
|
||||
- Try a slightly different tact to fix charge control slider
|
||||
|
||||
## [v6.1.1]
|
||||
|
||||
### Changed
|
||||
- Fix aura data matching
|
||||
- Fix charge control slider
|
||||
|
||||
## [v6.1.0]
|
||||
|
||||
|
||||
591
Cargo.lock
generated
591
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
17
Cargo.toml
17
Cargo.toml
@@ -1,5 +1,5 @@
|
||||
[workspace.package]
|
||||
version = "6.1.0"
|
||||
version = "6.1.7"
|
||||
rust-version = "1.82"
|
||||
license = "MPL-2.0"
|
||||
readme = "README.md"
|
||||
@@ -43,8 +43,9 @@ dirs = "^4.0"
|
||||
smol = "^2.0"
|
||||
mio = "0.8.11"
|
||||
|
||||
zbus = "5.1"
|
||||
logind-zbus = { version = "5.0.0" } #, default-features = false, features = ["non_blocking"] }
|
||||
futures-util = "0.3.31"
|
||||
zbus = "5.5.0"
|
||||
logind-zbus = { version = "5.2.0" } #, default-features = false, features = ["non_blocking"] }
|
||||
|
||||
serde = { version = "^1.0", features = ["serde_derive"] }
|
||||
ron = "*"
|
||||
@@ -65,26 +66,26 @@ gif = "^0.12.0"
|
||||
|
||||
versions = "6.2"
|
||||
|
||||
notify-rust = { version = "4.11.0", features = ["z", "async"] }
|
||||
notify-rust = { version = "4.11.5", features = ["z", "async"] }
|
||||
|
||||
sg = { git = "https://github.com/flukejones/sg-rs.git" }
|
||||
|
||||
[profile.release]
|
||||
# thin = 57s, asusd = 9.0M
|
||||
# fat = 72s, asusd = 6.4M
|
||||
lto = "fat"
|
||||
lto = "thin"
|
||||
debug = false
|
||||
opt-level = 3
|
||||
panic = "abort"
|
||||
codegen-units = 1
|
||||
# codegen-units = 1
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 1
|
||||
codegen-units = 16
|
||||
# codegen-units = 1
|
||||
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 1
|
||||
codegen-units = 16
|
||||
# codegen-units = 1
|
||||
|
||||
[profile.bench]
|
||||
debug = false
|
||||
|
||||
@@ -48,7 +48,7 @@ The LED controller (e.g, aura) enables setting many of the factory modes availab
|
||||
|
||||
#### Supported laptops
|
||||
|
||||
There are over 60 supported laptops as of 01-01-2023. Please see [the rog-aura crate readme for further details](/rog-aura/README.md).
|
||||
There are over 80 supported laptops as of 01-01-2023. Please see [the rog-aura crate readme for further details](/rog-aura/README.md).
|
||||
|
||||
### Charge control
|
||||
|
||||
@@ -420,13 +420,13 @@ To switch to next/previous Aura modes you will need to bind both the aura keys (
|
||||
**Next**
|
||||
|
||||
```
|
||||
asusctl led-mode -n
|
||||
asusctl aura -n
|
||||
```
|
||||
|
||||
**Previous**
|
||||
|
||||
```
|
||||
asusctl led-mode -p
|
||||
asusctl aura -p
|
||||
```
|
||||
|
||||
To switch Fan/Thermal profiles you need to bind the Fn+F5 key to `asusctl profile -n`.
|
||||
|
||||
@@ -23,7 +23,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
Path::new(&args[1]),
|
||||
None,
|
||||
args[2].parse::<f32>().unwrap(),
|
||||
AnimeType::GA401
|
||||
AnimeType::GA401,
|
||||
)?;
|
||||
|
||||
let anime_type = get_anime_type();
|
||||
|
||||
@@ -24,7 +24,7 @@ fn main() {
|
||||
seq.insert(0, &ActionLoader::AsusAnimation {
|
||||
file: path.into(),
|
||||
time: rog_anime::AnimTime::Infinite,
|
||||
brightness
|
||||
brightness,
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
args[3].parse::<f32>().unwrap(),
|
||||
Vec2::new(
|
||||
args[4].parse::<f32>().unwrap(),
|
||||
args[5].parse::<f32>().unwrap()
|
||||
args[5].parse::<f32>().unwrap(),
|
||||
),
|
||||
args[6].parse::<f32>().unwrap(),
|
||||
anime_type
|
||||
anime_type,
|
||||
)?;
|
||||
|
||||
proxy.write(<AnimeDataBuffer>::try_from(&matrix)?).unwrap();
|
||||
|
||||
@@ -30,10 +30,10 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
args[3].parse::<f32>().unwrap(),
|
||||
Vec2::new(
|
||||
args[4].parse::<f32>().unwrap(),
|
||||
args[5].parse::<f32>().unwrap()
|
||||
args[5].parse::<f32>().unwrap(),
|
||||
),
|
||||
args[6].parse::<f32>().unwrap(),
|
||||
anime_type
|
||||
anime_type,
|
||||
)?;
|
||||
|
||||
loop {
|
||||
|
||||
@@ -36,10 +36,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Colour {
|
||||
r: 200,
|
||||
g: 110,
|
||||
b: 0
|
||||
b: 0,
|
||||
},
|
||||
100,
|
||||
10
|
||||
10,
|
||||
));
|
||||
seq.push(zone);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ pub struct AnimeCommand {
|
||||
#[options(no_short, meta = "", help = "Off with his head!!!")]
|
||||
pub off_with_his_head: Option<bool>,
|
||||
#[options(command)]
|
||||
pub command: Option<AnimeActions>
|
||||
pub command: Option<AnimeActions>,
|
||||
}
|
||||
|
||||
#[derive(Options)]
|
||||
@@ -54,7 +54,7 @@ pub enum AnimeActions {
|
||||
#[options(help = "display an animated diagonal/pixel-perfect GIF")]
|
||||
PixelGif(AnimeGifDiagonal),
|
||||
#[options(help = "change which builtin animations are shown")]
|
||||
SetBuiltins(Builtins)
|
||||
SetBuiltins(Builtins),
|
||||
}
|
||||
|
||||
#[derive(Options)]
|
||||
@@ -82,7 +82,7 @@ pub struct Builtins {
|
||||
)]
|
||||
pub shutdown: AnimShutdown,
|
||||
#[options(meta = "", help = "set/apply the animations <true/false>")]
|
||||
pub set: Option<bool>
|
||||
pub set: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Options)]
|
||||
@@ -100,7 +100,7 @@ pub struct AnimeImage {
|
||||
#[options(meta = "", default = "0.0", help = "the angle in radians")]
|
||||
pub angle: f32,
|
||||
#[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")]
|
||||
pub bright: f32
|
||||
pub bright: f32,
|
||||
}
|
||||
|
||||
#[derive(Options)]
|
||||
@@ -110,7 +110,7 @@ pub struct AnimeImageDiagonal {
|
||||
#[options(meta = "", help = "full path to the png to display")]
|
||||
pub path: String,
|
||||
#[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")]
|
||||
pub bright: f32
|
||||
pub bright: f32,
|
||||
}
|
||||
|
||||
#[derive(Options)]
|
||||
@@ -134,7 +134,7 @@ pub struct AnimeGif {
|
||||
default = "1",
|
||||
help = "how many loops to play - 0 is infinite"
|
||||
)]
|
||||
pub loops: u32
|
||||
pub loops: u32,
|
||||
}
|
||||
|
||||
#[derive(Options)]
|
||||
@@ -150,5 +150,5 @@ pub struct AnimeGifDiagonal {
|
||||
default = "1",
|
||||
help = "how many loops to play - 0 is infinite"
|
||||
)]
|
||||
pub loops: u32
|
||||
pub loops: u32,
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ pub struct LedPowerCommand1 {
|
||||
#[options(meta = "", help = "Control boot animations <true/false>")]
|
||||
pub boot: Option<bool>,
|
||||
#[options(meta = "", help = "Control suspend animations <true/false>")]
|
||||
pub sleep: Option<bool>
|
||||
pub sleep: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Options, Debug)]
|
||||
@@ -25,7 +25,7 @@ pub struct LedPowerCommand2 {
|
||||
#[options(help = "print help message")]
|
||||
pub help: bool,
|
||||
#[options(command)]
|
||||
pub command: Option<SetAuraZoneEnabled>
|
||||
pub command: Option<SetAuraZoneEnabled>,
|
||||
}
|
||||
|
||||
#[derive(Options, Debug)]
|
||||
@@ -42,7 +42,7 @@ pub enum SetAuraZoneEnabled {
|
||||
#[options(help = "")]
|
||||
RearGlow(AuraPowerStates),
|
||||
#[options(help = "")]
|
||||
Ally(AuraPowerStates)
|
||||
Ally(AuraPowerStates),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Options)]
|
||||
@@ -56,12 +56,12 @@ pub struct AuraPowerStates {
|
||||
#[options(help = "defaults to false if option unused")]
|
||||
pub sleep: bool,
|
||||
#[options(help = "defaults to false if option unused")]
|
||||
pub shutdown: bool
|
||||
pub shutdown: bool,
|
||||
}
|
||||
|
||||
#[derive(Options)]
|
||||
pub struct LedBrightness {
|
||||
level: Option<u8>
|
||||
level: Option<u8>,
|
||||
}
|
||||
impl LedBrightness {
|
||||
pub fn new(level: Option<u8>) -> Self {
|
||||
@@ -96,7 +96,7 @@ impl ToString for LedBrightness {
|
||||
Some(0x00) => "low",
|
||||
Some(0x01) => "med",
|
||||
Some(0x02) => "high",
|
||||
_ => "unknown"
|
||||
_ => "unknown",
|
||||
};
|
||||
s.to_owned()
|
||||
}
|
||||
@@ -113,7 +113,7 @@ pub struct SingleSpeed {
|
||||
meta = "",
|
||||
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
|
||||
)]
|
||||
pub zone: AuraZone
|
||||
pub zone: AuraZone,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Options, Default)]
|
||||
@@ -129,7 +129,7 @@ pub struct SingleSpeedDirection {
|
||||
meta = "",
|
||||
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
|
||||
)]
|
||||
pub zone: AuraZone
|
||||
pub zone: AuraZone,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Options)]
|
||||
@@ -143,7 +143,7 @@ pub struct SingleColour {
|
||||
meta = "",
|
||||
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
|
||||
)]
|
||||
pub zone: AuraZone
|
||||
pub zone: AuraZone,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Options)]
|
||||
@@ -159,7 +159,7 @@ pub struct SingleColourSpeed {
|
||||
meta = "",
|
||||
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
|
||||
)]
|
||||
pub zone: AuraZone
|
||||
pub zone: AuraZone,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Options, Default)]
|
||||
@@ -177,7 +177,7 @@ pub struct TwoColourSpeed {
|
||||
meta = "",
|
||||
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left"
|
||||
)]
|
||||
pub zone: AuraZone
|
||||
pub zone: AuraZone,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Options)]
|
||||
@@ -191,7 +191,7 @@ pub struct MultiZone {
|
||||
#[options(short = "c", meta = "", help = "set the RGB value e.g, ff00ff")]
|
||||
pub colour3: Colour,
|
||||
#[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")]
|
||||
pub colour4: Colour
|
||||
pub colour4: Colour,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Options)]
|
||||
@@ -207,7 +207,7 @@ pub struct MultiColourSpeed {
|
||||
#[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")]
|
||||
pub colour4: Colour,
|
||||
#[options(no_long, meta = "", help = "set the speed: low, med, high")]
|
||||
pub speed: Speed
|
||||
pub speed: Speed,
|
||||
}
|
||||
|
||||
/// Byte value for setting the built-in mode.
|
||||
@@ -239,7 +239,7 @@ pub enum SetAuraBuiltin {
|
||||
#[options(help = "set a vertical line zooming from left")]
|
||||
Comet(SingleColour), // 11
|
||||
#[options(help = "set a wide vertical line zooming from left")]
|
||||
Flash(SingleColour) // 12
|
||||
Flash(SingleColour), // 12
|
||||
}
|
||||
|
||||
impl Default for SetAuraBuiltin {
|
||||
|
||||
@@ -26,7 +26,7 @@ pub struct CliStart {
|
||||
#[options(help = "Toggle one-shot battery charge to 100%")]
|
||||
pub one_shot_chg: bool,
|
||||
#[options(command)]
|
||||
pub command: Option<CliCommand>
|
||||
pub command: Option<CliCommand>,
|
||||
}
|
||||
|
||||
#[derive(Options)]
|
||||
@@ -53,7 +53,7 @@ pub enum CliCommand {
|
||||
help = "Change platform settings. This is a new interface exposed by the asus-armoury \
|
||||
driver, some of the settings will be the same as the older platform interface"
|
||||
)]
|
||||
Armoury(ArmouryCommand)
|
||||
Armoury(ArmouryCommand),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Options)]
|
||||
@@ -71,7 +71,7 @@ pub struct ProfileCommand {
|
||||
pub profile_get: bool,
|
||||
|
||||
#[options(meta = "", help = "set the active profile")]
|
||||
pub profile_set: Option<PlatformProfile>
|
||||
pub profile_set: Option<PlatformProfile>,
|
||||
}
|
||||
|
||||
#[derive(Options)]
|
||||
@@ -83,13 +83,13 @@ pub struct LedModeCommand {
|
||||
#[options(help = "switch to previous aura mode")]
|
||||
pub prev_mode: bool,
|
||||
#[options(command)]
|
||||
pub command: Option<SetAuraBuiltin>
|
||||
pub command: Option<SetAuraBuiltin>,
|
||||
}
|
||||
|
||||
#[derive(Options)]
|
||||
pub struct GraphicsCommand {
|
||||
#[options(help = "print help message")]
|
||||
pub help: bool
|
||||
pub help: bool,
|
||||
}
|
||||
|
||||
#[derive(Options, Debug)]
|
||||
@@ -100,5 +100,5 @@ pub struct ArmouryCommand {
|
||||
free,
|
||||
help = "append each value name followed by the value to set. `-1` sets to default"
|
||||
)]
|
||||
pub free: Vec<String>
|
||||
pub free: Vec<String>,
|
||||
}
|
||||
|
||||
@@ -45,5 +45,5 @@ pub struct FanCurveCommand {
|
||||
help = "data format = 30c:1%,49c:2%,59c:3%,69c:4%,79c:31%,89c:49%,99c:56%,109c:58%. \
|
||||
`--mod-profile` required. If '%' is omitted the fan range is 0-255"
|
||||
)]
|
||||
pub data: Option<CurveData>
|
||||
pub data: Option<CurveData>,
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ fn main() {
|
||||
fn print_error_help(
|
||||
err: &dyn std::error::Error,
|
||||
supported_interfaces: &[String],
|
||||
supported_properties: &[Properties]
|
||||
supported_properties: &[Properties],
|
||||
) {
|
||||
check_service("asusd");
|
||||
println!("\nError: {}\n", err);
|
||||
@@ -147,7 +147,7 @@ fn check_service(name: &str) -> bool {
|
||||
|
||||
fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
|
||||
where
|
||||
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>
|
||||
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>,
|
||||
{
|
||||
let conn = zbus::blocking::Connection::system().unwrap();
|
||||
let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
|
||||
@@ -174,7 +174,7 @@ where
|
||||
T::builder(&conn)
|
||||
.path(path.clone())?
|
||||
.destination("xyz.ljones.Asusd")?
|
||||
.build()?
|
||||
.build()?,
|
||||
);
|
||||
}
|
||||
return Ok(ctrl);
|
||||
@@ -187,7 +187,7 @@ fn do_parsed(
|
||||
parsed: &CliStart,
|
||||
supported_interfaces: &[String],
|
||||
supported_properties: &[Properties],
|
||||
conn: Connection
|
||||
conn: Connection,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
match &parsed.command {
|
||||
Some(CliCommand::Aura(mode)) => handle_led_mode(mode)?,
|
||||
@@ -295,7 +295,7 @@ fn do_parsed(
|
||||
let level = aura.brightness()?;
|
||||
println!("Current keyboard led brightness: {level:?}");
|
||||
}
|
||||
Some(level) => aura.set_brightness(rog_aura::LedBrightness::from(level))?
|
||||
Some(level) => aura.set_brightness(rog_aura::LedBrightness::from(level))?,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -444,7 +444,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
|
||||
image.angle,
|
||||
Vec2::new(image.x_pos, image.y_pos),
|
||||
image.bright,
|
||||
anime_type
|
||||
anime_type,
|
||||
)?;
|
||||
|
||||
proxy.write(<AnimeDataBuffer>::try_from(&matrix)?)?;
|
||||
@@ -463,7 +463,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
|
||||
Path::new(&image.path),
|
||||
None,
|
||||
image.bright,
|
||||
anime_type
|
||||
anime_type,
|
||||
)?;
|
||||
|
||||
proxy.write(matrix.into_data_buffer(anime_type)?)?;
|
||||
@@ -485,7 +485,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
|
||||
Vec2::new(gif.x_pos, gif.y_pos),
|
||||
AnimTime::Count(1),
|
||||
gif.bright,
|
||||
anime_type
|
||||
anime_type,
|
||||
)?;
|
||||
|
||||
let mut loops = gif.loops as i32;
|
||||
@@ -516,7 +516,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
|
||||
Path::new(&gif.path),
|
||||
AnimTime::Count(1),
|
||||
gif.bright,
|
||||
anime_type
|
||||
anime_type,
|
||||
)?;
|
||||
|
||||
let mut loops = gif.loops as i32;
|
||||
@@ -549,7 +549,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
|
||||
boot: builtins.boot,
|
||||
awake: builtins.awake,
|
||||
sleep: builtins.sleep,
|
||||
shutdown: builtins.shutdown
|
||||
shutdown: builtins.shutdown,
|
||||
})?;
|
||||
}
|
||||
}
|
||||
@@ -575,6 +575,7 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
|
||||
&& cmd.show_on_sleep.is_none()
|
||||
&& cmd.show_on_battery.is_none()
|
||||
&& cmd.show_battery_warning.is_none()
|
||||
// && cmd.show_on_lid_closed.is_none()
|
||||
&& cmd.mode.is_none()
|
||||
&& !cmd.list
|
||||
&& !cmd.enable
|
||||
@@ -620,6 +621,9 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if let Some(show) = cmd.show_battery_warning {
|
||||
proxy.set_show_battery_warning(show)?;
|
||||
}
|
||||
// if let Some(show) = cmd.show_on_lid_closed {
|
||||
// proxy.set_show_on_lid_closed(show)?;
|
||||
// }
|
||||
}
|
||||
if cmd.list {
|
||||
let res = SlashMode::list();
|
||||
@@ -812,7 +816,7 @@ fn handle_led_power1(power: &LedPowerCommand1) -> Result<(), Box<dyn std::error:
|
||||
|
||||
fn handle_led_power_1_do_1866(
|
||||
aura: &AuraProxyBlocking,
|
||||
power: &LedPowerCommand1
|
||||
power: &LedPowerCommand1,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut states = Vec::new();
|
||||
if power.keyboard {
|
||||
@@ -821,7 +825,7 @@ fn handle_led_power_1_do_1866(
|
||||
boot: power.boot.unwrap_or_default(),
|
||||
awake: power.awake.unwrap_or_default(),
|
||||
sleep: power.sleep.unwrap_or_default(),
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
});
|
||||
}
|
||||
if power.lightbar {
|
||||
@@ -830,7 +834,7 @@ fn handle_led_power_1_do_1866(
|
||||
boot: power.boot.unwrap_or_default(),
|
||||
awake: power.awake.unwrap_or_default(),
|
||||
sleep: power.sleep.unwrap_or_default(),
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -892,7 +896,7 @@ fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error:
|
||||
aura_cli::SetAuraZoneEnabled::Lightbar(l) => set(PowerZones::Lightbar, l),
|
||||
aura_cli::SetAuraZoneEnabled::Lid(l) => set(PowerZones::Lid, l),
|
||||
aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(PowerZones::RearGlow, r),
|
||||
aura_cli::SetAuraZoneEnabled::Ally(r) => set(PowerZones::Ally, r)
|
||||
aura_cli::SetAuraZoneEnabled::Ally(r) => set(PowerZones::Ally, r),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -906,7 +910,7 @@ fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error:
|
||||
fn handle_throttle_profile(
|
||||
conn: &Connection,
|
||||
supported: &[Properties],
|
||||
cmd: &ProfileCommand
|
||||
cmd: &ProfileCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if !supported.contains(&Properties::ThrottlePolicy) {
|
||||
println!("Profiles not supported by either this kernel or by the laptop.");
|
||||
@@ -927,16 +931,16 @@ fn handle_throttle_profile(
|
||||
|
||||
let proxy = PlatformProxyBlocking::new(conn)?;
|
||||
let current = proxy.platform_profile()?;
|
||||
let choices = proxy.platform_profile_choices()?;
|
||||
|
||||
if cmd.next {
|
||||
proxy.set_platform_profile(current.next())?;
|
||||
proxy.set_platform_profile(PlatformProfile::next(current, &choices))?;
|
||||
} else if let Some(profile) = cmd.profile_set {
|
||||
proxy.set_platform_profile(profile)?;
|
||||
}
|
||||
|
||||
if cmd.list {
|
||||
let res = PlatformProfile::list();
|
||||
for p in &res {
|
||||
for p in &choices {
|
||||
println!("{:?}", p);
|
||||
}
|
||||
}
|
||||
@@ -950,7 +954,7 @@ fn handle_throttle_profile(
|
||||
|
||||
fn handle_fan_curve(
|
||||
conn: &Connection,
|
||||
cmd: &FanCurveCommand
|
||||
cmd: &FanCurveCommand,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let Ok(fan_proxy) = FanCurvesProxyBlocking::new(conn).map_err(|e| {
|
||||
println!("Fan-curves not supported by either this kernel or by the laptop: {e:?}");
|
||||
@@ -1045,7 +1049,7 @@ fn check_systemd_unit_enabled(name: &str) -> bool {
|
||||
.output()
|
||||
{
|
||||
let buf = String::from_utf8_lossy(&out.stdout);
|
||||
return buf.contains("enabled");
|
||||
return buf.contains("enabled") || buf.contains("linked");
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
@@ -31,5 +31,5 @@ pub struct ScsiCommand {
|
||||
pub colours: Vec<Colour>,
|
||||
|
||||
#[options(help = "list available animations")]
|
||||
pub list: bool
|
||||
pub list: bool,
|
||||
}
|
||||
|
||||
@@ -26,10 +26,12 @@ pub struct SlashCommand {
|
||||
pub show_on_sleep: Option<bool>,
|
||||
#[options(short = "b", meta = "", help = "Show the animation on battery")]
|
||||
pub show_on_battery: Option<bool>,
|
||||
// #[options(short = "L", meta = "", help = "Show the animation on lid closed")]
|
||||
// pub show_on_lid_closed: Option<bool>,
|
||||
#[options(
|
||||
short = "w",
|
||||
meta = "",
|
||||
help = "Show the low-battery warning animation"
|
||||
)]
|
||||
pub show_battery_warning: Option<bool>
|
||||
pub show_battery_warning: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ fn root_conf_dir() -> PathBuf {
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct ConfigAnime {
|
||||
pub name: String,
|
||||
pub anime: Vec<ActionLoader>
|
||||
pub anime: Vec<ActionLoader>,
|
||||
}
|
||||
|
||||
impl ConfigAnime {
|
||||
@@ -52,8 +52,8 @@ impl Default for ConfigAnime {
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(2),
|
||||
None,
|
||||
Duration::from_secs(2)
|
||||
))
|
||||
Duration::from_secs(2),
|
||||
)),
|
||||
},
|
||||
ActionLoader::AsusAnimation {
|
||||
file: "/usr/share/asusd/anime/asus/rog/Sunset.gif".into(),
|
||||
@@ -61,8 +61,8 @@ impl Default for ConfigAnime {
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(6),
|
||||
None,
|
||||
Duration::from_secs(3)
|
||||
))
|
||||
Duration::from_secs(3),
|
||||
)),
|
||||
},
|
||||
ActionLoader::ImageAnimation {
|
||||
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
|
||||
@@ -73,8 +73,8 @@ impl Default for ConfigAnime {
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(2),
|
||||
Some(Duration::from_secs(2)),
|
||||
Duration::from_secs(2)
|
||||
))
|
||||
Duration::from_secs(2),
|
||||
)),
|
||||
},
|
||||
ActionLoader::Image {
|
||||
file: "/usr/share/asusd/anime/custom/rust.png".into(),
|
||||
@@ -84,9 +84,9 @@ impl Default for ConfigAnime {
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(2),
|
||||
Some(Duration::from_secs(1)),
|
||||
Duration::from_secs(2)
|
||||
Duration::from_secs(2),
|
||||
)),
|
||||
brightness: 0.6
|
||||
brightness: 0.6,
|
||||
},
|
||||
ActionLoader::Pause(Duration::from_secs(1)),
|
||||
ActionLoader::ImageAnimation {
|
||||
@@ -95,9 +95,9 @@ impl Default for ConfigAnime {
|
||||
angle: 0.0,
|
||||
translation: Vec2::new(3.0, 2.0),
|
||||
brightness: 0.5,
|
||||
time: AnimTime::Count(2)
|
||||
time: AnimTime::Count(2),
|
||||
},
|
||||
]
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ impl StdConfigLoad for ConfigAnime {}
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct ConfigAura {
|
||||
pub name: String,
|
||||
pub aura: AuraSequences
|
||||
pub aura: AuraSequences,
|
||||
}
|
||||
|
||||
impl ConfigAura {
|
||||
@@ -139,14 +139,14 @@ impl Default for ConfigAura {
|
||||
Colour {
|
||||
r: 255,
|
||||
g: 0,
|
||||
b: 20
|
||||
b: 20,
|
||||
},
|
||||
Colour {
|
||||
r: 20,
|
||||
g: 255,
|
||||
b: 0
|
||||
b: 0,
|
||||
},
|
||||
Speed::Low
|
||||
Speed::Low,
|
||||
));
|
||||
|
||||
seq.push(key.clone());
|
||||
@@ -161,7 +161,7 @@ impl Default for ConfigAura {
|
||||
LedCode::F,
|
||||
Colour { r: 255, g: 0, b: 0 },
|
||||
Colour { r: 255, g: 0, b: 0 },
|
||||
Speed::High
|
||||
Speed::High,
|
||||
));
|
||||
seq.push(key);
|
||||
|
||||
@@ -176,13 +176,13 @@ impl Default for ConfigAura {
|
||||
LedCode::N9,
|
||||
Colour { r: 0, g: 0, b: 255 },
|
||||
80,
|
||||
40
|
||||
40,
|
||||
));
|
||||
seq.push(key);
|
||||
|
||||
Self {
|
||||
name: "aura-default".to_owned(),
|
||||
aura: seq
|
||||
aura: seq,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,14 +209,14 @@ pub struct ConfigBase {
|
||||
/// Name of active anime config file in the user config directory
|
||||
pub active_anime: Option<String>,
|
||||
/// Name of active aura config file in the user config directory
|
||||
pub active_aura: Option<String>
|
||||
pub active_aura: Option<String>,
|
||||
}
|
||||
|
||||
impl StdConfig for ConfigBase {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
active_anime: Some("anime-default".to_owned()),
|
||||
active_aura: Some("aura-default".to_owned())
|
||||
active_aura: Some("aura-default".to_owned()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ pub struct Timer {
|
||||
/// Used only for `TimeType::Timer`, milliseonds to fade the image in for
|
||||
fade_in: u64,
|
||||
/// Used only for `TimeType::Timer`, milliseonds to fade the image out for
|
||||
fade_out: u64
|
||||
fade_out: u64,
|
||||
}
|
||||
|
||||
impl From<Timer> for AnimTime {
|
||||
@@ -46,7 +46,7 @@ impl From<Timer> for AnimTime {
|
||||
}
|
||||
}
|
||||
TimeType::Count => AnimTime::Count(time.count as u32),
|
||||
TimeType::Infinite => AnimTime::Infinite
|
||||
TimeType::Infinite => AnimTime::Infinite,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ impl From<Timer> for AnimTime {
|
||||
pub enum TimeType {
|
||||
Timer,
|
||||
Count,
|
||||
Infinite
|
||||
Infinite,
|
||||
}
|
||||
|
||||
/// The inner object exists to allow the zbus proxy to share it with a runner
|
||||
@@ -63,19 +63,19 @@ pub enum TimeType {
|
||||
pub struct CtrlAnimeInner<'a> {
|
||||
sequences: Sequences,
|
||||
client: AnimeProxyBlocking<'a>,
|
||||
do_early_return: Arc<AtomicBool>
|
||||
do_early_return: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl CtrlAnimeInner<'static> {
|
||||
pub fn new(
|
||||
sequences: Sequences,
|
||||
client: AnimeProxyBlocking<'static>,
|
||||
do_early_return: Arc<AtomicBool>
|
||||
do_early_return: Arc<AtomicBool>,
|
||||
) -> Result<Self, Error> {
|
||||
Ok(Self {
|
||||
sequences,
|
||||
client,
|
||||
do_early_return
|
||||
do_early_return,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ pub struct CtrlAnime<'a> {
|
||||
client: AnimeProxyBlocking<'a>,
|
||||
inner: Arc<Mutex<CtrlAnimeInner<'a>>>,
|
||||
/// Must be the same Atomic as in CtrlAnimeInner
|
||||
inner_early_return: Arc<AtomicBool>
|
||||
inner_early_return: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl CtrlAnime<'static> {
|
||||
@@ -138,13 +138,13 @@ impl CtrlAnime<'static> {
|
||||
config: Arc<Mutex<ConfigAnime>>,
|
||||
inner: Arc<Mutex<CtrlAnimeInner<'static>>>,
|
||||
client: AnimeProxyBlocking<'static>,
|
||||
inner_early_return: Arc<AtomicBool>
|
||||
inner_early_return: Arc<AtomicBool>,
|
||||
) -> Result<Self, Error> {
|
||||
Ok(CtrlAnime {
|
||||
config,
|
||||
client,
|
||||
inner,
|
||||
inner_early_return
|
||||
inner_early_return,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ impl CtrlAnime<'static> {
|
||||
index: u32,
|
||||
file: &str,
|
||||
time: Timer,
|
||||
brightness: f32
|
||||
brightness: f32,
|
||||
) -> zbus::fdo::Result<String> {
|
||||
if let Ok(mut config) = self.config.try_lock() {
|
||||
let time: AnimTime = time.into();
|
||||
@@ -182,7 +182,7 @@ impl CtrlAnime<'static> {
|
||||
let action = ActionLoader::AsusAnimation {
|
||||
file: file.into(),
|
||||
brightness,
|
||||
time
|
||||
time,
|
||||
};
|
||||
|
||||
// Must make the inner run loop return early
|
||||
@@ -216,7 +216,7 @@ impl CtrlAnime<'static> {
|
||||
angle: f32,
|
||||
xy: (f32, f32),
|
||||
time: Timer,
|
||||
brightness: f32
|
||||
brightness: f32,
|
||||
) -> zbus::fdo::Result<String> {
|
||||
if let Ok(mut config) = self.config.try_lock() {
|
||||
let time: AnimTime = time.into();
|
||||
@@ -228,7 +228,7 @@ impl CtrlAnime<'static> {
|
||||
angle,
|
||||
translation,
|
||||
brightness,
|
||||
time
|
||||
time,
|
||||
};
|
||||
|
||||
// Must make the inner run loop return early
|
||||
@@ -261,7 +261,7 @@ impl CtrlAnime<'static> {
|
||||
angle: f32,
|
||||
xy: (f32, f32),
|
||||
time: Timer,
|
||||
brightness: f32
|
||||
brightness: f32,
|
||||
) -> zbus::fdo::Result<String> {
|
||||
if let Ok(mut config) = self.config.try_lock() {
|
||||
let file = Path::new(&file);
|
||||
@@ -272,7 +272,7 @@ impl CtrlAnime<'static> {
|
||||
angle,
|
||||
translation: Vec2::new(xy.0, xy.1),
|
||||
brightness,
|
||||
time
|
||||
time,
|
||||
};
|
||||
|
||||
// Must make the inner run loop return early
|
||||
|
||||
@@ -61,16 +61,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
CtrlAnimeInner::new(
|
||||
anime,
|
||||
anime_proxy_blocking.clone(),
|
||||
early_return.clone()
|
||||
early_return.clone(),
|
||||
)
|
||||
.unwrap()
|
||||
.unwrap(),
|
||||
));
|
||||
// Need new client object for dbus control part
|
||||
let anime_control = CtrlAnime::new(
|
||||
anime_config,
|
||||
inner.clone(),
|
||||
anime_proxy_blocking,
|
||||
early_return
|
||||
early_return,
|
||||
)
|
||||
.unwrap();
|
||||
anime_control.add_to_server(&mut connection).await;
|
||||
|
||||
@@ -8,7 +8,7 @@ pub enum Error {
|
||||
ConfigLoadFail,
|
||||
ConfigLockFail,
|
||||
XdgVars,
|
||||
Anime(AnimeError)
|
||||
Anime(AnimeError),
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
@@ -19,7 +19,7 @@ impl fmt::Display for Error {
|
||||
Error::ConfigLoadFail => write!(f, "Failed to load user config"),
|
||||
Error::ConfigLockFail => write!(f, "Failed to lock user config"),
|
||||
Error::XdgVars => write!(f, "XDG environment vars appear unset"),
|
||||
Error::Anime(err) => write!(f, "Anime error: {}", err)
|
||||
Error::Anime(err) => write!(f, "Anime error: {}", err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ trait Daemon {
|
||||
file: &str,
|
||||
time: u32,
|
||||
count: u32,
|
||||
brightness: f64
|
||||
brightness: f64,
|
||||
) -> zbus::Result<String>;
|
||||
|
||||
/// InsertImage method
|
||||
@@ -43,7 +43,7 @@ trait Daemon {
|
||||
scale: f64,
|
||||
angle: f64,
|
||||
xy: &(f64, f64),
|
||||
brightness: f64
|
||||
brightness: f64,
|
||||
) -> zbus::Result<String>;
|
||||
|
||||
/// InsertImageGif method
|
||||
@@ -56,7 +56,7 @@ trait Daemon {
|
||||
xy: &(f64, f64),
|
||||
time: u32,
|
||||
count: u32,
|
||||
brightness: f64
|
||||
brightness: f64,
|
||||
) -> zbus::Result<String>;
|
||||
|
||||
/// InsertPause method
|
||||
|
||||
@@ -34,6 +34,7 @@ tokio.workspace = true
|
||||
log.workspace = true
|
||||
env_logger.workspace = true
|
||||
|
||||
futures-util.workspace = true
|
||||
zbus.workspace = true
|
||||
logind-zbus.workspace = true
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use ::zbus::export::futures_util::lock::Mutex;
|
||||
use config_traits::StdConfig;
|
||||
use futures_util::lock::Mutex;
|
||||
use log::{debug, error, info};
|
||||
use rog_platform::asus_armoury::{AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes};
|
||||
use rog_platform::platform::{PlatformProfile, RogPlatform};
|
||||
@@ -20,7 +20,7 @@ const MOD_NAME: &str = "asus_armoury";
|
||||
#[derive(Debug, Default, Clone, Deserialize, Serialize, Type, Value, OwnedValue)]
|
||||
pub struct PossibleValues {
|
||||
strings: Vec<String>,
|
||||
nums: Vec<i32>
|
||||
nums: Vec<i32>,
|
||||
}
|
||||
|
||||
fn dbus_path_for_attr(attr_name: &str) -> OwnedObjectPath {
|
||||
@@ -33,7 +33,7 @@ pub struct AsusArmouryAttribute {
|
||||
config: Arc<Mutex<Config>>,
|
||||
/// platform control required here for access to PPD or Throttle profile
|
||||
platform: RogPlatform,
|
||||
power: AsusPower
|
||||
power: AsusPower,
|
||||
}
|
||||
|
||||
impl AsusArmouryAttribute {
|
||||
@@ -41,13 +41,13 @@ impl AsusArmouryAttribute {
|
||||
attr: Attribute,
|
||||
platform: RogPlatform,
|
||||
power: AsusPower,
|
||||
config: Arc<Mutex<Config>>
|
||||
config: Arc<Mutex<Config>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
attr,
|
||||
config,
|
||||
platform,
|
||||
power
|
||||
power,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ impl AsusArmouryAttribute {
|
||||
|
||||
async fn watch_and_notify(
|
||||
&mut self,
|
||||
signal_ctxt: SignalEmitter<'static>
|
||||
signal_ctxt: SignalEmitter<'static>,
|
||||
) -> Result<(), RogError> {
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use futures_util::StreamExt;
|
||||
|
||||
let name = self.name();
|
||||
macro_rules! watch_value_notify {
|
||||
@@ -92,7 +92,7 @@ impl AsusArmouryAttribute {
|
||||
"inotify watch failed: {}. You can ignore this if your device does not \
|
||||
support the feature",
|
||||
e
|
||||
)
|
||||
),
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -187,7 +187,7 @@ impl AsusArmouryAttribute {
|
||||
async fn default_value(&self) -> i32 {
|
||||
match self.attr.default_value() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1
|
||||
_ => -1,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ impl AsusArmouryAttribute {
|
||||
async fn min_value(&self) -> i32 {
|
||||
match self.attr.min_value() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1
|
||||
_ => -1,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ impl AsusArmouryAttribute {
|
||||
async fn max_value(&self) -> i32 {
|
||||
match self.attr.max_value() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1
|
||||
_ => -1,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ impl AsusArmouryAttribute {
|
||||
async fn scalar_increment(&self) -> i32 {
|
||||
match self.attr.scalar_increment() {
|
||||
AttrValue::Integer(i) => *i,
|
||||
_ => -1
|
||||
_ => -1,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ impl AsusArmouryAttribute {
|
||||
async fn possible_values(&self) -> Vec<i32> {
|
||||
match self.attr.possible_values() {
|
||||
AttrValue::EnumInt(i) => i.clone(),
|
||||
_ => Vec::default()
|
||||
_ => Vec::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ impl AsusArmouryAttribute {
|
||||
return Ok(*i);
|
||||
}
|
||||
return Err(fdo::Error::Failed(
|
||||
"Could not read current value".to_string()
|
||||
"Could not read current value".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ impl AsusArmouryAttribute {
|
||||
return Ok(i);
|
||||
}
|
||||
Err(fdo::Error::Failed(
|
||||
"Could not read current value".to_string()
|
||||
"Could not read current value".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -362,14 +362,14 @@ pub async fn start_attributes_zbus(
|
||||
platform: RogPlatform,
|
||||
power: AsusPower,
|
||||
attributes: FirmwareAttributes,
|
||||
config: Arc<Mutex<Config>>
|
||||
config: Arc<Mutex<Config>>,
|
||||
) -> Result<(), RogError> {
|
||||
for attr in attributes.attributes() {
|
||||
let mut attr = AsusArmouryAttribute::new(
|
||||
attr.clone(),
|
||||
platform.clone(),
|
||||
power.clone(),
|
||||
config.clone()
|
||||
config.clone(),
|
||||
);
|
||||
attr.reload().await?;
|
||||
|
||||
@@ -386,7 +386,7 @@ pub async fn set_config_or_default(
|
||||
attrs: &FirmwareAttributes,
|
||||
config: &mut Config,
|
||||
power_plugged: bool,
|
||||
profile: PlatformProfile
|
||||
profile: PlatformProfile,
|
||||
) {
|
||||
for attr in attrs.attributes().iter() {
|
||||
let name: FirmwareAttribute = attr.name().into();
|
||||
|
||||
@@ -4,7 +4,7 @@ use config_traits::{StdConfig, StdConfigLoad};
|
||||
use rog_anime::error::AnimeError;
|
||||
use rog_anime::usb::Brightness;
|
||||
use rog_anime::{
|
||||
ActionData, ActionLoader, AnimTime, Animations, AnimeType, DeviceState, Fade, Vec2
|
||||
ActionData, ActionLoader, AnimTime, Animations, AnimeType, DeviceState, Fade, Vec2,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -15,14 +15,14 @@ pub struct AniMeConfigCached {
|
||||
pub system: Vec<ActionData>,
|
||||
pub boot: Vec<ActionData>,
|
||||
pub wake: Vec<ActionData>,
|
||||
pub shutdown: Vec<ActionData>
|
||||
pub shutdown: Vec<ActionData>,
|
||||
}
|
||||
|
||||
impl AniMeConfigCached {
|
||||
pub fn init_from_config(
|
||||
&mut self,
|
||||
config: &AniMeConfig,
|
||||
anime_type: AnimeType
|
||||
anime_type: AnimeType,
|
||||
) -> Result<(), AnimeError> {
|
||||
let mut sys = Vec::with_capacity(config.system.len());
|
||||
for ani in &config.system {
|
||||
@@ -68,7 +68,7 @@ pub struct AniMeConfig {
|
||||
pub off_when_suspended: bool,
|
||||
pub off_when_lid_closed: bool,
|
||||
pub brightness_on_battery: Brightness,
|
||||
pub builtin_anims: Animations
|
||||
pub builtin_anims: Animations,
|
||||
}
|
||||
|
||||
impl Default for AniMeConfig {
|
||||
@@ -87,7 +87,7 @@ impl Default for AniMeConfig {
|
||||
off_when_suspended: true,
|
||||
off_when_lid_closed: true,
|
||||
brightness_on_battery: Brightness::Low,
|
||||
builtin_anims: Animations::default()
|
||||
builtin_anims: Animations::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ impl From<&AniMeConfig> for DeviceState {
|
||||
off_when_unplugged: config.off_when_unplugged,
|
||||
off_when_suspended: config.off_when_suspended,
|
||||
off_when_lid_closed: config.off_when_lid_closed,
|
||||
brightness_on_battery: config.brightness_on_battery
|
||||
brightness_on_battery: config.brightness_on_battery,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,8 +148,8 @@ impl AniMeConfig {
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(2),
|
||||
Some(Duration::from_secs(2)),
|
||||
Duration::from_secs(2)
|
||||
))
|
||||
Duration::from_secs(2),
|
||||
)),
|
||||
},
|
||||
],
|
||||
wake: vec![
|
||||
@@ -162,8 +162,8 @@ impl AniMeConfig {
|
||||
time: AnimTime::Fade(Fade::new(
|
||||
Duration::from_secs(2),
|
||||
Some(Duration::from_secs(2)),
|
||||
Duration::from_secs(2)
|
||||
))
|
||||
Duration::from_secs(2),
|
||||
)),
|
||||
},
|
||||
],
|
||||
shutdown: vec![
|
||||
@@ -173,7 +173,7 @@ impl AniMeConfig {
|
||||
angle: 0.0,
|
||||
translation: Vec2::new(3.0, 2.0),
|
||||
brightness: 1.0,
|
||||
time: AnimTime::Infinite
|
||||
time: AnimTime::Infinite,
|
||||
},
|
||||
],
|
||||
..Default::default()
|
||||
|
||||
@@ -8,15 +8,15 @@ 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,
|
||||
pkts_for_init, Brightness
|
||||
pkts_for_init, Brightness,
|
||||
};
|
||||
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;
|
||||
@@ -30,14 +30,14 @@ pub struct AniMe {
|
||||
// set to force thread to exit
|
||||
thread_exit: Arc<AtomicBool>,
|
||||
// Set to false when the thread exits
|
||||
thread_running: Arc<AtomicBool>
|
||||
thread_running: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl AniMe {
|
||||
pub fn new(
|
||||
hid: Option<Arc<Mutex<HidRaw>>>,
|
||||
usb: Option<Arc<Mutex<USBRaw>>>,
|
||||
config: Arc<Mutex<AniMeConfig>>
|
||||
config: Arc<Mutex<AniMeConfig>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
hid,
|
||||
@@ -45,13 +45,13 @@ impl AniMe {
|
||||
config,
|
||||
cache: AniMeConfigCached::default(),
|
||||
thread_exit: Arc::new(AtomicBool::new(false)),
|
||||
thread_running: Arc::new(AtomicBool::new(false))
|
||||
thread_running: Arc::new(AtomicBool::new(false)),
|
||||
}
|
||||
}
|
||||
|
||||
/// 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:?}"
|
||||
@@ -106,7 +106,7 @@ impl AniMe {
|
||||
pub async fn set_builtins_enabled(
|
||||
&self,
|
||||
enabled: bool,
|
||||
bright: Brightness
|
||||
bright: Brightness,
|
||||
) -> Result<(), RogError> {
|
||||
self.write_bytes(&pkt_set_enable_powersave_anim(enabled))
|
||||
.await?;
|
||||
|
||||
@@ -5,7 +5,7 @@ use log::{debug, error, warn};
|
||||
use logind_zbus::manager::ManagerProxy;
|
||||
use rog_anime::usb::{
|
||||
pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display,
|
||||
pkt_set_enable_powersave_anim, Brightness
|
||||
pkt_set_enable_powersave_anim, Brightness,
|
||||
};
|
||||
use rog_anime::{Animations, AnimeDataBuffer, DeviceState};
|
||||
use zbus::object_server::SignalEmitter;
|
||||
@@ -41,7 +41,7 @@ impl AniMeZbus {
|
||||
pub async fn start_tasks(
|
||||
mut self,
|
||||
connection: &Connection,
|
||||
path: OwnedObjectPath
|
||||
path: OwnedObjectPath,
|
||||
) -> Result<(), RogError> {
|
||||
// let task = zbus.clone();
|
||||
self.reload()
|
||||
@@ -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()
|
||||
@@ -169,7 +169,7 @@ impl AniMeZbus {
|
||||
async fn set_builtin_animations(&self, settings: Animations) {
|
||||
self.0
|
||||
.write_bytes(&pkt_set_builtin_animations(
|
||||
settings.boot, settings.awake, settings.sleep, settings.shutdown
|
||||
settings.boot, settings.awake, settings.sleep, settings.shutdown,
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -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
|
||||
@@ -319,7 +319,7 @@ impl crate::CtrlTask for AniMeZbus {
|
||||
|
||||
inner
|
||||
.write_bytes(&pkt_set_enable_display(
|
||||
!(sleeping && config.off_when_suspended)
|
||||
!(sleeping && config.off_when_suspended),
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -330,7 +330,7 @@ impl crate::CtrlTask for AniMeZbus {
|
||||
if config.builtin_anims_enabled {
|
||||
inner
|
||||
.write_bytes(&pkt_set_enable_powersave_anim(
|
||||
!(sleeping && config.off_when_suspended)
|
||||
!(sleeping && config.off_when_suspended),
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -433,7 +433,7 @@ impl crate::CtrlTask for AniMeZbus {
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -460,7 +460,7 @@ impl crate::Reloadable for AniMeZbus {
|
||||
builtin_anims.boot,
|
||||
builtin_anims.awake,
|
||||
builtin_anims.sleep,
|
||||
builtin_anims.shutdown
|
||||
builtin_anims.shutdown,
|
||||
))
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use log::{debug, info, warn};
|
||||
use rog_aura::aura_detection::LedSupportData;
|
||||
use rog_aura::keyboard::LaptopAuraPower;
|
||||
use rog_aura::{
|
||||
AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT
|
||||
AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -29,7 +29,7 @@ pub struct AuraConfig {
|
||||
pub multizone_on: bool,
|
||||
pub enabled: LaptopAuraPower,
|
||||
#[serde(skip)]
|
||||
pub per_key_mode_active: bool
|
||||
pub per_key_mode_active: bool,
|
||||
}
|
||||
|
||||
impl StdConfig for AuraConfig {
|
||||
@@ -74,7 +74,7 @@ impl AuraConfig {
|
||||
multizone: None,
|
||||
multizone_on: false,
|
||||
enabled,
|
||||
per_key_mode_active: false
|
||||
per_key_mode_active: false,
|
||||
};
|
||||
|
||||
for n in &config.support_data.basic_modes {
|
||||
@@ -92,7 +92,7 @@ impl AuraConfig {
|
||||
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
|
||||
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Left
|
||||
direction: Direction::Left,
|
||||
});
|
||||
}
|
||||
if let Some(m) = config.multizone.as_mut() {
|
||||
@@ -156,7 +156,7 @@ impl AuraConfig {
|
||||
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
|
||||
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Left
|
||||
direction: Direction::Left,
|
||||
});
|
||||
}
|
||||
if default.is_empty() {
|
||||
@@ -232,7 +232,7 @@ impl AuraConfig {
|
||||
mod tests {
|
||||
use rog_aura::keyboard::AuraPowerState;
|
||||
use rog_aura::{
|
||||
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed
|
||||
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed,
|
||||
};
|
||||
|
||||
use super::AuraConfig;
|
||||
@@ -246,7 +246,7 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0xff
|
||||
b: 0xff,
|
||||
},
|
||||
zone: AuraZone::Key1,
|
||||
..Default::default()
|
||||
@@ -259,7 +259,7 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0x00,
|
||||
g: 0xff,
|
||||
b: 0xff
|
||||
b: 0xff,
|
||||
},
|
||||
zone: AuraZone::Key2,
|
||||
..Default::default()
|
||||
@@ -270,7 +270,7 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0xff,
|
||||
g: 0xff,
|
||||
b: 0x00
|
||||
b: 0x00,
|
||||
},
|
||||
zone: AuraZone::Key3,
|
||||
..Default::default()
|
||||
@@ -281,7 +281,7 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0x00,
|
||||
g: 0xff,
|
||||
b: 0x00
|
||||
b: 0x00,
|
||||
},
|
||||
zone: AuraZone::Key4,
|
||||
..Default::default()
|
||||
|
||||
@@ -2,13 +2,13 @@ use std::sync::Arc;
|
||||
|
||||
use config::AuraConfig;
|
||||
use config_traits::StdConfig;
|
||||
use futures_util::lock::{Mutex, MutexGuard};
|
||||
use log::info;
|
||||
use rog_aura::keyboard::{AuraLaptopUsbPackets, LedUsbPackets};
|
||||
use rog_aura::usb::{AURA_LAPTOP_LED_APPLY, AURA_LAPTOP_LED_SET};
|
||||
use rog_aura::{AuraDeviceType, AuraEffect, LedBrightness, PowerZones, AURA_LAPTOP_LED_MSG_LEN};
|
||||
use rog_platform::hid_raw::HidRaw;
|
||||
use rog_platform::keyboard_led::KeyboardBacklight;
|
||||
use tokio::sync::{Mutex, MutexGuard};
|
||||
|
||||
use crate::error::RogError;
|
||||
|
||||
@@ -19,7 +19,7 @@ pub mod trait_impls;
|
||||
pub struct Aura {
|
||||
pub hid: Option<Arc<Mutex<HidRaw>>>,
|
||||
pub backlight: Option<Arc<Mutex<KeyboardBacklight>>>,
|
||||
pub config: Arc<Mutex<AuraConfig>>
|
||||
pub config: Arc<Mutex<AuraConfig>>,
|
||||
}
|
||||
|
||||
impl Aura {
|
||||
@@ -91,13 +91,13 @@ impl Aura {
|
||||
pub async fn write_effect_and_apply(
|
||||
&self,
|
||||
dev_type: AuraDeviceType,
|
||||
mode: &AuraEffect
|
||||
mode: &AuraEffect,
|
||||
) -> Result<(), RogError> {
|
||||
if matches!(dev_type, AuraDeviceType::LaptopKeyboardTuf) {
|
||||
if let Some(platform) = &self.backlight {
|
||||
let buf = [
|
||||
1, mode.mode as u8, mode.colour1.r, mode.colour1.g, mode.colour1.b,
|
||||
mode.speed as u8
|
||||
mode.speed as u8,
|
||||
];
|
||||
platform.lock().await.set_kbd_rgb_mode(&buf)?;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ impl Aura {
|
||||
return Ok(());
|
||||
}
|
||||
Err(RogError::MissingFunction(
|
||||
"No LED backlight control available".to_string()
|
||||
"No LED backlight control available".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ impl Aura {
|
||||
0x01,
|
||||
p.new_to_byte() as u8,
|
||||
0x0,
|
||||
0x0
|
||||
0x0,
|
||||
];
|
||||
hid_raw.write_bytes(&msg)?;
|
||||
return Ok(());
|
||||
@@ -154,7 +154,7 @@ impl Aura {
|
||||
|
||||
let bytes = config.enabled.to_bytes(config.led_type);
|
||||
let msg = [
|
||||
0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]
|
||||
0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3],
|
||||
];
|
||||
hid_raw.write_bytes(&msg)?;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ impl Aura {
|
||||
pub async fn write_effect_block(
|
||||
&self,
|
||||
config: &mut AuraConfig,
|
||||
effect: &AuraLaptopUsbPackets
|
||||
effect: &AuraLaptopUsbPackets,
|
||||
) -> Result<(), RogError> {
|
||||
if config.brightness == LedBrightness::Off {
|
||||
config.brightness = LedBrightness::Med;
|
||||
@@ -201,7 +201,7 @@ impl Aura {
|
||||
let g = row[10];
|
||||
let b = row[11];
|
||||
tuf.lock().await.set_kbd_rgb_mode(&[
|
||||
0, 0, r, g, b, 0
|
||||
0, 0, r, g, b, 0,
|
||||
])?;
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ impl Aura {
|
||||
let mut config = self.config.lock().await;
|
||||
if config.ally_fix.is_none() {
|
||||
let msg = [
|
||||
0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff
|
||||
0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff,
|
||||
];
|
||||
hid_raw.lock().await.write_bytes(&msg)?;
|
||||
info!("Reset Ally power settings to base");
|
||||
|
||||
@@ -28,7 +28,7 @@ impl AuraZbus {
|
||||
mut self,
|
||||
connection: &Connection,
|
||||
// _signal_ctx: SignalEmitter<'static>,
|
||||
path: OwnedObjectPath
|
||||
path: OwnedObjectPath,
|
||||
) -> Result<(), RogError> {
|
||||
// let task = zbus.clone();
|
||||
// let signal_ctx = signal_ctx.clone();
|
||||
@@ -112,7 +112,7 @@ impl AuraZbus {
|
||||
// entirely possible to deadlock here, so use try instead of lock()
|
||||
// let ctrl = self.0.lock().await;
|
||||
// Ok(config.current_mode)
|
||||
if let Ok(config) = self.0.config.try_lock() {
|
||||
if let Some(config) = self.0.config.try_lock() {
|
||||
Ok(config.current_mode)
|
||||
} else {
|
||||
Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
|
||||
@@ -140,11 +140,11 @@ impl AuraZbus {
|
||||
#[zbus(property)]
|
||||
async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> {
|
||||
// entirely possible to deadlock here, so use try instead of lock()
|
||||
if let Ok(config) = self.0.config.try_lock() {
|
||||
if let Some(config) = self.0.config.try_lock() {
|
||||
let mode = config.current_mode;
|
||||
match config.builtins.get(&mode) {
|
||||
Some(effect) => Ok(effect.clone()),
|
||||
None => Err(ZbErr::Failed("Could not get the current effect".into()))
|
||||
None => Err(ZbErr::Failed("Could not get the current effect".into())),
|
||||
}
|
||||
} else {
|
||||
Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
|
||||
@@ -297,7 +297,7 @@ impl CtrlTask for AuraZbus {
|
||||
move |_power_plugged| {
|
||||
// power change
|
||||
async move {}
|
||||
}
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ use std::sync::Arc;
|
||||
|
||||
use dmi_id::DMIID;
|
||||
use futures_lite::future::block_on;
|
||||
use futures_util::lock::Mutex;
|
||||
use log::{debug, error, info, warn};
|
||||
use mio::{Events, Interest, Poll, Token};
|
||||
use rog_platform::error::PlatformError;
|
||||
use rog_platform::hid_raw::HidRaw;
|
||||
use tokio::sync::Mutex;
|
||||
use udev::{Device, MonitorBuilder};
|
||||
use zbus::zvariant::{ObjectPath, OwnedObjectPath};
|
||||
use zbus::Connection;
|
||||
@@ -56,7 +56,7 @@ fn dbus_path_for_dev(parent: &Device) -> Option<OwnedObjectPath> {
|
||||
if let Some(filename) = filename_partial(parent) {
|
||||
return Some(
|
||||
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{filename}"))
|
||||
.into()
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
None
|
||||
@@ -91,17 +91,17 @@ fn dev_prop_matches(dev: &Device, prop: &str, value: &str) -> bool {
|
||||
/// required.
|
||||
pub struct AsusDevice {
|
||||
device: DeviceHandle,
|
||||
dbus_path: OwnedObjectPath
|
||||
dbus_path: OwnedObjectPath,
|
||||
}
|
||||
|
||||
pub struct DeviceManager {
|
||||
_dbus_connection: Connection
|
||||
_dbus_connection: Connection,
|
||||
}
|
||||
|
||||
impl DeviceManager {
|
||||
async fn init_hid_devices(
|
||||
connection: &Connection,
|
||||
device: Device
|
||||
device: Device,
|
||||
) -> Result<Vec<AsusDevice>, RogError> {
|
||||
let mut devices = Vec::new();
|
||||
if let Some(usb_device) = device.parent_with_subsystem_devtype("usb", "usb_device")? {
|
||||
@@ -122,7 +122,7 @@ impl DeviceManager {
|
||||
// SLASH DEVICE
|
||||
if let Ok(dev_type) = DeviceHandle::new_slash_hid(
|
||||
dev.clone(),
|
||||
usb_id.to_str().unwrap_or_default()
|
||||
usb_id.to_str().unwrap_or_default(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -133,14 +133,14 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path
|
||||
dbus_path: path,
|
||||
});
|
||||
}
|
||||
}
|
||||
// ANIME MATRIX DEVICE
|
||||
if let Ok(dev_type) = DeviceHandle::maybe_anime_hid(
|
||||
dev.clone(),
|
||||
usb_id.to_str().unwrap_or_default()
|
||||
usb_id.to_str().unwrap_or_default(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -151,14 +151,14 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path
|
||||
dbus_path: path,
|
||||
});
|
||||
}
|
||||
}
|
||||
// AURA LAPTOP DEVICE
|
||||
if let Ok(dev_type) = DeviceHandle::maybe_laptop_aura(
|
||||
Some(dev),
|
||||
usb_id.to_str().unwrap_or_default()
|
||||
usb_id.to_str().unwrap_or_default(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -169,7 +169,7 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path
|
||||
dbus_path: path,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@ impl DeviceManager {
|
||||
async fn init_scsi(
|
||||
connection: &Connection,
|
||||
device: &Device,
|
||||
path: OwnedObjectPath
|
||||
path: OwnedObjectPath,
|
||||
) -> Option<AsusDevice> {
|
||||
// "ID_MODEL_ID" "1932"
|
||||
// "ID_VENDOR_ID" "0b05"
|
||||
@@ -227,7 +227,7 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
return Some(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path
|
||||
dbus_path: path,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -305,7 +305,7 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path
|
||||
dbus_path: path,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -327,7 +327,7 @@ impl DeviceManager {
|
||||
{
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path
|
||||
dbus_path: path,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ impl DeviceManager {
|
||||
ctrl.start_tasks(connection, path.clone()).await.unwrap();
|
||||
devices.push(AsusDevice {
|
||||
device: dev_type,
|
||||
dbus_path: path
|
||||
dbus_path: path,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -374,7 +374,7 @@ impl DeviceManager {
|
||||
info!("Found {} valid devices on startup", devices.len());
|
||||
let devices = Arc::new(Mutex::new(devices));
|
||||
let manager = Self {
|
||||
_dbus_connection: connection
|
||||
_dbus_connection: connection,
|
||||
};
|
||||
|
||||
// TODO: The /sysfs/ LEDs don't cause events, so they need to be manually
|
||||
@@ -509,7 +509,7 @@ impl DeviceManager {
|
||||
.remove::<ScsiZbus, _>(&path)
|
||||
.await?
|
||||
}
|
||||
_ => todo!()
|
||||
_ => todo!(),
|
||||
};
|
||||
info!("AuraManager removed: {path:?}, {res}");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ pub struct ScsiConfig {
|
||||
pub dev_type: AuraDeviceType,
|
||||
pub enabled: bool,
|
||||
pub current_mode: AuraMode,
|
||||
pub modes: BTreeMap<AuraMode, AuraEffect>
|
||||
pub modes: BTreeMap<AuraMode, AuraEffect>,
|
||||
}
|
||||
|
||||
impl ScsiConfig {
|
||||
@@ -38,61 +38,61 @@ impl Default for ScsiConfig {
|
||||
(AuraMode::Off, AuraEffect::default_with_mode(AuraMode::Off)),
|
||||
(
|
||||
AuraMode::Static,
|
||||
AuraEffect::default_with_mode(AuraMode::Static)
|
||||
AuraEffect::default_with_mode(AuraMode::Static),
|
||||
),
|
||||
(
|
||||
AuraMode::Breathe,
|
||||
AuraEffect::default_with_mode(AuraMode::Breathe)
|
||||
AuraEffect::default_with_mode(AuraMode::Breathe),
|
||||
),
|
||||
(
|
||||
AuraMode::Flashing,
|
||||
AuraEffect::default_with_mode(AuraMode::Flashing)
|
||||
AuraEffect::default_with_mode(AuraMode::Flashing),
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowCycle,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycle)
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycle),
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowWave,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowWave)
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowWave),
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowCycleBreathe,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleBreathe)
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleBreathe),
|
||||
),
|
||||
(
|
||||
AuraMode::ChaseFade,
|
||||
AuraEffect::default_with_mode(AuraMode::ChaseFade)
|
||||
AuraEffect::default_with_mode(AuraMode::ChaseFade),
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowCycleChaseFade,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleChaseFade)
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleChaseFade),
|
||||
),
|
||||
(
|
||||
AuraMode::Chase,
|
||||
AuraEffect::default_with_mode(AuraMode::Chase)
|
||||
AuraEffect::default_with_mode(AuraMode::Chase),
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowCycleChase,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleChase)
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleChase),
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowCycleWave,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleWave)
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowCycleWave),
|
||||
),
|
||||
(
|
||||
AuraMode::RainbowPulseChase,
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowPulseChase)
|
||||
AuraEffect::default_with_mode(AuraMode::RainbowPulseChase),
|
||||
),
|
||||
(
|
||||
AuraMode::RandomFlicker,
|
||||
AuraEffect::default_with_mode(AuraMode::RandomFlicker)
|
||||
AuraEffect::default_with_mode(AuraMode::RandomFlicker),
|
||||
),
|
||||
(
|
||||
AuraMode::DoubleFade,
|
||||
AuraEffect::default_with_mode(AuraMode::DoubleFade)
|
||||
)
|
||||
])
|
||||
AuraEffect::default_with_mode(AuraMode::DoubleFade),
|
||||
),
|
||||
]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use config::ScsiConfig;
|
||||
use futures_util::lock::{Mutex, MutexGuard};
|
||||
use rog_scsi::{AuraEffect, Device, Task};
|
||||
use tokio::sync::{Mutex, MutexGuard};
|
||||
|
||||
use crate::error::RogError;
|
||||
|
||||
@@ -12,7 +12,7 @@ pub mod trait_impls;
|
||||
#[derive(Clone)]
|
||||
pub struct ScsiAura {
|
||||
device: Arc<Mutex<Device>>,
|
||||
config: Arc<Mutex<ScsiConfig>>
|
||||
config: Arc<Mutex<ScsiConfig>>,
|
||||
}
|
||||
|
||||
impl ScsiAura {
|
||||
|
||||
@@ -22,7 +22,7 @@ impl ScsiZbus {
|
||||
pub async fn start_tasks(
|
||||
self,
|
||||
connection: &Connection,
|
||||
path: OwnedObjectPath
|
||||
path: OwnedObjectPath,
|
||||
) -> Result<(), RogError> {
|
||||
connection
|
||||
.object_server()
|
||||
@@ -83,11 +83,11 @@ impl ScsiZbus {
|
||||
#[zbus(property)]
|
||||
async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> {
|
||||
// entirely possible to deadlock here, so use try instead of lock()
|
||||
if let Ok(config) = self.0.config.try_lock() {
|
||||
if let Some(config) = self.0.config.try_lock() {
|
||||
let mode = config.current_mode;
|
||||
match config.modes.get(&mode) {
|
||||
Some(effect) => Ok(effect.clone()),
|
||||
None => Err(ZbErr::Failed("Could not get the current effect".into()))
|
||||
None => Err(ZbErr::Failed("Could not get the current effect".into())),
|
||||
}
|
||||
} else {
|
||||
Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
|
||||
|
||||
@@ -17,7 +17,8 @@ pub struct SlashConfig {
|
||||
pub show_on_shutdown: bool,
|
||||
pub show_on_sleep: bool,
|
||||
pub show_on_battery: bool,
|
||||
pub show_battery_warning: bool
|
||||
pub show_battery_warning: bool,
|
||||
pub show_on_lid_closed: bool,
|
||||
}
|
||||
|
||||
impl Default for SlashConfig {
|
||||
@@ -32,7 +33,8 @@ impl Default for SlashConfig {
|
||||
show_on_shutdown: true,
|
||||
show_on_sleep: true,
|
||||
show_on_battery: true,
|
||||
show_battery_warning: true
|
||||
show_battery_warning: true,
|
||||
show_on_lid_closed: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +60,7 @@ impl From<&SlashConfig> for DeviceState {
|
||||
slash_enabled: config.enabled,
|
||||
slash_brightness: config.brightness,
|
||||
slash_interval: config.display_interval,
|
||||
slash_mode: config.display_mode
|
||||
slash_mode: config.display_mode,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use config::SlashConfig;
|
||||
use futures_util::lock::{Mutex, MutexGuard};
|
||||
use rog_platform::hid_raw::HidRaw;
|
||||
use rog_platform::usb_raw::USBRaw;
|
||||
use rog_slash::usb::{get_options_packet, pkt_set_mode, pkts_for_init};
|
||||
use rog_slash::SlashType;
|
||||
use tokio::sync::{Mutex, MutexGuard};
|
||||
use rog_slash::usb::{slash_pkt_enable, slash_pkt_init, slash_pkt_options, slash_pkt_set_mode};
|
||||
|
||||
use crate::error::RogError;
|
||||
|
||||
@@ -16,14 +15,14 @@ pub mod trait_impls;
|
||||
pub struct Slash {
|
||||
hid: Option<Arc<Mutex<HidRaw>>>,
|
||||
usb: Option<Arc<Mutex<USBRaw>>>,
|
||||
config: Arc<Mutex<SlashConfig>>
|
||||
config: Arc<Mutex<SlashConfig>>,
|
||||
}
|
||||
|
||||
impl Slash {
|
||||
pub fn new(
|
||||
hid: Option<Arc<Mutex<HidRaw>>>,
|
||||
usb: Option<Arc<Mutex<USBRaw>>>,
|
||||
config: Arc<Mutex<SlashConfig>>
|
||||
config: Arc<Mutex<SlashConfig>>,
|
||||
) -> Self {
|
||||
Self { hid, usb, config }
|
||||
}
|
||||
@@ -46,22 +45,22 @@ impl Slash {
|
||||
pub async fn do_initialization(&self) -> Result<(), RogError> {
|
||||
// Don't try to initialise these models as the asus drivers already did
|
||||
let config = self.config.lock().await;
|
||||
if !matches!(config.slash_type, SlashType::GA605 | SlashType::GU605) {
|
||||
for pkt in &pkts_for_init(config.slash_type) {
|
||||
self.write_bytes(pkt).await?;
|
||||
}
|
||||
for pkt in &slash_pkt_init(config.slash_type) {
|
||||
self.write_bytes(pkt).await?;
|
||||
}
|
||||
self.write_bytes(&slash_pkt_enable(config.slash_type, config.enabled))
|
||||
.await?;
|
||||
|
||||
// Apply config upon initialization
|
||||
let option_packets = get_options_packet(
|
||||
let option_packets = slash_pkt_options(
|
||||
config.slash_type,
|
||||
config.enabled,
|
||||
config.brightness,
|
||||
config.display_interval
|
||||
config.display_interval,
|
||||
);
|
||||
self.write_bytes(&option_packets).await?;
|
||||
|
||||
let mode_packets = pkt_set_mode(config.slash_type, config.display_mode);
|
||||
let mode_packets = slash_pkt_set_mode(config.slash_type, config.display_mode);
|
||||
// self.node.write_bytes(&mode_packets[0])?;
|
||||
self.write_bytes(&mode_packets[1]).await?;
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use config_traits::StdConfig;
|
||||
use log::{debug, error, warn};
|
||||
use rog_slash::usb::{
|
||||
get_battery_saver_packet, get_boot_packet, get_low_battery_packet, get_options_packet,
|
||||
get_shutdown_packet, get_sleep_packet, pkt_save, pkt_set_mode
|
||||
slash_pkt_battery_saver, slash_pkt_boot, slash_pkt_enable, slash_pkt_lid_closed,
|
||||
slash_pkt_low_battery, slash_pkt_options, slash_pkt_save, slash_pkt_set_mode,
|
||||
slash_pkt_shutdown, slash_pkt_sleep,
|
||||
};
|
||||
use rog_slash::{DeviceState, SlashMode};
|
||||
use zbus::zvariant::OwnedObjectPath;
|
||||
@@ -23,7 +24,7 @@ impl SlashZbus {
|
||||
pub async fn start_tasks(
|
||||
mut self,
|
||||
connection: &Connection,
|
||||
path: OwnedObjectPath
|
||||
path: OwnedObjectPath,
|
||||
) -> Result<(), RogError> {
|
||||
// let task = zbus.clone();
|
||||
self.reload()
|
||||
@@ -58,11 +59,18 @@ impl SlashZbus {
|
||||
config.brightness
|
||||
};
|
||||
self.0
|
||||
.write_bytes(&get_options_packet(
|
||||
.write_bytes(&slash_pkt_enable(config.slash_type, enabled))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
warn!("ctrl_slash::enable {}", err);
|
||||
})
|
||||
.ok();
|
||||
self.0
|
||||
.write_bytes(&slash_pkt_options(
|
||||
config.slash_type,
|
||||
enabled,
|
||||
brightness,
|
||||
config.display_interval
|
||||
config.display_interval,
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -88,11 +96,11 @@ impl SlashZbus {
|
||||
let mut config = self.0.lock_config().await;
|
||||
let enabled = brightness > 0;
|
||||
self.0
|
||||
.write_bytes(&get_options_packet(
|
||||
.write_bytes(&slash_pkt_options(
|
||||
config.slash_type,
|
||||
enabled,
|
||||
brightness,
|
||||
config.display_interval
|
||||
config.display_interval,
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -116,8 +124,8 @@ impl SlashZbus {
|
||||
async fn set_interval(&self, interval: u8) {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_options_packet(
|
||||
config.slash_type, config.enabled, config.brightness, interval
|
||||
.write_bytes(&slash_pkt_options(
|
||||
config.slash_type, config.enabled, config.brightness, interval,
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -140,10 +148,12 @@ impl SlashZbus {
|
||||
async fn set_mode(&self, mode: SlashMode) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
|
||||
let command_packets = pkt_set_mode(config.slash_type, mode);
|
||||
let command_packets = slash_pkt_set_mode(config.slash_type, mode);
|
||||
// self.node.write_bytes(&command_packets[0])?;
|
||||
self.0.write_bytes(&command_packets[1]).await?;
|
||||
self.0.write_bytes(&pkt_save(config.slash_type)).await?;
|
||||
self.0
|
||||
.write_bytes(&slash_pkt_save(config.slash_type))
|
||||
.await?;
|
||||
|
||||
config.display_mode = mode;
|
||||
config.write();
|
||||
@@ -167,7 +177,7 @@ impl SlashZbus {
|
||||
async fn set_show_on_boot(&self, enable: bool) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_boot_packet(config.slash_type, enable))
|
||||
.write_bytes(&slash_pkt_boot(config.slash_type, enable))
|
||||
.await?;
|
||||
config.show_on_boot = enable;
|
||||
config.write();
|
||||
@@ -184,7 +194,7 @@ impl SlashZbus {
|
||||
async fn set_show_on_sleep(&self, enable: bool) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_sleep_packet(config.slash_type, enable))
|
||||
.write_bytes(&slash_pkt_sleep(config.slash_type, enable))
|
||||
.await?;
|
||||
config.show_on_sleep = enable;
|
||||
config.write();
|
||||
@@ -201,7 +211,7 @@ impl SlashZbus {
|
||||
async fn set_show_on_shutdown(&self, enable: bool) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_shutdown_packet(config.slash_type, enable))
|
||||
.write_bytes(&slash_pkt_shutdown(config.slash_type, enable))
|
||||
.await?;
|
||||
config.show_on_shutdown = enable;
|
||||
config.write();
|
||||
@@ -218,7 +228,7 @@ impl SlashZbus {
|
||||
async fn set_show_on_battery(&self, enable: bool) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_battery_saver_packet(config.slash_type, enable))
|
||||
.write_bytes(&slash_pkt_battery_saver(config.slash_type, enable))
|
||||
.await?;
|
||||
config.show_on_battery = enable;
|
||||
config.write();
|
||||
@@ -235,12 +245,32 @@ impl SlashZbus {
|
||||
async fn set_show_battery_warning(&self, enable: bool) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_low_battery_packet(config.slash_type, enable))
|
||||
.write_bytes(&slash_pkt_low_battery(config.slash_type, enable))
|
||||
.await?;
|
||||
config.show_battery_warning = enable;
|
||||
config.write();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn show_on_lid_closed(&self) -> zbus::fdo::Result<bool> {
|
||||
let config = self.0.lock_config().await;
|
||||
Ok(config.show_on_lid_closed)
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn set_show_on_lid_closed(&self, enable: bool) -> zbus::Result<()> {
|
||||
let mut config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&slash_pkt_lid_closed(config.slash_type, enable))
|
||||
.await?;
|
||||
self.0
|
||||
.write_bytes(&slash_pkt_save(config.slash_type))
|
||||
.await?;
|
||||
config.show_on_lid_closed = enable;
|
||||
config.write();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Reloadable for SlashZbus {
|
||||
@@ -248,11 +278,11 @@ impl Reloadable for SlashZbus {
|
||||
debug!("reloading slash settings");
|
||||
let config = self.0.lock_config().await;
|
||||
self.0
|
||||
.write_bytes(&get_options_packet(
|
||||
.write_bytes(&slash_pkt_options(
|
||||
config.slash_type,
|
||||
config.enabled,
|
||||
config.brightness,
|
||||
config.display_interval
|
||||
config.display_interval,
|
||||
))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
@@ -272,12 +302,12 @@ impl Reloadable for SlashZbus {
|
||||
};
|
||||
}
|
||||
|
||||
write_bytes_with_warning!(get_boot_packet, show_on_boot, "show_on_boot");
|
||||
write_bytes_with_warning!(get_sleep_packet, show_on_sleep, "show_on_sleep");
|
||||
write_bytes_with_warning!(get_shutdown_packet, show_on_shutdown, "show_on_shutdown");
|
||||
write_bytes_with_warning!(get_battery_saver_packet, show_on_battery, "show_on_battery");
|
||||
write_bytes_with_warning!(slash_pkt_boot, show_on_boot, "show_on_boot");
|
||||
write_bytes_with_warning!(slash_pkt_sleep, show_on_sleep, "show_on_sleep");
|
||||
write_bytes_with_warning!(slash_pkt_shutdown, show_on_shutdown, "show_on_shutdown");
|
||||
write_bytes_with_warning!(slash_pkt_battery_saver, show_on_battery, "show_on_battery");
|
||||
write_bytes_with_warning!(
|
||||
get_low_battery_packet,
|
||||
slash_pkt_low_battery,
|
||||
show_battery_warning,
|
||||
"show_battery_warning"
|
||||
);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use futures_util::lock::Mutex;
|
||||
use log::{debug, error, info};
|
||||
use rog_anime::error::AnimeError;
|
||||
use rog_anime::usb::get_anime_type;
|
||||
@@ -12,7 +13,6 @@ use rog_platform::usb_raw::USBRaw;
|
||||
use rog_scsi::{open_device, ScsiType};
|
||||
use rog_slash::error::SlashError;
|
||||
use rog_slash::SlashType;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use crate::aura_anime::config::AniMeConfig;
|
||||
use crate::aura_anime::AniMe;
|
||||
@@ -31,7 +31,7 @@ pub enum _DeviceHandle {
|
||||
LedClass(KeyboardBacklight),
|
||||
/// TODO
|
||||
MulticolourLed,
|
||||
None
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -47,14 +47,14 @@ pub enum DeviceHandle {
|
||||
TufLedClass(Arc<Mutex<HidRaw>>),
|
||||
/// TODO
|
||||
MulticolourLed,
|
||||
None
|
||||
None,
|
||||
}
|
||||
|
||||
impl DeviceHandle {
|
||||
/// Try Slash HID. If one exists it is initialsed and returned.
|
||||
pub async fn new_slash_hid(
|
||||
device: Arc<Mutex<HidRaw>>,
|
||||
prod_id: &str
|
||||
prod_id: &str,
|
||||
) -> Result<Self, RogError> {
|
||||
debug!("Testing for HIDRAW Slash");
|
||||
let slash_type = SlashType::from_dmi();
|
||||
@@ -93,7 +93,7 @@ impl DeviceHandle {
|
||||
let slash = Slash::new(
|
||||
None,
|
||||
Some(Arc::new(Mutex::new(usb))),
|
||||
Arc::new(Mutex::new(config))
|
||||
Arc::new(Mutex::new(config)),
|
||||
);
|
||||
slash.do_initialization().await?;
|
||||
Ok(Self::Slash(slash))
|
||||
@@ -105,11 +105,11 @@ impl DeviceHandle {
|
||||
/// Try AniMe Matrix HID. If one exists it is initialsed and returned.
|
||||
pub async fn maybe_anime_hid(
|
||||
_device: Arc<Mutex<HidRaw>>,
|
||||
_prod_id: &str
|
||||
_prod_id: &str,
|
||||
) -> Result<Self, RogError> {
|
||||
// TODO: can't use HIDRAW for anime at the moment
|
||||
Err(RogError::NotFound(
|
||||
"Can't use anime over hidraw yet. Skip.".to_string()
|
||||
"Can't use anime over hidraw yet. Skip.".to_string(),
|
||||
))
|
||||
|
||||
// debug!("Testing for HIDRAW AniMe");
|
||||
@@ -144,13 +144,13 @@ impl DeviceHandle {
|
||||
let mut anime = AniMe::new(
|
||||
None,
|
||||
Some(Arc::new(Mutex::new(usb))),
|
||||
Arc::new(Mutex::new(config))
|
||||
Arc::new(Mutex::new(config)),
|
||||
);
|
||||
anime.do_initialization().await?;
|
||||
Ok(Self::AniMe(anime))
|
||||
} else {
|
||||
Err(RogError::NotFound(
|
||||
"No AnimeMatrix device found".to_string()
|
||||
"No AnimeMatrix device found".to_string(),
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ impl DeviceHandle {
|
||||
|
||||
pub async fn maybe_laptop_aura(
|
||||
device: Option<Arc<Mutex<HidRaw>>>,
|
||||
prod_id: &str
|
||||
prod_id: &str,
|
||||
) -> Result<Self, RogError> {
|
||||
debug!("Testing for laptop aura");
|
||||
let aura_type = AuraDeviceType::from(prod_id);
|
||||
@@ -201,7 +201,7 @@ impl DeviceHandle {
|
||||
let aura = Aura {
|
||||
hid: device,
|
||||
backlight,
|
||||
config: Arc::new(Mutex::new(config))
|
||||
config: Arc::new(Mutex::new(config)),
|
||||
};
|
||||
aura.do_initialization().await?;
|
||||
Ok(Self::Aura(aura))
|
||||
|
||||
@@ -11,7 +11,7 @@ const CONFIG_FILE: &str = "asusd.ron";
|
||||
#[derive(Default, Clone, Deserialize, Serialize, PartialEq)]
|
||||
pub struct Tuning {
|
||||
pub enabled: bool,
|
||||
pub group: HashMap<FirmwareAttribute, i32>
|
||||
pub group: HashMap<FirmwareAttribute, i32>,
|
||||
}
|
||||
type Tunings = HashMap<PlatformProfile, Tuning>;
|
||||
|
||||
@@ -49,7 +49,7 @@ pub struct Config {
|
||||
pub armoury_settings: HashMap<FirmwareAttribute, i32>,
|
||||
/// Temporary state for AC/Batt
|
||||
#[serde(skip)]
|
||||
pub last_power_plugged: u8
|
||||
pub last_power_plugged: u8,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@@ -82,7 +82,7 @@ impl Default for Config {
|
||||
ac_profile_tunings: HashMap::default(),
|
||||
dc_profile_tunings: HashMap::default(),
|
||||
armoury_settings: HashMap::default(),
|
||||
last_power_plugged: Default::default()
|
||||
last_power_plugged: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ pub struct Config601 {
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
pub nv_temp_target: Option<u8>,
|
||||
#[serde(skip)]
|
||||
pub last_power_plugged: u8
|
||||
pub last_power_plugged: u8,
|
||||
}
|
||||
|
||||
impl From<Config601> for Config {
|
||||
@@ -170,7 +170,7 @@ impl From<Config601> for Config {
|
||||
last_power_plugged: c.last_power_plugged,
|
||||
ac_profile_tunings: HashMap::default(),
|
||||
dc_profile_tunings: HashMap::default(),
|
||||
armoury_settings: HashMap::default()
|
||||
armoury_settings: HashMap::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ use std::sync::Arc;
|
||||
|
||||
use config_traits::{StdConfig, StdConfigLoad};
|
||||
use futures_lite::StreamExt;
|
||||
use futures_util::lock::Mutex;
|
||||
use log::{debug, error, info, warn};
|
||||
use rog_platform::platform::{PlatformProfile, RogPlatform};
|
||||
use rog_profiles::error::ProfileError;
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::Mutex;
|
||||
use zbus::object_server::SignalEmitter;
|
||||
use zbus::{interface, Connection};
|
||||
|
||||
@@ -23,7 +23,7 @@ pub const FAN_CURVE_ZBUS_PATH: &str = "/xyz/ljones";
|
||||
pub struct FanCurveConfig {
|
||||
pub profiles: FanCurveProfiles,
|
||||
#[serde(skip)]
|
||||
pub current: PlatformProfile
|
||||
pub current: PlatformProfile,
|
||||
}
|
||||
|
||||
impl StdConfig for FanCurveConfig {
|
||||
@@ -47,7 +47,7 @@ impl StdConfigLoad for FanCurveConfig {}
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CtrlFanCurveZbus {
|
||||
config: Arc<Mutex<FanCurveConfig>>,
|
||||
platform: RogPlatform
|
||||
platform: RogPlatform,
|
||||
}
|
||||
|
||||
// Non-zbus-derive impl
|
||||
@@ -69,7 +69,7 @@ impl CtrlFanCurveZbus {
|
||||
for this in [
|
||||
PlatformProfile::Balanced,
|
||||
PlatformProfile::Performance,
|
||||
PlatformProfile::Quiet
|
||||
PlatformProfile::Quiet,
|
||||
] {
|
||||
// For each profile we need to switch to it before we
|
||||
// can read the existing values from hardware. The ACPI method used
|
||||
@@ -93,7 +93,7 @@ impl CtrlFanCurveZbus {
|
||||
|
||||
return Ok(Self {
|
||||
config: Arc::new(Mutex::new(config)),
|
||||
platform
|
||||
platform,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ impl CtrlFanCurveZbus {
|
||||
async fn set_fan_curves_enabled(
|
||||
&mut self,
|
||||
profile: PlatformProfile,
|
||||
enabled: bool
|
||||
enabled: bool,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.config
|
||||
.lock()
|
||||
@@ -130,7 +130,7 @@ impl CtrlFanCurveZbus {
|
||||
&mut self,
|
||||
profile: PlatformProfile,
|
||||
fan: FanCurvePU,
|
||||
enabled: bool
|
||||
enabled: bool,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.config
|
||||
.lock()
|
||||
@@ -149,7 +149,7 @@ impl CtrlFanCurveZbus {
|
||||
/// Get the fan-curve data for the currently active ThrottlePolicy
|
||||
async fn fan_curve_data(
|
||||
&mut self,
|
||||
profile: PlatformProfile
|
||||
profile: PlatformProfile,
|
||||
) -> zbus::fdo::Result<Vec<CurveData>> {
|
||||
let curve = self
|
||||
.config
|
||||
@@ -166,7 +166,7 @@ impl CtrlFanCurveZbus {
|
||||
async fn set_fan_curve(
|
||||
&mut self,
|
||||
profile: PlatformProfile,
|
||||
curve: CurveData
|
||||
curve: CurveData,
|
||||
) -> zbus::fdo::Result<()> {
|
||||
self.config
|
||||
.lock()
|
||||
@@ -216,7 +216,7 @@ impl CtrlFanCurveZbus {
|
||||
.lock()
|
||||
.await
|
||||
.profiles
|
||||
.set_active_curve_to_defaults((&active).into(), &mut find_fan_curve_node()?)?;
|
||||
.set_active_curve_to_defaults(active.as_str().into(), &mut find_fan_curve_node()?)?;
|
||||
self.platform.set_platform_profile(active.as_str())?;
|
||||
|
||||
self.config.lock().await.write();
|
||||
@@ -261,7 +261,7 @@ impl CtrlTask for CtrlFanCurveZbus {
|
||||
.profiles
|
||||
.write_profile_curve_to_platform(
|
||||
profile,
|
||||
&mut find_fan_curve_node().unwrap()
|
||||
&mut find_fan_curve_node().unwrap(),
|
||||
)
|
||||
.map_err(|e| warn!("write_profile_curve_to_platform, {}", e))
|
||||
.ok();
|
||||
|
||||
@@ -3,12 +3,12 @@ use std::process::Command;
|
||||
use std::sync::Arc;
|
||||
|
||||
use config_traits::StdConfig;
|
||||
use futures_util::lock::Mutex;
|
||||
use log::{debug, error, info, warn};
|
||||
use rog_platform::asus_armoury::{AttrValue, FirmwareAttribute, FirmwareAttributes};
|
||||
use rog_platform::cpu::{CPUControl, CPUGovernor, CPUEPP};
|
||||
use rog_platform::platform::{PlatformProfile, Properties, RogPlatform};
|
||||
use rog_platform::power::AsusPower;
|
||||
use zbus::export::futures_util::lock::Mutex;
|
||||
use zbus::fdo::Error as FdoErr;
|
||||
use zbus::object_server::SignalEmitter;
|
||||
use zbus::{interface, Connection};
|
||||
@@ -45,7 +45,7 @@ pub struct CtrlPlatform {
|
||||
platform: RogPlatform,
|
||||
attributes: FirmwareAttributes,
|
||||
cpu_control: Option<CPUControl>,
|
||||
config: Arc<Mutex<Config>>
|
||||
config: Arc<Mutex<Config>>,
|
||||
}
|
||||
|
||||
impl CtrlPlatform {
|
||||
@@ -55,7 +55,7 @@ impl CtrlPlatform {
|
||||
attributes: FirmwareAttributes,
|
||||
config: Arc<Mutex<Config>>,
|
||||
config_path: &Path,
|
||||
signal_context: SignalEmitter<'static>
|
||||
signal_context: SignalEmitter<'static>,
|
||||
) -> Result<Self, RogError> {
|
||||
let config1 = config.clone();
|
||||
let config_path = config_path.to_owned();
|
||||
@@ -67,12 +67,12 @@ impl CtrlPlatform {
|
||||
config,
|
||||
cpu_control: CPUControl::new()
|
||||
.map_err(|e| error!("Couldn't get CPU control sysfs: {e}"))
|
||||
.ok()
|
||||
.ok(),
|
||||
};
|
||||
let mut inotify_self = ret_self.clone();
|
||||
|
||||
tokio::spawn(async move {
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use futures_util::StreamExt;
|
||||
info!("Starting inotify watch for asusd config file");
|
||||
|
||||
let mut buffer = [0; 32];
|
||||
@@ -86,7 +86,7 @@ impl CtrlPlatform {
|
||||
inotify::WatchMask::MODIFY
|
||||
| inotify::WatchMask::CLOSE_WRITE
|
||||
| inotify::WatchMask::ATTRIB
|
||||
| inotify::WatchMask::CREATE
|
||||
| inotify::WatchMask::CREATE,
|
||||
)
|
||||
.inspect_err(|e| {
|
||||
if e.kind() == std::io::ErrorKind::NotFound {
|
||||
@@ -128,7 +128,7 @@ impl CtrlPlatform {
|
||||
if limit > 0
|
||||
&& std::mem::replace(
|
||||
&mut self.config.lock().await.charge_control_end_threshold,
|
||||
limit
|
||||
limit,
|
||||
) != limit
|
||||
{
|
||||
self.power
|
||||
@@ -210,7 +210,8 @@ impl CtrlPlatform {
|
||||
match throttle {
|
||||
PlatformProfile::Balanced => self.config.lock().await.profile_balanced_epp,
|
||||
PlatformProfile::Performance => self.config.lock().await.profile_performance_epp,
|
||||
PlatformProfile::Quiet => self.config.lock().await.profile_quiet_epp
|
||||
PlatformProfile::Quiet => self.config.lock().await.profile_quiet_epp,
|
||||
PlatformProfile::LowPower => self.config.lock().await.profile_quiet_epp,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +306,7 @@ impl CtrlPlatform {
|
||||
async fn one_shot_full_charge(&self) -> Result<(), FdoErr> {
|
||||
let base_limit = std::mem::replace(
|
||||
&mut self.config.lock().await.charge_control_end_threshold,
|
||||
100
|
||||
100,
|
||||
);
|
||||
if base_limit != 100 {
|
||||
self.power.set_charge_control_end_threshold(100)?;
|
||||
@@ -319,11 +320,13 @@ impl CtrlPlatform {
|
||||
/// If fan-curves are supported will also activate a fan curve for profile.
|
||||
async fn next_platform_profile(
|
||||
&mut self,
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
|
||||
) -> Result<(), FdoErr> {
|
||||
let policy: PlatformProfile =
|
||||
platform_get_value!(self, platform_profile, "platform_profile").map(|n| n.into())?;
|
||||
let policy = PlatformProfile::next(policy);
|
||||
let choices =
|
||||
platform_get_value!(self, platform_profile_choices, "platform_profile_choices")?;
|
||||
let policy = PlatformProfile::next(policy, &choices);
|
||||
|
||||
if self.platform.has_platform_profile() {
|
||||
let change_epp = self.config.lock().await.platform_profile_linked_epp;
|
||||
@@ -339,21 +342,36 @@ impl CtrlPlatform {
|
||||
Ok(self.platform_profile_changed(&ctxt).await?)
|
||||
} else {
|
||||
Err(FdoErr::NotSupported(
|
||||
"RogPlatform: platform_profile not supported".to_owned()
|
||||
"RogPlatform: platform_profile not supported".to_owned(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn platform_profile_choices(&self) -> Result<Vec<PlatformProfile>, FdoErr> {
|
||||
platform_get_value!(self, platform_profile_choices, "platform_profile_choices")
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
fn platform_profile(&self) -> Result<PlatformProfile, FdoErr> {
|
||||
platform_get_value!(self, platform_profile, "platform_profile").map(|n| n.into())
|
||||
let choices = self.platform.get_platform_profile_choices()?;
|
||||
let policy: PlatformProfile = self.platform.get_platform_profile()?.as_str().into();
|
||||
let policy = if policy == PlatformProfile::LowPower
|
||||
&& choices.contains(&PlatformProfile::LowPower)
|
||||
{
|
||||
PlatformProfile::Quiet
|
||||
} else {
|
||||
policy
|
||||
};
|
||||
|
||||
Ok(policy)
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn set_platform_profile(
|
||||
&mut self,
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
|
||||
policy: PlatformProfile
|
||||
policy: PlatformProfile,
|
||||
) -> Result<(), FdoErr> {
|
||||
// TODO: watch for external changes
|
||||
if self.platform.has_platform_profile() {
|
||||
@@ -362,7 +380,16 @@ impl CtrlPlatform {
|
||||
self.check_and_set_epp(epp, change_epp);
|
||||
|
||||
self.config.lock().await.write();
|
||||
// TODO: Need to get supported profiles here and ensure we translate to one
|
||||
|
||||
let choices = self.platform.get_platform_profile_choices()?;
|
||||
let policy = if policy == PlatformProfile::Quiet
|
||||
&& choices.contains(&PlatformProfile::LowPower)
|
||||
{
|
||||
PlatformProfile::LowPower
|
||||
} else {
|
||||
policy
|
||||
};
|
||||
|
||||
self.platform
|
||||
.set_platform_profile(policy.into())
|
||||
.map_err(|err| {
|
||||
@@ -373,7 +400,7 @@ impl CtrlPlatform {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(FdoErr::NotSupported(
|
||||
"RogPlatform: platform_profile not supported".to_owned()
|
||||
"RogPlatform: platform_profile not supported".to_owned(),
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -399,7 +426,7 @@ impl CtrlPlatform {
|
||||
async fn set_platform_profile_on_battery(
|
||||
&mut self,
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
|
||||
policy: PlatformProfile
|
||||
policy: PlatformProfile,
|
||||
) -> Result<(), FdoErr> {
|
||||
self.config.lock().await.platform_profile_on_battery = policy;
|
||||
self.set_platform_profile(ctxt, policy).await?;
|
||||
@@ -428,7 +455,7 @@ impl CtrlPlatform {
|
||||
async fn set_platform_profile_on_ac(
|
||||
&mut self,
|
||||
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
|
||||
policy: PlatformProfile
|
||||
policy: PlatformProfile,
|
||||
) -> Result<(), FdoErr> {
|
||||
self.config.lock().await.platform_profile_on_ac = policy;
|
||||
self.set_platform_profile(ctxt, policy).await?;
|
||||
@@ -593,7 +620,7 @@ impl ReloadAndNotify for CtrlPlatform {
|
||||
async fn reload_and_notify(
|
||||
&mut self,
|
||||
signal_context: &SignalEmitter<'static>,
|
||||
data: Self::Data
|
||||
data: Self::Data,
|
||||
) -> Result<(), RogError> {
|
||||
let mut config = self.config.lock().await;
|
||||
if *config != data {
|
||||
@@ -622,7 +649,8 @@ impl ReloadAndNotify for CtrlPlatform {
|
||||
let epp = match profile {
|
||||
PlatformProfile::Balanced => data.profile_balanced_epp,
|
||||
PlatformProfile::Performance => data.profile_performance_epp,
|
||||
PlatformProfile::Quiet => data.profile_quiet_epp
|
||||
PlatformProfile::Quiet => data.profile_quiet_epp,
|
||||
PlatformProfile::LowPower => data.profile_quiet_epp,
|
||||
};
|
||||
warn!("setting epp to {epp:?}");
|
||||
self.check_and_set_epp(epp, true);
|
||||
@@ -694,7 +722,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
platform1
|
||||
.power
|
||||
.set_charge_control_end_threshold(
|
||||
platform1.config.lock().await.charge_control_end_threshold
|
||||
platform1.config.lock().await.charge_control_end_threshold,
|
||||
)
|
||||
.ok();
|
||||
}
|
||||
@@ -728,7 +756,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
platform2
|
||||
.power
|
||||
.set_charge_control_end_threshold(
|
||||
lock.base_charge_control_end_threshold
|
||||
lock.base_charge_control_end_threshold,
|
||||
)
|
||||
.map_err(|err| {
|
||||
warn!("CtrlCharge: charge_control_end_threshold {}", err);
|
||||
@@ -773,7 +801,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
&attrs,
|
||||
&mut *platform3.config.lock().await,
|
||||
power_plugged,
|
||||
profile
|
||||
profile,
|
||||
)
|
||||
.await;
|
||||
platform3
|
||||
@@ -782,7 +810,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -829,7 +857,7 @@ impl CtrlTask for CtrlPlatform {
|
||||
&attrs,
|
||||
&mut *ctrl.config.lock().await,
|
||||
power_plugged == 1,
|
||||
profile
|
||||
profile,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ use std::env;
|
||||
use std::error::Error;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ::zbus::export::futures_util::lock::Mutex;
|
||||
use ::zbus::Connection;
|
||||
use asusd::asus_armoury::start_attributes_zbus;
|
||||
use asusd::aura_manager::DeviceManager;
|
||||
@@ -11,6 +10,7 @@ use asusd::ctrl_fancurves::CtrlFanCurveZbus;
|
||||
use asusd::ctrl_platform::CtrlPlatform;
|
||||
use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME};
|
||||
use config_traits::{StdConfig, StdConfigLoad1};
|
||||
use futures_util::lock::Mutex;
|
||||
use log::{error, info};
|
||||
use rog_platform::asus_armoury::FirmwareAttributes;
|
||||
use rog_platform::platform::RogPlatform;
|
||||
@@ -30,7 +30,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let is_service = match env::var_os("IS_SERVICE") {
|
||||
Some(val) => val == "1",
|
||||
None => true
|
||||
None => true,
|
||||
};
|
||||
|
||||
if !is_service {
|
||||
@@ -76,7 +76,7 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
platform.clone(),
|
||||
power.clone(),
|
||||
attributes.clone(),
|
||||
config.clone()
|
||||
config.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -96,7 +96,7 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
||||
attributes,
|
||||
config.clone(),
|
||||
&cfg_path,
|
||||
CtrlPlatform::signal_context(&server)?
|
||||
CtrlPlatform::signal_context(&server)?,
|
||||
) {
|
||||
Ok(ctrl) => {
|
||||
let sig_ctx = CtrlPlatform::signal_context(&server)?;
|
||||
|
||||
@@ -37,7 +37,7 @@ pub enum RogError {
|
||||
SystemdUnitAction(String),
|
||||
SystemdUnitWaitTimeout(String),
|
||||
Command(String, std::io::Error),
|
||||
ParseRon(ron::Error)
|
||||
ParseRon(ron::Error),
|
||||
}
|
||||
|
||||
impl fmt::Display for RogError {
|
||||
@@ -87,7 +87,7 @@ impl fmt::Display for RogError {
|
||||
)
|
||||
}
|
||||
RogError::Command(func, error) => write!(f, "Command exec error: {}: {}", func, error),
|
||||
RogError::ParseRon(error) => write!(f, "Parse config error: {}", error)
|
||||
RogError::ParseRon(error) => write!(f, "Parse config error: {}", error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ macro_rules! task_watch_item {
|
||||
&self,
|
||||
signal_ctxt: SignalEmitter<'static>,
|
||||
) -> Result<(), RogError> {
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use futures_util::StreamExt;
|
||||
|
||||
let ctrl = self.clone();
|
||||
concat_idents::concat_idents!(watch_fn = monitor_, $name {
|
||||
@@ -107,7 +107,7 @@ macro_rules! task_watch_item_notify {
|
||||
&self,
|
||||
signal_ctxt: SignalEmitter<'static>,
|
||||
) -> Result<(), RogError> {
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use futures_util::StreamExt;
|
||||
|
||||
let ctrl = self.clone();
|
||||
concat_idents::concat_idents!(watch_fn = monitor_, $name {
|
||||
@@ -149,7 +149,7 @@ pub trait ReloadAndNotify {
|
||||
fn reload_and_notify(
|
||||
&mut self,
|
||||
signal_context: &SignalEmitter<'static>,
|
||||
data: Self::Data
|
||||
data: Self::Data,
|
||||
) -> impl Future<Output = Result<(), RogError>> + Send;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ pub trait ZbusRun {
|
||||
fn add_to_server_helper(
|
||||
iface: impl Interface,
|
||||
path: &str,
|
||||
server: &mut Connection
|
||||
server: &mut Connection,
|
||||
) -> impl Future<Output = ()> + Send {
|
||||
async move {
|
||||
server
|
||||
@@ -188,7 +188,7 @@ pub trait CtrlTask {
|
||||
/// separate thread.
|
||||
fn create_tasks(
|
||||
&self,
|
||||
signal: SignalEmitter<'static>
|
||||
signal: SignalEmitter<'static>,
|
||||
) -> impl Future<Output = Result<(), RogError>> + Send;
|
||||
|
||||
// /// Create a timed repeating task
|
||||
@@ -212,7 +212,7 @@ pub trait CtrlTask {
|
||||
mut on_prepare_for_sleep: F1,
|
||||
mut on_prepare_for_shutdown: F2,
|
||||
mut on_lid_change: F3,
|
||||
mut on_external_power_change: F4
|
||||
mut on_external_power_change: F4,
|
||||
) -> impl Future<Output = ()> + Send
|
||||
where
|
||||
F1: FnMut(bool) -> Fut1 + Send + 'static,
|
||||
@@ -222,7 +222,7 @@ pub trait CtrlTask {
|
||||
Fut1: Future<Output = ()> + Send,
|
||||
Fut2: Future<Output = ()> + Send,
|
||||
Fut3: Future<Output = ()> + Send,
|
||||
Fut4: Future<Output = ()> + Send
|
||||
Fut4: Future<Output = ()> + Send,
|
||||
{
|
||||
async {
|
||||
let connection = Connection::system()
|
||||
@@ -302,10 +302,10 @@ pub trait GetSupported {
|
||||
pub async fn start_tasks<T>(
|
||||
mut zbus: T,
|
||||
connection: &mut Connection,
|
||||
signal_ctx: SignalEmitter<'static>
|
||||
signal_ctx: SignalEmitter<'static>,
|
||||
) -> Result<(), RogError>
|
||||
where
|
||||
T: ZbusRun + Reloadable + CtrlTask + Clone
|
||||
T: ZbusRun + Reloadable + CtrlTask + Clone,
|
||||
{
|
||||
let zbus_clone = zbus.clone();
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ use serde::Serialize;
|
||||
/// implemented, the rest are intended to be free methods.
|
||||
pub trait StdConfig
|
||||
where
|
||||
Self: Serialize + DeserializeOwned
|
||||
Self: Serialize + DeserializeOwned,
|
||||
{
|
||||
/// Taking over the standard `new()` to ensure things can be generic
|
||||
fn new() -> Self;
|
||||
|
||||
@@ -12,7 +12,7 @@ pub struct DMIID {
|
||||
pub bios_vendor: String,
|
||||
pub bios_version: String,
|
||||
pub product_family: String,
|
||||
pub product_name: String
|
||||
pub product_name: String,
|
||||
}
|
||||
|
||||
impl DMIID {
|
||||
@@ -77,7 +77,7 @@ impl DMIID {
|
||||
product_name: device
|
||||
.attribute_value("product_name")
|
||||
.map(|s| s.to_string_lossy().to_string())
|
||||
.unwrap_or("Unknown".to_string())
|
||||
.unwrap_or("Unknown".to_string()),
|
||||
});
|
||||
}
|
||||
Err("dmi not found".into())
|
||||
|
||||
@@ -23,15 +23,15 @@ const PANE_LEN: usize = BLOCK_END - BLOCK_START;
|
||||
|
||||
/// First packet is for GA401 + GA402
|
||||
pub const USB_PREFIX1: [u8; 7] = [
|
||||
0x5e, 0xc0, 0x02, 0x01, 0x00, 0x73, 0x02
|
||||
0x5e, 0xc0, 0x02, 0x01, 0x00, 0x73, 0x02,
|
||||
];
|
||||
/// Second packet is for GA401 + GA402
|
||||
pub const USB_PREFIX2: [u8; 7] = [
|
||||
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02
|
||||
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02,
|
||||
];
|
||||
/// Third packet is for GA402 matrix
|
||||
pub const USB_PREFIX3: [u8; 7] = [
|
||||
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02
|
||||
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02,
|
||||
];
|
||||
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
@@ -40,7 +40,7 @@ pub struct Animations {
|
||||
pub boot: AnimBooting,
|
||||
pub awake: AnimAwake,
|
||||
pub sleep: AnimSleeping,
|
||||
pub shutdown: AnimShutdown
|
||||
pub shutdown: AnimShutdown,
|
||||
}
|
||||
|
||||
// TODO: move this out
|
||||
@@ -54,7 +54,7 @@ pub struct DeviceState {
|
||||
pub off_when_unplugged: bool,
|
||||
pub off_when_suspended: bool,
|
||||
pub off_when_lid_closed: bool,
|
||||
pub brightness_on_battery: Brightness
|
||||
pub brightness_on_battery: Brightness,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
|
||||
@@ -64,7 +64,7 @@ pub enum AnimeType {
|
||||
GA402,
|
||||
GU604,
|
||||
#[default]
|
||||
Unsupported
|
||||
Unsupported,
|
||||
}
|
||||
|
||||
impl FromStr for AnimeType {
|
||||
@@ -75,7 +75,7 @@ impl FromStr for AnimeType {
|
||||
"ga401" | "GA401" => Self::GA401,
|
||||
"ga402" | "GA402" => Self::GA402,
|
||||
"gu604" | "GU604" => Self::GU604,
|
||||
_ => Self::Unsupported
|
||||
_ => Self::Unsupported,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ impl AnimeType {
|
||||
pub fn width(&self) -> usize {
|
||||
match self {
|
||||
AnimeType::GU604 => 70,
|
||||
_ => 74
|
||||
_ => 74,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ impl AnimeType {
|
||||
match self {
|
||||
AnimeType::GA401 => 36,
|
||||
AnimeType::GU604 => 43,
|
||||
_ => 39
|
||||
_ => 39,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ impl AnimeType {
|
||||
match self {
|
||||
AnimeType::GA401 => PANE_LEN * 2,
|
||||
AnimeType::GU604 => PANE_LEN * 3,
|
||||
_ => PANE_LEN * 3
|
||||
_ => PANE_LEN * 3,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ impl AnimeType {
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct AnimeDataBuffer {
|
||||
data: Vec<u8>,
|
||||
anime: AnimeType
|
||||
anime: AnimeType,
|
||||
}
|
||||
|
||||
impl AnimeDataBuffer {
|
||||
@@ -137,7 +137,7 @@ impl AnimeDataBuffer {
|
||||
|
||||
AnimeDataBuffer {
|
||||
data: vec![0u8; len],
|
||||
anime
|
||||
anime,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ impl TryFrom<AnimeDataBuffer> for AnimePacketType {
|
||||
|
||||
let mut buffers = match anime.anime {
|
||||
AnimeType::GA401 => vec![[0; 640]; 2],
|
||||
AnimeType::GA402 | AnimeType::GU604 | AnimeType::Unsupported => vec![[0; 640]; 3]
|
||||
AnimeType::GA402 | AnimeType::GU604 | AnimeType::Unsupported => vec![[0; 640]; 3],
|
||||
};
|
||||
|
||||
for (idx, chunk) in anime.data.as_slice().chunks(PANE_LEN).enumerate() {
|
||||
|
||||
@@ -20,7 +20,7 @@ impl AnimeDiagonal {
|
||||
Self(
|
||||
anime_type,
|
||||
vec![vec![0; anime_type.width()]; anime_type.height()],
|
||||
duration
|
||||
duration,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ impl AnimeDiagonal {
|
||||
path: &Path,
|
||||
duration: Option<Duration>,
|
||||
bright: f32,
|
||||
anime_type: AnimeType
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
let data = std::fs::read(path).map_err(|e| {
|
||||
error!("Could not open {path:?}: {e:?}");
|
||||
@@ -86,7 +86,7 @@ impl AnimeDiagonal {
|
||||
png_pong::PngRaster::Rgba16(ras) => {
|
||||
Self::pixels_from_16bit(ras, &mut matrix, bright, false);
|
||||
}
|
||||
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format)
|
||||
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format),
|
||||
};
|
||||
|
||||
Ok(matrix)
|
||||
@@ -96,9 +96,9 @@ impl AnimeDiagonal {
|
||||
ras: &pix::Raster<P>,
|
||||
matrix: &mut AnimeDiagonal,
|
||||
bright: f32,
|
||||
grey: bool
|
||||
grey: bool,
|
||||
) where
|
||||
P: pix::el::Pixel<Chan = pix::chan::Ch8>
|
||||
P: pix::el::Pixel<Chan = pix::chan::Ch8>,
|
||||
{
|
||||
let width = ras.width();
|
||||
for (y, row) in ras.pixels().chunks(width as usize).enumerate() {
|
||||
@@ -121,9 +121,9 @@ impl AnimeDiagonal {
|
||||
ras: &pix::Raster<P>,
|
||||
matrix: &mut AnimeDiagonal,
|
||||
bright: f32,
|
||||
grey: bool
|
||||
grey: bool,
|
||||
) where
|
||||
P: pix::el::Pixel<Chan = pix::chan::Ch16>
|
||||
P: pix::el::Pixel<Chan = pix::chan::Ch16>,
|
||||
{
|
||||
let width = ras.width();
|
||||
for (y, row) in ras.pixels().chunks(width as usize).enumerate() {
|
||||
@@ -146,7 +146,7 @@ impl AnimeDiagonal {
|
||||
match anime_type {
|
||||
AnimeType::GA401 => self.to_ga401_packets(),
|
||||
AnimeType::GU604 => self.to_gu604_packets(),
|
||||
_ => self.to_ga402_packets()
|
||||
_ => self.to_ga402_packets(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ impl AnimeDiagonal {
|
||||
x: usize,
|
||||
y: usize,
|
||||
start_index: &mut usize,
|
||||
len: usize
|
||||
len: usize,
|
||||
) {
|
||||
buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len));
|
||||
*start_index += len;
|
||||
@@ -307,7 +307,7 @@ impl AnimeDiagonal {
|
||||
x: usize,
|
||||
y: usize,
|
||||
start_index: &mut usize,
|
||||
len: usize
|
||||
len: usize,
|
||||
) {
|
||||
buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len));
|
||||
*start_index += len;
|
||||
|
||||
@@ -24,7 +24,7 @@ pub enum AnimeError {
|
||||
DataBufferLength,
|
||||
PixelGifWidth(usize),
|
||||
PixelGifHeight(usize),
|
||||
ParseError(String)
|
||||
ParseError(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for AnimeError {
|
||||
@@ -61,7 +61,7 @@ impl fmt::Display for AnimeError {
|
||||
AnimeError::PixelGifHeight(n) => write!(
|
||||
f,
|
||||
"The gif used for pixel-perfect gif is is taller than {n}"
|
||||
)
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ pub struct AnimeFrame {
|
||||
/// the `asusd` daemon over dbus or converted to USB packet with
|
||||
/// `AnimePacketType::from(buffer)`
|
||||
data: AnimeDataBuffer,
|
||||
delay: Duration
|
||||
delay: Duration,
|
||||
}
|
||||
|
||||
impl AnimeFrame {
|
||||
@@ -44,7 +44,7 @@ pub enum AnimTime {
|
||||
/// Run for infinite time
|
||||
Infinite,
|
||||
/// Fade in, play for, fade out
|
||||
Fade(Fade)
|
||||
Fade(Fade),
|
||||
}
|
||||
|
||||
impl Default for AnimTime {
|
||||
@@ -59,7 +59,7 @@ impl Default for AnimTime {
|
||||
pub struct Fade {
|
||||
fade_in: Duration,
|
||||
show_for: Option<Duration>,
|
||||
fade_out: Duration
|
||||
fade_out: Duration,
|
||||
}
|
||||
|
||||
impl Fade {
|
||||
@@ -67,7 +67,7 @@ impl Fade {
|
||||
Self {
|
||||
fade_in,
|
||||
show_for,
|
||||
fade_out
|
||||
fade_out,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ impl AnimeGif {
|
||||
file_name: &Path,
|
||||
duration: AnimTime,
|
||||
brightness: f32,
|
||||
anime_type: AnimeType
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
let mut matrix = AnimeDiagonal::new(anime_type, None);
|
||||
|
||||
@@ -142,7 +142,7 @@ impl AnimeGif {
|
||||
|
||||
frames.push(AnimeFrame {
|
||||
data: matrix.into_data_buffer(anime_type)?,
|
||||
delay: Duration::from_millis(wait as u64)
|
||||
delay: Duration::from_millis(wait as u64),
|
||||
});
|
||||
}
|
||||
Ok(Self(frames, duration))
|
||||
@@ -154,7 +154,7 @@ impl AnimeGif {
|
||||
file_name: &Path,
|
||||
anime_type: AnimeType,
|
||||
duration: AnimTime,
|
||||
brightness: f32
|
||||
brightness: f32,
|
||||
) -> Result<Self> {
|
||||
let image = AnimeDiagonal::from_png(file_name, None, brightness, anime_type)?;
|
||||
|
||||
@@ -170,7 +170,7 @@ impl AnimeGif {
|
||||
|
||||
let single = AnimeFrame {
|
||||
data: image.into_data_buffer(anime_type)?,
|
||||
delay: Duration::from_millis(30)
|
||||
delay: Duration::from_millis(30),
|
||||
};
|
||||
let frames = vec![single; frame_count as usize];
|
||||
|
||||
@@ -187,7 +187,7 @@ impl AnimeGif {
|
||||
translation: Vec2,
|
||||
duration: AnimTime,
|
||||
brightness: f32,
|
||||
anime_type: AnimeType
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
let mut frames = Vec::new();
|
||||
let mut decoder = gif::DecodeOptions::new();
|
||||
@@ -211,7 +211,7 @@ impl AnimeGif {
|
||||
brightness,
|
||||
pixels,
|
||||
decoder.width() as u32,
|
||||
anime_type
|
||||
anime_type,
|
||||
)?;
|
||||
|
||||
while let Some(frame) = decoder.read_next_frame()? {
|
||||
@@ -226,7 +226,7 @@ impl AnimeGif {
|
||||
brightness,
|
||||
pixels,
|
||||
width as u32,
|
||||
anime_type
|
||||
anime_type,
|
||||
)?;
|
||||
}
|
||||
for (y, row) in frame.buffer.chunks(frame.width as usize * 4).enumerate() {
|
||||
@@ -239,7 +239,7 @@ impl AnimeGif {
|
||||
(x + frame.left as usize) + ((y + frame.top as usize) * width as usize);
|
||||
image.get_mut()[pos] = Pixel {
|
||||
color: ((px[0] as u32 + px[1] as u32 + px[2] as u32) / 3),
|
||||
alpha: 1.0
|
||||
alpha: 1.0,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,7 @@ impl AnimeGif {
|
||||
|
||||
frames.push(AnimeFrame {
|
||||
data: <AnimeDataBuffer>::try_from(&image)?,
|
||||
delay: Duration::from_millis(wait as u64)
|
||||
delay: Duration::from_millis(wait as u64),
|
||||
});
|
||||
}
|
||||
Ok(Self(frames, duration))
|
||||
@@ -265,7 +265,7 @@ impl AnimeGif {
|
||||
translation: Vec2,
|
||||
duration: AnimTime,
|
||||
brightness: f32,
|
||||
anime_type: AnimeType
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
let image =
|
||||
AnimeImage::from_png(file_name, scale, angle, translation, brightness, anime_type)?;
|
||||
@@ -282,7 +282,7 @@ impl AnimeGif {
|
||||
|
||||
let single = AnimeFrame {
|
||||
data: <AnimeDataBuffer>::try_from(&image)?,
|
||||
delay: Duration::from_millis(30)
|
||||
delay: Duration::from_millis(30),
|
||||
};
|
||||
let frames = vec![single; frame_count as usize];
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ const HEIGHT: usize = 55;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AnimeGrid {
|
||||
anime_type: AnimeType,
|
||||
data: [[u8; WIDTH]; HEIGHT]
|
||||
data: [[u8; WIDTH]; HEIGHT],
|
||||
}
|
||||
|
||||
impl AnimeGrid {
|
||||
@@ -26,7 +26,7 @@ impl AnimeGrid {
|
||||
pub fn new(anime_type: AnimeType) -> Self {
|
||||
Self {
|
||||
anime_type,
|
||||
data: [[0u8; WIDTH]; HEIGHT]
|
||||
data: [[0u8; WIDTH]; HEIGHT],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ mod tests {
|
||||
0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
];
|
||||
assert_eq!(matrix.data(), &data_cmp);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::AnimeType;
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct Pixel {
|
||||
pub color: u32,
|
||||
pub alpha: f32
|
||||
pub alpha: f32,
|
||||
}
|
||||
|
||||
impl Default for Pixel {
|
||||
@@ -21,7 +21,7 @@ impl Default for Pixel {
|
||||
fn default() -> Self {
|
||||
Pixel {
|
||||
color: 0,
|
||||
alpha: 0.0
|
||||
alpha: 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ pub struct AnimeImage {
|
||||
/// The type of the display. The GA401 and GA402 use the same controller and
|
||||
/// therefore same ID, so the identifier must be by laptop model in
|
||||
/// `AnimeType`.
|
||||
anime_type: AnimeType
|
||||
anime_type: AnimeType,
|
||||
}
|
||||
|
||||
impl AnimeImage {
|
||||
@@ -88,7 +88,7 @@ impl AnimeImage {
|
||||
bright: f32,
|
||||
pixels: Vec<Pixel>,
|
||||
width: u32,
|
||||
anime_type: AnimeType
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
if !(0.0..=1.0).contains(&bright) {
|
||||
return Err(AnimeError::InvalidBrightness(bright));
|
||||
@@ -102,7 +102,7 @@ impl AnimeImage {
|
||||
led_pos: Self::generate_image_positioning(anime_type),
|
||||
img_pixels: pixels,
|
||||
width,
|
||||
anime_type
|
||||
anime_type,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ impl AnimeImage {
|
||||
match anime_type {
|
||||
AnimeType::GA401 => 0.8,
|
||||
AnimeType::GU604 => 0.78,
|
||||
_ => 0.77
|
||||
_ => 0.77,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ impl AnimeImage {
|
||||
match anime_type {
|
||||
AnimeType::GA401 => 0.3,
|
||||
AnimeType::GU604 => 0.28,
|
||||
_ => 0.283
|
||||
_ => 0.283,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ impl AnimeImage {
|
||||
AnimeType::GA401 => (33.0 + 0.5) * Self::scale_x(anime_type),
|
||||
|
||||
AnimeType::GU604 => (38.0 + 0.5) * Self::scale_x(anime_type),
|
||||
_ => (35.0 + 0.5) * Self::scale_x(anime_type)
|
||||
_ => (35.0 + 0.5) * Self::scale_x(anime_type),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ impl AnimeImage {
|
||||
match anime_type {
|
||||
AnimeType::GA401 => 55,
|
||||
AnimeType::GU604 => 62,
|
||||
_ => 61
|
||||
_ => 61,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ impl AnimeImage {
|
||||
AnimeType::GA401 => (54.0 + 1.0) * Self::scale_y(anime_type),
|
||||
AnimeType::GU604 => 62.0 * Self::scale_y(anime_type),
|
||||
// GA402 may not have dead pixels and require only the physical LED count
|
||||
_ => 61.0 * Self::scale_y(anime_type)
|
||||
_ => 61.0 * Self::scale_y(anime_type),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,11 +267,11 @@ impl AnimeImage {
|
||||
AnimeType::GA401 => match y {
|
||||
0 | 2 | 4 => 33,
|
||||
1 | 3 => 35, // Some rows are padded
|
||||
_ => 36 - y / 2
|
||||
_ => 36 - y / 2,
|
||||
},
|
||||
AnimeType::GU604 => AnimeImage::width(anime_type, y),
|
||||
// GA402 does not have padding, equivalent to width
|
||||
_ => AnimeImage::width(anime_type, y)
|
||||
_ => AnimeImage::width(anime_type, y),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ impl AnimeImage {
|
||||
let x0 = led_from_px.mul_vec3(pos + Vec3::new(0.0, -0.5, 0.0));
|
||||
|
||||
const GROUP: [f32; 4] = [
|
||||
0.0, 0.5, 1.0, 1.5
|
||||
0.0, 0.5, 1.0, 1.5,
|
||||
];
|
||||
for u in &GROUP {
|
||||
for v in &GROUP {
|
||||
@@ -399,7 +399,7 @@ impl AnimeImage {
|
||||
|
||||
let led_from_cm = Mat3::from_scale(Vec2::new(
|
||||
1.0 / AnimeImage::scale_x(self.anime_type),
|
||||
1.0 / AnimeImage::scale_y(self.anime_type)
|
||||
1.0 / AnimeImage::scale_y(self.anime_type),
|
||||
));
|
||||
|
||||
let transform =
|
||||
@@ -422,7 +422,7 @@ impl AnimeImage {
|
||||
angle: f32,
|
||||
translation: Vec2,
|
||||
bright: f32,
|
||||
anime_type: AnimeType
|
||||
anime_type: AnimeType,
|
||||
) -> Result<Self> {
|
||||
let data = std::fs::read(path).map_err(|e| {
|
||||
error!("Could not open {path:?}: {e:?}");
|
||||
@@ -466,7 +466,7 @@ impl AnimeImage {
|
||||
width = ras.width();
|
||||
Self::pixels_from_16bit(ras, false)
|
||||
}
|
||||
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format)
|
||||
png_pong::PngRaster::Palette(..) => return Err(AnimeError::Format),
|
||||
};
|
||||
|
||||
let mut matrix = AnimeImage::new(
|
||||
@@ -476,7 +476,7 @@ impl AnimeImage {
|
||||
bright,
|
||||
pixels,
|
||||
width,
|
||||
anime_type
|
||||
anime_type,
|
||||
)?;
|
||||
|
||||
matrix.update();
|
||||
@@ -485,7 +485,7 @@ impl AnimeImage {
|
||||
|
||||
fn pixels_from_8bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel>
|
||||
where
|
||||
P: pix::el::Pixel<Chan = pix::chan::Ch8>
|
||||
P: pix::el::Pixel<Chan = pix::chan::Ch8>,
|
||||
{
|
||||
ras.pixels()
|
||||
.iter()
|
||||
@@ -497,14 +497,14 @@ impl AnimeImage {
|
||||
+ (<u8>::from(px.two()) / 3) as u32
|
||||
+ (<u8>::from(px.three()) / 3) as u32
|
||||
},
|
||||
alpha: <f32>::from(px.alpha())
|
||||
alpha: <f32>::from(px.alpha()),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn pixels_from_16bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel>
|
||||
where
|
||||
P: pix::el::Pixel<Chan = pix::chan::Ch16>
|
||||
P: pix::el::Pixel<Chan = pix::chan::Ch16>,
|
||||
{
|
||||
ras.pixels()
|
||||
.iter()
|
||||
@@ -516,7 +516,7 @@ impl AnimeImage {
|
||||
+ ((<u16>::from(px.two()) / 3) >> 8) as u32
|
||||
+ ((<u16>::from(px.three()) / 3) >> 8) as u32
|
||||
},
|
||||
alpha: <f32>::from(px.alpha())
|
||||
alpha: <f32>::from(px.alpha()),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -653,7 +653,7 @@ mod tests {
|
||||
Vec2::default(),
|
||||
AnimTime::Infinite,
|
||||
1.0,
|
||||
AnimeType::GA402
|
||||
AnimeType::GA402,
|
||||
)
|
||||
.unwrap();
|
||||
matrix.frames()[0].frame();
|
||||
|
||||
@@ -16,13 +16,13 @@ pub enum ActionLoader {
|
||||
AsusAnimation {
|
||||
file: PathBuf,
|
||||
time: AnimTime,
|
||||
brightness: f32
|
||||
brightness: f32,
|
||||
},
|
||||
/// Image designed to be pixel perfect using the slanted template
|
||||
AsusImage {
|
||||
file: PathBuf,
|
||||
time: AnimTime,
|
||||
brightness: f32
|
||||
brightness: f32,
|
||||
},
|
||||
/// Animated gif. If the file is a png a static gif is created using the
|
||||
/// `time` properties
|
||||
@@ -32,7 +32,7 @@ pub enum ActionLoader {
|
||||
angle: f32,
|
||||
translation: Vec2,
|
||||
time: AnimTime,
|
||||
brightness: f32
|
||||
brightness: f32,
|
||||
},
|
||||
Image {
|
||||
file: PathBuf,
|
||||
@@ -40,10 +40,10 @@ pub enum ActionLoader {
|
||||
angle: f32,
|
||||
translation: Vec2,
|
||||
time: AnimTime,
|
||||
brightness: f32
|
||||
brightness: f32,
|
||||
},
|
||||
/// A pause to be used between sequences
|
||||
Pause(Duration)
|
||||
Pause(Duration),
|
||||
}
|
||||
|
||||
/// All the possible `AniMe` actions that can be used. The enum is intended to
|
||||
@@ -64,7 +64,7 @@ pub enum ActionData {
|
||||
/// Placeholder
|
||||
TimeDate,
|
||||
/// Placeholder
|
||||
Matrix
|
||||
Matrix,
|
||||
}
|
||||
|
||||
impl ActionData {
|
||||
@@ -73,14 +73,14 @@ impl ActionData {
|
||||
ActionLoader::AsusAnimation {
|
||||
file,
|
||||
time,
|
||||
brightness
|
||||
brightness,
|
||||
} => ActionData::Animation(AnimeGif::from_diagonal_gif(
|
||||
file, *time, *brightness, anime_type
|
||||
file, *time, *brightness, anime_type,
|
||||
)?),
|
||||
ActionLoader::AsusImage {
|
||||
file,
|
||||
time,
|
||||
brightness
|
||||
brightness,
|
||||
} => match time {
|
||||
AnimTime::Infinite => {
|
||||
let image = AnimeDiagonal::from_png(file, None, *brightness, anime_type)?;
|
||||
@@ -88,8 +88,8 @@ impl ActionData {
|
||||
ActionData::Image(Box::new(data))
|
||||
}
|
||||
_ => ActionData::Animation(AnimeGif::from_diagonal_png(
|
||||
file, anime_type, *time, *brightness
|
||||
)?)
|
||||
file, anime_type, *time, *brightness,
|
||||
)?),
|
||||
},
|
||||
ActionLoader::ImageAnimation {
|
||||
file,
|
||||
@@ -97,17 +97,17 @@ impl ActionData {
|
||||
angle,
|
||||
translation,
|
||||
time,
|
||||
brightness
|
||||
brightness,
|
||||
} => {
|
||||
if let Some(ext) = file.extension() {
|
||||
if ext.to_string_lossy().to_lowercase() == "png" {
|
||||
return Ok(ActionData::Animation(AnimeGif::from_png(
|
||||
file, *scale, *angle, *translation, *time, *brightness, anime_type
|
||||
file, *scale, *angle, *translation, *time, *brightness, anime_type,
|
||||
)?));
|
||||
}
|
||||
}
|
||||
ActionData::Animation(AnimeGif::from_gif(
|
||||
file, *scale, *angle, *translation, *time, *brightness, anime_type
|
||||
file, *scale, *angle, *translation, *time, *brightness, anime_type,
|
||||
)?)
|
||||
}
|
||||
ActionLoader::Image {
|
||||
@@ -116,23 +116,23 @@ impl ActionData {
|
||||
angle,
|
||||
translation,
|
||||
brightness,
|
||||
time
|
||||
time,
|
||||
} => {
|
||||
match time {
|
||||
AnimTime::Infinite => {
|
||||
// If no time then create a plain static image
|
||||
let image = AnimeImage::from_png(
|
||||
file, *scale, *angle, *translation, *brightness, anime_type
|
||||
file, *scale, *angle, *translation, *brightness, anime_type,
|
||||
)?;
|
||||
let data = <AnimeDataBuffer>::try_from(&image)?;
|
||||
ActionData::Image(Box::new(data))
|
||||
}
|
||||
_ => ActionData::Animation(AnimeGif::from_png(
|
||||
file, *scale, *angle, *translation, *time, *brightness, anime_type
|
||||
)?)
|
||||
file, *scale, *angle, *translation, *time, *brightness, anime_type,
|
||||
)?),
|
||||
}
|
||||
}
|
||||
ActionLoader::Pause(duration) => ActionData::Pause(*duration)
|
||||
ActionLoader::Pause(duration) => ActionData::Pause(*duration),
|
||||
};
|
||||
Ok(a)
|
||||
}
|
||||
@@ -171,7 +171,7 @@ impl Sequences {
|
||||
pub fn iter(&self) -> ActionIterator<'_> {
|
||||
ActionIterator {
|
||||
actions: self,
|
||||
next_idx: 0
|
||||
next_idx: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ impl Sequences {
|
||||
/// Iteractor helper for iterating over all the actions in `Sequences`
|
||||
pub struct ActionIterator<'a> {
|
||||
actions: &'a Sequences,
|
||||
next_idx: usize
|
||||
next_idx: usize,
|
||||
}
|
||||
|
||||
impl<'a> Iterator for ActionIterator<'a> {
|
||||
|
||||
@@ -35,7 +35,7 @@ pub enum Brightness {
|
||||
Low = 1,
|
||||
#[default]
|
||||
Med = 2,
|
||||
High = 3
|
||||
High = 3,
|
||||
}
|
||||
|
||||
impl FromStr for Brightness {
|
||||
@@ -47,7 +47,7 @@ impl FromStr for Brightness {
|
||||
"Low" | "low" => Brightness::Low,
|
||||
"Med" | "med" => Brightness::Med,
|
||||
"High" | "high" => Brightness::High,
|
||||
_ => Brightness::Med
|
||||
_ => Brightness::Med,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ impl From<u8> for Brightness {
|
||||
0 => Brightness::Off,
|
||||
1 => Brightness::Low,
|
||||
3 => Brightness::High,
|
||||
_ => Brightness::Med
|
||||
_ => Brightness::Med,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ impl From<Brightness> for i32 {
|
||||
pub enum AnimBooting {
|
||||
#[default]
|
||||
GlitchConstruction = 0,
|
||||
StaticEmergence = 1
|
||||
StaticEmergence = 1,
|
||||
}
|
||||
|
||||
impl FromStr for AnimBooting {
|
||||
@@ -94,7 +94,7 @@ impl FromStr for AnimBooting {
|
||||
match s {
|
||||
"GlitchConstruction" => Ok(Self::GlitchConstruction),
|
||||
"StaticEmergence" => Ok(Self::StaticEmergence),
|
||||
_ => Err(AnimeError::ParseError(s.to_owned()))
|
||||
_ => Err(AnimeError::ParseError(s.to_owned())),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ impl From<i32> for AnimBooting {
|
||||
match value {
|
||||
0 => Self::GlitchConstruction,
|
||||
1 => Self::StaticEmergence,
|
||||
_ => Self::default()
|
||||
_ => Self::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ impl From<AnimBooting> for i32 {
|
||||
pub enum AnimAwake {
|
||||
#[default]
|
||||
BinaryBannerScroll = 0,
|
||||
RogLogoGlitch = 1
|
||||
RogLogoGlitch = 1,
|
||||
}
|
||||
|
||||
impl FromStr for AnimAwake {
|
||||
@@ -134,7 +134,7 @@ impl FromStr for AnimAwake {
|
||||
match s {
|
||||
"BinaryBannerScroll" => Ok(Self::BinaryBannerScroll),
|
||||
"RogLogoGlitch" => Ok(Self::RogLogoGlitch),
|
||||
_ => Err(AnimeError::ParseError(s.to_owned()))
|
||||
_ => Err(AnimeError::ParseError(s.to_owned())),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ impl From<i32> for AnimAwake {
|
||||
match value {
|
||||
0 => Self::BinaryBannerScroll,
|
||||
1 => Self::RogLogoGlitch,
|
||||
_ => Self::default()
|
||||
_ => Self::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ impl From<AnimAwake> for i32 {
|
||||
pub enum AnimSleeping {
|
||||
#[default]
|
||||
BannerSwipe = 0,
|
||||
Starfield = 1
|
||||
Starfield = 1,
|
||||
}
|
||||
|
||||
impl FromStr for AnimSleeping {
|
||||
@@ -174,7 +174,7 @@ impl FromStr for AnimSleeping {
|
||||
match s {
|
||||
"BannerSwipe" => Ok(Self::BannerSwipe),
|
||||
"Starfield" => Ok(Self::Starfield),
|
||||
_ => Err(AnimeError::ParseError(s.to_owned()))
|
||||
_ => Err(AnimeError::ParseError(s.to_owned())),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ impl From<i32> for AnimSleeping {
|
||||
match value {
|
||||
0 => Self::BannerSwipe,
|
||||
1 => Self::Starfield,
|
||||
_ => Self::default()
|
||||
_ => Self::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ impl From<AnimSleeping> for i32 {
|
||||
pub enum AnimShutdown {
|
||||
#[default]
|
||||
GlitchOut = 0,
|
||||
SeeYa = 1
|
||||
SeeYa = 1,
|
||||
}
|
||||
|
||||
impl FromStr for AnimShutdown {
|
||||
@@ -214,7 +214,7 @@ impl FromStr for AnimShutdown {
|
||||
match s {
|
||||
"GlitchOut" => Ok(Self::GlitchOut),
|
||||
"SeeYa" => Ok(Self::SeeYa),
|
||||
_ => Err(AnimeError::ParseError(s.to_owned()))
|
||||
_ => Err(AnimeError::ParseError(s.to_owned())),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -224,7 +224,7 @@ impl From<i32> for AnimShutdown {
|
||||
match value {
|
||||
0 => Self::GlitchOut,
|
||||
1 => Self::SeeYa,
|
||||
_ => Self::default()
|
||||
_ => Self::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,7 +326,7 @@ pub const fn pkt_set_builtin_animations(
|
||||
boot: AnimBooting,
|
||||
awake: AnimAwake,
|
||||
sleep: AnimSleeping,
|
||||
shutdown: AnimShutdown
|
||||
shutdown: AnimShutdown,
|
||||
) -> [u8; PACKET_SIZE] {
|
||||
let mut pkt = [0; PACKET_SIZE];
|
||||
pkt[0] = DEV_PAGE;
|
||||
|
||||
@@ -52,7 +52,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt1_check = [
|
||||
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -100,7 +100,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
|
||||
let mut matrix = AnimeImage::new(
|
||||
@@ -110,7 +110,7 @@ mod tests {
|
||||
0.0,
|
||||
vec![Pixel::default(); 1000],
|
||||
100,
|
||||
AnimeType::GA401
|
||||
AnimeType::GA401,
|
||||
)
|
||||
.unwrap();
|
||||
matrix.edge_outline();
|
||||
@@ -175,7 +175,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt1_check = [
|
||||
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -223,7 +223,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
|
||||
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
|
||||
@@ -52,7 +52,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt1_check = [
|
||||
0x5e, 0xc0, 0x2, 0x74, 0x2, 0x73, 0x2, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -100,7 +100,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt2_check = [
|
||||
0x5e, 0xc0, 0x2, 0xe7, 0x4, 0x73, 0x2, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00,
|
||||
@@ -148,7 +148,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
|
||||
let mut matrix = AnimeImage::new(
|
||||
@@ -158,7 +158,7 @@ mod tests {
|
||||
0.0,
|
||||
vec![Pixel::default(); 1000],
|
||||
100,
|
||||
AnimeType::GA402
|
||||
AnimeType::GA402,
|
||||
)
|
||||
.unwrap();
|
||||
matrix.edge_outline();
|
||||
@@ -218,7 +218,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt1_check = [
|
||||
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00,
|
||||
@@ -266,7 +266,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt2_check = [
|
||||
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
|
||||
@@ -314,7 +314,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
|
||||
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
@@ -378,7 +378,7 @@ mod tests {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt1_check = [
|
||||
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -426,7 +426,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt2_check = [
|
||||
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
|
||||
@@ -474,7 +474,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
|
||||
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
|
||||
@@ -52,7 +52,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt1_check = [
|
||||
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -100,7 +100,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt2_check = [
|
||||
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -148,7 +148,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
|
||||
let mut matrix = AnimeImage::new(
|
||||
@@ -158,7 +158,7 @@ mod tests {
|
||||
0.0,
|
||||
vec![Pixel::default(); 1000],
|
||||
100,
|
||||
AnimeType::GU604
|
||||
AnimeType::GU604,
|
||||
)
|
||||
.unwrap();
|
||||
matrix.edge_outline();
|
||||
@@ -218,7 +218,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt1_check = [
|
||||
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -266,7 +266,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
let pkt2_check = [
|
||||
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -314,7 +314,7 @@ mod tests {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
|
||||
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
(
|
||||
device_name: "FA617NS",
|
||||
product_id: "",
|
||||
layout_name: "fa617ns",
|
||||
layout_name: "fx505d",
|
||||
basic_modes: [Static, Breathe, Pulse],
|
||||
basic_zones: [],
|
||||
advanced_type: None,
|
||||
@@ -161,6 +161,15 @@
|
||||
advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]),
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
device_name: "G513RW",
|
||||
product_id: "",
|
||||
layout_name: "g513i-per-key",
|
||||
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Star, Rain, Highlight, Laser, Ripple, Pulse, Comet, Flash],
|
||||
basic_zones: [],
|
||||
advanced_type: PerKey,
|
||||
power_zones: [Keyboard, Lightbar],
|
||||
),
|
||||
(
|
||||
device_name: "G531G",
|
||||
product_id: "",
|
||||
|
||||
@@ -54,7 +54,7 @@ pub struct LedSupportData {
|
||||
#[serde(default)]
|
||||
pub advanced_type: AdvancedAuraType,
|
||||
/// If empty will default to `Keyboard` power zone
|
||||
pub power_zones: Vec<PowerZones>
|
||||
pub power_zones: Vec<PowerZones>,
|
||||
}
|
||||
|
||||
impl LedSupportData {
|
||||
@@ -116,7 +116,7 @@ impl LedSupportFile {
|
||||
basic_modes: vec![AuraModeNum::Static],
|
||||
basic_zones: vec![],
|
||||
advanced_type: AdvancedAuraType::None,
|
||||
power_zones: vec![PowerZones::Keyboard]
|
||||
power_zones: vec![PowerZones::Keyboard],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ mod tests {
|
||||
power_zones: vec![
|
||||
PowerZones::Keyboard,
|
||||
PowerZones::RearGlow,
|
||||
]
|
||||
],
|
||||
};
|
||||
|
||||
assert!(ron::to_string(&led).is_ok());
|
||||
|
||||
@@ -19,7 +19,7 @@ pub enum LedBrightness {
|
||||
Low = 1,
|
||||
#[default]
|
||||
Med = 2,
|
||||
High = 3
|
||||
High = 3,
|
||||
}
|
||||
|
||||
impl LedBrightness {
|
||||
@@ -28,7 +28,7 @@ impl LedBrightness {
|
||||
Self::Off => Self::Low,
|
||||
Self::Low => Self::Med,
|
||||
Self::Med => Self::High,
|
||||
Self::High => Self::Off
|
||||
Self::High => Self::Off,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ impl LedBrightness {
|
||||
Self::Off => Self::High,
|
||||
Self::Low => Self::Off,
|
||||
Self::Med => Self::Low,
|
||||
Self::High => Self::Med
|
||||
Self::High => Self::Med,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ impl From<u8> for LedBrightness {
|
||||
0 => LedBrightness::Off,
|
||||
1 => LedBrightness::Low,
|
||||
3 => LedBrightness::High,
|
||||
_ => LedBrightness::Med
|
||||
_ => LedBrightness::Med,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ impl From<i32> for LedBrightness {
|
||||
1 => LedBrightness::Low,
|
||||
2 => LedBrightness::Med,
|
||||
3 => LedBrightness::High,
|
||||
_ => LedBrightness::Med
|
||||
_ => LedBrightness::Med,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ impl From<i32> for LedBrightness {
|
||||
pub struct Colour {
|
||||
pub r: u8,
|
||||
pub g: u8,
|
||||
pub b: u8
|
||||
pub b: u8,
|
||||
}
|
||||
|
||||
impl Default for Colour {
|
||||
@@ -110,7 +110,7 @@ impl From<&[f32; 3]> for Colour {
|
||||
Self {
|
||||
r: (255.0 * c[0]) as u8,
|
||||
g: (255.0 * c[1]) as u8,
|
||||
b: (255.0 * c[2]) as u8
|
||||
b: (255.0 * c[2]) as u8,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ impl From<Colour> for [f32; 3] {
|
||||
[
|
||||
c.r as f32 / 255.0,
|
||||
c.g as f32 / 255.0,
|
||||
c.b as f32 / 255.0
|
||||
c.b as f32 / 255.0,
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,7 @@ impl From<&[u8; 3]> for Colour {
|
||||
Self {
|
||||
r: c[0],
|
||||
g: c[1],
|
||||
b: c[2]
|
||||
b: c[2],
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ impl From<&[u8; 3]> for Colour {
|
||||
impl From<Colour> for [u8; 3] {
|
||||
fn from(c: Colour) -> Self {
|
||||
[
|
||||
c.r, c.g, c.b
|
||||
c.r, c.g, c.b,
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ pub enum Speed {
|
||||
Low = 0xe1,
|
||||
#[default]
|
||||
Med = 0xeb,
|
||||
High = 0xf5
|
||||
High = 0xf5,
|
||||
}
|
||||
|
||||
impl FromStr for Speed {
|
||||
@@ -165,7 +165,7 @@ impl FromStr for Speed {
|
||||
"low" => Ok(Speed::Low),
|
||||
"med" => Ok(Speed::Med),
|
||||
"high" => Ok(Speed::High),
|
||||
_ => Err(Error::ParseSpeed)
|
||||
_ => Err(Error::ParseSpeed),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ impl From<i32> for Speed {
|
||||
match value {
|
||||
0 => Self::Low,
|
||||
2 => Self::High,
|
||||
_ => Self::Med
|
||||
_ => Self::Med,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ impl From<Speed> for i32 {
|
||||
match value {
|
||||
Speed::Low => 0,
|
||||
Speed::Med => 1,
|
||||
Speed::High => 2
|
||||
Speed::High => 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ impl From<Speed> for u8 {
|
||||
match s {
|
||||
Speed::Low => 0,
|
||||
Speed::Med => 1,
|
||||
Speed::High => 2
|
||||
Speed::High => 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ pub enum Direction {
|
||||
Right = 0,
|
||||
Left = 1,
|
||||
Up = 2,
|
||||
Down = 3
|
||||
Down = 3,
|
||||
}
|
||||
|
||||
impl FromStr for Direction {
|
||||
@@ -226,7 +226,7 @@ impl FromStr for Direction {
|
||||
"up" => Ok(Direction::Up),
|
||||
"down" => Ok(Direction::Down),
|
||||
"left" => Ok(Direction::Left),
|
||||
_ => Err(Error::ParseDirection)
|
||||
_ => Err(Error::ParseDirection),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,7 +237,7 @@ impl From<i32> for Direction {
|
||||
1 => Self::Left,
|
||||
2 => Self::Up,
|
||||
3 => Self::Down,
|
||||
_ => Self::Right
|
||||
_ => Self::Right,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,7 +270,7 @@ pub enum AuraModeNum {
|
||||
Ripple = 8,
|
||||
Pulse = 10,
|
||||
Comet = 11,
|
||||
Flash = 12
|
||||
Flash = 12,
|
||||
}
|
||||
|
||||
impl Display for AuraModeNum {
|
||||
@@ -299,7 +299,7 @@ impl From<&AuraModeNum> for &str {
|
||||
AuraModeNum::Ripple => "Ripple",
|
||||
AuraModeNum::Pulse => "Pulse",
|
||||
AuraModeNum::Comet => "Comet",
|
||||
AuraModeNum::Flash => "Flash"
|
||||
AuraModeNum::Flash => "Flash",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,7 +317,7 @@ impl From<&str> for AuraModeNum {
|
||||
"Pulse" => AuraModeNum::Pulse,
|
||||
"Comet" => AuraModeNum::Comet,
|
||||
"Flash" => AuraModeNum::Flash,
|
||||
_ => AuraModeNum::Static
|
||||
_ => AuraModeNum::Static,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,7 +336,7 @@ impl From<u8> for AuraModeNum {
|
||||
10 => AuraModeNum::Pulse,
|
||||
11 => AuraModeNum::Comet,
|
||||
12 => AuraModeNum::Flash,
|
||||
_ => AuraModeNum::Static
|
||||
_ => AuraModeNum::Static,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -383,7 +383,7 @@ pub enum AuraZone {
|
||||
/// The left part of a lightbar (typically on the front of laptop)
|
||||
BarLeft = 6,
|
||||
/// The right part of a lightbar
|
||||
BarRight = 7
|
||||
BarRight = 7,
|
||||
}
|
||||
|
||||
impl FromStr for AuraZone {
|
||||
@@ -400,7 +400,7 @@ impl FromStr for AuraZone {
|
||||
"5" | "logo" => Ok(AuraZone::Logo),
|
||||
"6" | "lightbar-left" => Ok(AuraZone::BarLeft),
|
||||
"7" | "lightbar-right" => Ok(AuraZone::BarRight),
|
||||
_ => Err(Error::ParseSpeed)
|
||||
_ => Err(Error::ParseSpeed),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,7 +415,7 @@ impl From<i32> for AuraZone {
|
||||
5 => Self::Logo,
|
||||
6 => Self::BarLeft,
|
||||
7 => Self::BarRight,
|
||||
_ => Self::default()
|
||||
_ => Self::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -445,7 +445,7 @@ pub struct AuraEffect {
|
||||
/// One of three speeds for modes that support speed (most that animate)
|
||||
pub speed: Speed,
|
||||
/// Up, down, left, right. Only Rainbow mode seems to use this
|
||||
pub direction: Direction
|
||||
pub direction: Direction,
|
||||
}
|
||||
|
||||
impl AuraEffect {
|
||||
@@ -481,7 +481,7 @@ impl Default for AuraEffect {
|
||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right
|
||||
direction: Direction::Right,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -541,7 +541,7 @@ impl From<&AuraEffect> for Vec<u8> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, Speed, AURA_LAPTOP_LED_MSG_LEN
|
||||
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, Speed, AURA_LAPTOP_LED_MSG_LEN,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -552,18 +552,18 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0xff,
|
||||
g: 0x11,
|
||||
b: 0xdd
|
||||
b: 0xdd,
|
||||
},
|
||||
colour2: Colour::default(),
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right
|
||||
direction: Direction::Right,
|
||||
};
|
||||
let ar = <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st);
|
||||
|
||||
println!("{:02x?}", ar);
|
||||
let check = [
|
||||
0x5d, 0xb3, 0x0, 0x0, 0xff, 0x11, 0xdd, 0xeb, 0x0, 0x0, 0xa6, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0
|
||||
0x0,
|
||||
];
|
||||
assert_eq!(ar, check);
|
||||
}
|
||||
@@ -576,15 +576,15 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0xff,
|
||||
g: 0,
|
||||
b: 0
|
||||
b: 0,
|
||||
},
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Low,
|
||||
direction: Direction::Left
|
||||
direction: Direction::Left,
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x01, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0
|
||||
0x0, 0x0,
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -595,11 +595,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0xff,
|
||||
g: 0xff,
|
||||
b: 0
|
||||
b: 0,
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x02, 0x00, 0xff, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0
|
||||
0x0, 0x0,
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -610,11 +610,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0,
|
||||
g: 0xff,
|
||||
b: 0xff
|
||||
b: 0xff,
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0
|
||||
0x0, 0x0,
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -625,11 +625,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0xff
|
||||
b: 0xff,
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x04, 0x00, 0xff, 0x00, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0
|
||||
0x0, 0x0,
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -640,11 +640,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0x2c,
|
||||
g: 0xff,
|
||||
b: 0x00
|
||||
b: 0x00,
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x05, 0x00, 0x2c, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0
|
||||
0x0, 0x0,
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -655,11 +655,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0x00
|
||||
b: 0x00,
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x06, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0
|
||||
0x0, 0x0,
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -670,11 +670,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0xcd
|
||||
b: 0xcd,
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x07, 0x00, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0
|
||||
0x0, 0x0,
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -684,7 +684,7 @@ mod tests {
|
||||
st.mode = AuraModeNum::RainbowWave;
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x07, 0x03, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0
|
||||
0x0, 0x0,
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
|
||||
@@ -11,7 +11,7 @@ pub struct InputBased {
|
||||
/// - temperature
|
||||
/// - fan speed
|
||||
/// - time
|
||||
input: Box<dyn InputForEffect>
|
||||
input: Box<dyn InputForEffect>,
|
||||
}
|
||||
|
||||
impl EffectState for InputBased {
|
||||
|
||||
@@ -19,7 +19,7 @@ pub struct Breathe {
|
||||
#[serde(skip)]
|
||||
count_flipped: bool,
|
||||
#[serde(skip)]
|
||||
use_colour1: bool
|
||||
use_colour1: bool,
|
||||
}
|
||||
|
||||
impl Breathe {
|
||||
@@ -31,7 +31,7 @@ impl Breathe {
|
||||
speed,
|
||||
colour: colour1,
|
||||
count_flipped: false,
|
||||
use_colour1: true
|
||||
use_colour1: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ pub struct DoomFlicker {
|
||||
#[serde(skip)]
|
||||
count: u8,
|
||||
#[serde(skip)]
|
||||
colour: Colour
|
||||
colour: Colour,
|
||||
}
|
||||
|
||||
impl DoomFlicker {
|
||||
@@ -24,7 +24,7 @@ impl DoomFlicker {
|
||||
count: 4,
|
||||
max_percentage,
|
||||
min_percentage,
|
||||
start_colour: colour
|
||||
start_colour: colour,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,13 +53,13 @@ impl EffectState for DoomFlicker {
|
||||
let max_light = Colour {
|
||||
r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
g: (start_colour.g as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8
|
||||
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
};
|
||||
// min light is a percentage of the set colour
|
||||
let min_light = Colour {
|
||||
r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
g: (start_colour.g as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8
|
||||
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
};
|
||||
|
||||
// Convert the 255 to percentage
|
||||
@@ -96,7 +96,7 @@ pub struct DoomLightFlash {
|
||||
#[serde(skip)]
|
||||
count: u8,
|
||||
#[serde(skip)]
|
||||
colour: Colour
|
||||
colour: Colour,
|
||||
}
|
||||
|
||||
impl DoomLightFlash {
|
||||
@@ -109,7 +109,7 @@ impl DoomLightFlash {
|
||||
min_percentage,
|
||||
start_colour: colour,
|
||||
max_time: 32,
|
||||
min_time: 7
|
||||
min_time: 7,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,13 +135,13 @@ impl EffectState for DoomLightFlash {
|
||||
let max_light = Colour {
|
||||
r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
g: (start_colour.g as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8
|
||||
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
};
|
||||
// min light is a percentage of the set colour
|
||||
let min_light = Colour {
|
||||
r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
g: (start_colour.g as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8
|
||||
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
};
|
||||
|
||||
if *colour == max_light {
|
||||
|
||||
@@ -32,7 +32,7 @@ pub const RNDTABLE: [i32; 256] = [
|
||||
206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95, 28, 139, 123, 98, 125, 196, 15, 70, 194, 253,
|
||||
54, 14, 109, 226, 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36, 17, 46, 52,
|
||||
231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106, 197, 242, 98, 43, 39, 175, 254, 145, 190,
|
||||
84, 118, 222, 187, 136, 120, 163, 236, 249
|
||||
84, 118, 222, 187, 136, 120, 163, 236, 249,
|
||||
];
|
||||
|
||||
pub fn p_random() -> i32 {
|
||||
@@ -67,7 +67,7 @@ pub(crate) trait EffectState {
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct AdvancedEffects {
|
||||
effects: Vec<Effect>,
|
||||
zoned: bool
|
||||
zoned: bool,
|
||||
}
|
||||
|
||||
impl AdvancedEffects {
|
||||
@@ -75,7 +75,7 @@ impl AdvancedEffects {
|
||||
pub fn new(zoned: bool) -> Self {
|
||||
Self {
|
||||
effects: Default::default(),
|
||||
zoned
|
||||
zoned,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ pub enum Effect {
|
||||
Static(Static),
|
||||
Breathe(Breathe),
|
||||
DoomFlicker(DoomFlicker),
|
||||
DoomLightFlash(DoomLightFlash)
|
||||
DoomLightFlash(DoomLightFlash),
|
||||
}
|
||||
|
||||
impl Default for Effect {
|
||||
@@ -211,7 +211,7 @@ mod tests {
|
||||
.push(Effect::Static(Static::new(LedCode::F, Colour {
|
||||
r: 255,
|
||||
g: 127,
|
||||
b: 0
|
||||
b: 0,
|
||||
})));
|
||||
|
||||
seq.next_state(&layout);
|
||||
@@ -232,14 +232,14 @@ mod tests {
|
||||
Colour {
|
||||
r: 255,
|
||||
g: 127,
|
||||
b: 0
|
||||
b: 0,
|
||||
},
|
||||
Colour {
|
||||
r: 127,
|
||||
g: 0,
|
||||
b: 255
|
||||
b: 255,
|
||||
},
|
||||
Speed::Med
|
||||
Speed::Med,
|
||||
)));
|
||||
|
||||
let s =
|
||||
@@ -274,10 +274,10 @@ mod tests {
|
||||
Colour {
|
||||
r: 255,
|
||||
g: 127,
|
||||
b: 80
|
||||
b: 80,
|
||||
},
|
||||
100,
|
||||
10
|
||||
10,
|
||||
)));
|
||||
|
||||
seq.next_state(&layout);
|
||||
|
||||
@@ -8,14 +8,14 @@ use crate::{effect_state_impl, Colour};
|
||||
pub struct Static {
|
||||
led: LedCode,
|
||||
/// The starting colour
|
||||
colour: Colour
|
||||
colour: Colour,
|
||||
}
|
||||
|
||||
impl Static {
|
||||
pub fn new(address: LedCode, colour: Colour) -> Self {
|
||||
Self {
|
||||
led: address,
|
||||
colour
|
||||
colour,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ pub enum Error {
|
||||
ParseBrightness,
|
||||
IoPath(String, std::io::Error),
|
||||
Ron(ron::Error),
|
||||
RonParse(ron::error::SpannedError)
|
||||
RonParse(ron::error::SpannedError),
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
@@ -21,7 +21,7 @@ impl fmt::Display for Error {
|
||||
Error::ParseBrightness => write!(f, "Could not parse brightness"),
|
||||
Error::IoPath(path, io) => write!(f, "IO Error: {path}, {io}"),
|
||||
Error::Ron(e) => write!(f, "RON Parse Error: {e}"),
|
||||
Error::RonParse(e) => write!(f, "RON Parse Error: {e}")
|
||||
Error::RonParse(e) => write!(f, "RON Parse Error: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ pub enum LedCode {
|
||||
/// To be ignored by effects
|
||||
Spacing,
|
||||
/// To be ignored by effects
|
||||
Blocking
|
||||
Blocking,
|
||||
}
|
||||
|
||||
impl LedCode {
|
||||
@@ -210,7 +210,7 @@ pub struct LedUsbPackets {
|
||||
/// Wether or not this packet collection is zoned. The determines which
|
||||
/// starting bytes are used and what the indexing is for lightbar RGB
|
||||
/// colours
|
||||
zoned: bool
|
||||
zoned: bool,
|
||||
}
|
||||
|
||||
impl Default for LedUsbPackets {
|
||||
@@ -244,7 +244,7 @@ impl LedUsbPackets {
|
||||
}
|
||||
Self {
|
||||
usb_packets: set,
|
||||
zoned: false
|
||||
zoned: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ impl LedUsbPackets {
|
||||
}
|
||||
Self {
|
||||
usb_packets: vec![pkt],
|
||||
zoned: true
|
||||
zoned: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ impl From<&LedCode> for &str {
|
||||
LedCode::ZonedKbLeft => "Left Zone (zone 1)",
|
||||
LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)",
|
||||
LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)",
|
||||
LedCode::ZonedKbRight => "Right Zone (zone 4)"
|
||||
LedCode::ZonedKbRight => "Right Zone (zone 4)",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ pub enum KeyShape {
|
||||
pad_left: f32,
|
||||
pad_right: f32,
|
||||
pad_top: f32,
|
||||
pad_bottom: f32
|
||||
pad_bottom: f32,
|
||||
},
|
||||
Blank {
|
||||
width: f32,
|
||||
height: f32
|
||||
}
|
||||
height: f32,
|
||||
},
|
||||
}
|
||||
|
||||
impl KeyShape {
|
||||
@@ -41,7 +41,7 @@ impl KeyShape {
|
||||
pad_left: f32,
|
||||
pad_right: f32,
|
||||
pad_top: f32,
|
||||
pad_bottom: f32
|
||||
pad_bottom: f32,
|
||||
) -> Self {
|
||||
Self::Led {
|
||||
width,
|
||||
@@ -49,7 +49,7 @@ impl KeyShape {
|
||||
pad_left,
|
||||
pad_right,
|
||||
pad_top,
|
||||
pad_bottom
|
||||
pad_bottom,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ impl KeyShape {
|
||||
pad_left,
|
||||
pad_right,
|
||||
pad_top,
|
||||
pad_bottom
|
||||
pad_bottom,
|
||||
} => {
|
||||
*width *= scale;
|
||||
*height *= scale;
|
||||
@@ -97,7 +97,7 @@ pub struct KeyRow {
|
||||
row: Vec<(LedCode, String)>,
|
||||
/// The final data structure merged key_shapes and rows
|
||||
#[serde(skip)]
|
||||
built_row: Vec<(LedCode, KeyShape)>
|
||||
built_row: Vec<(LedCode, KeyShape)>,
|
||||
}
|
||||
|
||||
impl KeyRow {
|
||||
@@ -106,7 +106,7 @@ impl KeyRow {
|
||||
pad_left,
|
||||
pad_top,
|
||||
row,
|
||||
built_row: Default::default()
|
||||
built_row: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ impl KeyRow {
|
||||
pad_bottom,
|
||||
..
|
||||
} => height + pad_top + pad_bottom,
|
||||
KeyShape::Blank { height, .. } => *height
|
||||
KeyShape::Blank { height, .. } => *height,
|
||||
};
|
||||
|
||||
if h < height {
|
||||
@@ -156,7 +156,7 @@ impl KeyRow {
|
||||
pad_right,
|
||||
..
|
||||
} => w += width + pad_left + pad_right,
|
||||
KeyShape::Blank { width, .. } => w += width
|
||||
KeyShape::Blank { width, .. } => w += width,
|
||||
}
|
||||
}
|
||||
w
|
||||
@@ -185,7 +185,7 @@ pub struct KeyLayout {
|
||||
/// Should be copied from the `LaptopLedData` as laptops may have the same
|
||||
/// layout, but different EC features.
|
||||
#[serde(skip)]
|
||||
advanced_type: AdvancedAuraType
|
||||
advanced_type: AdvancedAuraType,
|
||||
}
|
||||
|
||||
impl KeyLayout {
|
||||
@@ -195,7 +195,7 @@ impl KeyLayout {
|
||||
if buf.is_empty() {
|
||||
Err(Error::IoPath(
|
||||
path.to_string_lossy().to_string(),
|
||||
std::io::ErrorKind::InvalidData.into()
|
||||
std::io::ErrorKind::InvalidData.into(),
|
||||
))
|
||||
} else {
|
||||
let mut data = ron::from_str::<Self>(&buf)?;
|
||||
@@ -332,7 +332,7 @@ impl KeyLayout {
|
||||
advanced_type: AdvancedAuraType::None,
|
||||
key_shapes: HashMap::from([(
|
||||
"regular".to_owned(),
|
||||
KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1)
|
||||
KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1),
|
||||
)]),
|
||||
key_rows: vec![
|
||||
KeyRow::new(0.1, 0.1, vec![
|
||||
@@ -422,7 +422,7 @@ impl KeyLayout {
|
||||
(LedCode::PrtSc, "regular".to_owned()),
|
||||
(LedCode::RCtrl, "regular".to_owned()),
|
||||
]),
|
||||
]
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,5 @@ pub enum AdvancedAuraType {
|
||||
#[default]
|
||||
None,
|
||||
Zoned(Vec<LedCode>),
|
||||
PerKey
|
||||
PerKey,
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct AuraPowerState {
|
||||
pub awake: bool,
|
||||
pub sleep: bool,
|
||||
/// Ignored for pre-2021 and Tuf
|
||||
pub shutdown: bool
|
||||
pub shutdown: bool,
|
||||
}
|
||||
|
||||
impl Default for AuraPowerState {
|
||||
@@ -34,7 +34,7 @@ impl Default for AuraPowerState {
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true
|
||||
shutdown: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ impl AuraPowerState {
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true
|
||||
shutdown: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ impl AuraPowerState {
|
||||
| ((self.sleep as u32) << (23 + 3))
|
||||
| ((self.shutdown as u32) << (23 + 4))
|
||||
}
|
||||
PowerZones::None | PowerZones::KeyboardAndLightbar => 0
|
||||
PowerZones::None | PowerZones::KeyboardAndLightbar => 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ impl AuraPowerState {
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct LaptopAuraPower {
|
||||
pub states: Vec<AuraPowerState>
|
||||
pub states: Vec<AuraPowerState>,
|
||||
}
|
||||
|
||||
impl LaptopAuraPower {
|
||||
@@ -206,19 +206,19 @@ impl LaptopAuraPower {
|
||||
// 3. KeyboardAndLightbar
|
||||
if support_data.power_zones.contains(&PowerZones::Lightbar) {
|
||||
Self {
|
||||
states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)]
|
||||
states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)],
|
||||
}
|
||||
} else {
|
||||
Self {
|
||||
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)]
|
||||
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)],
|
||||
}
|
||||
}
|
||||
}
|
||||
AuraDeviceType::LaptopKeyboardTuf => Self {
|
||||
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)]
|
||||
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)],
|
||||
},
|
||||
AuraDeviceType::ScsiExtDisk => todo!(),
|
||||
AuraDeviceType::AnimeOrSlash => todo!()
|
||||
AuraDeviceType::AnimeOrSlash => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ impl LaptopAuraPower {
|
||||
self.new_to_bytes()
|
||||
}
|
||||
AuraDeviceType::ScsiExtDisk => todo!("scsi disk not implemented yet"),
|
||||
AuraDeviceType::AnimeOrSlash => todo!("anime/slash not implemented yet")
|
||||
AuraDeviceType::AnimeOrSlash => todo!("anime/slash not implemented yet"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,7 +285,7 @@ enum OldAuraPower {
|
||||
Boot = 0xc31209,
|
||||
Sleep = 0x300804,
|
||||
Keyboard = 0x080000,
|
||||
Lightbar = 0x040500
|
||||
Lightbar = 0x040500,
|
||||
}
|
||||
|
||||
impl BitOr<OldAuraPower> for OldAuraPower {
|
||||
@@ -332,9 +332,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
};
|
||||
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
@@ -347,9 +347,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
};
|
||||
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
@@ -369,16 +369,16 @@ mod test {
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
};
|
||||
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
@@ -394,9 +394,9 @@ mod test {
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let boot_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -405,9 +405,9 @@ mod test {
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let sleep_logo = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -416,9 +416,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let sleep_keyb = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -427,9 +427,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let awake_logo = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -438,9 +438,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let awake_keyb = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -449,9 +449,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let shut_logo_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -460,9 +460,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true
|
||||
shutdown: true,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let shut_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -471,9 +471,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true
|
||||
shutdown: true,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let boot_bar__ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -482,9 +482,9 @@ mod test {
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let awake_bar_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -493,9 +493,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let sleep_bar_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -504,9 +504,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let shut_bar__ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -515,9 +515,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true
|
||||
shutdown: true,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let boot_lid__ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -526,9 +526,9 @@ mod test {
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let awake_lid_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -537,9 +537,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let sleep_lid_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -548,9 +548,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let shut_lid__ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -559,9 +559,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true
|
||||
shutdown: true,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let boot_rear_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -570,9 +570,9 @@ mod test {
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let awake_rear = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -581,9 +581,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let sleep_rear = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -592,9 +592,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
shutdown: false,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
let shut_rear_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![
|
||||
@@ -603,9 +603,9 @@ mod test {
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true
|
||||
shutdown: true,
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
|
||||
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
|
||||
@@ -655,7 +655,7 @@ mod test {
|
||||
zone: PowerZones::RearGlow,
|
||||
..Default::default()
|
||||
},
|
||||
]
|
||||
],
|
||||
});
|
||||
assert_eq!(byte1, "11111111, 00011110, 00001111, 00001111");
|
||||
}
|
||||
|
||||
@@ -29,40 +29,40 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
pub const RED: Colour = Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0x00
|
||||
b: 0x00,
|
||||
};
|
||||
pub const GREEN: Colour = Colour {
|
||||
r: 0x00,
|
||||
g: 0xff,
|
||||
b: 0x00
|
||||
b: 0x00,
|
||||
};
|
||||
pub const BLUE: Colour = Colour {
|
||||
r: 0x00,
|
||||
g: 0x00,
|
||||
b: 0xff
|
||||
b: 0xff,
|
||||
};
|
||||
pub const VIOLET: Colour = Colour {
|
||||
r: 0x9b,
|
||||
g: 0x26,
|
||||
b: 0xb6
|
||||
b: 0xb6,
|
||||
};
|
||||
pub const TEAL: Colour = Colour {
|
||||
r: 0x00,
|
||||
g: 0x7c,
|
||||
b: 0x80
|
||||
b: 0x80,
|
||||
};
|
||||
pub const YELLOW: Colour = Colour {
|
||||
r: 0xff,
|
||||
g: 0xef,
|
||||
b: 0x00
|
||||
b: 0x00,
|
||||
};
|
||||
pub const ORANGE: Colour = Colour {
|
||||
r: 0xff,
|
||||
g: 0xa4,
|
||||
b: 0x00
|
||||
b: 0x00,
|
||||
};
|
||||
pub const GRADIENT: [Colour; 7] = [
|
||||
RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE
|
||||
RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE,
|
||||
];
|
||||
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
@@ -76,7 +76,7 @@ pub enum AuraDeviceType {
|
||||
ScsiExtDisk = 3,
|
||||
Ally = 4,
|
||||
AnimeOrSlash = 5,
|
||||
Unknown = 255
|
||||
Unknown = 255,
|
||||
}
|
||||
|
||||
impl AuraDeviceType {
|
||||
@@ -110,7 +110,7 @@ impl From<&str> for AuraDeviceType {
|
||||
"1abe" | "1b4c" => Self::Ally,
|
||||
"19b3" | "193b" => Self::AnimeOrSlash,
|
||||
"19b6" => Self::LaptopKeyboard2021,
|
||||
_ => Self::Unknown
|
||||
_ => Self::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,5 +138,5 @@ pub enum PowerZones {
|
||||
KeyboardAndLightbar = 5,
|
||||
/// Ally specific for creating correct packet
|
||||
Ally = 6,
|
||||
None = 255
|
||||
None = 255,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Only these two packets must be 17 bytes
|
||||
pub const AURA_LAPTOP_LED_APPLY: [u8; 17] = [
|
||||
0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
];
|
||||
pub const AURA_LAPTOP_LED_SET: [u8; 17] = [
|
||||
0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
];
|
||||
|
||||
@@ -41,6 +41,7 @@ zbus.workspace = true
|
||||
dirs.workspace = true
|
||||
notify-rust.workspace = true
|
||||
concat-idents.workspace = true
|
||||
futures-util.workspace = true
|
||||
|
||||
versions.workspace = true
|
||||
|
||||
@@ -48,10 +49,11 @@ versions.workspace = true
|
||||
git = "https://github.com/slint-ui/slint.git"
|
||||
default-features = false
|
||||
features = [
|
||||
"gettext",
|
||||
"compat-1-2",
|
||||
"gettext",
|
||||
"accessibility",
|
||||
"backend-winit-wayland",
|
||||
"renderer-winit-femtovg",
|
||||
"renderer-femtovg",
|
||||
# "renderer-skia-opengl",
|
||||
]
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ fn main() {
|
||||
CompilerConfiguration::new()
|
||||
// .embed_resources(EmbedResourcesKind::EmbedFiles)
|
||||
.with_include_paths(vec![include])
|
||||
.with_style("fluent".into())
|
||||
.with_style("fluent".into()),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@@ -23,5 +23,5 @@ pub struct CliStart {
|
||||
help = "put ROGCC in layout viewing mode - this is helpful for finding existing layouts \
|
||||
that might match your laptop"
|
||||
)]
|
||||
pub layout_viewing: bool
|
||||
pub layout_viewing: bool,
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ pub struct Config {
|
||||
pub fullscreen_width: u32,
|
||||
pub fullscreen_height: u32,
|
||||
// This field must be last
|
||||
pub notifications: EnabledNotifications
|
||||
pub notifications: EnabledNotifications,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -36,7 +36,7 @@ impl Default for Config {
|
||||
fullscreen_height: 1080,
|
||||
notifications: EnabledNotifications::default(),
|
||||
ac_command: String::new(),
|
||||
bat_command: String::new()
|
||||
bat_command: String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ pub struct Config461 {
|
||||
pub enable_dgpu_notifications: bool,
|
||||
pub dark_mode: bool,
|
||||
// This field must be last
|
||||
pub enabled_notifications: EnabledNotifications
|
||||
pub enabled_notifications: EnabledNotifications,
|
||||
}
|
||||
|
||||
impl From<Config461> for Config {
|
||||
@@ -92,7 +92,7 @@ impl From<Config461> for Config {
|
||||
start_fullscreen: false,
|
||||
fullscreen_width: 1920,
|
||||
fullscreen_height: 1080,
|
||||
notifications: c.enabled_notifications
|
||||
notifications: c.enabled_notifications,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ pub enum Error {
|
||||
ConfigLockFail,
|
||||
XdgVars,
|
||||
Zbus(zbus::Error),
|
||||
Notification(notify_rust::error::Error)
|
||||
Notification(notify_rust::error::Error),
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
@@ -21,7 +21,7 @@ impl fmt::Display for Error {
|
||||
Error::ConfigLockFail => write!(f, "Failed to lock user config"),
|
||||
Error::XdgVars => write!(f, "XDG environment vars appear unset"),
|
||||
Error::Zbus(err) => write!(f, "Error: {}", err),
|
||||
Error::Notification(err) => write!(f, "Notification Error: {}", err)
|
||||
Error::Notification(err) => write!(f, "Notification Error: {}", err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,5 +38,5 @@ pub enum Page {
|
||||
System,
|
||||
AuraEffects,
|
||||
AnimeMatrix,
|
||||
FanCurves
|
||||
FanCurves,
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ use rog_control_center::slint::ComponentHandle;
|
||||
use rog_control_center::tray::init_tray;
|
||||
use rog_control_center::ui::setup_window;
|
||||
use rog_control_center::zbus_proxies::{
|
||||
AppState, ROGCCZbus, ROGCCZbusProxyBlocking, ZBUS_IFACE, ZBUS_PATH
|
||||
AppState, ROGCCZbus, ROGCCZbusProxyBlocking, ZBUS_IFACE, ZBUS_PATH,
|
||||
};
|
||||
use rog_control_center::{print_versions, MainWindow};
|
||||
use tokio::runtime::Runtime;
|
||||
@@ -35,8 +35,21 @@ async fn main() -> Result<()> {
|
||||
// If we're running under gamescope we have to set WAYLAND_DISPLAY for winit to
|
||||
// use
|
||||
if let Ok(gamescope) = env::var("GAMESCOPE_WAYLAND_DISPLAY") {
|
||||
env::set_var("WAYLAND_DISPLAY", gamescope);
|
||||
dbg!(1);
|
||||
if !gamescope.is_empty() {
|
||||
dbg!(2);
|
||||
env::set_var("WAYLAND_DISPLAY", gamescope);
|
||||
}
|
||||
// gamescope-0
|
||||
else if let Ok(wayland) = env::var("WAYLAND_DISPLAY") {
|
||||
dbg!(3);
|
||||
if wayland.is_empty() {
|
||||
dbg!(4);
|
||||
env::set_var("WAYLAND_DISPLAY", "gamescope-0");
|
||||
}
|
||||
}
|
||||
}
|
||||
dbg!("SHITR");
|
||||
|
||||
// Try to open a proxy and check for app state first
|
||||
{
|
||||
@@ -90,7 +103,7 @@ async fn main() -> Result<()> {
|
||||
let board_name = dmi.board_name;
|
||||
let prod_family = dmi.product_family;
|
||||
info!("Running on {board_name}, product: {prod_family}");
|
||||
let is_rog_ally = prod_family == "RC71L" || prod_family == "RC72L";
|
||||
let is_rog_ally = board_name == "RC71L" || board_name == "RC72L" || prod_family == "ROG Ally";
|
||||
|
||||
let args: Vec<String> = args().skip(1).collect();
|
||||
|
||||
@@ -161,73 +174,101 @@ async fn main() -> Result<()> {
|
||||
thread::spawn(move || {
|
||||
let mut state = AppState::StartingUp;
|
||||
loop {
|
||||
// save as a var, don't hold the lock the entire time or deadlocks happen
|
||||
if let Ok(app_state) = app_state.lock() {
|
||||
state = *app_state;
|
||||
}
|
||||
if is_rog_ally {
|
||||
let config_copy_2 = config.clone();
|
||||
let newui = setup_window(config.clone());
|
||||
newui.window().on_close_requested(move || {
|
||||
exit(0);
|
||||
});
|
||||
|
||||
// This sleep is required to give the event loop time to react
|
||||
sleep(Duration::from_millis(300));
|
||||
if state == AppState::MainWindowShouldOpen {
|
||||
if let Ok(mut app_state) = app_state.lock() {
|
||||
*app_state = AppState::MainWindowOpen;
|
||||
}
|
||||
|
||||
let config_copy = config.clone();
|
||||
let app_state_copy = app_state.clone();
|
||||
slint::invoke_from_event_loop(move || {
|
||||
UI.with(|ui| {
|
||||
let app_state_copy = app_state_copy.clone();
|
||||
let mut ui = ui.borrow_mut();
|
||||
if let Some(ui) = ui.as_mut() {
|
||||
ui.window().show().unwrap();
|
||||
ui.window().on_close_requested(move || {
|
||||
if let Ok(mut app_state) = app_state_copy.lock() {
|
||||
*app_state = AppState::MainWindowClosed;
|
||||
}
|
||||
slint::CloseRequestResponse::HideWindow
|
||||
});
|
||||
} else {
|
||||
let config_copy_2 = config_copy.clone();
|
||||
let newui = setup_window(config_copy);
|
||||
newui.window().on_close_requested(move || {
|
||||
if let Ok(mut app_state) = app_state_copy.lock() {
|
||||
*app_state = AppState::MainWindowClosed;
|
||||
}
|
||||
slint::CloseRequestResponse::HideWindow
|
||||
});
|
||||
|
||||
let ui_copy = newui.as_weak();
|
||||
newui
|
||||
.window()
|
||||
.set_rendering_notifier(move |s, _| {
|
||||
if let slint::RenderingState::RenderingSetup = s {
|
||||
let config = config_copy_2.clone();
|
||||
ui_copy
|
||||
.upgrade_in_event_loop(move |w| {
|
||||
let fullscreen =
|
||||
config.lock().is_ok_and(|c| c.start_fullscreen);
|
||||
if fullscreen && !w.window().is_fullscreen() {
|
||||
w.window().set_fullscreen(fullscreen);
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
let ui_copy = newui.as_weak();
|
||||
newui
|
||||
.window()
|
||||
.set_rendering_notifier(move |s, _| {
|
||||
if let slint::RenderingState::BeforeRendering = s {
|
||||
let config = config_copy_2.clone();
|
||||
ui_copy
|
||||
.upgrade_in_event_loop(move |w| {
|
||||
let fullscreen =
|
||||
config.lock().is_ok_and(|c| c.start_fullscreen);
|
||||
if fullscreen && !w.window().is_fullscreen() {
|
||||
w.window().set_fullscreen(fullscreen);
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
ui.replace(newui);
|
||||
}
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
} else if state == AppState::QuitApp {
|
||||
slint::quit_event_loop().unwrap();
|
||||
exit(0);
|
||||
} else if state != AppState::MainWindowOpen {
|
||||
if let Ok(config) = config.lock() {
|
||||
if !config.run_in_background {
|
||||
slint::quit_event_loop().unwrap();
|
||||
exit(0);
|
||||
})
|
||||
.ok();
|
||||
} else {
|
||||
// save as a var, don't hold the lock the entire time or deadlocks happen
|
||||
if let Ok(app_state) = app_state.lock() {
|
||||
state = *app_state;
|
||||
}
|
||||
|
||||
// This sleep is required to give the event loop time to react
|
||||
sleep(Duration::from_millis(300));
|
||||
if state == AppState::MainWindowShouldOpen {
|
||||
if let Ok(mut app_state) = app_state.lock() {
|
||||
*app_state = AppState::MainWindowOpen;
|
||||
}
|
||||
|
||||
let config_copy = config.clone();
|
||||
let app_state_copy = app_state.clone();
|
||||
slint::invoke_from_event_loop(move || {
|
||||
UI.with(|ui| {
|
||||
let app_state_copy = app_state_copy.clone();
|
||||
let mut ui = ui.borrow_mut();
|
||||
if let Some(ui) = ui.as_mut() {
|
||||
ui.window().show().unwrap();
|
||||
ui.window().on_close_requested(move || {
|
||||
if let Ok(mut app_state) = app_state_copy.lock() {
|
||||
*app_state = AppState::MainWindowClosed;
|
||||
}
|
||||
slint::CloseRequestResponse::HideWindow
|
||||
});
|
||||
} else {
|
||||
let config_copy_2 = config_copy.clone();
|
||||
let newui = setup_window(config_copy);
|
||||
newui.window().on_close_requested(move || {
|
||||
if let Ok(mut app_state) = app_state_copy.lock() {
|
||||
*app_state = AppState::MainWindowClosed;
|
||||
}
|
||||
slint::CloseRequestResponse::HideWindow
|
||||
});
|
||||
|
||||
let ui_copy = newui.as_weak();
|
||||
newui
|
||||
.window()
|
||||
.set_rendering_notifier(move |s, _| {
|
||||
if let slint::RenderingState::RenderingSetup = s {
|
||||
let config = config_copy_2.clone();
|
||||
ui_copy
|
||||
.upgrade_in_event_loop(move |w| {
|
||||
let fullscreen = config
|
||||
.lock()
|
||||
.is_ok_and(|c| c.start_fullscreen);
|
||||
if fullscreen && !w.window().is_fullscreen() {
|
||||
w.window().set_fullscreen(fullscreen);
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
ui.replace(newui);
|
||||
}
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
} else if state == AppState::QuitApp {
|
||||
slint::quit_event_loop().unwrap();
|
||||
exit(0);
|
||||
} else if state != AppState::MainWindowOpen {
|
||||
if let Ok(config) = config.lock() {
|
||||
if !config.run_in_background {
|
||||
slint::quit_event_loop().unwrap();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use rog_aura::{AuraEffect, AuraModeNum, AuraZone};
|
||||
use rog_platform::platform::GpuMode;
|
||||
use rog_platform::supported::{
|
||||
AdvancedAura, AnimeSupportedFunctions, ChargeSupportedFunctions, LedSupportedFunctions,
|
||||
PlatformProfileFunctions, RogBiosSupportedFunctions, SupportedFunctions
|
||||
PlatformProfileFunctions, RogBiosSupportedFunctions, SupportedFunctions,
|
||||
};
|
||||
use rog_profiles::fan_curve_set::{CurveData, FanCurveSet};
|
||||
use supergfxctl::pci_device::{GfxMode, GfxPower};
|
||||
@@ -16,7 +16,7 @@ const NOPE: &str = "";
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct DaemonProxyBlocking<'a> {
|
||||
_phantom: &'a str
|
||||
_phantom: &'a str,
|
||||
}
|
||||
|
||||
impl<'a> DaemonProxyBlocking<'a> {
|
||||
@@ -35,7 +35,7 @@ impl<'a> DaemonProxyBlocking<'a> {
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct RogDbusClientBlocking<'a> {
|
||||
_phantom: &'a str
|
||||
_phantom: &'a str,
|
||||
}
|
||||
|
||||
impl<'a> RogDbusClientBlocking<'a> {
|
||||
@@ -126,16 +126,16 @@ impl Profile {
|
||||
pub fn fan_curve_data(&self, _p: rog_profiles::Profile) -> Result<FanCurveSet> {
|
||||
let mut curve = FanCurveSet::default();
|
||||
curve.cpu.pwm = [
|
||||
30, 40, 60, 100, 140, 180, 200, 250
|
||||
30, 40, 60, 100, 140, 180, 200, 250,
|
||||
];
|
||||
curve.cpu.temp = [
|
||||
20, 30, 40, 50, 70, 80, 90, 100
|
||||
20, 30, 40, 50, 70, 80, 90, 100,
|
||||
];
|
||||
curve.gpu.pwm = [
|
||||
40, 80, 100, 140, 170, 200, 230, 250
|
||||
40, 80, 100, 140, 170, 200, 230, 250,
|
||||
];
|
||||
curve.gpu.temp = [
|
||||
20, 30, 40, 50, 70, 80, 90, 100
|
||||
20, 30, 40, 50, 70, 80, 90, 100,
|
||||
];
|
||||
Ok(curve)
|
||||
}
|
||||
@@ -204,7 +204,7 @@ impl Led {
|
||||
AuraDevRog2::AwakeKeyb,
|
||||
AuraDevRog2::SleepLogo,
|
||||
AuraDevRog2::AwakeLogo,
|
||||
]
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -242,11 +242,11 @@ impl Supported {
|
||||
Ok(SupportedFunctions {
|
||||
anime_ctrl: AnimeSupportedFunctions(true),
|
||||
charge_ctrl: ChargeSupportedFunctions {
|
||||
charge_level_set: true
|
||||
charge_level_set: true,
|
||||
},
|
||||
platform_profile: PlatformProfileFunctions {
|
||||
platform_profile: true,
|
||||
fan_curves: true
|
||||
fan_curves: true,
|
||||
},
|
||||
keyboard_led: LedSupportedFunctions {
|
||||
dev_id: AuraDevice::X19b6,
|
||||
@@ -267,7 +267,7 @@ impl Supported {
|
||||
AuraZone::BarRight,
|
||||
AuraZone::Logo,
|
||||
],
|
||||
advanced_type: AdvancedAura::PerKey
|
||||
advanced_type: AdvancedAura::PerKey,
|
||||
},
|
||||
rog_bios_ctrl: RogBiosSupportedFunctions {
|
||||
post_sound: true,
|
||||
@@ -275,8 +275,8 @@ impl Supported {
|
||||
panel_overdrive: true,
|
||||
dgpu_disable: true,
|
||||
mini_led_mode: true,
|
||||
egpu_enable: true
|
||||
}
|
||||
egpu_enable: true,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use std::process::Command;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
use futures_util::StreamExt;
|
||||
use log::{debug, error, info, warn};
|
||||
use notify_rust::{Hint, Notification, Timeout, Urgency};
|
||||
use rog_platform::platform::GpuMode;
|
||||
@@ -19,7 +20,6 @@ use supergfxctl::pci_device::{GfxMode, GfxPower};
|
||||
use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy;
|
||||
use tokio::runtime::Runtime;
|
||||
use tokio::task::JoinHandle;
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::Result;
|
||||
@@ -31,7 +31,7 @@ const NOTIF_HEADER: &str = "ROG Control";
|
||||
pub struct EnabledNotifications {
|
||||
pub enabled: bool,
|
||||
pub receive_notify_gfx: bool,
|
||||
pub receive_notify_gfx_status: bool
|
||||
pub receive_notify_gfx_status: bool,
|
||||
}
|
||||
|
||||
impl Default for EnabledNotifications {
|
||||
@@ -39,7 +39,7 @@ impl Default for EnabledNotifications {
|
||||
Self {
|
||||
enabled: true,
|
||||
receive_notify_gfx: true,
|
||||
receive_notify_gfx_status: true
|
||||
receive_notify_gfx_status: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ fn start_dpu_status_mon(config: Arc<Mutex<Config>>) {
|
||||
|
||||
pub fn start_notifications(
|
||||
config: Arc<Mutex<Config>>,
|
||||
rt: &Runtime
|
||||
rt: &Runtime,
|
||||
) -> Result<Vec<JoinHandle<()>>> {
|
||||
// Setup the AC/BAT commands that will run on power status change
|
||||
let config_copy = config.clone();
|
||||
@@ -214,7 +214,7 @@ pub fn start_notifications(
|
||||
supergfxctl::actions::UserActionRequired::Reboot => {
|
||||
do_mux_notification("Graphics mode change requires reboot", &mode)
|
||||
}
|
||||
_ => do_gfx_action_notif(<&str>::from(action), *action, mode)
|
||||
_ => do_gfx_action_notif(<&str>::from(action), *action, mode),
|
||||
}
|
||||
.map_err(|e| {
|
||||
error!("zbus signal: do_gfx_action_notif: {e}");
|
||||
@@ -266,13 +266,13 @@ fn convert_gfx_mode(gfx: GfxMode) -> GpuMode {
|
||||
GfxMode::Vfio => GpuMode::Vfio,
|
||||
GfxMode::AsusEgpu => GpuMode::Egpu,
|
||||
GfxMode::AsusMuxDgpu => GpuMode::Ultimate,
|
||||
GfxMode::None => GpuMode::Error
|
||||
GfxMode::None => GpuMode::Error,
|
||||
}
|
||||
}
|
||||
|
||||
fn base_notification<T>(message: &str, data: &T) -> Notification
|
||||
where
|
||||
T: Display
|
||||
T: Display,
|
||||
{
|
||||
let mut notif = Notification::new();
|
||||
notif
|
||||
@@ -290,7 +290,7 @@ fn do_gpu_status_notif(message: &str, data: &GfxPower) -> Notification {
|
||||
GfxPower::Off => "asus_notif_green",
|
||||
GfxPower::AsusDisabled => "asus_notif_white",
|
||||
GfxPower::AsusMuxDiscreet | GfxPower::Active => "asus_notif_red",
|
||||
GfxPower::Unknown => "gpu-integrated"
|
||||
GfxPower::Unknown => "gpu-integrated",
|
||||
};
|
||||
notif.icon(icon);
|
||||
notif
|
||||
@@ -331,7 +331,7 @@ fn do_gfx_action_notif(message: &str, action: GfxUserAction, mode: GpuMode) -> R
|
||||
if id == "gfx-mode-session-action" {
|
||||
let mut cmd = Command::new("qdbus");
|
||||
cmd.args([
|
||||
"org.kde.ksmserver", "/KSMServer", "logout", "1", "0", "0"
|
||||
"org.kde.ksmserver", "/KSMServer", "logout", "1", "0", "0",
|
||||
]);
|
||||
cmd.spawn().ok();
|
||||
} else if id == "__closed" {
|
||||
@@ -375,7 +375,7 @@ fn do_mux_notification(message: &str, m: &GpuMode) -> Result<()> {
|
||||
if id == "gfx-mode-session-action" {
|
||||
let mut cmd = Command::new("qdbus");
|
||||
cmd.args([
|
||||
"org.kde.ksmserver", "/KSMServer", "logout", "1", "1", "0"
|
||||
"org.kde.ksmserver", "/KSMServer", "logout", "1", "1", "0",
|
||||
]);
|
||||
cmd.spawn().ok();
|
||||
} else if id == "__closed" {
|
||||
|
||||
@@ -24,7 +24,7 @@ struct Icons {
|
||||
rog_red: Icon,
|
||||
rog_green: Icon,
|
||||
rog_white: Icon,
|
||||
gpu_integrated: Icon
|
||||
gpu_integrated: Icon,
|
||||
}
|
||||
|
||||
static ICONS: OnceLock<Icons> = OnceLock::new();
|
||||
@@ -32,7 +32,10 @@ static ICONS: OnceLock<Icons> = OnceLock::new();
|
||||
fn read_icon(file: &Path) -> Icon {
|
||||
let mut path = PathBuf::from(TRAY_ICON_PATH);
|
||||
path.push(file);
|
||||
let mut file = OpenOptions::new().read(true).open(path).unwrap();
|
||||
let mut file = OpenOptions::new()
|
||||
.read(true)
|
||||
.open(&path)
|
||||
.unwrap_or_else(|_| panic!("Missing icon: {:?}", path));
|
||||
let mut bytes = Vec::new();
|
||||
file.read_to_end(&mut bytes).unwrap();
|
||||
|
||||
@@ -48,14 +51,14 @@ fn read_icon(file: &Path) -> Icon {
|
||||
Icon {
|
||||
width: width as i32,
|
||||
height: height as i32,
|
||||
data: img.into_raw()
|
||||
data: img.into_raw(),
|
||||
}
|
||||
}
|
||||
|
||||
struct AsusTray {
|
||||
current_title: String,
|
||||
current_icon: Icon,
|
||||
proxy: ROGCCZbusProxyBlocking<'static>
|
||||
proxy: ROGCCZbusProxyBlocking<'static>,
|
||||
}
|
||||
|
||||
impl ksni::Tray for AsusTray {
|
||||
@@ -103,7 +106,7 @@ async fn set_tray_icon_and_tip(
|
||||
mode: GfxMode,
|
||||
power: GfxPower,
|
||||
tray: &mut Handle<AsusTray>,
|
||||
supergfx_active: bool
|
||||
supergfx_active: bool,
|
||||
) {
|
||||
if let Some(icons) = ICONS.get() {
|
||||
let icon = match power {
|
||||
@@ -162,7 +165,7 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
|
||||
let tray_init = AsusTray {
|
||||
current_title: TRAY_LABEL.to_string(),
|
||||
current_icon: rog_red.clone(),
|
||||
proxy
|
||||
proxy,
|
||||
};
|
||||
|
||||
// TODO: return an error to the UI
|
||||
@@ -187,7 +190,7 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
|
||||
rog_red: rog_red.clone(),
|
||||
rog_green,
|
||||
rog_white,
|
||||
gpu_integrated
|
||||
gpu_integrated,
|
||||
});
|
||||
|
||||
let mut has_supergfx = false;
|
||||
@@ -215,8 +218,8 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
|
||||
may not be running or installed"
|
||||
)
|
||||
}
|
||||
_ => warn!("Couldn't get mode from supergfxd: {e:?}")
|
||||
}
|
||||
_ => warn!("Couldn't get mode from supergfxd: {e:?}"),
|
||||
},
|
||||
}
|
||||
|
||||
info!("Started ROGTray");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::slint_generatedMainWindow::{
|
||||
AuraDevType as SlintDeviceType, AuraPowerState as SlintAuraPowerState,
|
||||
LaptopAuraPower as SlintLaptopAuraPower
|
||||
LaptopAuraPower as SlintLaptopAuraPower,
|
||||
};
|
||||
|
||||
impl From<rog_aura::AuraEffect> for crate::slint_generatedMainWindow::AuraEffect {
|
||||
@@ -10,20 +10,20 @@ impl From<rog_aura::AuraEffect> for crate::slint_generatedMainWindow::AuraEffect
|
||||
red: m.colour1.r,
|
||||
green: m.colour1.g,
|
||||
blue: m.colour1.b,
|
||||
alpha: 255
|
||||
alpha: 255,
|
||||
}
|
||||
.into(),
|
||||
colour2: RgbaColor {
|
||||
red: m.colour2.r,
|
||||
green: m.colour2.g,
|
||||
blue: m.colour2.b,
|
||||
alpha: 255
|
||||
alpha: 255,
|
||||
}
|
||||
.into(),
|
||||
direction: m.direction.into(),
|
||||
mode: m.mode.into(),
|
||||
speed: m.speed.into(),
|
||||
zone: m.zone.into()
|
||||
zone: m.zone.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,17 +36,17 @@ impl From<crate::slint_generatedMainWindow::AuraEffect> for rog_aura::AuraEffect
|
||||
colour1: rog_aura::Colour {
|
||||
r: c1.red,
|
||||
g: c1.green,
|
||||
b: c1.blue
|
||||
b: c1.blue,
|
||||
},
|
||||
colour2: rog_aura::Colour {
|
||||
r: c2.red,
|
||||
g: c2.green,
|
||||
b: c2.blue
|
||||
b: c2.blue,
|
||||
},
|
||||
direction: m.direction.into(),
|
||||
mode: m.mode.into(),
|
||||
speed: m.speed.into(),
|
||||
zone: m.zone.into()
|
||||
zone: m.zone.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ impl From<PowerZones> for SlintPowerZones {
|
||||
PowerZones::RearGlow => SlintPowerZones::RearGlow,
|
||||
PowerZones::KeyboardAndLightbar => SlintPowerZones::KeyboardAndLightbar,
|
||||
PowerZones::Ally => SlintPowerZones::Ally,
|
||||
PowerZones::None => SlintPowerZones::Keyboard
|
||||
PowerZones::None => SlintPowerZones::Keyboard,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ impl From<SlintPowerZones> for PowerZones {
|
||||
SlintPowerZones::Lid => PowerZones::Lid,
|
||||
SlintPowerZones::RearGlow => PowerZones::RearGlow,
|
||||
SlintPowerZones::KeyboardAndLightbar => PowerZones::KeyboardAndLightbar,
|
||||
SlintPowerZones::Ally => PowerZones::Ally
|
||||
SlintPowerZones::Ally => PowerZones::Ally,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ impl From<SlintAuraPowerState> for AuraPowerState {
|
||||
boot: value.boot,
|
||||
awake: value.awake,
|
||||
sleep: value.sleep,
|
||||
shutdown: value.shutdown
|
||||
shutdown: value.shutdown,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ impl From<AuraPowerState> for SlintAuraPowerState {
|
||||
sleep: value.sleep,
|
||||
shutdown: value.shutdown,
|
||||
zone,
|
||||
zone_name_idx: zone as i32
|
||||
zone_name_idx: zone as i32,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ impl From<&AuraPowerState> for SlintAuraPowerState {
|
||||
sleep: value.sleep,
|
||||
shutdown: value.shutdown,
|
||||
zone,
|
||||
zone_name_idx: zone as i32
|
||||
zone_name_idx: zone as i32,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ impl From<LaptopAuraPower> for SlintLaptopAuraPower {
|
||||
let converted: Vec<SlintAuraPowerState> =
|
||||
value.states.iter().map(SlintAuraPowerState::from).collect();
|
||||
Self {
|
||||
states: ModelRc::from(converted.as_slice())
|
||||
states: ModelRc::from(converted.as_slice()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ impl From<SlintDeviceType> for AuraDeviceType {
|
||||
SlintDeviceType::ScsiExtDisk => Self::ScsiExtDisk,
|
||||
SlintDeviceType::Unknown => Self::Unknown,
|
||||
SlintDeviceType::Ally => Self::Ally,
|
||||
SlintDeviceType::AnimeOrSlash => Self::AnimeOrSlash
|
||||
SlintDeviceType::AnimeOrSlash => Self::AnimeOrSlash,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ impl From<AuraDeviceType> for SlintDeviceType {
|
||||
AuraDeviceType::ScsiExtDisk => SlintDeviceType::ScsiExtDisk,
|
||||
AuraDeviceType::Unknown => SlintDeviceType::Unknown,
|
||||
AuraDeviceType::Ally => SlintDeviceType::Ally,
|
||||
AuraDeviceType::AnimeOrSlash => SlintDeviceType::AnimeOrSlash
|
||||
AuraDeviceType::AnimeOrSlash => SlintDeviceType::AnimeOrSlash,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ impl From<Profile> for PlatformProfile {
|
||||
match value {
|
||||
Profile::Balanced => PlatformProfile::Balanced,
|
||||
Profile::Performance => PlatformProfile::Performance,
|
||||
Profile::Quiet => PlatformProfile::Quiet
|
||||
Profile::Quiet => PlatformProfile::Quiet,
|
||||
Profile::LowPower => PlatformProfile::LowPower,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +19,8 @@ impl From<PlatformProfile> for Profile {
|
||||
match value {
|
||||
PlatformProfile::Balanced => Profile::Balanced,
|
||||
PlatformProfile::Performance => Profile::Performance,
|
||||
PlatformProfile::Quiet => Profile::Quiet
|
||||
PlatformProfile::Quiet => Profile::Quiet,
|
||||
PlatformProfile::LowPower => Profile::LowPower,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +30,7 @@ impl From<FanType> for FanCurvePU {
|
||||
match value {
|
||||
FanType::CPU => FanCurvePU::CPU,
|
||||
FanType::Middle => FanCurvePU::MID,
|
||||
FanType::GPU => FanCurvePU::GPU
|
||||
FanType::GPU => FanCurvePU::GPU,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +40,7 @@ impl From<FanCurvePU> for FanType {
|
||||
match value {
|
||||
FanCurvePU::CPU => FanType::CPU,
|
||||
FanCurvePU::GPU => FanType::GPU,
|
||||
FanCurvePU::MID => FanType::Middle
|
||||
FanCurvePU::MID => FanType::Middle,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ macro_rules! set_ui_callbacks {
|
||||
tokio::spawn(async move {
|
||||
let mut x = proxy_copy.receive().await;
|
||||
concat_idents::concat_idents!(set = set_, $proxy_fn {
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use futures_util::StreamExt;
|
||||
while let Some(e) = x.next().await {
|
||||
if let Ok(out) = e.get().await {
|
||||
handle_copy.upgrade_in_event_loop(move |handle| {
|
||||
@@ -68,7 +68,7 @@ pub fn show_toast(
|
||||
success: SharedString,
|
||||
fail: SharedString,
|
||||
handle: Weak<MainWindow>,
|
||||
result: zbus::Result<()>
|
||||
result: zbus::Result<()>,
|
||||
) {
|
||||
match result {
|
||||
Ok(_) => {
|
||||
@@ -78,7 +78,7 @@ pub fn show_toast(
|
||||
log::warn!("{fail}: {e}");
|
||||
handle.unwrap().invoke_show_toast(fail)
|
||||
})
|
||||
.ok()
|
||||
.ok(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -98,9 +98,9 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
|
||||
available.contains(&"xyz.ljones.Anime".to_string()),
|
||||
available.contains(&"xyz.ljones.FanCurves".to_string()),
|
||||
true,
|
||||
true
|
||||
true,
|
||||
]
|
||||
.into()
|
||||
.into(),
|
||||
);
|
||||
|
||||
ui.on_exit_app(move || {
|
||||
|
||||
@@ -51,9 +51,9 @@ pub fn setup_anime_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
||||
boot: boot.into(),
|
||||
awake: awake.into(),
|
||||
sleep: sleep.into(),
|
||||
shutdown: shutdown.into()
|
||||
shutdown: shutdown.into(),
|
||||
})
|
||||
.await
|
||||
.await,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -62,7 +62,7 @@ pub fn setup_anime_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
||||
let anime_copy = anime.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut x = anime_copy.receive_builtin_animations_changed().await;
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use futures_util::StreamExt;
|
||||
while let Some(e) = x.next().await {
|
||||
if let Ok(out) = e.get().await {
|
||||
handle_copy
|
||||
|
||||
@@ -9,7 +9,7 @@ use slint::{ComponentHandle, Model, RgbaColor, SharedString};
|
||||
use crate::config::Config;
|
||||
use crate::ui::show_toast;
|
||||
use crate::{
|
||||
set_ui_callbacks, set_ui_props_async, AuraPageData, MainWindow, PowerZones as SlintPowerZones
|
||||
set_ui_callbacks, set_ui_props_async, AuraPageData, MainWindow, PowerZones as SlintPowerZones,
|
||||
};
|
||||
|
||||
fn decode_hex(s: &str) -> RgbaColor<u8> {
|
||||
@@ -19,7 +19,7 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
|
||||
alpha: 255,
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0
|
||||
blue: 0,
|
||||
};
|
||||
}
|
||||
let c: Vec<u8> = (0..s.len())
|
||||
@@ -30,7 +30,7 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
|
||||
alpha: 255,
|
||||
red: *c.first().unwrap_or(&255),
|
||||
green: *c.get(1).unwrap_or(&128),
|
||||
blue: *c.get(2).unwrap_or(&32)
|
||||
blue: *c.get(2).unwrap_or(&32),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
||||
"Aura power settings changed".into(),
|
||||
"Failed to set Aura power settings".into(),
|
||||
handle_copy,
|
||||
proxy_copy.set_led_power(power).await
|
||||
proxy_copy.set_led_power(power).await,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -211,7 +211,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
|
||||
// spawn required since the while let never exits
|
||||
tokio::spawn(async move {
|
||||
let mut x = proxy_copy.receive_led_mode_data_changed().await;
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use futures_util::StreamExt;
|
||||
while let Some(e) = x.next().await {
|
||||
if let Ok(out) = e.get().await {
|
||||
handle_copy
|
||||
|
||||
@@ -13,7 +13,7 @@ pub fn update_fan_data(
|
||||
handle: Weak<MainWindow>,
|
||||
bal: Vec<CurveData>,
|
||||
perf: Vec<CurveData>,
|
||||
quiet: Vec<CurveData>
|
||||
quiet: Vec<CurveData>,
|
||||
) {
|
||||
handle
|
||||
.upgrade_in_event_loop(move |handle| {
|
||||
@@ -24,7 +24,7 @@ pub fn update_fan_data(
|
||||
.zip(pwm.iter())
|
||||
.map(|(x, y)| Node {
|
||||
x: *x as f32,
|
||||
y: *y as f32
|
||||
y: *y as f32,
|
||||
})
|
||||
.collect();
|
||||
tmp.as_slice().into()
|
||||
@@ -111,21 +111,21 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
let Ok(balanced) = fans
|
||||
.fan_curve_data(PlatformProfile::Balanced)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
.map_err(|e| error!("Couldn't get balanced data: {e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(perf) = fans
|
||||
.fan_curve_data(PlatformProfile::Performance)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
.map_err(|e| error!("Couldn't get performance data: {e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(quiet) = fans
|
||||
.fan_curve_data(PlatformProfile::Quiet)
|
||||
.await
|
||||
.map_err(|e| error!("{e:}"))
|
||||
.map_err(|e| error!("Couldn't get quiet data: {e:}"))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
@@ -199,6 +199,6 @@ fn fan_data_for(fan: FanType, enabled: bool, data: Vec<Node>) -> CurveData {
|
||||
fan: fan.into(),
|
||||
pwm,
|
||||
temp,
|
||||
enabled
|
||||
enabled,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use crate::{set_ui_callbacks, set_ui_props_async, AttrMinMax, MainWindow, System
|
||||
const MINMAX: AttrMinMax = AttrMinMax {
|
||||
min: 0,
|
||||
max: 0,
|
||||
current: -1.0
|
||||
current: -1.0,
|
||||
};
|
||||
|
||||
pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
@@ -28,6 +28,8 @@ pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
// Null everything before the setup step
|
||||
ui.global::<SystemPageData>()
|
||||
.set_charge_control_end_threshold(-1.0);
|
||||
ui.global::<SystemPageData>()
|
||||
.set_charge_control_enabled(false);
|
||||
ui.global::<SystemPageData>().set_platform_profile(-1);
|
||||
ui.global::<SystemPageData>().set_panel_overdrive(-1);
|
||||
ui.global::<SystemPageData>().set_boot_sound(-1);
|
||||
@@ -40,12 +42,17 @@ pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
ui.global::<SystemPageData>().set_ppt_platform_sppt(MINMAX);
|
||||
ui.global::<SystemPageData>().set_nv_dynamic_boost(MINMAX);
|
||||
ui.global::<SystemPageData>().set_nv_temp_target(MINMAX);
|
||||
ui.global::<SystemPageData>().set_ppt_enabled(false);
|
||||
ui.global::<SystemPageData>()
|
||||
.set_ppt_enabled_available(false);
|
||||
|
||||
let sys_props = platform.supported_properties().unwrap();
|
||||
log::debug!("Available system properties: {sys_props:?}");
|
||||
log::debug!("Available system properties: {:?}", &sys_props);
|
||||
if sys_props.contains(&Properties::ChargeControlEndThreshold) {
|
||||
ui.global::<SystemPageData>()
|
||||
.set_charge_control_end_threshold(60.0);
|
||||
ui.global::<SystemPageData>()
|
||||
.set_charge_control_enabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +163,7 @@ macro_rules! setup_external {
|
||||
concat_idents!(setter = set_, $property {
|
||||
tokio::spawn(async move {
|
||||
let mut x = proxy_copy.receive_current_value_changed().await;
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use futures_util::StreamExt;
|
||||
while let Some(e) = x.next().await {
|
||||
if let Ok(out) = e.get().await {
|
||||
handle_copy
|
||||
@@ -182,7 +189,7 @@ macro_rules! setup_value_watch {
|
||||
let mut x = concat_idents!(recv = receive_, $value_type, _value_changed {
|
||||
proxy_copy.recv().await
|
||||
});
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use futures_util::StreamExt;
|
||||
while let Some(e) = x.next().await {
|
||||
if let Ok(out) = e.get().await {
|
||||
concat_idents!(getter = get_, $property {
|
||||
@@ -214,7 +221,7 @@ macro_rules! setup_minmax_external {
|
||||
let platform_proxy_copy = $platform.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut x = platform_proxy_copy.receive_platform_profile_changed().await;
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use futures_util::StreamExt;
|
||||
while let Some(e) = x.next().await {
|
||||
if let Ok(_) = e.get().await {
|
||||
debug!("receive_platform_profile_changed, getting new {}", stringify!(attr));
|
||||
@@ -400,6 +407,36 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
|
||||
FirmwareAttribute::ApuMem => {}
|
||||
FirmwareAttribute::CoresPerformance => {}
|
||||
FirmwareAttribute::CoresEfficiency => {}
|
||||
FirmwareAttribute::PptEnabled => {
|
||||
init_property!(ppt_enabled, handle, value, bool);
|
||||
setup_callback!(ppt_enabled, handle, attr, bool);
|
||||
let handle_copy = handle.as_weak();
|
||||
let proxy_copy = attr.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut x = proxy_copy.receive_current_value_changed().await;
|
||||
use futures_util::StreamExt;
|
||||
while let Some(e) = x.next().await {
|
||||
if let Ok(out) = e.get().await {
|
||||
handle_copy
|
||||
.upgrade_in_event_loop(move |handle| {
|
||||
handle
|
||||
.global::<SystemPageData>()
|
||||
.set_enable_ppt_group(out == 1);
|
||||
handle
|
||||
.global::<SystemPageData>()
|
||||
.set_ppt_enabled(out == 1);
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
});
|
||||
handle
|
||||
.global::<SystemPageData>()
|
||||
.set_ppt_enabled_available(true);
|
||||
handle
|
||||
.global::<SystemPageData>()
|
||||
.set_enable_ppt_group(value == 1);
|
||||
}
|
||||
FirmwareAttribute::PptPl1Spl => {
|
||||
init_minmax_property!(ppt_pl1_spl, handle, attr);
|
||||
setup_callback!(ppt_pl1_spl, handle, attr, i32);
|
||||
|
||||
@@ -14,18 +14,18 @@ pub enum AppState {
|
||||
MainWindowClosed = 2,
|
||||
StartingUp = 3,
|
||||
QuitApp = 4,
|
||||
LockFailed = 5
|
||||
LockFailed = 5,
|
||||
}
|
||||
|
||||
pub struct ROGCCZbus {
|
||||
state: Arc<Mutex<AppState>>
|
||||
state: Arc<Mutex<AppState>>,
|
||||
}
|
||||
|
||||
impl ROGCCZbus {
|
||||
#[allow(clippy::new_without_default)]
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
state: Arc::new(Mutex::new(AppState::StartingUp))
|
||||
state: Arc::new(Mutex::new(AppState::StartingUp)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ pub trait ROGCCZbus {
|
||||
|
||||
pub fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
|
||||
where
|
||||
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>
|
||||
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>,
|
||||
{
|
||||
let conn = Connection::system().unwrap();
|
||||
let f = fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
|
||||
@@ -99,7 +99,7 @@ where
|
||||
T::builder(&conn)
|
||||
.path(path.clone())?
|
||||
.destination("xyz.ljones.Asusd")?
|
||||
.build()?
|
||||
.build()?,
|
||||
);
|
||||
}
|
||||
return Ok(ctrl);
|
||||
@@ -110,7 +110,7 @@ where
|
||||
|
||||
pub async fn find_iface_async<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
|
||||
where
|
||||
T: zbus::proxy::ProxyImpl<'static> + From<zbus::Proxy<'static>>
|
||||
T: zbus::proxy::ProxyImpl<'static> + From<zbus::Proxy<'static>>,
|
||||
{
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/")
|
||||
@@ -140,7 +140,7 @@ where
|
||||
.path(path.clone())?
|
||||
.destination("xyz.ljones.Asusd")?
|
||||
.build()
|
||||
.await?
|
||||
.await?,
|
||||
);
|
||||
}
|
||||
return Ok(ctrl);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2025-02-06 20:42+0000\n"
|
||||
"POT-Creation-Date: 2025-02-15 22:50+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -12,238 +12,238 @@ msgstr ""
|
||||
"Language: \n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:19
|
||||
#: rog-control-center/ui/pages/system.slint:20
|
||||
msgctxt "SystemPageData"
|
||||
msgid "Balanced"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:19 rog-control-center/ui/pages/system.slint:23
|
||||
#: rog-control-center/ui/pages/system.slint:20 rog-control-center/ui/pages/system.slint:24
|
||||
msgctxt "SystemPageData"
|
||||
msgid "Performance"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:19
|
||||
#: rog-control-center/ui/pages/system.slint:20
|
||||
msgctxt "SystemPageData"
|
||||
msgid "Quiet"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:22
|
||||
#: rog-control-center/ui/pages/system.slint:23
|
||||
msgctxt "SystemPageData"
|
||||
msgid "Default"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:24
|
||||
#: rog-control-center/ui/pages/system.slint:25
|
||||
msgctxt "SystemPageData"
|
||||
msgid "BalancePerformance"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:25
|
||||
#: rog-control-center/ui/pages/system.slint:26
|
||||
msgctxt "SystemPageData"
|
||||
msgid "BalancePower"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:26
|
||||
#: rog-control-center/ui/pages/system.slint:27
|
||||
msgctxt "SystemPageData"
|
||||
msgid "Power"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:142
|
||||
#: rog-control-center/ui/pages/system.slint:147
|
||||
msgctxt "PageSystem"
|
||||
msgid "Power settings"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:147
|
||||
#: rog-control-center/ui/pages/system.slint:152
|
||||
msgctxt "PageSystem"
|
||||
msgid "Charge limit"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:161
|
||||
#: rog-control-center/ui/pages/system.slint:167
|
||||
msgctxt "PageSystem"
|
||||
msgid "Platform Profile"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:171
|
||||
#: rog-control-center/ui/pages/system.slint:177
|
||||
msgctxt "PageSystem"
|
||||
msgid "Advanced"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:189
|
||||
#: rog-control-center/ui/pages/system.slint:195
|
||||
msgctxt "PageSystem"
|
||||
msgid "Armoury settings"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:199
|
||||
#: rog-control-center/ui/pages/system.slint:205
|
||||
msgctxt "no_asus_armoury_driver_1"
|
||||
msgid "The asus-armoury driver is not loaded"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:205
|
||||
#: rog-control-center/ui/pages/system.slint:211
|
||||
msgctxt "no_asus_armoury_driver_2"
|
||||
msgid "For advanced features you will require a kernel with this driver added."
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:216
|
||||
#: rog-control-center/ui/pages/system.slint:222
|
||||
msgctxt "PageSystem"
|
||||
msgid "Panel Overdrive"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:224
|
||||
#: rog-control-center/ui/pages/system.slint:230
|
||||
msgctxt "PageSystem"
|
||||
msgid "MiniLED Mode"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:232
|
||||
#: rog-control-center/ui/pages/system.slint:238
|
||||
msgctxt "PageSystem"
|
||||
msgid "POST boot sound"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:248
|
||||
#: rog-control-center/ui/pages/system.slint:254
|
||||
msgctxt "ppt_warning"
|
||||
msgid "The following settings are not applied until the toggle is enabled."
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:253
|
||||
#: rog-control-center/ui/pages/system.slint:259 rog-control-center/ui/pages/system.slint:266
|
||||
msgctxt "ppt_group_enabled"
|
||||
msgid "Enable Tuning"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:262 rog-control-center/ui/pages/system.slint:263
|
||||
#: rog-control-center/ui/pages/system.slint:277 rog-control-center/ui/pages/system.slint:278
|
||||
msgctxt "ppt_pl1_spl"
|
||||
msgid "CPU Sustained Power Limit"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:264
|
||||
#: rog-control-center/ui/pages/system.slint:279
|
||||
msgctxt "ppt_pl1_spl_help"
|
||||
msgid ""
|
||||
"Long-term CPU power limit that affects sustained workload performance. "
|
||||
"Higher values may increase heat and power consumption."
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:280 rog-control-center/ui/pages/system.slint:281
|
||||
#: rog-control-center/ui/pages/system.slint:295 rog-control-center/ui/pages/system.slint:296
|
||||
msgctxt "ppt_pl2_sppt"
|
||||
msgid "CPU Turbo Power Limit"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:282
|
||||
#: rog-control-center/ui/pages/system.slint:297
|
||||
msgctxt "ppt_pl2_sppt_help"
|
||||
msgid ""
|
||||
"Short-term CPU power limit for boost periods. Controls maximum power during "
|
||||
"brief high-performance bursts."
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:298 rog-control-center/ui/pages/system.slint:299
|
||||
#: rog-control-center/ui/pages/system.slint:313 rog-control-center/ui/pages/system.slint:314
|
||||
msgctxt "ppt_pl3_fppt"
|
||||
msgid "CPU Fast Burst Power Limit"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:300
|
||||
#: rog-control-center/ui/pages/system.slint:315
|
||||
msgctxt "ppt_pl3_fppt_help"
|
||||
msgid ""
|
||||
"Ultra-short duration power limit for instantaneous CPU bursts. Affects "
|
||||
"responsiveness during sudden workload spikes."
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:315 rog-control-center/ui/pages/system.slint:316
|
||||
#: rog-control-center/ui/pages/system.slint:330 rog-control-center/ui/pages/system.slint:331
|
||||
msgctxt "ppt_fppt"
|
||||
msgid "Fast Package Power Limit"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:317
|
||||
#: rog-control-center/ui/pages/system.slint:332
|
||||
msgctxt "ppt_fppt_help"
|
||||
msgid ""
|
||||
"Ultra-short duration power limit for system package. Controls maximum power "
|
||||
"during millisecond-scale load spikes."
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:333 rog-control-center/ui/pages/system.slint:334
|
||||
#: rog-control-center/ui/pages/system.slint:348 rog-control-center/ui/pages/system.slint:349
|
||||
msgctxt "ppt_apu_sppt"
|
||||
msgid "APU Sustained Power Limit"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:335
|
||||
#: rog-control-center/ui/pages/system.slint:350
|
||||
msgctxt "ppt_apu_sppt_help"
|
||||
msgid ""
|
||||
"Long-term power limit for integrated graphics and CPU combined. Affects "
|
||||
"sustained performance of APU-based workloads."
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:351 rog-control-center/ui/pages/system.slint:352
|
||||
#: rog-control-center/ui/pages/system.slint:366 rog-control-center/ui/pages/system.slint:367
|
||||
msgctxt "ppt_platform_sppt"
|
||||
msgid "Platform Sustained Power Limit"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:353
|
||||
#: rog-control-center/ui/pages/system.slint:368
|
||||
msgctxt "ppt_platform_sppt_help"
|
||||
msgid ""
|
||||
"Overall system power limit for sustained operations. Controls total platform "
|
||||
"power consumption over extended periods."
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:369 rog-control-center/ui/pages/system.slint:370
|
||||
#: rog-control-center/ui/pages/system.slint:384 rog-control-center/ui/pages/system.slint:385
|
||||
msgctxt "nv_dynamic_boost"
|
||||
msgid "GPU Power Boost"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:371
|
||||
#: rog-control-center/ui/pages/system.slint:386
|
||||
msgctxt "nv_dynamic_boost_help"
|
||||
msgid ""
|
||||
"Additional power allocation for GPU dynamic boost. Higher values increase "
|
||||
"GPU performance but generate more heat."
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:387 rog-control-center/ui/pages/system.slint:388
|
||||
#: rog-control-center/ui/pages/system.slint:402 rog-control-center/ui/pages/system.slint:403
|
||||
msgctxt "nv_temp_target"
|
||||
msgid "GPU Temperature Limit"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:389
|
||||
#: rog-control-center/ui/pages/system.slint:404
|
||||
msgctxt "nv_temp_target_help"
|
||||
msgid ""
|
||||
"Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain "
|
||||
"temperature below this limit."
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:441
|
||||
#: rog-control-center/ui/pages/system.slint:456
|
||||
msgctxt "PageSystem"
|
||||
msgid "Energy Performance Preference linked to Throttle Policy"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:445
|
||||
#: rog-control-center/ui/pages/system.slint:460
|
||||
msgctxt "PageSystem"
|
||||
msgid "Change EPP based on Throttle Policy"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:453
|
||||
#: rog-control-center/ui/pages/system.slint:468
|
||||
msgctxt "PageSystem"
|
||||
msgid "EPP for Balanced Policy"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:463
|
||||
#: rog-control-center/ui/pages/system.slint:478
|
||||
msgctxt "PageSystem"
|
||||
msgid "EPP for Performance Policy"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:473
|
||||
#: rog-control-center/ui/pages/system.slint:488
|
||||
msgctxt "PageSystem"
|
||||
msgid "EPP for Quiet Policy"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:491
|
||||
#: rog-control-center/ui/pages/system.slint:506
|
||||
msgctxt "PageSystem"
|
||||
msgid "Throttle Policy for power state"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:497
|
||||
#: rog-control-center/ui/pages/system.slint:512
|
||||
msgctxt "PageSystem"
|
||||
msgid "Throttle Policy on Battery"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:507 rog-control-center/ui/pages/system.slint:528
|
||||
#: rog-control-center/ui/pages/system.slint:522 rog-control-center/ui/pages/system.slint:543
|
||||
msgctxt "PageSystem"
|
||||
msgid "Enabled"
|
||||
msgstr ""
|
||||
|
||||
#: rog-control-center/ui/pages/system.slint:518
|
||||
#: rog-control-center/ui/pages/system.slint:533
|
||||
msgctxt "PageSystem"
|
||||
msgid "Throttle Policy on AC"
|
||||
msgstr ""
|
||||
|
||||
@@ -13,6 +13,7 @@ export struct AttrPossible {
|
||||
}
|
||||
|
||||
export global SystemPageData {
|
||||
in-out property <bool> charge_control_enabled: true;
|
||||
in-out property <float> charge_control_end_threshold: 30;
|
||||
callback cb_charge_control_end_threshold(/* charge limit */ int);
|
||||
in-out property <int> platform_profile: 0;
|
||||
@@ -115,8 +116,12 @@ export global SystemPageData {
|
||||
callback cb_nv_temp_target(int);
|
||||
callback cb_default_nv_temp_target();
|
||||
|
||||
in-out property <bool> enable_ppt_group;
|
||||
in-out property <bool> enable_ppt_group: false;
|
||||
callback cb_enable_ppt_group(bool);
|
||||
|
||||
in-out property <bool> ppt_enabled_available;
|
||||
in-out property <bool> ppt_enabled;
|
||||
callback cb_ppt_enabled(bool);
|
||||
}
|
||||
|
||||
export component PageSystem inherits Rectangle {
|
||||
@@ -148,6 +153,7 @@ export component PageSystem inherits Rectangle {
|
||||
minimum: 20;
|
||||
maximum: 100;
|
||||
has_reset: false;
|
||||
enabled <=> SystemPageData.charge_control_enabled;
|
||||
value: SystemPageData.charge_control_end_threshold;
|
||||
released => {
|
||||
SystemPageData.charge_control_end_threshold = self.value;
|
||||
@@ -249,13 +255,22 @@ export component PageSystem inherits Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
Switch {
|
||||
text: @tr("ppt_group_enabled" => "Enable Tuning");
|
||||
if !SystemPageData.ppt_enabled_available: Switch {
|
||||
text: @tr("ppt_group_enabled" => "Enable Tuning");
|
||||
checked <=> SystemPageData.enable_ppt_group;
|
||||
toggled => {
|
||||
SystemPageData.cb_enable_ppt_group(SystemPageData.enable_ppt_group)
|
||||
}
|
||||
}
|
||||
if SystemPageData.ppt_enabled_available: Switch {
|
||||
text: @tr("ppt_group_enabled" => "Enable Tuning");
|
||||
checked <=> SystemPageData.ppt_enabled;
|
||||
toggled => {
|
||||
SystemPageData.enable_ppt_group = self.checked;
|
||||
SystemPageData.cb_ppt_enabled(SystemPageData.ppt_enabled)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if SystemPageData.ppt_pl1_spl.current != -1: SystemSlider {
|
||||
|
||||
@@ -4,6 +4,7 @@ export enum Profile {
|
||||
Balanced,
|
||||
Performance,
|
||||
Quiet,
|
||||
LowPower,
|
||||
}
|
||||
|
||||
export enum FanType {
|
||||
|
||||
@@ -12,7 +12,7 @@ export component RogItem inherits Rectangle {
|
||||
export component SystemSlider inherits RogItem {
|
||||
in property <string> title;
|
||||
in property <string> text;
|
||||
in-out property <bool> enabled;
|
||||
in-out property <bool> enabled: true;
|
||||
in-out property <float> value;
|
||||
in-out property <float> minimum;
|
||||
in-out property <float> maximum;
|
||||
|
||||
@@ -54,7 +54,7 @@ pub async fn has_iface(iface: &str) -> Result<bool, Box<dyn std::error::Error>>
|
||||
|
||||
pub async fn find_iface_async<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
|
||||
where
|
||||
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>
|
||||
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>,
|
||||
{
|
||||
let conn = zbus::Connection::system().await?;
|
||||
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").await?;
|
||||
@@ -82,7 +82,7 @@ where
|
||||
.path(path.clone())?
|
||||
.destination("xyz.ljones.Asusd")?
|
||||
.build()
|
||||
.await?
|
||||
.await?,
|
||||
);
|
||||
}
|
||||
return Ok(ctrl);
|
||||
|
||||
@@ -57,6 +57,6 @@ pub trait FanCurves {
|
||||
&self,
|
||||
profile: PlatformProfile,
|
||||
fan: FanCurvePU,
|
||||
enabled: bool
|
||||
enabled: bool,
|
||||
) -> zbus::Result<()>;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ pub trait Platform {
|
||||
#[zbus(property)]
|
||||
fn set_platform_profile_on_battery(
|
||||
&self,
|
||||
platform_profile: PlatformProfile
|
||||
platform_profile: PlatformProfile,
|
||||
) -> zbus::Result<()>;
|
||||
|
||||
/// ChangeThrottlePolicyOnAc property
|
||||
@@ -99,6 +99,10 @@ pub trait Platform {
|
||||
#[zbus(property)]
|
||||
fn set_profile_quiet_epp(&self, epp: CPUEPP) -> zbus::Result<()>;
|
||||
|
||||
/// PlatformProfileChoices property
|
||||
#[zbus(property)]
|
||||
fn platform_profile_choices(&self) -> zbus::Result<Vec<PlatformProfile>>;
|
||||
|
||||
/// ThrottlePolicy property
|
||||
#[zbus(property)]
|
||||
fn platform_profile(&self) -> zbus::Result<PlatformProfile>;
|
||||
|
||||
@@ -60,4 +60,10 @@ pub trait Slash {
|
||||
fn show_on_sleep(&self) -> zbus::Result<bool>;
|
||||
#[zbus(property)]
|
||||
fn set_show_on_sleep(&self, value: bool) -> zbus::Result<()>;
|
||||
|
||||
/// ShowOnLidClosed property
|
||||
#[zbus(property)]
|
||||
fn show_on_lid_closed(&self) -> zbus::Result<bool>;
|
||||
#[zbus(property)]
|
||||
fn set_show_on_lid_closed(&self, value: bool) -> zbus::Result<()>;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
usb_node = Some(node);
|
||||
println!("Looked for keyboard controller 0x{}: Found", id);
|
||||
}
|
||||
Err(err) => println!("Looked for keyboard controller: {err}")
|
||||
Err(err) => println!("Looked for keyboard controller: {err}"),
|
||||
}
|
||||
|
||||
if usb_node.is_none() {
|
||||
@@ -24,7 +24,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
|
||||
let x_stable = 2107;
|
||||
@@ -72,7 +72,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
node.write_bytes(&packet)?;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
];
|
||||
node.write_bytes(&packet)?;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
usb_node = Some(node);
|
||||
println!("Looked for keyboard controller 0x{}: Found", id);
|
||||
}
|
||||
Err(err) => println!("Looked for keyboard controller: {err}")
|
||||
Err(err) => println!("Looked for keyboard controller: {err}"),
|
||||
}
|
||||
|
||||
if usb_node.is_none() {
|
||||
@@ -24,31 +24,31 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
// node.write_bytes(&[0x5a, 0xd1, 0x0a, 0x01])?; // TODO: need to CHECK
|
||||
println!("Set mouse mode for 10 seconds");
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x03
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x03,
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x0f, 0x20
|
||||
0x5a, 0xd1, 0x0f, 0x20,
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x00
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x00,
|
||||
])?;
|
||||
sleep(Duration::from_secs(10));
|
||||
|
||||
println!("Set wasd mode for 10 seconds");
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x02
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x02,
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x0f, 0x20
|
||||
0x5a, 0xd1, 0x0f, 0x20,
|
||||
])?;
|
||||
sleep(Duration::from_secs(10));
|
||||
|
||||
println!("Set back to gamepad mode");
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x01
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x01,
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x0f, 0x20
|
||||
0x5a, 0xd1, 0x0f, 0x20,
|
||||
])?;
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -10,7 +10,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
usb_node = Some(node);
|
||||
println!("Looked for keyboard controller 0x{}: Found", id);
|
||||
}
|
||||
Err(err) => println!("Looked for keyboard controller: {err}")
|
||||
Err(err) => println!("Looked for keyboard controller: {err}"),
|
||||
}
|
||||
|
||||
if usb_node.is_none() {
|
||||
@@ -22,13 +22,13 @@ pub fn main() -> Result<(), Box<dyn Error>> {
|
||||
// node.write_bytes(&[0x5a, 0xd1, 0x0a, 0x01])?; // TODO: need to CHECK
|
||||
println!("Set mouse mode for 10 seconds");
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x03
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x03,
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x0f, 0x20
|
||||
0x5a, 0xd1, 0x0f, 0x20,
|
||||
])?;
|
||||
node.write_bytes(&[
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x00
|
||||
0x5a, 0xd1, 0x01, 0x01, 0x00,
|
||||
])?;
|
||||
// sleep(Duration::from_secs(10));
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user