Compare commits

...

54 Commits

Author SHA1 Message Date
Luke Jones ae8ce83583 Fix slash enable 2025-02-17 11:38:29 +13:00
Luke Jones 5c3348a9f5 Add small env fixes for Ally
Signed-off-by: Luke Jones <luke@ljones.dev>
2025-02-16 23:18:58 +13:00
Luke Jones f299ffeb6e Disable skia again, new release 2025-02-16 21:46:04 +13:00
Luke Jones 21c468cf02 Update supergfx
Signed-off-by: Luke Jones <luke@ljones.dev>
2025-02-16 11:50:56 +13:00
Luke Jones 7f12f62ad5 Temp 2025-02-16 09:38:33 +13:00
Luke Jones 5fb0e26331 Fix git losing the last set of fixes. Prep new release
Signed-off-by: Luke Jones <luke@ljones.dev>
2025-02-14 22:23:11 +13:00
Luke Jones 4dd29952c8 Fix the handling of of the kernel change from "quiet" to "low-power"
A coming kernel change will convert "quiet" to "low-power" due to how
platform_profile can now have multiple registered handlers.
(kernel 6.14 est)

Fixes #609
2025-02-14 20:02:08 +13:00
Luke Jones 2c006699f2 Reformat with trailing comma 2025-02-14 20:00:11 +13:00
Luke Jones 0bdf0474c9 Small error message fix 2025-02-14 20:00:11 +13:00
Kamo Kuma 66196ceb17 systemctl is-enabled can return 'linked' even if service is enabled. 2025-02-10 21:00:21 -05:00
Luke Jones b2726f3a67 Fix: charge control 2025-02-10 22:18:34 +13:00
Luke Jones 663f87d5e2 Checkpoint 2025-02-10 13:56:26 +13:00
Luke Jones 377bb4d6ad Merge branch 'private/Rohitrajak1807/G513RW-ledfix' into 'main'
Add ROG G513RW led cfgs

See merge request asus-linux/asusctl!217
2025-02-10 00:55:33 +00:00
Rohit Rajak 98e60db2da Add ROG G513RW led cfgs 2025-02-10 00:55:33 +00:00
Luke Jones 11ac46df11 Edit README.md 2025-02-08 02:39:30 +00:00
Luke Jones 05bec93644 Edit README.md 2025-02-08 02:33:08 +00:00
Luke Jones c77e7cf1ce Fix: correction to wrong matching function used for aura data find
Closes #607
2025-02-07 09:45:05 +13:00
Luke Jones d30f7dc2ea Merge branch 'main' into 'main'
feat (rog-aura): ASUS TUF FA617NS AURA Support

See merge request asus-linux/asusctl!214
2025-02-05 02:58:05 +00:00
Luke Jones 759606fca3 Merge branch 'aura' into 'main'
Update 'led-mode' -> 'aura' in example command.

See merge request asus-linux/asusctl!215
2025-02-05 02:57:38 +00:00
Luke Jones 25ed8bdeed Fix spelling mistake 2025-02-05 14:35:17 +13:00
Luke Jones de61a15b7a Prep 6.1.0 2025-02-04 18:52:55 +13:00
Luke Jones 16700e55f4 ROGCC: refactor many more parts of the PPT settings 2025-02-04 18:50:48 +13:00
Luke Jones 5833a011ce Merge branch 'g513rc-zonefix' into 'main'
Add basic zones for G513RC

See merge request asus-linux/asusctl!216
2025-02-03 04:08:29 +00:00
loystonpais 62577ee0e4 Add basic zones for G513RC 2025-02-03 07:36:32 +05:30
Luke Jones dac35996b1 Enable use of GAMESCOPE_WAYLAND_DISPLAY 2025-02-02 20:02:51 +13:00
Luke Jones 5c2bcad7c6 Various UI fixes 2025-02-01 20:31:09 +13:00
armdebug 81f6c18a24 Update 'led-mode' -> 'aura' in example command.
led-mode is renamed to aura in 19ffcf3376
2025-01-28 02:18:56 +05:30
riarumoda bcc3d42789 feat (rog-aura): ASUS TUF FA617NS AURA Support 2025-01-23 15:14:52 +08:00
Luke Jones 36c34cb3dd Merge branch 'fix/anime-animation-crash' into 'main'
fix: Use spawn instead of spawn_local in anime animation callback

Closes #588

See merge request asus-linux/asusctl!213
2025-01-22 02:05:04 +00:00
I-Al-Istannen 9b82b875f1 fix: Use spawn instead of spawn_local in anime animation callback
Closes #588
2025-01-21 21:04:20 +01:00
Luke D. Jones bddccc696f Update deps 2025-01-21 19:49:20 +13:00
Luke D. Jones 51e9f10087 Prep 6.1.0-rc7 2025-01-21 16:44:58 +13:00
Luke D. Jones 911ff8690e feature: rework PPT tuning handling more
1. Per profile, per-ac/dc
2. Do not apply unless group is enabled
3. Better reset/disable handling
4. Selecting a profile defaults PPT to off/disabled
2025-01-21 16:39:34 +13:00
Luke D. Jones 25823dc6b7 asusd: anime: don't cause async deadlocks damnit
Same old song, an async mutex lock being held for a wide scope.
In particular being held for a scope that includes a function call which
also tries to get the lock.

Fix it by copy/clone of the config interior values required.

Fixes #588
2025-01-21 12:24:24 +13:00
Luke D. Jones cba8e1a473 Add extra debug logging to anime path 2025-01-20 13:43:38 +13:00
Luke D. Jones fb98827a1a Prep 6.1.0-rc6 2025-01-19 23:35:32 +13:00
Luke D. Jones b9296862df Move entirely to using only platform-profile
throttle_thermal_policy is not ideal anymore and may be
removed from kernel in the future.
2025-01-19 21:52:32 +13:00
Luke D. Jones 450205f9a9 Bug fix: correctly set charge limit from UI 2025-01-19 17:29:36 +13:00
Luke D. Jones 82431ee25b Prep 6.1.0-rc5 2025-01-19 16:11:48 +13:00
Luke D. Jones f11aea02a8 Add help and reset to UI for ppt values 2025-01-19 16:01:57 +13:00
Luke D. Jones 2d6d669c22 PPT restor defaults (WIP) 2025-01-19 12:02:22 +13:00
Luke D. Jones f9cebf9221 Per-AC/DC per-profile tunings enabled 2025-01-19 11:33:48 +13:00
Luke D. Jones a00808313e Prep 6.1.0-rc4 2025-01-18 23:11:46 +13:00
Luke D. Jones 3426591d32 Finalise per-profile PPT settings 2025-01-18 22:46:50 +13:00
Luke D. Jones ef3b6636f5 Allow each performance profile to have different PPT values 2025-01-18 21:54:37 +13:00
Luke D. Jones ee9e0a1e31 Fix: ROGCC: fix anime matrix settings 2025-01-18 21:27:57 +13:00
Luke D. Jones 9e84997cbf Fix: ROGCC: don't crash out if no tray area available 2025-01-18 20:54:25 +13:00
Luke D. Jones 2b22f82b72 Cleanup unsafe sysfs interfaces. Bugfixes for UI 2025-01-16 23:56:12 +13:00
Luke D. Jones 7a1b45071d Correct changelog rc3 tag 2025-01-15 22:25:24 +13:00
Luke D. Jones ad63c429cb Bugfix: urgent small fixes 2025-01-15 22:19:46 +13:00
Luke D. Jones a790d9a499 Remove dangerous use of ppt* in platform, add use of ppt_pl3_fppt in asus_armoury handler 2025-01-13 23:18:19 +13:00
Luke D. Jones be51a1ab77 Disable strip in Makefile 2025-01-13 22:38:30 +13:00
Luke D. Jones d9a88e7cc3 Notify user via message in UI if asus-armoury not loaded 2025-01-13 14:32:13 +13:00
Luke D. Jones d785e17f95 Allow version in makefile to have '-rc*' 2025-01-12 18:52:45 +13:00
136 changed files with 4689 additions and 3013 deletions
+84
View File
@@ -2,6 +2,90 @@
## [Unreleased] ## [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]
### Changed
- Update deps
- Add support for G513RC RGB modes
- Many UI fixes
- Fixes to PPT settings in UI
## [v6.1.0-rc7]
- Refactor PPT handling more:
1. Per profile, per-ac/dc
2. Do not apply unless group is enabled
3. Better reset/disable handling
4. Selecting a profile defaults PPT to off/disabled
- Bugfix: prevent an AniMe thread async deadlock
## [v6.1.0-rc6]
### Changed
- Two small fixes, one for `low-power` profile name, and one for base gpu tdp
- Move to using platform_profile api only (no throttle_thermal_policy)
## [v6.1.0-rc5]
### Changed
- Per-AC/DC, per-profile tunings enabled (Battery vs AC power + platform profile)
- Add ability to restore PPT defaults
- Add PPT help dialogue to UI
- Bug fix: correctly set charge limit from UI
## [v6.1.0-rc4]
### Changed
- Bug fix: UI was setting incorrect value for FPPT
- Bug fix: Re-add callbacks for the throttle and epp settings in UI
- Bug fix: Fix UI settigns for AniMe Matrix display
- Bug fix: better handle missing tray (for example gnome)
- Strip out all outdated and unsafe tuning stuff
- Allow each performance profile to have different PPT settings
## [v6.1.0-rc3]
### Changed
- Bug fixes
- Partial support for per-profile CPU tunings (WIP)
## [v6.1.0-rc2] ## [v6.1.0-rc2]
### Added ### Added
Generated
+1360 -533
View File
File diff suppressed because it is too large Load Diff
+9 -8
View File
@@ -1,5 +1,5 @@
[workspace.package] [workspace.package]
version = "6.1.0-rc2" version = "6.1.7"
rust-version = "1.82" rust-version = "1.82"
license = "MPL-2.0" license = "MPL-2.0"
readme = "README.md" readme = "README.md"
@@ -43,8 +43,9 @@ dirs = "^4.0"
smol = "^2.0" smol = "^2.0"
mio = "0.8.11" mio = "0.8.11"
zbus = "5.1" futures-util = "0.3.31"
logind-zbus = { version = "5.0.0" } #, default-features = false, features = ["non_blocking"] } zbus = "5.5.0"
logind-zbus = { version = "5.2.0" } #, default-features = false, features = ["non_blocking"] }
serde = { version = "^1.0", features = ["serde_derive"] } serde = { version = "^1.0", features = ["serde_derive"] }
ron = "*" ron = "*"
@@ -65,26 +66,26 @@ gif = "^0.12.0"
versions = "6.2" 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" } sg = { git = "https://github.com/flukejones/sg-rs.git" }
[profile.release] [profile.release]
# thin = 57s, asusd = 9.0M # thin = 57s, asusd = 9.0M
# fat = 72s, asusd = 6.4M # fat = 72s, asusd = 6.4M
lto = "fat" lto = "thin"
debug = false debug = false
opt-level = 3 opt-level = 3
panic = "abort" panic = "abort"
codegen-units = 1 # codegen-units = 1
[profile.dev] [profile.dev]
opt-level = 1 opt-level = 1
codegen-units = 16 # codegen-units = 1
[profile.dev.package."*"] [profile.dev.package."*"]
opt-level = 1 opt-level = 1
codegen-units = 16 # codegen-units = 1
[profile.bench] [profile.bench]
debug = false debug = false
+3 -3
View File
@@ -48,7 +48,7 @@ The LED controller (e.g, aura) enables setting many of the factory modes availab
#### Supported laptops #### 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 ### Charge control
@@ -420,13 +420,13 @@ To switch to next/previous Aura modes you will need to bind both the aura keys (
**Next** **Next**
``` ```
asusctl led-mode -n asusctl aura -n
``` ```
**Previous** **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`. To switch Fan/Thermal profiles you need to bind the Fn+F5 key to `asusctl profile -n`.
+2 -2
View File
@@ -1,4 +1,4 @@
VERSION := $(shell /usr/bin/grep -Pm1 'version = "(\d+.\d+.\d+)"' Cargo.toml | cut -d'"' -f2) VERSION := $(shell /usr/bin/grep -Pm1 'version = "(\d+.\d+.\d+.*)"' Cargo.toml | cut -d'"' -f2)
INSTALL = install INSTALL = install
INSTALL_PROGRAM = ${INSTALL} -D -m 0755 INSTALL_PROGRAM = ${INSTALL} -D -m 0755
@@ -19,7 +19,7 @@ LEDCFG := aura_support.ron
SRC := Cargo.toml Cargo.lock Makefile $(shell find -type f -wholename '**/src/*.rs') SRC := Cargo.toml Cargo.lock Makefile $(shell find -type f -wholename '**/src/*.rs')
STRIP_BINARIES ?= 1 STRIP_BINARIES ?= 0
DEBUG ?= 0 DEBUG ?= 0
ifeq ($(DEBUG),0) ifeq ($(DEBUG),0)
+1 -1
View File
@@ -39,7 +39,7 @@ See the [rog-aura readme](./rog-aura/README.md) for more details.
## Discord ## Discord
[![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/z8y99XqPb7) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/B8GftRW2Hd)
## SUPPORTED LAPTOPS ## SUPPORTED LAPTOPS
+3 -1
View File
@@ -18,10 +18,12 @@ rog_profiles = { path = "../rog-profiles" }
rog_platform = { path = "../rog-platform" } rog_platform = { path = "../rog-platform" }
dmi_id = { path = "../dmi-id" } dmi_id = { path = "../dmi-id" }
log.workspace = true
env_logger.workspace = true
ron.workspace = true ron.workspace = true
gumdrop.workspace = true gumdrop.workspace = true
zbus.workspace = true zbus.workspace = true
[dev-dependencies] [dev-dependencies]
rog_dbus = { path = "../rog-dbus" } rog_dbus = { path = "../rog-dbus" }
+1 -1
View File
@@ -23,7 +23,7 @@ fn main() -> Result<(), Box<dyn Error>> {
Path::new(&args[1]), Path::new(&args[1]),
None, None,
args[2].parse::<f32>().unwrap(), args[2].parse::<f32>().unwrap(),
AnimeType::GA401 AnimeType::GA401,
)?; )?;
let anime_type = get_anime_type(); let anime_type = get_anime_type();
+1 -1
View File
@@ -24,7 +24,7 @@ fn main() {
seq.insert(0, &ActionLoader::AsusAnimation { seq.insert(0, &ActionLoader::AsusAnimation {
file: path.into(), file: path.into(),
time: rog_anime::AnimTime::Infinite, time: rog_anime::AnimTime::Infinite,
brightness brightness,
}) })
.unwrap(); .unwrap();
+2 -2
View File
@@ -27,10 +27,10 @@ fn main() -> Result<(), Box<dyn Error>> {
args[3].parse::<f32>().unwrap(), args[3].parse::<f32>().unwrap(),
Vec2::new( Vec2::new(
args[4].parse::<f32>().unwrap(), args[4].parse::<f32>().unwrap(),
args[5].parse::<f32>().unwrap() args[5].parse::<f32>().unwrap(),
), ),
args[6].parse::<f32>().unwrap(), args[6].parse::<f32>().unwrap(),
anime_type anime_type,
)?; )?;
proxy.write(<AnimeDataBuffer>::try_from(&matrix)?).unwrap(); proxy.write(<AnimeDataBuffer>::try_from(&matrix)?).unwrap();
+2 -2
View File
@@ -30,10 +30,10 @@ fn main() -> Result<(), Box<dyn Error>> {
args[3].parse::<f32>().unwrap(), args[3].parse::<f32>().unwrap(),
Vec2::new( Vec2::new(
args[4].parse::<f32>().unwrap(), args[4].parse::<f32>().unwrap(),
args[5].parse::<f32>().unwrap() args[5].parse::<f32>().unwrap(),
), ),
args[6].parse::<f32>().unwrap(), args[6].parse::<f32>().unwrap(),
anime_type anime_type,
)?; )?;
loop { loop {
+2 -2
View File
@@ -36,10 +36,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Colour { Colour {
r: 200, r: 200,
g: 110, g: 110,
b: 0 b: 0,
}, },
100, 100,
10 10,
)); ));
seq.push(zone); seq.push(zone);
+7 -7
View File
@@ -40,7 +40,7 @@ pub struct AnimeCommand {
#[options(no_short, meta = "", help = "Off with his head!!!")] #[options(no_short, meta = "", help = "Off with his head!!!")]
pub off_with_his_head: Option<bool>, pub off_with_his_head: Option<bool>,
#[options(command)] #[options(command)]
pub command: Option<AnimeActions> pub command: Option<AnimeActions>,
} }
#[derive(Options)] #[derive(Options)]
@@ -54,7 +54,7 @@ pub enum AnimeActions {
#[options(help = "display an animated diagonal/pixel-perfect GIF")] #[options(help = "display an animated diagonal/pixel-perfect GIF")]
PixelGif(AnimeGifDiagonal), PixelGif(AnimeGifDiagonal),
#[options(help = "change which builtin animations are shown")] #[options(help = "change which builtin animations are shown")]
SetBuiltins(Builtins) SetBuiltins(Builtins),
} }
#[derive(Options)] #[derive(Options)]
@@ -82,7 +82,7 @@ pub struct Builtins {
)] )]
pub shutdown: AnimShutdown, pub shutdown: AnimShutdown,
#[options(meta = "", help = "set/apply the animations <true/false>")] #[options(meta = "", help = "set/apply the animations <true/false>")]
pub set: Option<bool> pub set: Option<bool>,
} }
#[derive(Options)] #[derive(Options)]
@@ -100,7 +100,7 @@ pub struct AnimeImage {
#[options(meta = "", default = "0.0", help = "the angle in radians")] #[options(meta = "", default = "0.0", help = "the angle in radians")]
pub angle: f32, pub angle: f32,
#[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")] #[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")]
pub bright: f32 pub bright: f32,
} }
#[derive(Options)] #[derive(Options)]
@@ -110,7 +110,7 @@ pub struct AnimeImageDiagonal {
#[options(meta = "", help = "full path to the png to display")] #[options(meta = "", help = "full path to the png to display")]
pub path: String, pub path: String,
#[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")] #[options(meta = "", default = "1.0", help = "brightness 0.0-1.0")]
pub bright: f32 pub bright: f32,
} }
#[derive(Options)] #[derive(Options)]
@@ -134,7 +134,7 @@ pub struct AnimeGif {
default = "1", default = "1",
help = "how many loops to play - 0 is infinite" help = "how many loops to play - 0 is infinite"
)] )]
pub loops: u32 pub loops: u32,
} }
#[derive(Options)] #[derive(Options)]
@@ -150,5 +150,5 @@ pub struct AnimeGifDiagonal {
default = "1", default = "1",
help = "how many loops to play - 0 is infinite" help = "how many loops to play - 0 is infinite"
)] )]
pub loops: u32 pub loops: u32,
} }
+14 -14
View File
@@ -17,7 +17,7 @@ pub struct LedPowerCommand1 {
#[options(meta = "", help = "Control boot animations <true/false>")] #[options(meta = "", help = "Control boot animations <true/false>")]
pub boot: Option<bool>, pub boot: Option<bool>,
#[options(meta = "", help = "Control suspend animations <true/false>")] #[options(meta = "", help = "Control suspend animations <true/false>")]
pub sleep: Option<bool> pub sleep: Option<bool>,
} }
#[derive(Options, Debug)] #[derive(Options, Debug)]
@@ -25,7 +25,7 @@ pub struct LedPowerCommand2 {
#[options(help = "print help message")] #[options(help = "print help message")]
pub help: bool, pub help: bool,
#[options(command)] #[options(command)]
pub command: Option<SetAuraZoneEnabled> pub command: Option<SetAuraZoneEnabled>,
} }
#[derive(Options, Debug)] #[derive(Options, Debug)]
@@ -42,7 +42,7 @@ pub enum SetAuraZoneEnabled {
#[options(help = "")] #[options(help = "")]
RearGlow(AuraPowerStates), RearGlow(AuraPowerStates),
#[options(help = "")] #[options(help = "")]
Ally(AuraPowerStates) Ally(AuraPowerStates),
} }
#[derive(Debug, Clone, Options)] #[derive(Debug, Clone, Options)]
@@ -56,12 +56,12 @@ pub struct AuraPowerStates {
#[options(help = "defaults to false if option unused")] #[options(help = "defaults to false if option unused")]
pub sleep: bool, pub sleep: bool,
#[options(help = "defaults to false if option unused")] #[options(help = "defaults to false if option unused")]
pub shutdown: bool pub shutdown: bool,
} }
#[derive(Options)] #[derive(Options)]
pub struct LedBrightness { pub struct LedBrightness {
level: Option<u8> level: Option<u8>,
} }
impl LedBrightness { impl LedBrightness {
pub fn new(level: Option<u8>) -> Self { pub fn new(level: Option<u8>) -> Self {
@@ -96,7 +96,7 @@ impl ToString for LedBrightness {
Some(0x00) => "low", Some(0x00) => "low",
Some(0x01) => "med", Some(0x01) => "med",
Some(0x02) => "high", Some(0x02) => "high",
_ => "unknown" _ => "unknown",
}; };
s.to_owned() s.to_owned()
} }
@@ -113,7 +113,7 @@ pub struct SingleSpeed {
meta = "", meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left" 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)] #[derive(Debug, Clone, Options, Default)]
@@ -129,7 +129,7 @@ pub struct SingleSpeedDirection {
meta = "", meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left" 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)] #[derive(Debug, Clone, Default, Options)]
@@ -143,7 +143,7 @@ pub struct SingleColour {
meta = "", meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left" 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)] #[derive(Debug, Clone, Default, Options)]
@@ -159,7 +159,7 @@ pub struct SingleColourSpeed {
meta = "", meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left" 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)] #[derive(Debug, Clone, Options, Default)]
@@ -177,7 +177,7 @@ pub struct TwoColourSpeed {
meta = "", meta = "",
help = "set the zone for this effect e.g, 0, 1, one, logo, lightbar-left" 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)] #[derive(Debug, Clone, Default, Options)]
@@ -191,7 +191,7 @@ pub struct MultiZone {
#[options(short = "c", meta = "", help = "set the RGB value e.g, ff00ff")] #[options(short = "c", meta = "", help = "set the RGB value e.g, ff00ff")]
pub colour3: Colour, pub colour3: Colour,
#[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")] #[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")]
pub colour4: Colour pub colour4: Colour,
} }
#[derive(Debug, Clone, Default, Options)] #[derive(Debug, Clone, Default, Options)]
@@ -207,7 +207,7 @@ pub struct MultiColourSpeed {
#[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")] #[options(short = "d", meta = "", help = "set the RGB value e.g, ff00ff")]
pub colour4: Colour, pub colour4: Colour,
#[options(no_long, meta = "", help = "set the speed: low, med, high")] #[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. /// Byte value for setting the built-in mode.
@@ -239,7 +239,7 @@ pub enum SetAuraBuiltin {
#[options(help = "set a vertical line zooming from left")] #[options(help = "set a vertical line zooming from left")]
Comet(SingleColour), // 11 Comet(SingleColour), // 11
#[options(help = "set a wide vertical line zooming from left")] #[options(help = "set a wide vertical line zooming from left")]
Flash(SingleColour) // 12 Flash(SingleColour), // 12
} }
impl Default for SetAuraBuiltin { impl Default for SetAuraBuiltin {
+10 -42
View File
@@ -1,5 +1,5 @@
use gumdrop::Options; use gumdrop::Options;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use crate::anime_cli::AnimeCommand; use crate::anime_cli::AnimeCommand;
use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin}; use crate::aura_cli::{LedBrightness, LedPowerCommand1, LedPowerCommand2, SetAuraBuiltin};
@@ -26,7 +26,7 @@ pub struct CliStart {
#[options(help = "Toggle one-shot battery charge to 100%")] #[options(help = "Toggle one-shot battery charge to 100%")]
pub one_shot_chg: bool, pub one_shot_chg: bool,
#[options(command)] #[options(command)]
pub command: Option<CliCommand> pub command: Option<CliCommand>,
} }
#[derive(Options)] #[derive(Options)]
@@ -49,13 +49,11 @@ pub enum CliCommand {
Slash(SlashCommand), Slash(SlashCommand),
#[options(name = "scsi", help = "Manage SCSI external drive")] #[options(name = "scsi", help = "Manage SCSI external drive")]
Scsi(ScsiCommand), Scsi(ScsiCommand),
#[options(help = "Change bios settings")]
PlatformOld(PlatformCommand),
#[options( #[options(
help = "Change platform settings. This is a new interface exposed by the asus-armoury \ 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" driver, some of the settings will be the same as the older platform interface"
)] )]
Armoury(ArmouryCommand) Armoury(ArmouryCommand),
} }
#[derive(Debug, Clone, Options)] #[derive(Debug, Clone, Options)]
@@ -73,7 +71,7 @@ pub struct ProfileCommand {
pub profile_get: bool, pub profile_get: bool,
#[options(meta = "", help = "set the active profile")] #[options(meta = "", help = "set the active profile")]
pub profile_set: Option<ThrottlePolicy> pub profile_set: Option<PlatformProfile>,
} }
#[derive(Options)] #[derive(Options)]
@@ -85,52 +83,22 @@ pub struct LedModeCommand {
#[options(help = "switch to previous aura mode")] #[options(help = "switch to previous aura mode")]
pub prev_mode: bool, pub prev_mode: bool,
#[options(command)] #[options(command)]
pub command: Option<SetAuraBuiltin> pub command: Option<SetAuraBuiltin>,
} }
#[derive(Options)] #[derive(Options)]
pub struct GraphicsCommand { pub struct GraphicsCommand {
#[options(help = "print help message")]
pub help: bool
}
#[derive(Options, Debug)]
pub struct PlatformCommand {
#[options(help = "print help message")] #[options(help = "print help message")]
pub help: bool, pub help: bool,
#[options(
meta = "",
short = "S",
no_long,
help = "set bios POST sound: asusctl -S <true/false>"
)]
pub post_sound_set: Option<bool>,
#[options(no_long, short = "s", help = "read bios POST sound")]
pub post_sound_get: bool,
#[options(
meta = "",
short = "D",
no_long,
help = "Switch GPU MUX mode: 0 = Discrete, 1 = Optimus, reboot required"
)]
pub gpu_mux_mode_set: Option<u8>,
#[options(no_long, short = "d", help = "get GPU mode")]
pub gpu_mux_mode_get: bool,
#[options(
meta = "",
short = "O",
no_long,
help = "Set device panel overdrive <true/false>"
)]
pub panel_overdrive_set: Option<bool>,
#[options(no_long, short = "o", help = "get panel overdrive")]
pub panel_overdrive_get: bool
} }
#[derive(Options, Debug)] #[derive(Options, Debug)]
pub struct ArmouryCommand { pub struct ArmouryCommand {
#[options(help = "print help message")] #[options(help = "print help message")]
pub help: bool, pub help: bool,
#[options(free)] #[options(
pub free: Vec<String> free,
help = "append each value name followed by the value to set. `-1` sets to default"
)]
pub free: Vec<String>,
} }
+3 -3
View File
@@ -1,5 +1,5 @@
use gumdrop::Options; use gumdrop::Options;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
@@ -18,7 +18,7 @@ pub struct FanCurveCommand {
meta = "", meta = "",
help = "profile to modify fan-curve for. Shows data if no options provided" help = "profile to modify fan-curve for. Shows data if no options provided"
)] )]
pub mod_profile: Option<ThrottlePolicy>, pub mod_profile: Option<PlatformProfile>,
#[options( #[options(
meta = "", meta = "",
@@ -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%. \ 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" `--mod-profile` required. If '%' is omitted the fan range is 0-255"
)] )]
pub data: Option<CurveData> pub data: Option<CurveData>,
} }
+62 -98
View File
@@ -9,6 +9,7 @@ use aura_cli::{LedPowerCommand1, LedPowerCommand2};
use dmi_id::DMIID; use dmi_id::DMIID;
use fan_curve_cli::FanCurveCommand; use fan_curve_cli::FanCurveCommand;
use gumdrop::{Opt, Options}; use gumdrop::{Opt, Options};
use log::{error, info};
use rog_anime::usb::get_anime_type; use rog_anime::usb::get_anime_type;
use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2}; use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage, AnimeType, Vec2};
use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower}; use rog_aura::keyboard::{AuraPowerState, LaptopAuraPower};
@@ -21,7 +22,7 @@ use rog_dbus::zbus_aura::AuraProxyBlocking;
use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking; use rog_dbus::zbus_fan_curves::FanCurvesProxyBlocking;
use rog_dbus::zbus_platform::PlatformProxyBlocking; use rog_dbus::zbus_platform::PlatformProxyBlocking;
use rog_dbus::zbus_slash::SlashProxyBlocking; use rog_dbus::zbus_slash::SlashProxyBlocking;
use rog_platform::platform::{GpuMode, Properties, ThrottlePolicy}; use rog_platform::platform::{PlatformProfile, Properties};
use rog_profiles::error::ProfileError; use rog_profiles::error::ProfileError;
use rog_scsi::AuraMode; use rog_scsi::AuraMode;
use rog_slash::SlashMode; use rog_slash::SlashMode;
@@ -42,6 +43,14 @@ mod scsi_cli;
mod slash_cli; mod slash_cli;
fn main() { fn main() {
let mut logger = env_logger::Builder::new();
logger
.parse_default_env()
.target(env_logger::Target::Stdout)
.format_timestamp(None)
.filter_level(log::LevelFilter::Debug)
.init();
let self_version = env!("CARGO_PKG_VERSION"); let self_version = env!("CARGO_PKG_VERSION");
println!("Starting version {self_version}"); println!("Starting version {self_version}");
let args: Vec<String> = args().skip(1).collect(); let args: Vec<String> = args().skip(1).collect();
@@ -65,7 +74,15 @@ fn main() {
println!("\nError: {e}\n"); println!("\nError: {e}\n");
print_info(); print_info();
}) { }) {
let asusd_version = platform_proxy.version().unwrap(); let asusd_version = platform_proxy
.version()
.map_err(|e| {
error!(
"Could not get asusd version: {e:?}\nIs asusd.service running? {}",
check_service("asusd")
);
})
.unwrap();
if asusd_version != self_version { if asusd_version != self_version {
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}"); println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
return; return;
@@ -89,7 +106,7 @@ fn main() {
fn print_error_help( fn print_error_help(
err: &dyn std::error::Error, err: &dyn std::error::Error,
supported_interfaces: &[String], supported_interfaces: &[String],
supported_properties: &[Properties] supported_properties: &[Properties],
) { ) {
check_service("asusd"); check_service("asusd");
println!("\nError: {}\n", err); println!("\nError: {}\n", err);
@@ -130,7 +147,7 @@ fn check_service(name: &str) -> bool {
fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>> fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where where
T: ProxyImpl<'static> + From<zbus::Proxy<'static>> T: ProxyImpl<'static> + From<zbus::Proxy<'static>>,
{ {
let conn = zbus::blocking::Connection::system().unwrap(); let conn = zbus::blocking::Connection::system().unwrap();
let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap(); let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
@@ -157,20 +174,20 @@ where
T::builder(&conn) T::builder(&conn)
.path(path.clone())? .path(path.clone())?
.destination("xyz.ljones.Asusd")? .destination("xyz.ljones.Asusd")?
.build()? .build()?,
); );
} }
return Ok(ctrl); return Ok(ctrl);
} }
Err("No Aura interface".into()) Err(format!("Did not find {iface_name}").into())
} }
fn do_parsed( fn do_parsed(
parsed: &CliStart, parsed: &CliStart,
supported_interfaces: &[String], supported_interfaces: &[String],
supported_properties: &[Properties], supported_properties: &[Properties],
conn: Connection conn: Connection,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
match &parsed.command { match &parsed.command {
Some(CliCommand::Aura(mode)) => handle_led_mode(mode)?, Some(CliCommand::Aura(mode)) => handle_led_mode(mode)?,
@@ -186,9 +203,6 @@ fn do_parsed(
Some(CliCommand::Anime(cmd)) => handle_anime(cmd)?, Some(CliCommand::Anime(cmd)) => handle_anime(cmd)?,
Some(CliCommand::Slash(cmd)) => handle_slash(cmd)?, Some(CliCommand::Slash(cmd)) => handle_slash(cmd)?,
Some(CliCommand::Scsi(cmd)) => handle_scsi(cmd)?, Some(CliCommand::Scsi(cmd)) => handle_scsi(cmd)?,
Some(CliCommand::PlatformOld(cmd)) => {
handle_platform_properties(&conn, supported_properties, cmd)?
}
Some(CliCommand::Armoury(cmd)) => handle_armoury_command(cmd)?, Some(CliCommand::Armoury(cmd)) => handle_armoury_command(cmd)?,
None => { None => {
if (!parsed.show_supported if (!parsed.show_supported
@@ -267,8 +281,8 @@ fn do_parsed(
} }
println!("\nExtra help can be requested on any command or subcommand:"); println!("\nExtra help can be requested on any command or subcommand:");
println!(" asusctl led-mode --help"); println!(" asusctl aura --help");
println!(" asusctl led-mode static --help"); println!(" asusctl aura static --help");
} }
} }
} }
@@ -281,7 +295,7 @@ fn do_parsed(
let level = aura.brightness()?; let level = aura.brightness()?;
println!("Current keyboard led brightness: {level:?}"); 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 { } else {
@@ -370,7 +384,12 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
println!("\n{}", lst); println!("\n{}", lst);
} }
} }
let animes = find_iface::<AnimeProxyBlocking>("xyz.ljones.Anime")?;
let animes = find_iface::<AnimeProxyBlocking>("xyz.ljones.Anime").map_err(|e| {
error!("Did not find any interface for xyz.ljones.Anime: {e:?}");
e
})?;
for proxy in animes { for proxy in animes {
if let Some(enable) = cmd.enable_display { if let Some(enable) = cmd.enable_display {
proxy.set_enable_display(enable)?; proxy.set_enable_display(enable)?;
@@ -425,7 +444,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
image.angle, image.angle,
Vec2::new(image.x_pos, image.y_pos), Vec2::new(image.x_pos, image.y_pos),
image.bright, image.bright,
anime_type anime_type,
)?; )?;
proxy.write(<AnimeDataBuffer>::try_from(&matrix)?)?; proxy.write(<AnimeDataBuffer>::try_from(&matrix)?)?;
@@ -444,7 +463,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
Path::new(&image.path), Path::new(&image.path),
None, None,
image.bright, image.bright,
anime_type anime_type,
)?; )?;
proxy.write(matrix.into_data_buffer(anime_type)?)?; proxy.write(matrix.into_data_buffer(anime_type)?)?;
@@ -466,7 +485,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
Vec2::new(gif.x_pos, gif.y_pos), Vec2::new(gif.x_pos, gif.y_pos),
AnimTime::Count(1), AnimTime::Count(1),
gif.bright, gif.bright,
anime_type anime_type,
)?; )?;
let mut loops = gif.loops as i32; let mut loops = gif.loops as i32;
@@ -497,7 +516,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
Path::new(&gif.path), Path::new(&gif.path),
AnimTime::Count(1), AnimTime::Count(1),
gif.bright, gif.bright,
anime_type anime_type,
)?; )?;
let mut loops = gif.loops as i32; let mut loops = gif.loops as i32;
@@ -530,7 +549,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
boot: builtins.boot, boot: builtins.boot,
awake: builtins.awake, awake: builtins.awake,
sleep: builtins.sleep, sleep: builtins.sleep,
shutdown: builtins.shutdown shutdown: builtins.shutdown,
})?; })?;
} }
} }
@@ -556,6 +575,7 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
&& cmd.show_on_sleep.is_none() && cmd.show_on_sleep.is_none()
&& cmd.show_on_battery.is_none() && cmd.show_on_battery.is_none()
&& cmd.show_battery_warning.is_none() && cmd.show_battery_warning.is_none()
// && cmd.show_on_lid_closed.is_none()
&& cmd.mode.is_none() && cmd.mode.is_none()
&& !cmd.list && !cmd.list
&& !cmd.enable && !cmd.enable
@@ -601,6 +621,9 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
if let Some(show) = cmd.show_battery_warning { if let Some(show) = cmd.show_battery_warning {
proxy.set_show_battery_warning(show)?; 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 { if cmd.list {
let res = SlashMode::list(); let res = SlashMode::list();
@@ -793,7 +816,7 @@ fn handle_led_power1(power: &LedPowerCommand1) -> Result<(), Box<dyn std::error:
fn handle_led_power_1_do_1866( fn handle_led_power_1_do_1866(
aura: &AuraProxyBlocking, aura: &AuraProxyBlocking,
power: &LedPowerCommand1 power: &LedPowerCommand1,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
let mut states = Vec::new(); let mut states = Vec::new();
if power.keyboard { if power.keyboard {
@@ -802,7 +825,7 @@ fn handle_led_power_1_do_1866(
boot: power.boot.unwrap_or_default(), boot: power.boot.unwrap_or_default(),
awake: power.awake.unwrap_or_default(), awake: power.awake.unwrap_or_default(),
sleep: power.sleep.unwrap_or_default(), sleep: power.sleep.unwrap_or_default(),
shutdown: false shutdown: false,
}); });
} }
if power.lightbar { if power.lightbar {
@@ -811,7 +834,7 @@ fn handle_led_power_1_do_1866(
boot: power.boot.unwrap_or_default(), boot: power.boot.unwrap_or_default(),
awake: power.awake.unwrap_or_default(), awake: power.awake.unwrap_or_default(),
sleep: power.sleep.unwrap_or_default(), sleep: power.sleep.unwrap_or_default(),
shutdown: false shutdown: false,
}); });
} }
@@ -873,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::Lightbar(l) => set(PowerZones::Lightbar, l),
aura_cli::SetAuraZoneEnabled::Lid(l) => set(PowerZones::Lid, l), aura_cli::SetAuraZoneEnabled::Lid(l) => set(PowerZones::Lid, l),
aura_cli::SetAuraZoneEnabled::RearGlow(r) => set(PowerZones::RearGlow, r), 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),
} }
} }
@@ -887,7 +910,7 @@ fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error:
fn handle_throttle_profile( fn handle_throttle_profile(
conn: &Connection, conn: &Connection,
supported: &[Properties], supported: &[Properties],
cmd: &ProfileCommand cmd: &ProfileCommand,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
if !supported.contains(&Properties::ThrottlePolicy) { if !supported.contains(&Properties::ThrottlePolicy) {
println!("Profiles not supported by either this kernel or by the laptop."); println!("Profiles not supported by either this kernel or by the laptop.");
@@ -907,17 +930,17 @@ fn handle_throttle_profile(
} }
let proxy = PlatformProxyBlocking::new(conn)?; let proxy = PlatformProxyBlocking::new(conn)?;
let current = proxy.throttle_thermal_policy()?; let current = proxy.platform_profile()?;
let choices = proxy.platform_profile_choices()?;
if cmd.next { if cmd.next {
proxy.set_throttle_thermal_policy(current.next())?; proxy.set_platform_profile(PlatformProfile::next(current, &choices))?;
} else if let Some(profile) = cmd.profile_set { } else if let Some(profile) = cmd.profile_set {
proxy.set_throttle_thermal_policy(profile)?; proxy.set_platform_profile(profile)?;
} }
if cmd.list { if cmd.list {
let res = ThrottlePolicy::list(); for p in &choices {
for p in &res {
println!("{:?}", p); println!("{:?}", p);
} }
} }
@@ -931,7 +954,7 @@ fn handle_throttle_profile(
fn handle_fan_curve( fn handle_fan_curve(
conn: &Connection, conn: &Connection,
cmd: &FanCurveCommand cmd: &FanCurveCommand,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
let Ok(fan_proxy) = FanCurvesProxyBlocking::new(conn).map_err(|e| { let Ok(fan_proxy) = FanCurvesProxyBlocking::new(conn).map_err(|e| {
println!("Fan-curves not supported by either this kernel or by the laptop: {e:?}"); println!("Fan-curves not supported by either this kernel or by the laptop: {e:?}");
@@ -963,7 +986,7 @@ fn handle_fan_curve(
let plat_proxy = PlatformProxyBlocking::new(conn)?; let plat_proxy = PlatformProxyBlocking::new(conn)?;
if cmd.get_enabled { if cmd.get_enabled {
let profile = plat_proxy.throttle_thermal_policy()?; let profile = plat_proxy.platform_profile()?;
let curves = fan_proxy.fan_curve_data(profile)?; let curves = fan_proxy.fan_curve_data(profile)?;
for curve in curves.iter() { for curve in curves.iter() {
println!("{}", String::from(curve)); println!("{}", String::from(curve));
@@ -971,7 +994,7 @@ fn handle_fan_curve(
} }
if cmd.default { if cmd.default {
let active = plat_proxy.throttle_thermal_policy()?; let active = plat_proxy.platform_profile()?;
fan_proxy.set_curves_to_defaults(active)?; fan_proxy.set_curves_to_defaults(active)?;
} }
@@ -1007,70 +1030,6 @@ fn handle_fan_curve(
Ok(()) Ok(())
} }
fn handle_platform_properties(
conn: &Connection,
supported: &[Properties],
cmd: &PlatformCommand
) -> Result<(), Box<dyn std::error::Error>> {
{
if (cmd.gpu_mux_mode_set.is_none()
&& !cmd.gpu_mux_mode_get
&& cmd.post_sound_set.is_none()
&& !cmd.post_sound_get
&& cmd.panel_overdrive_set.is_none()
&& !cmd.panel_overdrive_get)
|| cmd.help
{
println!("Missing arg or command\n");
let usage: Vec<String> = PlatformCommand::usage()
.lines()
.map(|s| s.to_owned())
.collect();
for line in usage.iter().filter(|line| {
line.contains("sound") && supported.contains(&Properties::PostAnimationSound)
|| line.contains("GPU") && supported.contains(&Properties::GpuMuxMode)
|| line.contains("panel") && supported.contains(&Properties::PanelOd)
}) {
println!("{}", line);
}
}
let proxy = PlatformProxyBlocking::new(conn)?;
if let Some(opt) = cmd.post_sound_set {
proxy.set_boot_sound(opt)?;
}
if cmd.post_sound_get {
let res = proxy.boot_sound()?;
println!("Bios POST sound on: {}", res);
}
if let Some(opt) = cmd.gpu_mux_mode_set {
println!("Rebuilding initrd to include drivers");
proxy.set_gpu_mux_mode(GpuMode::from_mux(opt))?;
println!(
"The mode change is not active until you reboot, on boot the bios will make the \
required change"
);
}
if cmd.gpu_mux_mode_get {
let res = proxy.gpu_mux_mode()?;
println!("Bios GPU MUX: {:?}", res);
}
if let Some(opt) = cmd.panel_overdrive_set {
proxy.set_panel_od(opt)?;
}
if cmd.panel_overdrive_get {
let res = proxy.panel_od()?;
println!("Panel overdrive on: {}", res);
}
}
Ok(())
}
fn check_systemd_unit_active(name: &str) -> bool { fn check_systemd_unit_active(name: &str) -> bool {
if let Ok(out) = Command::new("systemctl") if let Ok(out) = Command::new("systemctl")
.arg("is-active") .arg("is-active")
@@ -1090,7 +1049,7 @@ fn check_systemd_unit_enabled(name: &str) -> bool {
.output() .output()
{ {
let buf = String::from_utf8_lossy(&out.stdout); let buf = String::from_utf8_lossy(&out.stdout);
return buf.contains("enabled"); return buf.contains("enabled") || buf.contains("linked");
} }
false false
} }
@@ -1175,7 +1134,12 @@ fn handle_armoury_command(cmd: &ArmouryCommand) -> Result<(), Box<dyn std::error
for attr in attr.iter() { for attr in attr.iter() {
let name = attr.name()?; let name = attr.name()?;
if <&str>::from(name) == cmd[0] { if <&str>::from(name) == cmd[0] {
attr.set_current_value(cmd[1].parse()?)?; let mut value: i32 = cmd[1].parse()?;
if value == -1 {
info!("Setting to default");
value = attr.default_value()?;
}
attr.set_current_value(value)?;
print_firmware_attr(attr)?; print_firmware_attr(attr)?;
} }
} }
+1 -1
View File
@@ -31,5 +31,5 @@ pub struct ScsiCommand {
pub colours: Vec<Colour>, pub colours: Vec<Colour>,
#[options(help = "list available animations")] #[options(help = "list available animations")]
pub list: bool pub list: bool,
} }
+4 -2
View File
@@ -7,7 +7,7 @@ pub struct SlashCommand {
pub help: bool, pub help: bool,
#[options(help = "Enable the Slash Ledbar")] #[options(help = "Enable the Slash Ledbar")]
pub enable: bool, pub enable: bool,
#[options(help = "Ddisable the Slash Ledbar")] #[options(help = "Disable the Slash Ledbar")]
pub disable: bool, pub disable: bool,
#[options(short = "l", meta = "", help = "Set brightness value <0-255>")] #[options(short = "l", meta = "", help = "Set brightness value <0-255>")]
pub brightness: Option<u8>, pub brightness: Option<u8>,
@@ -26,10 +26,12 @@ pub struct SlashCommand {
pub show_on_sleep: Option<bool>, pub show_on_sleep: Option<bool>,
#[options(short = "b", meta = "", help = "Show the animation on battery")] #[options(short = "b", meta = "", help = "Show the animation on battery")]
pub show_on_battery: Option<bool>, 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( #[options(
short = "w", short = "w",
meta = "", meta = "",
help = "Show the low-battery warning animation" help = "Show the low-battery warning animation"
)] )]
pub show_battery_warning: Option<bool> pub show_battery_warning: Option<bool>,
} }
+20 -20
View File
@@ -21,7 +21,7 @@ fn root_conf_dir() -> PathBuf {
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
pub struct ConfigAnime { pub struct ConfigAnime {
pub name: String, pub name: String,
pub anime: Vec<ActionLoader> pub anime: Vec<ActionLoader>,
} }
impl ConfigAnime { impl ConfigAnime {
@@ -52,8 +52,8 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new( time: AnimTime::Fade(Fade::new(
Duration::from_secs(2), Duration::from_secs(2),
None, None,
Duration::from_secs(2) Duration::from_secs(2),
)) )),
}, },
ActionLoader::AsusAnimation { ActionLoader::AsusAnimation {
file: "/usr/share/asusd/anime/asus/rog/Sunset.gif".into(), file: "/usr/share/asusd/anime/asus/rog/Sunset.gif".into(),
@@ -61,8 +61,8 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new( time: AnimTime::Fade(Fade::new(
Duration::from_secs(6), Duration::from_secs(6),
None, None,
Duration::from_secs(3) Duration::from_secs(3),
)) )),
}, },
ActionLoader::ImageAnimation { ActionLoader::ImageAnimation {
file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(), file: "/usr/share/asusd/anime/custom/sonic-run.gif".into(),
@@ -73,8 +73,8 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new( time: AnimTime::Fade(Fade::new(
Duration::from_secs(2), Duration::from_secs(2),
Some(Duration::from_secs(2)), Some(Duration::from_secs(2)),
Duration::from_secs(2) Duration::from_secs(2),
)) )),
}, },
ActionLoader::Image { ActionLoader::Image {
file: "/usr/share/asusd/anime/custom/rust.png".into(), file: "/usr/share/asusd/anime/custom/rust.png".into(),
@@ -84,9 +84,9 @@ impl Default for ConfigAnime {
time: AnimTime::Fade(Fade::new( time: AnimTime::Fade(Fade::new(
Duration::from_secs(2), Duration::from_secs(2),
Some(Duration::from_secs(1)), 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::Pause(Duration::from_secs(1)),
ActionLoader::ImageAnimation { ActionLoader::ImageAnimation {
@@ -95,9 +95,9 @@ impl Default for ConfigAnime {
angle: 0.0, angle: 0.0,
translation: Vec2::new(3.0, 2.0), translation: Vec2::new(3.0, 2.0),
brightness: 0.5, brightness: 0.5,
time: AnimTime::Count(2) time: AnimTime::Count(2),
}, },
] ],
} }
} }
} }
@@ -121,7 +121,7 @@ impl StdConfigLoad for ConfigAnime {}
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
pub struct ConfigAura { pub struct ConfigAura {
pub name: String, pub name: String,
pub aura: AuraSequences pub aura: AuraSequences,
} }
impl ConfigAura { impl ConfigAura {
@@ -139,14 +139,14 @@ impl Default for ConfigAura {
Colour { Colour {
r: 255, r: 255,
g: 0, g: 0,
b: 20 b: 20,
}, },
Colour { Colour {
r: 20, r: 20,
g: 255, g: 255,
b: 0 b: 0,
}, },
Speed::Low Speed::Low,
)); ));
seq.push(key.clone()); seq.push(key.clone());
@@ -161,7 +161,7 @@ impl Default for ConfigAura {
LedCode::F, LedCode::F,
Colour { r: 255, g: 0, b: 0 }, Colour { r: 255, g: 0, b: 0 },
Colour { r: 255, g: 0, b: 0 }, Colour { r: 255, g: 0, b: 0 },
Speed::High Speed::High,
)); ));
seq.push(key); seq.push(key);
@@ -176,13 +176,13 @@ impl Default for ConfigAura {
LedCode::N9, LedCode::N9,
Colour { r: 0, g: 0, b: 255 }, Colour { r: 0, g: 0, b: 255 },
80, 80,
40 40,
)); ));
seq.push(key); seq.push(key);
Self { Self {
name: "aura-default".to_owned(), 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 /// Name of active anime config file in the user config directory
pub active_anime: Option<String>, pub active_anime: Option<String>,
/// Name of active aura config file in the user config directory /// 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 { impl StdConfig for ConfigBase {
fn new() -> Self { fn new() -> Self {
Self { Self {
active_anime: Some("anime-default".to_owned()), active_anime: Some("anime-default".to_owned()),
active_aura: Some("aura-default".to_owned()) active_aura: Some("aura-default".to_owned()),
} }
} }
+15 -15
View File
@@ -25,7 +25,7 @@ pub struct Timer {
/// Used only for `TimeType::Timer`, milliseonds to fade the image in for /// Used only for `TimeType::Timer`, milliseonds to fade the image in for
fade_in: u64, fade_in: u64,
/// Used only for `TimeType::Timer`, milliseonds to fade the image out for /// Used only for `TimeType::Timer`, milliseonds to fade the image out for
fade_out: u64 fade_out: u64,
} }
impl From<Timer> for AnimTime { impl From<Timer> for AnimTime {
@@ -46,7 +46,7 @@ impl From<Timer> for AnimTime {
} }
} }
TimeType::Count => AnimTime::Count(time.count as u32), 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 { pub enum TimeType {
Timer, Timer,
Count, Count,
Infinite Infinite,
} }
/// The inner object exists to allow the zbus proxy to share it with a runner /// 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> { pub struct CtrlAnimeInner<'a> {
sequences: Sequences, sequences: Sequences,
client: AnimeProxyBlocking<'a>, client: AnimeProxyBlocking<'a>,
do_early_return: Arc<AtomicBool> do_early_return: Arc<AtomicBool>,
} }
impl CtrlAnimeInner<'static> { impl CtrlAnimeInner<'static> {
pub fn new( pub fn new(
sequences: Sequences, sequences: Sequences,
client: AnimeProxyBlocking<'static>, client: AnimeProxyBlocking<'static>,
do_early_return: Arc<AtomicBool> do_early_return: Arc<AtomicBool>,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
Ok(Self { Ok(Self {
sequences, sequences,
client, client,
do_early_return do_early_return,
}) })
} }
@@ -130,7 +130,7 @@ pub struct CtrlAnime<'a> {
client: AnimeProxyBlocking<'a>, client: AnimeProxyBlocking<'a>,
inner: Arc<Mutex<CtrlAnimeInner<'a>>>, inner: Arc<Mutex<CtrlAnimeInner<'a>>>,
/// Must be the same Atomic as in CtrlAnimeInner /// Must be the same Atomic as in CtrlAnimeInner
inner_early_return: Arc<AtomicBool> inner_early_return: Arc<AtomicBool>,
} }
impl CtrlAnime<'static> { impl CtrlAnime<'static> {
@@ -138,13 +138,13 @@ impl CtrlAnime<'static> {
config: Arc<Mutex<ConfigAnime>>, config: Arc<Mutex<ConfigAnime>>,
inner: Arc<Mutex<CtrlAnimeInner<'static>>>, inner: Arc<Mutex<CtrlAnimeInner<'static>>>,
client: AnimeProxyBlocking<'static>, client: AnimeProxyBlocking<'static>,
inner_early_return: Arc<AtomicBool> inner_early_return: Arc<AtomicBool>,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
Ok(CtrlAnime { Ok(CtrlAnime {
config, config,
client, client,
inner, inner,
inner_early_return inner_early_return,
}) })
} }
@@ -174,7 +174,7 @@ impl CtrlAnime<'static> {
index: u32, index: u32,
file: &str, file: &str,
time: Timer, time: Timer,
brightness: f32 brightness: f32,
) -> zbus::fdo::Result<String> { ) -> zbus::fdo::Result<String> {
if let Ok(mut config) = self.config.try_lock() { if let Ok(mut config) = self.config.try_lock() {
let time: AnimTime = time.into(); let time: AnimTime = time.into();
@@ -182,7 +182,7 @@ impl CtrlAnime<'static> {
let action = ActionLoader::AsusAnimation { let action = ActionLoader::AsusAnimation {
file: file.into(), file: file.into(),
brightness, brightness,
time time,
}; };
// Must make the inner run loop return early // Must make the inner run loop return early
@@ -216,7 +216,7 @@ impl CtrlAnime<'static> {
angle: f32, angle: f32,
xy: (f32, f32), xy: (f32, f32),
time: Timer, time: Timer,
brightness: f32 brightness: f32,
) -> zbus::fdo::Result<String> { ) -> zbus::fdo::Result<String> {
if let Ok(mut config) = self.config.try_lock() { if let Ok(mut config) = self.config.try_lock() {
let time: AnimTime = time.into(); let time: AnimTime = time.into();
@@ -228,7 +228,7 @@ impl CtrlAnime<'static> {
angle, angle,
translation, translation,
brightness, brightness,
time time,
}; };
// Must make the inner run loop return early // Must make the inner run loop return early
@@ -261,7 +261,7 @@ impl CtrlAnime<'static> {
angle: f32, angle: f32,
xy: (f32, f32), xy: (f32, f32),
time: Timer, time: Timer,
brightness: f32 brightness: f32,
) -> zbus::fdo::Result<String> { ) -> zbus::fdo::Result<String> {
if let Ok(mut config) = self.config.try_lock() { if let Ok(mut config) = self.config.try_lock() {
let file = Path::new(&file); let file = Path::new(&file);
@@ -272,7 +272,7 @@ impl CtrlAnime<'static> {
angle, angle,
translation: Vec2::new(xy.0, xy.1), translation: Vec2::new(xy.0, xy.1),
brightness, brightness,
time time,
}; };
// Must make the inner run loop return early // Must make the inner run loop return early
+3 -3
View File
@@ -61,16 +61,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
CtrlAnimeInner::new( CtrlAnimeInner::new(
anime, anime,
anime_proxy_blocking.clone(), anime_proxy_blocking.clone(),
early_return.clone() early_return.clone(),
) )
.unwrap() .unwrap(),
)); ));
// Need new client object for dbus control part // Need new client object for dbus control part
let anime_control = CtrlAnime::new( let anime_control = CtrlAnime::new(
anime_config, anime_config,
inner.clone(), inner.clone(),
anime_proxy_blocking, anime_proxy_blocking,
early_return early_return,
) )
.unwrap(); .unwrap();
anime_control.add_to_server(&mut connection).await; anime_control.add_to_server(&mut connection).await;
+2 -2
View File
@@ -8,7 +8,7 @@ pub enum Error {
ConfigLoadFail, ConfigLoadFail,
ConfigLockFail, ConfigLockFail,
XdgVars, XdgVars,
Anime(AnimeError) Anime(AnimeError),
} }
impl fmt::Display for Error { impl fmt::Display for Error {
@@ -19,7 +19,7 @@ impl fmt::Display for Error {
Error::ConfigLoadFail => write!(f, "Failed to load user config"), Error::ConfigLoadFail => write!(f, "Failed to load user config"),
Error::ConfigLockFail => write!(f, "Failed to lock user config"), Error::ConfigLockFail => write!(f, "Failed to lock user config"),
Error::XdgVars => write!(f, "XDG environment vars appear unset"), 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),
} }
} }
} }
+3 -3
View File
@@ -32,7 +32,7 @@ trait Daemon {
file: &str, file: &str,
time: u32, time: u32,
count: u32, count: u32,
brightness: f64 brightness: f64,
) -> zbus::Result<String>; ) -> zbus::Result<String>;
/// InsertImage method /// InsertImage method
@@ -43,7 +43,7 @@ trait Daemon {
scale: f64, scale: f64,
angle: f64, angle: f64,
xy: &(f64, f64), xy: &(f64, f64),
brightness: f64 brightness: f64,
) -> zbus::Result<String>; ) -> zbus::Result<String>;
/// InsertImageGif method /// InsertImageGif method
@@ -56,7 +56,7 @@ trait Daemon {
xy: &(f64, f64), xy: &(f64, f64),
time: u32, time: u32,
count: u32, count: u32,
brightness: f64 brightness: f64,
) -> zbus::Result<String>; ) -> zbus::Result<String>;
/// InsertPause method /// InsertPause method
+1
View File
@@ -34,6 +34,7 @@ tokio.workspace = true
log.workspace = true log.workspace = true
env_logger.workspace = true env_logger.workspace = true
futures-util.workspace = true
zbus.workspace = true zbus.workspace = true
logind-zbus.workspace = true logind-zbus.workspace = true
+316 -46
View File
@@ -1,38 +1,58 @@
use log::error; use std::sync::Arc;
use rog_platform::firmware_attributes::{
AttrValue, Attribute, FirmwareAttribute, FirmwareAttributes 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};
use rog_platform::power::AsusPower;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use zbus::object_server::SignalEmitter;
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value}; use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
use zbus::{fdo, interface, Connection}; use zbus::{fdo, interface, Connection};
use crate::config::Config;
use crate::error::RogError; use crate::error::RogError;
use crate::ASUS_ZBUS_PATH; use crate::{Reloadable, ASUS_ZBUS_PATH};
const MOD_NAME: &str = "asus_armoury"; const MOD_NAME: &str = "asus_armoury";
#[derive(Debug, Default, Clone, Deserialize, Serialize, Type, Value, OwnedValue)] #[derive(Debug, Default, Clone, Deserialize, Serialize, Type, Value, OwnedValue)]
pub struct PossibleValues { pub struct PossibleValues {
strings: Vec<String>, strings: Vec<String>,
nums: Vec<i32> nums: Vec<i32>,
} }
fn dbus_path_for_attr(attr_name: &str) -> OwnedObjectPath { fn dbus_path_for_attr(attr_name: &str) -> OwnedObjectPath {
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{attr_name}")).into() ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{attr_name}")).into()
} }
pub struct AsusArmouryAttribute(Attribute); #[derive(Clone)]
pub struct AsusArmouryAttribute {
attr: Attribute,
config: Arc<Mutex<Config>>,
/// platform control required here for access to PPD or Throttle profile
platform: RogPlatform,
power: AsusPower,
}
impl AsusArmouryAttribute { impl AsusArmouryAttribute {
pub fn new(attr: Attribute) -> Self { pub fn new(
Self(attr) attr: Attribute,
platform: RogPlatform,
power: AsusPower,
config: Arc<Mutex<Config>>,
) -> Self {
Self {
attr,
config,
platform,
power,
}
} }
pub async fn start_tasks(self, connection: &Connection) -> Result<(), RogError> { pub async fn move_to_zbus(self, connection: &Connection) -> Result<(), RogError> {
// self.reload() let path = dbus_path_for_attr(self.attr.name());
// .await
// .unwrap_or_else(|err| warn!("Controller error: {}", err));
let path = dbus_path_for_attr(self.0.name());
connection connection
.object_server() .object_server()
.at(path.clone(), self) .at(path.clone(), self)
@@ -41,6 +61,86 @@ impl AsusArmouryAttribute {
.ok(); .ok();
Ok(()) Ok(())
} }
async fn watch_and_notify(
&mut self,
signal_ctxt: SignalEmitter<'static>,
) -> Result<(), RogError> {
use futures_util::StreamExt;
let name = self.name();
macro_rules! watch_value_notify {
($attr_str:expr, $fn_prop_changed:ident) => {
match self.attr.get_watcher($attr_str) {
Ok(watch) => {
let name = <&str>::from(name);
let ctrl = self.clone();
let sig = signal_ctxt.clone();
tokio::spawn(async move {
let mut buffer = [0; 32];
watch
.into_event_stream(&mut buffer)
.unwrap()
.for_each(|_| async {
debug!("{} changed", name);
ctrl.$fn_prop_changed(&sig).await.ok();
})
.await;
});
}
Err(e) => info!(
"inotify watch failed: {}. You can ignore this if your device does not \
support the feature",
e
),
}
};
}
// "current_value", "default_value", "min_value", "max_value"
watch_value_notify!("current_value", current_value_changed);
watch_value_notify!("default_value", default_value_changed);
watch_value_notify!("min_value", min_value_changed);
watch_value_notify!("max_value", max_value_changed);
Ok(())
}
}
impl crate::Reloadable for AsusArmouryAttribute {
async fn reload(&mut self) -> Result<(), RogError> {
info!("Reloading {}", self.attr.name());
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let config = if power_plugged == 1 {
&self.config.lock().await.ac_profile_tunings
} else {
&self.config.lock().await.dc_profile_tunings
};
if let Some(tuning) = config.get(&profile) {
if tuning.enabled {
if let Some(tune) = tuning.group.get(&self.name()) {
self.attr
.set_current_value(&AttrValue::Integer(*tune))
.map_err(|e| {
error!("Could not set {} value: {e:?}", self.attr.name());
self.attr.base_path_exists();
e
})?;
info!("Set {} to {:?}", self.attr.name(), tune);
}
}
}
Ok(())
}
} }
/// If return is `-1` on a property then there is avilable value for that /// If return is `-1` on a property then there is avilable value for that
@@ -48,30 +148,30 @@ impl AsusArmouryAttribute {
#[interface(name = "xyz.ljones.AsusArmoury")] #[interface(name = "xyz.ljones.AsusArmoury")]
impl AsusArmouryAttribute { impl AsusArmouryAttribute {
#[zbus(property)] #[zbus(property)]
async fn name(&self) -> FirmwareAttribute { fn name(&self) -> FirmwareAttribute {
self.0.name().into() self.attr.name().into()
} }
#[zbus(property)] #[zbus(property)]
async fn available_attrs(&self) -> Vec<String> { async fn available_attrs(&self) -> Vec<String> {
let mut attrs = Vec::new(); let mut attrs = Vec::new();
if !matches!(self.0.default_value(), AttrValue::None) { if !matches!(self.attr.default_value(), AttrValue::None) {
attrs.push("default_value".to_string()); attrs.push("default_value".to_string());
} }
if !matches!(self.0.min_value(), AttrValue::None) { if !matches!(self.attr.min_value(), AttrValue::None) {
attrs.push("min_value".to_string()); attrs.push("min_value".to_string());
} }
if !matches!(self.0.max_value(), AttrValue::None) { if !matches!(self.attr.max_value(), AttrValue::None) {
attrs.push("max_value".to_string()); attrs.push("max_value".to_string());
} }
if !matches!(self.0.scalar_increment(), AttrValue::None) { if !matches!(self.attr.scalar_increment(), AttrValue::None) {
attrs.push("scalar_increment".to_string()); attrs.push("scalar_increment".to_string());
} }
if !matches!(self.0.possible_values(), AttrValue::None) { if !matches!(self.attr.possible_values(), AttrValue::None) {
attrs.push("possible_values".to_string()); attrs.push("possible_values".to_string());
} }
// TODO: Don't unwrap, use error // TODO: Don't unwrap, use error
if let Ok(value) = self.0.current_value().map_err(|e| { if let Ok(value) = self.attr.current_value().map_err(|e| {
error!("Failed to read: {e:?}"); error!("Failed to read: {e:?}");
e e
}) { }) {
@@ -85,71 +185,241 @@ impl AsusArmouryAttribute {
/// If return is `-1` then there is no default value /// If return is `-1` then there is no default value
#[zbus(property)] #[zbus(property)]
async fn default_value(&self) -> i32 { async fn default_value(&self) -> i32 {
match self.0.default_value() { match self.attr.default_value() {
AttrValue::Integer(i) => *i, AttrValue::Integer(i) => *i,
_ => -1 _ => -1,
} }
} }
async fn restore_default(&self) -> fdo::Result<()> {
self.attr.restore_default()?;
if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tuning.group.get_mut(&self.name()) {
if let AttrValue::Integer(i) = self.attr.default_value() {
*tune = *i;
}
}
if tuning.enabled {
self.attr
.set_current_value(self.attr.default_value())
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
}
config.write();
}
Ok(())
}
#[zbus(property)] #[zbus(property)]
async fn min_value(&self) -> i32 { async fn min_value(&self) -> i32 {
match self.0.min_value() { match self.attr.min_value() {
AttrValue::Integer(i) => *i, AttrValue::Integer(i) => *i,
_ => -1 _ => -1,
} }
} }
#[zbus(property)] #[zbus(property)]
async fn max_value(&self) -> i32 { async fn max_value(&self) -> i32 {
match self.0.max_value() { match self.attr.max_value() {
AttrValue::Integer(i) => *i, AttrValue::Integer(i) => *i,
_ => -1 _ => -1,
} }
} }
#[zbus(property)] #[zbus(property)]
async fn scalar_increment(&self) -> i32 { async fn scalar_increment(&self) -> i32 {
match self.0.scalar_increment() { match self.attr.scalar_increment() {
AttrValue::Integer(i) => *i, AttrValue::Integer(i) => *i,
_ => -1 _ => -1,
} }
} }
#[zbus(property)] #[zbus(property)]
async fn possible_values(&self) -> Vec<i32> { async fn possible_values(&self) -> Vec<i32> {
match self.0.possible_values() { match self.attr.possible_values() {
AttrValue::EnumInt(i) => i.clone(), AttrValue::EnumInt(i) => i.clone(),
_ => Vec::default() _ => Vec::default(),
} }
} }
#[zbus(property)] #[zbus(property)]
async fn current_value(&self) -> fdo::Result<i32> { async fn current_value(&self) -> fdo::Result<i32> {
if let Ok(AttrValue::Integer(i)) = self.0.current_value() { if self.name().is_ppt() {
let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
let power_plugged = self
.power
.get_online()
.map_err(|e| {
error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tuning.group.get(&self.name()) {
return Ok(*tune);
} else if let AttrValue::Integer(i) = self.attr.default_value() {
return Ok(*i);
}
return Err(fdo::Error::Failed(
"Could not read current value".to_string(),
));
}
if let Ok(AttrValue::Integer(i)) = self.attr.current_value() {
return Ok(i); return Ok(i);
} }
Err(fdo::Error::Failed( Err(fdo::Error::Failed(
"Could not read current value".to_string() "Could not read current value".to_string(),
)) ))
} }
#[zbus(property)] #[zbus(property)]
async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> { async fn set_current_value(&mut self, value: i32) -> fdo::Result<()> {
Ok(self if self.name().is_ppt() {
.0 let profile: PlatformProfile = self.platform.get_platform_profile()?.into();
.set_current_value(AttrValue::Integer(value)) let power_plugged = self
.map_err(|e| { .power
error!("Could not set value: {e:?}"); .get_online()
e .map_err(|e| {
})?) error!("Could not get power status: {e:?}");
e
})
.unwrap_or_default();
let mut config = self.config.lock().await;
let tuning = config.select_tunings(power_plugged == 1, profile);
if let Some(tune) = tuning.group.get_mut(&self.name()) {
*tune = value;
} else {
tuning.group.insert(self.name(), value);
debug!("Store tuning config for {} = {:?}", self.attr.name(), value);
}
if tuning.enabled {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
}
} else {
self.attr
.set_current_value(&AttrValue::Integer(value))
.map_err(|e| {
error!("Could not set value: {e:?}");
e
})?;
let has_attr = self
.config
.lock()
.await
.armoury_settings
.contains_key(&self.name());
if has_attr {
if let Some(setting) = self
.config
.lock()
.await
.armoury_settings
.get_mut(&self.name())
{
*setting = value
}
} else {
debug!("Adding config for {}", self.attr.name());
self.config
.lock()
.await
.armoury_settings
.insert(self.name(), value);
debug!("Set config for {} = {:?}", self.attr.name(), value);
}
}
self.config.lock().await.write();
Ok(())
} }
} }
pub async fn start_attributes_zbus(server: &Connection) -> Result<(), RogError> { pub async fn start_attributes_zbus(
for attr in FirmwareAttributes::new().attributes() { conn: &Connection,
AsusArmouryAttribute::new(attr.clone()) platform: RogPlatform,
.start_tasks(server) power: AsusPower,
.await?; attributes: FirmwareAttributes,
config: Arc<Mutex<Config>>,
) -> Result<(), RogError> {
for attr in attributes.attributes() {
let mut attr = AsusArmouryAttribute::new(
attr.clone(),
platform.clone(),
power.clone(),
config.clone(),
);
attr.reload().await?;
let path = dbus_path_for_attr(attr.attr.name());
let sig = zbus::object_server::SignalEmitter::new(conn, path)?;
attr.watch_and_notify(sig).await?;
attr.move_to_zbus(conn).await?;
} }
Ok(()) Ok(())
} }
pub async fn set_config_or_default(
attrs: &FirmwareAttributes,
config: &mut Config,
power_plugged: bool,
profile: PlatformProfile,
) {
for attr in attrs.attributes().iter() {
let name: FirmwareAttribute = attr.name().into();
if name.is_ppt() {
let tuning = config.select_tunings(power_plugged, profile);
if !tuning.enabled {
debug!("Tuning group is not enabled, skipping");
return;
}
if let Some(tune) = tuning.group.get(&name) {
attr.set_current_value(&AttrValue::Integer(*tune))
.map_err(|e| {
error!("Failed to set {}: {e}", <&str>::from(name));
})
.ok();
} else {
let default = attr.default_value();
attr.set_current_value(default)
.map_err(|e| {
error!("Failed to set {}: {e}", <&str>::from(name));
})
.ok();
if let AttrValue::Integer(i) = default {
tuning.group.insert(name, *i);
info!(
"Set default tuning config for {} = {:?}",
<&str>::from(name),
i
);
// config.write();
}
}
}
}
}
+11 -11
View File
@@ -4,7 +4,7 @@ use config_traits::{StdConfig, StdConfigLoad};
use rog_anime::error::AnimeError; use rog_anime::error::AnimeError;
use rog_anime::usb::Brightness; use rog_anime::usb::Brightness;
use rog_anime::{ use rog_anime::{
ActionData, ActionLoader, AnimTime, Animations, AnimeType, DeviceState, Fade, Vec2 ActionData, ActionLoader, AnimTime, Animations, AnimeType, DeviceState, Fade, Vec2,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -15,14 +15,14 @@ pub struct AniMeConfigCached {
pub system: Vec<ActionData>, pub system: Vec<ActionData>,
pub boot: Vec<ActionData>, pub boot: Vec<ActionData>,
pub wake: Vec<ActionData>, pub wake: Vec<ActionData>,
pub shutdown: Vec<ActionData> pub shutdown: Vec<ActionData>,
} }
impl AniMeConfigCached { impl AniMeConfigCached {
pub fn init_from_config( pub fn init_from_config(
&mut self, &mut self,
config: &AniMeConfig, config: &AniMeConfig,
anime_type: AnimeType anime_type: AnimeType,
) -> Result<(), AnimeError> { ) -> Result<(), AnimeError> {
let mut sys = Vec::with_capacity(config.system.len()); let mut sys = Vec::with_capacity(config.system.len());
for ani in &config.system { for ani in &config.system {
@@ -68,7 +68,7 @@ pub struct AniMeConfig {
pub off_when_suspended: bool, pub off_when_suspended: bool,
pub off_when_lid_closed: bool, pub off_when_lid_closed: bool,
pub brightness_on_battery: Brightness, pub brightness_on_battery: Brightness,
pub builtin_anims: Animations pub builtin_anims: Animations,
} }
impl Default for AniMeConfig { impl Default for AniMeConfig {
@@ -87,7 +87,7 @@ impl Default for AniMeConfig {
off_when_suspended: true, off_when_suspended: true,
off_when_lid_closed: true, off_when_lid_closed: true,
brightness_on_battery: Brightness::Low, 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_unplugged: config.off_when_unplugged,
off_when_suspended: config.off_when_suspended, off_when_suspended: config.off_when_suspended,
off_when_lid_closed: config.off_when_lid_closed, 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( time: AnimTime::Fade(Fade::new(
Duration::from_secs(2), Duration::from_secs(2),
Some(Duration::from_secs(2)), Some(Duration::from_secs(2)),
Duration::from_secs(2) Duration::from_secs(2),
)) )),
}, },
], ],
wake: vec![ wake: vec![
@@ -162,8 +162,8 @@ impl AniMeConfig {
time: AnimTime::Fade(Fade::new( time: AnimTime::Fade(Fade::new(
Duration::from_secs(2), Duration::from_secs(2),
Some(Duration::from_secs(2)), Some(Duration::from_secs(2)),
Duration::from_secs(2) Duration::from_secs(2),
)) )),
}, },
], ],
shutdown: vec![ shutdown: vec![
@@ -173,7 +173,7 @@ impl AniMeConfig {
angle: 0.0, angle: 0.0,
translation: Vec2::new(3.0, 2.0), translation: Vec2::new(3.0, 2.0),
brightness: 1.0, brightness: 1.0,
time: AnimTime::Infinite time: AnimTime::Infinite,
}, },
], ],
..Default::default() ..Default::default()
+18 -17
View File
@@ -8,15 +8,15 @@ use std::sync::Arc;
use std::thread::sleep; use std::thread::sleep;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{error, info, warn}; use futures_util::lock::Mutex;
use log::{debug, error, info, warn};
use rog_anime::usb::{ use rog_anime::usb::{
pkt_flush, pkt_set_brightness, pkt_set_enable_display, pkt_set_enable_powersave_anim, 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_anime::{ActionData, AnimeDataBuffer, AnimePacketType};
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw; use rog_platform::usb_raw::USBRaw;
use tokio::sync::{Mutex, MutexGuard};
use self::config::{AniMeConfig, AniMeConfigCached}; use self::config::{AniMeConfig, AniMeConfigCached};
use crate::error::RogError; use crate::error::RogError;
@@ -30,14 +30,14 @@ pub struct AniMe {
// set to force thread to exit // set to force thread to exit
thread_exit: Arc<AtomicBool>, thread_exit: Arc<AtomicBool>,
// Set to false when the thread exits // Set to false when the thread exits
thread_running: Arc<AtomicBool> thread_running: Arc<AtomicBool>,
} }
impl AniMe { impl AniMe {
pub fn new( pub fn new(
hid: Option<Arc<Mutex<HidRaw>>>, hid: Option<Arc<Mutex<HidRaw>>>,
usb: Option<Arc<Mutex<USBRaw>>>, usb: Option<Arc<Mutex<USBRaw>>>,
config: Arc<Mutex<AniMeConfig>> config: Arc<Mutex<AniMeConfig>>,
) -> Self { ) -> Self {
Self { Self {
hid, hid,
@@ -45,13 +45,13 @@ impl AniMe {
config, config,
cache: AniMeConfigCached::default(), cache: AniMeConfigCached::default(),
thread_exit: Arc::new(AtomicBool::new(false)), 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 /// Will fail if something is already holding the config lock
async fn do_init_cache(&mut self) { 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) { if let Err(e) = self.cache.init_from_config(&config, config.anime_type) {
error!( error!(
"Trying to cache the Anime Config failed, will reset to default config: {e:?}" "Trying to cache the Anime Config failed, will reset to default config: {e:?}"
@@ -59,6 +59,8 @@ impl AniMe {
config.rename_file_old(); config.rename_file_old();
*config = AniMeConfig::new(); *config = AniMeConfig::new();
config.write(); config.write();
} else {
debug!("Initialised AniMe cache");
} }
} else { } else {
error!("AniMe Matrix could not init cache") error!("AniMe Matrix could not init cache")
@@ -70,11 +72,9 @@ impl AniMe {
self.do_init_cache().await; self.do_init_cache().await;
let pkts = pkts_for_init(); let pkts = pkts_for_init();
self.write_bytes(&pkts[0]).await?; self.write_bytes(&pkts[0]).await?;
self.write_bytes(&pkts[1]).await self.write_bytes(&pkts[1]).await?;
} debug!("Succesfully initialised AniMe matrix display");
Ok(())
pub async fn lock_config(&self) -> MutexGuard<AniMeConfig> {
self.config.lock().await
} }
pub async fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> { pub async fn write_bytes(&self, message: &[u8]) -> Result<(), RogError> {
@@ -106,7 +106,7 @@ impl AniMe {
pub async fn set_builtins_enabled( pub async fn set_builtins_enabled(
&self, &self,
enabled: bool, enabled: bool,
bright: Brightness bright: Brightness,
) -> Result<(), RogError> { ) -> Result<(), RogError> {
self.write_bytes(&pkt_set_enable_powersave_anim(enabled)) self.write_bytes(&pkt_set_enable_powersave_anim(enabled))
.await?; .await?;
@@ -176,7 +176,7 @@ impl AniMe {
return Ok(true); // Do safe exit return Ok(true); // Do safe exit
} }
let inner = inner.clone(); let inner = inner.clone();
tokio::task::spawn_local(async move { tokio::task::spawn(async move {
inner inner
.write_data_buffer(frame) .write_data_buffer(frame)
.await .await
@@ -227,10 +227,11 @@ impl AniMe {
}) })
.ok(); .ok();
} }
// A write can block for many milliseconds so lets not hold the config lock for
// the same period
let enabled = inner.config.lock().await.builtin_anims_enabled;
inner inner
.write_bytes(&pkt_set_enable_powersave_anim( .write_bytes(&pkt_set_enable_powersave_anim(enabled))
inner.config.lock().await.builtin_anims_enabled
))
.await .await
.map_err(|err| { .map_err(|err| {
warn!("rog_anime::run_animation:callback {}", err); warn!("rog_anime::run_animation:callback {}", err);
+65 -52
View File
@@ -1,11 +1,11 @@
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{error, warn}; use log::{debug, error, warn};
use logind_zbus::manager::ManagerProxy; use logind_zbus::manager::ManagerProxy;
use rog_anime::usb::{ use rog_anime::usb::{
pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display, 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 rog_anime::{Animations, AnimeDataBuffer, DeviceState};
use zbus::object_server::SignalEmitter; use zbus::object_server::SignalEmitter;
@@ -41,7 +41,7 @@ impl AniMeZbus {
pub async fn start_tasks( pub async fn start_tasks(
mut self, mut self,
connection: &Connection, connection: &Connection,
path: OwnedObjectPath path: OwnedObjectPath,
) -> Result<(), RogError> { ) -> Result<(), RogError> {
// let task = zbus.clone(); // let task = zbus.clone();
self.reload() self.reload()
@@ -51,8 +51,11 @@ impl AniMeZbus {
.object_server() .object_server()
.at(path.clone(), self) .at(path.clone(), self)
.await .await
.map_err(|e| error!("Couldn't add server at path: {path}, {e:?}")) .map_err(|e| {
.ok(); error!("Couldn't add server at path: {path}, {e:?}");
e
})?;
debug!("start_tasks was successful");
Ok(()) Ok(())
} }
} }
@@ -78,7 +81,7 @@ impl AniMeZbus {
/// Set base brightness level /// Set base brightness level
#[zbus(property)] #[zbus(property)]
async fn brightness(&self) -> Brightness { 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; return config.display_brightness;
} }
Brightness::Off Brightness::Off
@@ -110,7 +113,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn builtins_enabled(&self) -> bool { 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; return config.builtin_anims_enabled;
} }
false false
@@ -155,7 +158,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn builtin_animations(&self) -> Animations { 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; return config.builtin_anims;
} }
Animations::default() Animations::default()
@@ -166,7 +169,7 @@ impl AniMeZbus {
async fn set_builtin_animations(&self, settings: Animations) { async fn set_builtin_animations(&self, settings: Animations) {
self.0 self.0
.write_bytes(&pkt_set_builtin_animations( .write_bytes(&pkt_set_builtin_animations(
settings.boot, settings.awake, settings.sleep, settings.shutdown settings.boot, settings.awake, settings.sleep, settings.shutdown,
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -188,7 +191,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn enable_display(&self) -> bool { 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; return config.display_enabled;
} }
false false
@@ -211,7 +214,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn off_when_unplugged(&self) -> bool { 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; return config.off_when_unplugged;
} }
false false
@@ -238,7 +241,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn off_when_suspended(&self) -> bool { 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; return config.off_when_suspended;
} }
false false
@@ -254,7 +257,7 @@ impl AniMeZbus {
#[zbus(property)] #[zbus(property)]
async fn off_when_lid_closed(&self) -> bool { 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; return config.off_when_lid_closed;
} }
false false
@@ -316,7 +319,7 @@ impl crate::CtrlTask for AniMeZbus {
inner inner
.write_bytes(&pkt_set_enable_display( .write_bytes(&pkt_set_enable_display(
!(sleeping && config.off_when_suspended) !(sleeping && config.off_when_suspended),
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -327,7 +330,7 @@ impl crate::CtrlTask for AniMeZbus {
if config.builtin_anims_enabled { if config.builtin_anims_enabled {
inner inner
.write_bytes(&pkt_set_enable_powersave_anim( .write_bytes(&pkt_set_enable_powersave_anim(
!(sleeping && config.off_when_suspended) !(sleeping && config.off_when_suspended),
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -430,7 +433,7 @@ impl crate::CtrlTask for AniMeZbus {
.ok(); .ok();
} }
} }
} },
) )
.await; .await;
@@ -440,50 +443,60 @@ impl crate::CtrlTask for AniMeZbus {
impl crate::Reloadable for AniMeZbus { impl crate::Reloadable for AniMeZbus {
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
if let Ok(config) = self.0.config.try_lock() { let AniMeConfig {
let anim = &config.builtin_anims; builtin_anims_enabled,
// Set builtins builtin_anims,
if config.builtin_anims_enabled { display_enabled,
self.0 display_brightness,
.write_bytes(&pkt_set_builtin_animations( off_when_lid_closed,
anim.boot, anim.awake, anim.sleep, anim.shutdown off_when_unplugged,
)) ..
.await?; } = *self.0.config.lock().await;
}
// Builtins enabled or na? // Set builtins
if builtin_anims_enabled {
self.0 self.0
.set_builtins_enabled(config.builtin_anims_enabled, config.display_brightness) .write_bytes(&pkt_set_builtin_animations(
builtin_anims.boot,
builtin_anims.awake,
builtin_anims.sleep,
builtin_anims.shutdown,
))
.await?; .await?;
}
// Builtins enabled or na?
self.0
.set_builtins_enabled(builtin_anims_enabled, display_brightness)
.await?;
let manager = get_logind_manager().await; let manager = get_logind_manager().await;
let lid_closed = manager.lid_closed().await.unwrap_or_default(); let lid_closed = manager.lid_closed().await.unwrap_or_default();
let power_plugged = manager.on_external_power().await.unwrap_or_default(); let power_plugged = manager.on_external_power().await.unwrap_or_default();
let turn_off = (lid_closed && config.off_when_lid_closed) let turn_off =
|| (!power_plugged && config.off_when_unplugged); (lid_closed && off_when_lid_closed) || (!power_plugged && off_when_unplugged);
self.0
.write_bytes(&pkt_set_enable_display(!turn_off))
.await
.map_err(|err| {
warn!("create_sys_event_tasks::reload {}", err);
})
.ok();
if turn_off || !display_enabled {
self.0.write_bytes(&pkt_set_enable_display(false)).await?;
// early return so we don't run animation thread
return Ok(());
}
if !builtin_anims_enabled && !self.0.cache.boot.is_empty() {
self.0 self.0
.write_bytes(&pkt_set_enable_display(!turn_off)) .write_bytes(&pkt_set_enable_powersave_anim(false))
.await .await
.map_err(|err| {
warn!("create_sys_event_tasks::reload {}", err);
})
.ok(); .ok();
if turn_off || !config.display_enabled { let action = self.0.cache.boot.clone();
self.0.write_bytes(&pkt_set_enable_display(false)).await?; self.0.run_thread(action, true).await;
// early return so we don't run animation thread
return Ok(());
}
if !config.builtin_anims_enabled && !self.0.cache.boot.is_empty() {
self.0
.write_bytes(&pkt_set_enable_powersave_anim(false))
.await
.ok();
let action = self.0.cache.boot.clone();
self.0.run_thread(action, true).await;
}
} }
Ok(()) Ok(())
} }
+10 -10
View File
@@ -5,7 +5,7 @@ use log::{debug, info, warn};
use rog_aura::aura_detection::LedSupportData; use rog_aura::aura_detection::LedSupportData;
use rog_aura::keyboard::LaptopAuraPower; use rog_aura::keyboard::LaptopAuraPower;
use rog_aura::{ use rog_aura::{
AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT AuraDeviceType, AuraEffect, AuraModeNum, AuraZone, Direction, LedBrightness, Speed, GRADIENT,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -29,7 +29,7 @@ pub struct AuraConfig {
pub multizone_on: bool, pub multizone_on: bool,
pub enabled: LaptopAuraPower, pub enabled: LaptopAuraPower,
#[serde(skip)] #[serde(skip)]
pub per_key_mode_active: bool pub per_key_mode_active: bool,
} }
impl StdConfig for AuraConfig { impl StdConfig for AuraConfig {
@@ -74,7 +74,7 @@ impl AuraConfig {
multizone: None, multizone: None,
multizone_on: false, multizone_on: false,
enabled, enabled,
per_key_mode_active: false per_key_mode_active: false,
}; };
for n in &config.support_data.basic_modes { for n in &config.support_data.basic_modes {
@@ -92,7 +92,7 @@ impl AuraConfig {
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]), colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]), colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
speed: Speed::Med, speed: Speed::Med,
direction: Direction::Left direction: Direction::Left,
}); });
} }
if let Some(m) = config.multizone.as_mut() { if let Some(m) = config.multizone.as_mut() {
@@ -156,7 +156,7 @@ impl AuraConfig {
colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]), colour1: *GRADIENT.get(i).unwrap_or(&GRADIENT[0]),
colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]), colour2: *GRADIENT.get(GRADIENT.len() - i).unwrap_or(&GRADIENT[6]),
speed: Speed::Med, speed: Speed::Med,
direction: Direction::Left direction: Direction::Left,
}); });
} }
if default.is_empty() { if default.is_empty() {
@@ -232,7 +232,7 @@ impl AuraConfig {
mod tests { mod tests {
use rog_aura::keyboard::AuraPowerState; use rog_aura::keyboard::AuraPowerState;
use rog_aura::{ use rog_aura::{
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed AuraEffect, AuraModeNum, AuraZone, Colour, Direction, LedBrightness, PowerZones, Speed,
}; };
use super::AuraConfig; use super::AuraConfig;
@@ -246,7 +246,7 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0xff, r: 0xff,
g: 0x00, g: 0x00,
b: 0xff b: 0xff,
}, },
zone: AuraZone::Key1, zone: AuraZone::Key1,
..Default::default() ..Default::default()
@@ -259,7 +259,7 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0x00, r: 0x00,
g: 0xff, g: 0xff,
b: 0xff b: 0xff,
}, },
zone: AuraZone::Key2, zone: AuraZone::Key2,
..Default::default() ..Default::default()
@@ -270,7 +270,7 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0xff, r: 0xff,
g: 0xff, g: 0xff,
b: 0x00 b: 0x00,
}, },
zone: AuraZone::Key3, zone: AuraZone::Key3,
..Default::default() ..Default::default()
@@ -281,7 +281,7 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0x00, r: 0x00,
g: 0xff, g: 0xff,
b: 0x00 b: 0x00,
}, },
zone: AuraZone::Key4, zone: AuraZone::Key4,
..Default::default() ..Default::default()
+10 -10
View File
@@ -2,13 +2,13 @@ use std::sync::Arc;
use config::AuraConfig; use config::AuraConfig;
use config_traits::StdConfig; use config_traits::StdConfig;
use futures_util::lock::{Mutex, MutexGuard};
use log::info; use log::info;
use rog_aura::keyboard::{AuraLaptopUsbPackets, LedUsbPackets}; use rog_aura::keyboard::{AuraLaptopUsbPackets, LedUsbPackets};
use rog_aura::usb::{AURA_LAPTOP_LED_APPLY, AURA_LAPTOP_LED_SET}; 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_aura::{AuraDeviceType, AuraEffect, LedBrightness, PowerZones, AURA_LAPTOP_LED_MSG_LEN};
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::keyboard_led::KeyboardBacklight; use rog_platform::keyboard_led::KeyboardBacklight;
use tokio::sync::{Mutex, MutexGuard};
use crate::error::RogError; use crate::error::RogError;
@@ -19,7 +19,7 @@ pub mod trait_impls;
pub struct Aura { pub struct Aura {
pub hid: Option<Arc<Mutex<HidRaw>>>, pub hid: Option<Arc<Mutex<HidRaw>>>,
pub backlight: Option<Arc<Mutex<KeyboardBacklight>>>, pub backlight: Option<Arc<Mutex<KeyboardBacklight>>>,
pub config: Arc<Mutex<AuraConfig>> pub config: Arc<Mutex<AuraConfig>>,
} }
impl Aura { impl Aura {
@@ -91,13 +91,13 @@ impl Aura {
pub async fn write_effect_and_apply( pub async fn write_effect_and_apply(
&self, &self,
dev_type: AuraDeviceType, dev_type: AuraDeviceType,
mode: &AuraEffect mode: &AuraEffect,
) -> Result<(), RogError> { ) -> Result<(), RogError> {
if matches!(dev_type, AuraDeviceType::LaptopKeyboardTuf) { if matches!(dev_type, AuraDeviceType::LaptopKeyboardTuf) {
if let Some(platform) = &self.backlight { if let Some(platform) = &self.backlight {
let buf = [ let buf = [
1, mode.mode as u8, mode.colour1.r, mode.colour1.g, mode.colour1.b, 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)?; platform.lock().await.set_kbd_rgb_mode(&buf)?;
} }
@@ -121,7 +121,7 @@ impl Aura {
return Ok(()); return Ok(());
} }
Err(RogError::MissingFunction( Err(RogError::MissingFunction(
"No LED backlight control available".to_string() "No LED backlight control available".to_string(),
)) ))
} }
@@ -145,7 +145,7 @@ impl Aura {
0x01, 0x01,
p.new_to_byte() as u8, p.new_to_byte() as u8,
0x0, 0x0,
0x0 0x0,
]; ];
hid_raw.write_bytes(&msg)?; hid_raw.write_bytes(&msg)?;
return Ok(()); return Ok(());
@@ -154,7 +154,7 @@ impl Aura {
let bytes = config.enabled.to_bytes(config.led_type); let bytes = config.enabled.to_bytes(config.led_type);
let msg = [ 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)?; hid_raw.write_bytes(&msg)?;
} }
@@ -167,7 +167,7 @@ impl Aura {
pub async fn write_effect_block( pub async fn write_effect_block(
&self, &self,
config: &mut AuraConfig, config: &mut AuraConfig,
effect: &AuraLaptopUsbPackets effect: &AuraLaptopUsbPackets,
) -> Result<(), RogError> { ) -> Result<(), RogError> {
if config.brightness == LedBrightness::Off { if config.brightness == LedBrightness::Off {
config.brightness = LedBrightness::Med; config.brightness = LedBrightness::Med;
@@ -201,7 +201,7 @@ impl Aura {
let g = row[10]; let g = row[10];
let b = row[11]; let b = row[11];
tuf.lock().await.set_kbd_rgb_mode(&[ 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; let mut config = self.config.lock().await;
if config.ally_fix.is_none() { if config.ally_fix.is_none() {
let msg = [ let msg = [
0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff 0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff,
]; ];
hid_raw.lock().await.write_bytes(&msg)?; hid_raw.lock().await.write_bytes(&msg)?;
info!("Reset Ally power settings to base"); info!("Reset Ally power settings to base");
+5 -5
View File
@@ -28,7 +28,7 @@ impl AuraZbus {
mut self, mut self,
connection: &Connection, connection: &Connection,
// _signal_ctx: SignalEmitter<'static>, // _signal_ctx: SignalEmitter<'static>,
path: OwnedObjectPath path: OwnedObjectPath,
) -> Result<(), RogError> { ) -> Result<(), RogError> {
// let task = zbus.clone(); // let task = zbus.clone();
// let signal_ctx = signal_ctx.clone(); // let signal_ctx = signal_ctx.clone();
@@ -112,7 +112,7 @@ impl AuraZbus {
// entirely possible to deadlock here, so use try instead of lock() // entirely possible to deadlock here, so use try instead of lock()
// let ctrl = self.0.lock().await; // let ctrl = self.0.lock().await;
// Ok(config.current_mode) // 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) Ok(config.current_mode)
} else { } else {
Err(ZbErr::Failed("Aura control couldn't lock self".to_string())) Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
@@ -140,11 +140,11 @@ impl AuraZbus {
#[zbus(property)] #[zbus(property)]
async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> { async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> {
// entirely possible to deadlock here, so use try instead of lock() // 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; let mode = config.current_mode;
match config.builtins.get(&mode) { match config.builtins.get(&mode) {
Some(effect) => Ok(effect.clone()), 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 { } else {
Err(ZbErr::Failed("Aura control couldn't lock self".to_string())) Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
@@ -297,7 +297,7 @@ impl CtrlTask for AuraZbus {
move |_power_plugged| { move |_power_plugged| {
// power change // power change
async move {} async move {}
} },
) )
.await; .await;
+35 -26
View File
@@ -8,11 +8,11 @@ use std::sync::Arc;
use dmi_id::DMIID; use dmi_id::DMIID;
use futures_lite::future::block_on; use futures_lite::future::block_on;
use futures_util::lock::Mutex;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use mio::{Events, Interest, Poll, Token}; use mio::{Events, Interest, Poll, Token};
use rog_platform::error::PlatformError; use rog_platform::error::PlatformError;
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use tokio::sync::Mutex;
use udev::{Device, MonitorBuilder}; use udev::{Device, MonitorBuilder};
use zbus::zvariant::{ObjectPath, OwnedObjectPath}; use zbus::zvariant::{ObjectPath, OwnedObjectPath};
use zbus::Connection; use zbus::Connection;
@@ -56,7 +56,7 @@ fn dbus_path_for_dev(parent: &Device) -> Option<OwnedObjectPath> {
if let Some(filename) = filename_partial(parent) { if let Some(filename) = filename_partial(parent) {
return Some( return Some(
ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{filename}")) ObjectPath::from_str_unchecked(&format!("{ASUS_ZBUS_PATH}/{MOD_NAME}/{filename}"))
.into() .into(),
); );
} }
None None
@@ -91,17 +91,17 @@ fn dev_prop_matches(dev: &Device, prop: &str, value: &str) -> bool {
/// required. /// required.
pub struct AsusDevice { pub struct AsusDevice {
device: DeviceHandle, device: DeviceHandle,
dbus_path: OwnedObjectPath dbus_path: OwnedObjectPath,
} }
pub struct DeviceManager { pub struct DeviceManager {
_dbus_connection: Connection _dbus_connection: Connection,
} }
impl DeviceManager { impl DeviceManager {
async fn init_hid_devices( async fn init_hid_devices(
connection: &Connection, connection: &Connection,
device: Device device: Device,
) -> Result<Vec<AsusDevice>, RogError> { ) -> Result<Vec<AsusDevice>, RogError> {
let mut devices = Vec::new(); let mut devices = Vec::new();
if let Some(usb_device) = device.parent_with_subsystem_devtype("usb", "usb_device")? { if let Some(usb_device) = device.parent_with_subsystem_devtype("usb", "usb_device")? {
@@ -122,7 +122,7 @@ impl DeviceManager {
// SLASH DEVICE // SLASH DEVICE
if let Ok(dev_type) = DeviceHandle::new_slash_hid( if let Ok(dev_type) = DeviceHandle::new_slash_hid(
dev.clone(), dev.clone(),
usb_id.to_str().unwrap_or_default() usb_id.to_str().unwrap_or_default(),
) )
.await .await
{ {
@@ -133,14 +133,14 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice { devices.push(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path dbus_path: path,
}); });
} }
} }
// ANIME MATRIX DEVICE // ANIME MATRIX DEVICE
if let Ok(dev_type) = DeviceHandle::maybe_anime_hid( if let Ok(dev_type) = DeviceHandle::maybe_anime_hid(
dev.clone(), dev.clone(),
usb_id.to_str().unwrap_or_default() usb_id.to_str().unwrap_or_default(),
) )
.await .await
{ {
@@ -151,14 +151,14 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice { devices.push(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path dbus_path: path,
}); });
} }
} }
// AURA LAPTOP DEVICE // AURA LAPTOP DEVICE
if let Ok(dev_type) = DeviceHandle::maybe_laptop_aura( if let Ok(dev_type) = DeviceHandle::maybe_laptop_aura(
Some(dev), Some(dev),
usb_id.to_str().unwrap_or_default() usb_id.to_str().unwrap_or_default(),
) )
.await .await
{ {
@@ -169,7 +169,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice { devices.push(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path dbus_path: path,
}); });
} }
} }
@@ -209,7 +209,7 @@ impl DeviceManager {
async fn init_scsi( async fn init_scsi(
connection: &Connection, connection: &Connection,
device: &Device, device: &Device,
path: OwnedObjectPath path: OwnedObjectPath,
) -> Option<AsusDevice> { ) -> Option<AsusDevice> {
// "ID_MODEL_ID" "1932" // "ID_MODEL_ID" "1932"
// "ID_VENDOR_ID" "0b05" // "ID_VENDOR_ID" "0b05"
@@ -227,7 +227,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
return Some(AsusDevice { return Some(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path dbus_path: path,
}); });
} }
} }
@@ -305,7 +305,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice { devices.push(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path dbus_path: path,
}); });
} }
} else { } else {
@@ -319,11 +319,17 @@ impl DeviceManager {
if let DeviceHandle::AniMe(anime) = dev_type.clone() { if let DeviceHandle::AniMe(anime) = dev_type.clone() {
let path = dbus_path_for_anime(); let path = dbus_path_for_anime();
let ctrl = AniMeZbus::new(anime); let ctrl = AniMeZbus::new(anime);
ctrl.start_tasks(connection, path.clone()).await.unwrap(); if ctrl
devices.push(AsusDevice { .start_tasks(connection, path.clone())
device: dev_type, .await
dbus_path: path .map_err(|e| error!("Failed to start tasks: {e:?}, not adding this device"))
}); .is_ok()
{
devices.push(AsusDevice {
device: dev_type,
dbus_path: path,
});
}
} }
} else { } else {
info!("Tested device was not AniMe Matrix"); info!("Tested device was not AniMe Matrix");
@@ -348,7 +354,7 @@ impl DeviceManager {
ctrl.start_tasks(connection, path.clone()).await.unwrap(); ctrl.start_tasks(connection, path.clone()).await.unwrap();
devices.push(AsusDevice { devices.push(AsusDevice {
device: dev_type, device: dev_type,
dbus_path: path dbus_path: path,
}); });
} }
} }
@@ -364,16 +370,16 @@ impl DeviceManager {
pub async fn new(connection: Connection) -> Result<Self, RogError> { pub async fn new(connection: Connection) -> Result<Self, RogError> {
let conn_copy = connection.clone(); let conn_copy = connection.clone();
let devices = Arc::new(Mutex::new(Self::find_all_devices(&conn_copy).await)); let devices = Self::find_all_devices(&conn_copy).await;
info!("Found {} valid devices on startup", devices.len());
let devices = Arc::new(Mutex::new(devices));
let manager = Self { let manager = Self {
_dbus_connection: connection _dbus_connection: connection,
}; };
// TODO: The /sysfs/ LEDs don't cause events, so they need to be manually // TODO: The /sysfs/ LEDs don't cause events, so they need to be manually
// checked for and added // checked for and added
// detect all plugged in aura devices (eventually)
// only USB devices are detected for here
std::thread::spawn(move || { std::thread::spawn(move || {
let mut monitor = MonitorBuilder::new()?.listen()?; let mut monitor = MonitorBuilder::new()?.listen()?;
let mut poll = Poll::new()?; let mut poll = Poll::new()?;
@@ -420,7 +426,10 @@ impl DeviceManager {
{ {
index index
} else { } else {
warn!("No device for dbus path: {path:?}"); if dev_prop_matches(&event.device(), "ID_VENDOR_ID", "0b05")
{
warn!("No device for dbus path: {path:?}");
}
return Ok(()); return Ok(());
}; };
info!("removing: {path:?}"); info!("removing: {path:?}");
@@ -500,7 +509,7 @@ impl DeviceManager {
.remove::<ScsiZbus, _>(&path) .remove::<ScsiZbus, _>(&path)
.await? .await?
} }
_ => todo!() _ => todo!(),
}; };
info!("AuraManager removed: {path:?}, {res}"); info!("AuraManager removed: {path:?}, {res}");
} }
+17 -17
View File
@@ -14,7 +14,7 @@ pub struct ScsiConfig {
pub dev_type: AuraDeviceType, pub dev_type: AuraDeviceType,
pub enabled: bool, pub enabled: bool,
pub current_mode: AuraMode, pub current_mode: AuraMode,
pub modes: BTreeMap<AuraMode, AuraEffect> pub modes: BTreeMap<AuraMode, AuraEffect>,
} }
impl ScsiConfig { impl ScsiConfig {
@@ -38,61 +38,61 @@ impl Default for ScsiConfig {
(AuraMode::Off, AuraEffect::default_with_mode(AuraMode::Off)), (AuraMode::Off, AuraEffect::default_with_mode(AuraMode::Off)),
( (
AuraMode::Static, AuraMode::Static,
AuraEffect::default_with_mode(AuraMode::Static) AuraEffect::default_with_mode(AuraMode::Static),
), ),
( (
AuraMode::Breathe, AuraMode::Breathe,
AuraEffect::default_with_mode(AuraMode::Breathe) AuraEffect::default_with_mode(AuraMode::Breathe),
), ),
( (
AuraMode::Flashing, AuraMode::Flashing,
AuraEffect::default_with_mode(AuraMode::Flashing) AuraEffect::default_with_mode(AuraMode::Flashing),
), ),
( (
AuraMode::RainbowCycle, AuraMode::RainbowCycle,
AuraEffect::default_with_mode(AuraMode::RainbowCycle) AuraEffect::default_with_mode(AuraMode::RainbowCycle),
), ),
( (
AuraMode::RainbowWave, AuraMode::RainbowWave,
AuraEffect::default_with_mode(AuraMode::RainbowWave) AuraEffect::default_with_mode(AuraMode::RainbowWave),
), ),
( (
AuraMode::RainbowCycleBreathe, AuraMode::RainbowCycleBreathe,
AuraEffect::default_with_mode(AuraMode::RainbowCycleBreathe) AuraEffect::default_with_mode(AuraMode::RainbowCycleBreathe),
), ),
( (
AuraMode::ChaseFade, AuraMode::ChaseFade,
AuraEffect::default_with_mode(AuraMode::ChaseFade) AuraEffect::default_with_mode(AuraMode::ChaseFade),
), ),
( (
AuraMode::RainbowCycleChaseFade, AuraMode::RainbowCycleChaseFade,
AuraEffect::default_with_mode(AuraMode::RainbowCycleChaseFade) AuraEffect::default_with_mode(AuraMode::RainbowCycleChaseFade),
), ),
( (
AuraMode::Chase, AuraMode::Chase,
AuraEffect::default_with_mode(AuraMode::Chase) AuraEffect::default_with_mode(AuraMode::Chase),
), ),
( (
AuraMode::RainbowCycleChase, AuraMode::RainbowCycleChase,
AuraEffect::default_with_mode(AuraMode::RainbowCycleChase) AuraEffect::default_with_mode(AuraMode::RainbowCycleChase),
), ),
( (
AuraMode::RainbowCycleWave, AuraMode::RainbowCycleWave,
AuraEffect::default_with_mode(AuraMode::RainbowCycleWave) AuraEffect::default_with_mode(AuraMode::RainbowCycleWave),
), ),
( (
AuraMode::RainbowPulseChase, AuraMode::RainbowPulseChase,
AuraEffect::default_with_mode(AuraMode::RainbowPulseChase) AuraEffect::default_with_mode(AuraMode::RainbowPulseChase),
), ),
( (
AuraMode::RandomFlicker, AuraMode::RandomFlicker,
AuraEffect::default_with_mode(AuraMode::RandomFlicker) AuraEffect::default_with_mode(AuraMode::RandomFlicker),
), ),
( (
AuraMode::DoubleFade, AuraMode::DoubleFade,
AuraEffect::default_with_mode(AuraMode::DoubleFade) AuraEffect::default_with_mode(AuraMode::DoubleFade),
) ),
]) ]),
} }
} }
} }
+2 -2
View File
@@ -1,8 +1,8 @@
use std::sync::Arc; use std::sync::Arc;
use config::ScsiConfig; use config::ScsiConfig;
use futures_util::lock::{Mutex, MutexGuard};
use rog_scsi::{AuraEffect, Device, Task}; use rog_scsi::{AuraEffect, Device, Task};
use tokio::sync::{Mutex, MutexGuard};
use crate::error::RogError; use crate::error::RogError;
@@ -12,7 +12,7 @@ pub mod trait_impls;
#[derive(Clone)] #[derive(Clone)]
pub struct ScsiAura { pub struct ScsiAura {
device: Arc<Mutex<Device>>, device: Arc<Mutex<Device>>,
config: Arc<Mutex<ScsiConfig>> config: Arc<Mutex<ScsiConfig>>,
} }
impl ScsiAura { impl ScsiAura {
+3 -3
View File
@@ -22,7 +22,7 @@ impl ScsiZbus {
pub async fn start_tasks( pub async fn start_tasks(
self, self,
connection: &Connection, connection: &Connection,
path: OwnedObjectPath path: OwnedObjectPath,
) -> Result<(), RogError> { ) -> Result<(), RogError> {
connection connection
.object_server() .object_server()
@@ -83,11 +83,11 @@ impl ScsiZbus {
#[zbus(property)] #[zbus(property)]
async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> { async fn led_mode_data(&self) -> Result<AuraEffect, ZbErr> {
// entirely possible to deadlock here, so use try instead of lock() // 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; let mode = config.current_mode;
match config.modes.get(&mode) { match config.modes.get(&mode) {
Some(effect) => Ok(effect.clone()), 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 { } else {
Err(ZbErr::Failed("Aura control couldn't lock self".to_string())) Err(ZbErr::Failed("Aura control couldn't lock self".to_string()))
+5 -3
View File
@@ -17,7 +17,8 @@ pub struct SlashConfig {
pub show_on_shutdown: bool, pub show_on_shutdown: bool,
pub show_on_sleep: bool, pub show_on_sleep: bool,
pub show_on_battery: 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 { impl Default for SlashConfig {
@@ -32,7 +33,8 @@ impl Default for SlashConfig {
show_on_shutdown: true, show_on_shutdown: true,
show_on_sleep: true, show_on_sleep: true,
show_on_battery: 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_enabled: config.enabled,
slash_brightness: config.brightness, slash_brightness: config.brightness,
slash_interval: config.display_interval, slash_interval: config.display_interval,
slash_mode: config.display_mode slash_mode: config.display_mode,
} }
} }
} }
+11 -12
View File
@@ -1,11 +1,10 @@
use std::sync::Arc; use std::sync::Arc;
use config::SlashConfig; use config::SlashConfig;
use futures_util::lock::{Mutex, MutexGuard};
use rog_platform::hid_raw::HidRaw; use rog_platform::hid_raw::HidRaw;
use rog_platform::usb_raw::USBRaw; use rog_platform::usb_raw::USBRaw;
use rog_slash::usb::{get_options_packet, pkt_set_mode, pkts_for_init}; use rog_slash::usb::{slash_pkt_enable, slash_pkt_init, slash_pkt_options, slash_pkt_set_mode};
use rog_slash::SlashType;
use tokio::sync::{Mutex, MutexGuard};
use crate::error::RogError; use crate::error::RogError;
@@ -16,14 +15,14 @@ pub mod trait_impls;
pub struct Slash { pub struct Slash {
hid: Option<Arc<Mutex<HidRaw>>>, hid: Option<Arc<Mutex<HidRaw>>>,
usb: Option<Arc<Mutex<USBRaw>>>, usb: Option<Arc<Mutex<USBRaw>>>,
config: Arc<Mutex<SlashConfig>> config: Arc<Mutex<SlashConfig>>,
} }
impl Slash { impl Slash {
pub fn new( pub fn new(
hid: Option<Arc<Mutex<HidRaw>>>, hid: Option<Arc<Mutex<HidRaw>>>,
usb: Option<Arc<Mutex<USBRaw>>>, usb: Option<Arc<Mutex<USBRaw>>>,
config: Arc<Mutex<SlashConfig>> config: Arc<Mutex<SlashConfig>>,
) -> Self { ) -> Self {
Self { hid, usb, config } Self { hid, usb, config }
} }
@@ -46,22 +45,22 @@ impl Slash {
pub async fn do_initialization(&self) -> Result<(), RogError> { pub async fn do_initialization(&self) -> Result<(), RogError> {
// Don't try to initialise these models as the asus drivers already did // Don't try to initialise these models as the asus drivers already did
let config = self.config.lock().await; let config = self.config.lock().await;
if !matches!(config.slash_type, SlashType::GA605 | SlashType::GU605) { for pkt in &slash_pkt_init(config.slash_type) {
for pkt in &pkts_for_init(config.slash_type) { self.write_bytes(pkt).await?;
self.write_bytes(pkt).await?;
}
} }
self.write_bytes(&slash_pkt_enable(config.slash_type, config.enabled))
.await?;
// Apply config upon initialization // Apply config upon initialization
let option_packets = get_options_packet( let option_packets = slash_pkt_options(
config.slash_type, config.slash_type,
config.enabled, config.enabled,
config.brightness, config.brightness,
config.display_interval config.display_interval,
); );
self.write_bytes(&option_packets).await?; 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.node.write_bytes(&mode_packets[0])?;
self.write_bytes(&mode_packets[1]).await?; self.write_bytes(&mode_packets[1]).await?;
+53 -23
View File
@@ -1,8 +1,9 @@
use config_traits::StdConfig; use config_traits::StdConfig;
use log::{debug, error, warn}; use log::{debug, error, warn};
use rog_slash::usb::{ use rog_slash::usb::{
get_battery_saver_packet, get_boot_packet, get_low_battery_packet, get_options_packet, slash_pkt_battery_saver, slash_pkt_boot, slash_pkt_enable, slash_pkt_lid_closed,
get_shutdown_packet, get_sleep_packet, pkt_save, pkt_set_mode 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 rog_slash::{DeviceState, SlashMode};
use zbus::zvariant::OwnedObjectPath; use zbus::zvariant::OwnedObjectPath;
@@ -23,7 +24,7 @@ impl SlashZbus {
pub async fn start_tasks( pub async fn start_tasks(
mut self, mut self,
connection: &Connection, connection: &Connection,
path: OwnedObjectPath path: OwnedObjectPath,
) -> Result<(), RogError> { ) -> Result<(), RogError> {
// let task = zbus.clone(); // let task = zbus.clone();
self.reload() self.reload()
@@ -58,11 +59,18 @@ impl SlashZbus {
config.brightness config.brightness
}; };
self.0 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, config.slash_type,
enabled, enabled,
brightness, brightness,
config.display_interval config.display_interval,
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -88,11 +96,11 @@ impl SlashZbus {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
let enabled = brightness > 0; let enabled = brightness > 0;
self.0 self.0
.write_bytes(&get_options_packet( .write_bytes(&slash_pkt_options(
config.slash_type, config.slash_type,
enabled, enabled,
brightness, brightness,
config.display_interval config.display_interval,
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -116,8 +124,8 @@ impl SlashZbus {
async fn set_interval(&self, interval: u8) { async fn set_interval(&self, interval: u8) {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
self.0 self.0
.write_bytes(&get_options_packet( .write_bytes(&slash_pkt_options(
config.slash_type, config.enabled, config.brightness, interval config.slash_type, config.enabled, config.brightness, interval,
)) ))
.await .await
.map_err(|err| { .map_err(|err| {
@@ -140,10 +148,12 @@ impl SlashZbus {
async fn set_mode(&self, mode: SlashMode) -> zbus::Result<()> { async fn set_mode(&self, mode: SlashMode) -> zbus::Result<()> {
let mut config = self.0.lock_config().await; 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.node.write_bytes(&command_packets[0])?;
self.0.write_bytes(&command_packets[1]).await?; 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.display_mode = mode;
config.write(); config.write();
@@ -167,7 +177,7 @@ impl SlashZbus {
async fn set_show_on_boot(&self, enable: bool) -> zbus::Result<()> { async fn set_show_on_boot(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
self.0 self.0
.write_bytes(&get_boot_packet(config.slash_type, enable)) .write_bytes(&slash_pkt_boot(config.slash_type, enable))
.await?; .await?;
config.show_on_boot = enable; config.show_on_boot = enable;
config.write(); config.write();
@@ -184,7 +194,7 @@ impl SlashZbus {
async fn set_show_on_sleep(&self, enable: bool) -> zbus::Result<()> { async fn set_show_on_sleep(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
self.0 self.0
.write_bytes(&get_sleep_packet(config.slash_type, enable)) .write_bytes(&slash_pkt_sleep(config.slash_type, enable))
.await?; .await?;
config.show_on_sleep = enable; config.show_on_sleep = enable;
config.write(); config.write();
@@ -201,7 +211,7 @@ impl SlashZbus {
async fn set_show_on_shutdown(&self, enable: bool) -> zbus::Result<()> { async fn set_show_on_shutdown(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
self.0 self.0
.write_bytes(&get_shutdown_packet(config.slash_type, enable)) .write_bytes(&slash_pkt_shutdown(config.slash_type, enable))
.await?; .await?;
config.show_on_shutdown = enable; config.show_on_shutdown = enable;
config.write(); config.write();
@@ -218,7 +228,7 @@ impl SlashZbus {
async fn set_show_on_battery(&self, enable: bool) -> zbus::Result<()> { async fn set_show_on_battery(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
self.0 self.0
.write_bytes(&get_battery_saver_packet(config.slash_type, enable)) .write_bytes(&slash_pkt_battery_saver(config.slash_type, enable))
.await?; .await?;
config.show_on_battery = enable; config.show_on_battery = enable;
config.write(); config.write();
@@ -235,12 +245,32 @@ impl SlashZbus {
async fn set_show_battery_warning(&self, enable: bool) -> zbus::Result<()> { async fn set_show_battery_warning(&self, enable: bool) -> zbus::Result<()> {
let mut config = self.0.lock_config().await; let mut config = self.0.lock_config().await;
self.0 self.0
.write_bytes(&get_low_battery_packet(config.slash_type, enable)) .write_bytes(&slash_pkt_low_battery(config.slash_type, enable))
.await?; .await?;
config.show_battery_warning = enable; config.show_battery_warning = enable;
config.write(); config.write();
Ok(()) 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 { impl Reloadable for SlashZbus {
@@ -248,11 +278,11 @@ impl Reloadable for SlashZbus {
debug!("reloading slash settings"); debug!("reloading slash settings");
let config = self.0.lock_config().await; let config = self.0.lock_config().await;
self.0 self.0
.write_bytes(&get_options_packet( .write_bytes(&slash_pkt_options(
config.slash_type, config.slash_type,
config.enabled, config.enabled,
config.brightness, config.brightness,
config.display_interval config.display_interval,
)) ))
.await .await
.map_err(|err| { .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!(slash_pkt_boot, show_on_boot, "show_on_boot");
write_bytes_with_warning!(get_sleep_packet, show_on_sleep, "show_on_sleep"); write_bytes_with_warning!(slash_pkt_sleep, show_on_sleep, "show_on_sleep");
write_bytes_with_warning!(get_shutdown_packet, show_on_shutdown, "show_on_shutdown"); write_bytes_with_warning!(slash_pkt_shutdown, 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_battery_saver, show_on_battery, "show_on_battery");
write_bytes_with_warning!( write_bytes_with_warning!(
get_low_battery_packet, slash_pkt_low_battery,
show_battery_warning, show_battery_warning,
"show_battery_warning" "show_battery_warning"
); );
+29 -24
View File
@@ -1,6 +1,7 @@
use std::sync::Arc; use std::sync::Arc;
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use futures_util::lock::Mutex;
use log::{debug, error, info}; use log::{debug, error, info};
use rog_anime::error::AnimeError; use rog_anime::error::AnimeError;
use rog_anime::usb::get_anime_type; 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_scsi::{open_device, ScsiType};
use rog_slash::error::SlashError; use rog_slash::error::SlashError;
use rog_slash::SlashType; use rog_slash::SlashType;
use tokio::sync::Mutex;
use crate::aura_anime::config::AniMeConfig; use crate::aura_anime::config::AniMeConfig;
use crate::aura_anime::AniMe; use crate::aura_anime::AniMe;
@@ -31,7 +31,7 @@ pub enum _DeviceHandle {
LedClass(KeyboardBacklight), LedClass(KeyboardBacklight),
/// TODO /// TODO
MulticolourLed, MulticolourLed,
None None,
} }
#[derive(Clone)] #[derive(Clone)]
@@ -47,14 +47,14 @@ pub enum DeviceHandle {
TufLedClass(Arc<Mutex<HidRaw>>), TufLedClass(Arc<Mutex<HidRaw>>),
/// TODO /// TODO
MulticolourLed, MulticolourLed,
None None,
} }
impl DeviceHandle { impl DeviceHandle {
/// Try Slash HID. If one exists it is initialsed and returned. /// Try Slash HID. If one exists it is initialsed and returned.
pub async fn new_slash_hid( pub async fn new_slash_hid(
device: Arc<Mutex<HidRaw>>, device: Arc<Mutex<HidRaw>>,
prod_id: &str prod_id: &str,
) -> Result<Self, RogError> { ) -> Result<Self, RogError> {
debug!("Testing for HIDRAW Slash"); debug!("Testing for HIDRAW Slash");
let slash_type = SlashType::from_dmi(); let slash_type = SlashType::from_dmi();
@@ -93,7 +93,7 @@ impl DeviceHandle {
let slash = Slash::new( let slash = Slash::new(
None, None,
Some(Arc::new(Mutex::new(usb))), Some(Arc::new(Mutex::new(usb))),
Arc::new(Mutex::new(config)) Arc::new(Mutex::new(config)),
); );
slash.do_initialization().await?; slash.do_initialization().await?;
Ok(Self::Slash(slash)) Ok(Self::Slash(slash))
@@ -104,23 +104,28 @@ impl DeviceHandle {
/// Try AniMe Matrix HID. If one exists it is initialsed and returned. /// Try AniMe Matrix HID. If one exists it is initialsed and returned.
pub async fn maybe_anime_hid( pub async fn maybe_anime_hid(
device: Arc<Mutex<HidRaw>>, _device: Arc<Mutex<HidRaw>>,
prod_id: &str _prod_id: &str,
) -> Result<Self, RogError> { ) -> Result<Self, RogError> {
debug!("Testing for HIDRAW AniMe"); // TODO: can't use HIDRAW for anime at the moment
let anime_type = AnimeType::from_dmi(); Err(RogError::NotFound(
dbg!(prod_id); "Can't use anime over hidraw yet. Skip.".to_string(),
if matches!(anime_type, AnimeType::Unsupported) || prod_id != "193b" { ))
log::info!("Unknown or invalid AniMe: {prod_id:?}, skipping");
return Err(RogError::NotFound("No anime-matrix device".to_string()));
}
info!("Found AniMe Matrix HIDRAW {anime_type:?}: {prod_id}");
let mut config = AniMeConfig::new().load(); // debug!("Testing for HIDRAW AniMe");
config.anime_type = anime_type; // let anime_type = AnimeType::from_dmi();
let mut anime = AniMe::new(Some(device), None, Arc::new(Mutex::new(config))); // dbg!(prod_id);
anime.do_initialization().await?; // if matches!(anime_type, AnimeType::Unsupported) || prod_id != "193b"
Ok(Self::AniMe(anime)) // { log::info!("Unknown or invalid AniMe: {prod_id:?},
// skipping"); return Err(RogError::NotFound("No
// anime-matrix device".to_string())); }
// info!("Found AniMe Matrix HIDRAW {anime_type:?}: {prod_id}");
// let mut config = AniMeConfig::new().load();
// config.anime_type = anime_type;
// let mut anime = AniMe::new(Some(device), None,
// Arc::new(Mutex::new(config))); anime.do_initialization().
// await?; Ok(Self::AniMe(anime))
} }
pub async fn maybe_anime_usb() -> Result<Self, RogError> { pub async fn maybe_anime_usb() -> Result<Self, RogError> {
@@ -139,13 +144,13 @@ impl DeviceHandle {
let mut anime = AniMe::new( let mut anime = AniMe::new(
None, None,
Some(Arc::new(Mutex::new(usb))), Some(Arc::new(Mutex::new(usb))),
Arc::new(Mutex::new(config)) Arc::new(Mutex::new(config)),
); );
anime.do_initialization().await?; anime.do_initialization().await?;
Ok(Self::AniMe(anime)) Ok(Self::AniMe(anime))
} else { } else {
Err(RogError::NotFound( Err(RogError::NotFound(
"No AnimeMatrix device found".to_string() "No AnimeMatrix device found".to_string(),
)) ))
} }
} }
@@ -169,7 +174,7 @@ impl DeviceHandle {
pub async fn maybe_laptop_aura( pub async fn maybe_laptop_aura(
device: Option<Arc<Mutex<HidRaw>>>, device: Option<Arc<Mutex<HidRaw>>>,
prod_id: &str prod_id: &str,
) -> Result<Self, RogError> { ) -> Result<Self, RogError> {
debug!("Testing for laptop aura"); debug!("Testing for laptop aura");
let aura_type = AuraDeviceType::from(prod_id); let aura_type = AuraDeviceType::from(prod_id);
@@ -196,7 +201,7 @@ impl DeviceHandle {
let aura = Aura { let aura = Aura {
hid: device, hid: device,
backlight, backlight,
config: Arc::new(Mutex::new(config)) config: Arc::new(Mutex::new(config)),
}; };
aura.do_initialization().await?; aura.do_initialization().await?;
Ok(Self::Aura(aura)) Ok(Self::Aura(aura))
+95 -92
View File
@@ -1,66 +1,66 @@
use std::collections::HashMap;
use config_traits::{StdConfig, StdConfigLoad1}; use config_traits::{StdConfig, StdConfigLoad1};
use rog_platform::asus_armoury::FirmwareAttribute;
use rog_platform::cpu::CPUEPP; use rog_platform::cpu::CPUEPP;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
const CONFIG_FILE: &str = "asusd.ron"; const CONFIG_FILE: &str = "asusd.ron";
#[derive(Deserialize, Serialize, Debug, PartialEq, PartialOrd)] #[derive(Default, Clone, Deserialize, Serialize, PartialEq)]
pub struct Tuning {
pub enabled: bool,
pub group: HashMap<FirmwareAttribute, i32>,
}
type Tunings = HashMap<PlatformProfile, Tuning>;
#[derive(Deserialize, Serialize, PartialEq)]
pub struct Config { pub struct Config {
// The current charge limit applied // The current charge limit applied
pub charge_control_end_threshold: u8, pub charge_control_end_threshold: u8,
/// Save charge limit for restoring /// Save charge limit for restoring
#[serde(skip)] #[serde(skip)]
pub base_charge_control_end_threshold: u8, pub base_charge_control_end_threshold: u8,
pub panel_od: bool,
pub boot_sound: bool,
pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool, pub disable_nvidia_powerd_on_battery: bool,
/// An optional command/script to run when power is changed to AC /// An optional command/script to run when power is changed to AC
pub ac_command: String, pub ac_command: String,
/// An optional command/script to run when power is changed to battery /// An optional command/script to run when power is changed to battery
pub bat_command: String, pub bat_command: String,
/// Set true if energy_performance_preference should be set if the /// Set true if energy_performance_preference should be set if the
/// throttle/platform profile is changed /// platform profile is changed
pub throttle_policy_linked_epp: bool, pub platform_profile_linked_epp: bool,
/// Which throttle/profile to use on battery power /// Which platform profile to use on battery power
pub throttle_policy_on_battery: ThrottlePolicy, pub platform_profile_on_battery: PlatformProfile,
/// Should the throttle policy be set on bat/ac change? /// Should the throttle policy be set on bat/ac change?
pub change_throttle_policy_on_battery: bool, pub change_platform_profile_on_battery: bool,
/// Which throttle/profile to use on AC power /// Which platform profile to use on AC power
pub throttle_policy_on_ac: ThrottlePolicy, pub platform_profile_on_ac: PlatformProfile,
/// Should the throttle policy be set on bat/ac change? /// Should the platform profile be set on bat/ac change?
pub change_throttle_policy_on_ac: bool, pub change_platform_profile_on_ac: bool,
/// The energy_performance_preference for this throttle/platform profile /// The energy_performance_preference for this platform profile
pub throttle_quiet_epp: CPUEPP, pub profile_quiet_epp: CPUEPP,
/// The energy_performance_preference for this throttle/platform profile /// The energy_performance_preference for this platform profile
pub throttle_balanced_epp: CPUEPP, pub profile_balanced_epp: CPUEPP,
/// The energy_performance_preference for this throttle/platform profile /// The energy_performance_preference for this platform profile
pub throttle_performance_epp: CPUEPP, pub profile_performance_epp: CPUEPP,
/// Defaults to `None` if not supported pub ac_profile_tunings: Tunings,
#[serde(skip_serializing_if = "Option::is_none", default)] pub dc_profile_tunings: Tunings,
pub ppt_pl1_spl: Option<u8>, pub armoury_settings: HashMap<FirmwareAttribute, i32>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl2_sppt: Option<u8>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_fppt: Option<u8>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_apu_sppt: Option<u8>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_platform_sppt: Option<u8>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub nv_dynamic_boost: Option<u8>,
/// Defaults to `None` if not supported
#[serde(skip_serializing_if = "Option::is_none", default)]
pub nv_temp_target: Option<u8>,
/// Temporary state for AC/Batt /// Temporary state for AC/Batt
#[serde(skip)] #[serde(skip)]
pub last_power_plugged: u8 pub last_power_plugged: u8,
}
impl Config {
pub fn select_tunings(&mut self, power_plugged: bool, profile: PlatformProfile) -> &mut Tuning {
let config = if power_plugged {
&mut self.ac_profile_tunings
} else {
&mut self.dc_profile_tunings
};
config.entry(profile).or_insert_with(Tuning::default)
}
} }
impl Default for Config { impl Default for Config {
@@ -68,28 +68,21 @@ impl Default for Config {
Self { Self {
charge_control_end_threshold: 100, charge_control_end_threshold: 100,
base_charge_control_end_threshold: 100, base_charge_control_end_threshold: 100,
panel_od: false,
boot_sound: false,
mini_led_mode: false,
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
ac_command: Default::default(), ac_command: Default::default(),
bat_command: Default::default(), bat_command: Default::default(),
throttle_policy_linked_epp: true, platform_profile_linked_epp: true,
throttle_policy_on_battery: ThrottlePolicy::Quiet, platform_profile_on_battery: PlatformProfile::Quiet,
change_throttle_policy_on_battery: true, change_platform_profile_on_battery: true,
throttle_policy_on_ac: ThrottlePolicy::Performance, platform_profile_on_ac: PlatformProfile::Performance,
change_throttle_policy_on_ac: true, change_platform_profile_on_ac: true,
throttle_quiet_epp: CPUEPP::Power, profile_quiet_epp: CPUEPP::Power,
throttle_balanced_epp: CPUEPP::BalancePower, profile_balanced_epp: CPUEPP::BalancePower,
throttle_performance_epp: CPUEPP::Performance, profile_performance_epp: CPUEPP::Performance,
ppt_pl1_spl: Default::default(), ac_profile_tunings: HashMap::default(),
ppt_pl2_sppt: Default::default(), dc_profile_tunings: HashMap::default(),
ppt_fppt: Default::default(), armoury_settings: HashMap::default(),
ppt_apu_sppt: Default::default(), last_power_plugged: Default::default(),
ppt_platform_sppt: Default::default(),
nv_dynamic_boost: Default::default(),
nv_temp_target: Default::default(),
last_power_plugged: Default::default()
} }
} }
} }
@@ -99,8 +92,8 @@ impl StdConfig for Config {
Config { Config {
charge_control_end_threshold: 100, charge_control_end_threshold: 100,
disable_nvidia_powerd_on_battery: true, disable_nvidia_powerd_on_battery: true,
throttle_policy_on_battery: ThrottlePolicy::Quiet, platform_profile_on_battery: PlatformProfile::Quiet,
throttle_policy_on_ac: ThrottlePolicy::Performance, platform_profile_on_ac: PlatformProfile::Performance,
ac_command: String::new(), ac_command: String::new(),
bat_command: String::new(), bat_command: String::new(),
..Default::default() ..Default::default()
@@ -116,58 +109,68 @@ impl StdConfig for Config {
} }
} }
impl StdConfigLoad1<Config507> for Config {} impl StdConfigLoad1<Config601> for Config {}
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
pub struct Config507 { pub struct Config601 {
// The current charge limit applied
pub charge_control_end_threshold: u8, pub charge_control_end_threshold: u8,
#[serde(skip)]
pub base_charge_control_end_threshold: u8,
pub panel_od: bool, pub panel_od: bool,
pub boot_sound: bool,
pub mini_led_mode: bool, pub mini_led_mode: bool,
pub disable_nvidia_powerd_on_battery: bool, pub disable_nvidia_powerd_on_battery: bool,
pub ac_command: String, pub ac_command: String,
pub bat_command: String, pub bat_command: String,
pub platform_policy_linked_epp: bool, pub platform_profile_linked_epp: bool,
pub platform_policy_on_battery: ThrottlePolicy, pub platform_profile_on_battery: PlatformProfile,
pub platform_policy_on_ac: ThrottlePolicy, pub change_platform_profile_on_battery: bool,
// pub platform_profile_on_ac: PlatformProfile,
pub change_platform_profile_on_ac: bool,
pub profile_quiet_epp: CPUEPP,
pub profile_balanced_epp: CPUEPP,
pub profile_performance_epp: CPUEPP,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl1_spl: Option<u8>, pub ppt_pl1_spl: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl2_sppt: Option<u8>, pub ppt_pl2_sppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_pl3_fppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_fppt: Option<u8>, pub ppt_fppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_apu_sppt: Option<u8>, pub ppt_apu_sppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ppt_platform_sppt: Option<u8>, pub ppt_platform_sppt: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub nv_dynamic_boost: Option<u8>, pub nv_dynamic_boost: Option<u8>,
pub nv_temp_target: Option<u8> #[serde(skip_serializing_if = "Option::is_none", default)]
pub nv_temp_target: Option<u8>,
#[serde(skip)]
pub last_power_plugged: u8,
} }
impl From<Config507> for Config { impl From<Config601> for Config {
fn from(c: Config507) -> Self { fn from(c: Config601) -> Self {
Self { Self {
// Restore the base charge limit // Restore the base charge limit
charge_control_end_threshold: c.charge_control_end_threshold, charge_control_end_threshold: c.charge_control_end_threshold,
base_charge_control_end_threshold: c.charge_control_end_threshold, base_charge_control_end_threshold: c.charge_control_end_threshold,
panel_od: c.panel_od,
boot_sound: false,
disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery, disable_nvidia_powerd_on_battery: c.disable_nvidia_powerd_on_battery,
ac_command: c.ac_command, ac_command: c.ac_command,
bat_command: c.bat_command, bat_command: c.bat_command,
mini_led_mode: c.mini_led_mode, platform_profile_linked_epp: c.platform_profile_linked_epp,
throttle_policy_linked_epp: true, platform_profile_on_battery: c.platform_profile_on_battery,
throttle_policy_on_battery: c.platform_policy_on_battery, change_platform_profile_on_battery: c.change_platform_profile_on_battery,
change_throttle_policy_on_battery: true, platform_profile_on_ac: c.platform_profile_on_ac,
throttle_policy_on_ac: c.platform_policy_on_ac, change_platform_profile_on_ac: c.change_platform_profile_on_ac,
change_throttle_policy_on_ac: true, profile_quiet_epp: c.profile_quiet_epp,
throttle_quiet_epp: CPUEPP::Power, profile_balanced_epp: c.profile_balanced_epp,
throttle_balanced_epp: CPUEPP::BalancePower, profile_performance_epp: c.profile_performance_epp,
throttle_performance_epp: CPUEPP::Performance, last_power_plugged: c.last_power_plugged,
ppt_pl1_spl: c.ppt_pl1_spl, ac_profile_tunings: HashMap::default(),
ppt_pl2_sppt: c.ppt_pl2_sppt, dc_profile_tunings: HashMap::default(),
ppt_fppt: c.ppt_fppt, armoury_settings: HashMap::default(),
ppt_apu_sppt: c.ppt_apu_sppt,
ppt_platform_sppt: c.ppt_platform_sppt,
nv_dynamic_boost: c.nv_dynamic_boost,
nv_temp_target: c.nv_temp_target,
last_power_plugged: 0
} }
} }
} }
+43 -38
View File
@@ -3,13 +3,13 @@ use std::sync::Arc;
use config_traits::{StdConfig, StdConfigLoad}; use config_traits::{StdConfig, StdConfigLoad};
use futures_lite::StreamExt; use futures_lite::StreamExt;
use futures_util::lock::Mutex;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use rog_platform::platform::{RogPlatform, ThrottlePolicy}; use rog_platform::platform::{PlatformProfile, RogPlatform};
use rog_profiles::error::ProfileError; use rog_profiles::error::ProfileError;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles}; use rog_profiles::{find_fan_curve_node, FanCurvePU, FanCurveProfiles};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::sync::Mutex;
use zbus::object_server::SignalEmitter; use zbus::object_server::SignalEmitter;
use zbus::{interface, Connection}; use zbus::{interface, Connection};
@@ -23,7 +23,7 @@ pub const FAN_CURVE_ZBUS_PATH: &str = "/xyz/ljones";
pub struct FanCurveConfig { pub struct FanCurveConfig {
pub profiles: FanCurveProfiles, pub profiles: FanCurveProfiles,
#[serde(skip)] #[serde(skip)]
pub current: u8 pub current: PlatformProfile,
} }
impl StdConfig for FanCurveConfig { impl StdConfig for FanCurveConfig {
@@ -47,14 +47,14 @@ impl StdConfigLoad for FanCurveConfig {}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct CtrlFanCurveZbus { pub struct CtrlFanCurveZbus {
config: Arc<Mutex<FanCurveConfig>>, config: Arc<Mutex<FanCurveConfig>>,
platform: RogPlatform platform: RogPlatform,
} }
// Non-zbus-derive impl // Non-zbus-derive impl
impl CtrlFanCurveZbus { impl CtrlFanCurveZbus {
pub fn new() -> Result<Self, RogError> { pub fn new() -> Result<Self, RogError> {
let platform = RogPlatform::new()?; let platform = RogPlatform::new()?;
if platform.has_throttle_thermal_policy() { if platform.has_platform_profile() {
info!("Device has profile control available"); info!("Device has profile control available");
find_fan_curve_node()?; find_fan_curve_node()?;
info!("Device has fan curves available"); info!("Device has fan curves available");
@@ -65,16 +65,16 @@ impl CtrlFanCurveZbus {
if config.profiles.balanced.is_empty() || !config.file_path().exists() { if config.profiles.balanced.is_empty() || !config.file_path().exists() {
info!("Fetching default fan curves"); info!("Fetching default fan curves");
let current = platform.get_throttle_thermal_policy()?; let current = platform.get_platform_profile()?;
for this in [ for this in [
ThrottlePolicy::Balanced, PlatformProfile::Balanced,
ThrottlePolicy::Performance, PlatformProfile::Performance,
ThrottlePolicy::Quiet PlatformProfile::Quiet,
] { ] {
// For each profile we need to switch to it before we // For each profile we need to switch to it before we
// can read the existing values from hardware. The ACPI method used // can read the existing values from hardware. The ACPI method used
// for this is what limits us. // for this is what limits us.
platform.set_throttle_thermal_policy(this.into())?; platform.set_platform_profile(this.into())?;
let mut dev = find_fan_curve_node()?; let mut dev = find_fan_curve_node()?;
fan_curves.set_active_curve_to_defaults(this, &mut dev)?; fan_curves.set_active_curve_to_defaults(this, &mut dev)?;
@@ -83,7 +83,7 @@ impl CtrlFanCurveZbus {
info!("{}", String::from(curve)); info!("{}", String::from(curve));
} }
} }
platform.set_throttle_thermal_policy(current)?; platform.set_platform_profile(current.as_str())?;
config.profiles = fan_curves; config.profiles = fan_curves;
config.write(); config.write();
} else { } else {
@@ -93,7 +93,7 @@ impl CtrlFanCurveZbus {
return Ok(Self { return Ok(Self {
config: Arc::new(Mutex::new(config)), config: Arc::new(Mutex::new(config)),
platform platform,
}); });
} }
@@ -107,8 +107,8 @@ impl CtrlFanCurveZbus {
/// fan curve if in the same profile mode /// fan curve if in the same profile mode
async fn set_fan_curves_enabled( async fn set_fan_curves_enabled(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
enabled: bool enabled: bool,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.config self.config
.lock() .lock()
@@ -128,9 +128,9 @@ impl CtrlFanCurveZbus {
/// activate a fan curve if in the same profile mode /// activate a fan curve if in the same profile mode
async fn set_profile_fan_curve_enabled( async fn set_profile_fan_curve_enabled(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
fan: FanCurvePU, fan: FanCurvePU,
enabled: bool enabled: bool,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.config self.config
.lock() .lock()
@@ -149,7 +149,7 @@ impl CtrlFanCurveZbus {
/// Get the fan-curve data for the currently active ThrottlePolicy /// Get the fan-curve data for the currently active ThrottlePolicy
async fn fan_curve_data( async fn fan_curve_data(
&mut self, &mut self,
profile: ThrottlePolicy profile: PlatformProfile,
) -> zbus::fdo::Result<Vec<CurveData>> { ) -> zbus::fdo::Result<Vec<CurveData>> {
let curve = self let curve = self
.config .config
@@ -165,15 +165,15 @@ impl CtrlFanCurveZbus {
/// Will also activate the fan curve if the user is in the same mode. /// Will also activate the fan curve if the user is in the same mode.
async fn set_fan_curve( async fn set_fan_curve(
&mut self, &mut self,
profile: ThrottlePolicy, profile: PlatformProfile,
curve: CurveData curve: CurveData,
) -> zbus::fdo::Result<()> { ) -> zbus::fdo::Result<()> {
self.config self.config
.lock() .lock()
.await .await
.profiles .profiles
.save_fan_curve(curve, profile)?; .save_fan_curve(curve, profile)?;
let active: ThrottlePolicy = self.platform.get_throttle_thermal_policy()?.into(); let active: PlatformProfile = self.platform.get_platform_profile()?.into();
if active == profile { if active == profile {
self.config self.config
.lock() .lock()
@@ -190,15 +190,15 @@ impl CtrlFanCurveZbus {
/// ///
/// Each platform_profile has a different default and the default can be /// Each platform_profile has a different default and the default can be
/// read only for the currently active profile. /// read only for the currently active profile.
async fn set_curves_to_defaults(&mut self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> { async fn set_curves_to_defaults(&mut self, profile: PlatformProfile) -> zbus::fdo::Result<()> {
let active = self.platform.get_throttle_thermal_policy()?; let active = self.platform.get_platform_profile()?;
self.platform.set_throttle_thermal_policy(profile.into())?; self.platform.set_platform_profile(profile.into())?;
self.config self.config
.lock() .lock()
.await .await
.profiles .profiles
.set_active_curve_to_defaults(profile, &mut find_fan_curve_node()?)?; .set_active_curve_to_defaults(profile, &mut find_fan_curve_node()?)?;
self.platform.set_throttle_thermal_policy(active)?; self.platform.set_platform_profile(active.as_str())?;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
} }
@@ -208,16 +208,16 @@ impl CtrlFanCurveZbus {
/// ///
/// Each platform_profile has a different default and the defualt can be /// Each platform_profile has a different default and the defualt can be
/// read only for the currently active profile. /// read only for the currently active profile.
async fn reset_profile_curves(&self, profile: ThrottlePolicy) -> zbus::fdo::Result<()> { async fn reset_profile_curves(&self, profile: PlatformProfile) -> zbus::fdo::Result<()> {
let active = self.platform.get_throttle_thermal_policy()?; let active = self.platform.get_platform_profile()?;
self.platform.set_throttle_thermal_policy(profile.into())?; self.platform.set_platform_profile(profile.into())?;
self.config self.config
.lock() .lock()
.await .await
.profiles .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_throttle_thermal_policy(active)?; self.platform.set_platform_profile(active.as_str())?;
self.config.lock().await.write(); self.config.lock().await.write();
Ok(()) Ok(())
@@ -236,27 +236,32 @@ impl CtrlTask for CtrlFanCurveZbus {
} }
async fn create_tasks(&self, _signal_ctxt: SignalEmitter<'static>) -> Result<(), RogError> { async fn create_tasks(&self, _signal_ctxt: SignalEmitter<'static>) -> Result<(), RogError> {
let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?; let watch_platform_profile = self.platform.monitor_platform_profile()?;
let platform = self.platform.clone(); let platform = self.platform.clone();
let config = self.config.clone(); let config = self.config.clone();
let fan_curves = self.config.clone(); let fan_curves = self.config.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut buffer = [0; 32]; let mut buffer = [0; 32];
if let Ok(mut stream) = watch_throttle_thermal_policy.into_event_stream(&mut buffer) { if let Ok(mut stream) = watch_platform_profile.into_event_stream(&mut buffer) {
while (stream.next().await).is_some() { while (stream.next().await).is_some() {
debug!("watch_throttle_thermal_policy changed"); debug!("watch_platform_profile changed");
if let Ok(profile) = platform.get_throttle_thermal_policy().map_err(|e| { if let Ok(profile) =
error!("get_throttle_thermal_policy error: {e}"); platform
}) { .get_platform_profile()
.map(|p| p.into())
.map_err(|e| {
error!("get_platform_profile error: {e}");
})
{
if profile != config.lock().await.current { if profile != config.lock().await.current {
fan_curves fan_curves
.lock() .lock()
.await .await
.profiles .profiles
.write_profile_curve_to_platform( .write_profile_curve_to_platform(
profile.into(), profile,
&mut find_fan_curve_node().unwrap() &mut find_fan_curve_node().unwrap(),
) )
.map_err(|e| warn!("write_profile_curve_to_platform, {}", e)) .map_err(|e| warn!("write_profile_curve_to_platform, {}", e))
.ok(); .ok();
@@ -274,7 +279,7 @@ impl CtrlTask for CtrlFanCurveZbus {
impl crate::Reloadable for CtrlFanCurveZbus { impl crate::Reloadable for CtrlFanCurveZbus {
/// Fetch the active profile and use that to set all related components up /// Fetch the active profile and use that to set all related components up
async fn reload(&mut self) -> Result<(), RogError> { async fn reload(&mut self) -> Result<(), RogError> {
let active = self.platform.get_throttle_thermal_policy()?.into(); let active = self.platform.get_platform_profile()?.into();
let mut config = self.config.lock().await; let mut config = self.config.lock().await;
if let Ok(mut device) = find_fan_curve_node() { if let Ok(mut device) = find_fan_curve_node() {
config config
+282 -494
View File
File diff suppressed because it is too large Load Diff
+21 -4
View File
@@ -2,7 +2,6 @@ use std::env;
use std::error::Error; use std::error::Error;
use std::sync::Arc; use std::sync::Arc;
use ::zbus::export::futures_util::lock::Mutex;
use ::zbus::Connection; use ::zbus::Connection;
use asusd::asus_armoury::start_attributes_zbus; use asusd::asus_armoury::start_attributes_zbus;
use asusd::aura_manager::DeviceManager; use asusd::aura_manager::DeviceManager;
@@ -11,7 +10,11 @@ use asusd::ctrl_fancurves::CtrlFanCurveZbus;
use asusd::ctrl_platform::CtrlPlatform; use asusd::ctrl_platform::CtrlPlatform;
use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME}; use asusd::{print_board_info, start_tasks, CtrlTask, DBUS_NAME};
use config_traits::{StdConfig, StdConfigLoad1}; use config_traits::{StdConfig, StdConfigLoad1};
use futures_util::lock::Mutex;
use log::{error, info}; use log::{error, info};
use rog_platform::asus_armoury::FirmwareAttributes;
use rog_platform::platform::RogPlatform;
use rog_platform::power::AsusPower;
use zbus::fdo::ObjectManager; use zbus::fdo::ObjectManager;
#[tokio::main] #[tokio::main]
@@ -27,7 +30,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let is_service = match env::var_os("IS_SERVICE") { let is_service = match env::var_os("IS_SERVICE") {
Some(val) => val == "1", Some(val) => val == "1",
None => true None => true,
}; };
if !is_service { if !is_service {
@@ -65,7 +68,17 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
let config = Arc::new(Mutex::new(config)); let config = Arc::new(Mutex::new(config));
// supported.add_to_server(&mut connection).await; // supported.add_to_server(&mut connection).await;
start_attributes_zbus(&server).await?; let platform = RogPlatform::new()?; // TODO: maybe needs async mutex?
let power = AsusPower::new()?; // TODO: maybe needs async mutex?
let attributes = FirmwareAttributes::new();
start_attributes_zbus(
&server,
platform.clone(),
power.clone(),
attributes.clone(),
config.clone(),
)
.await?;
match CtrlFanCurveZbus::new() { match CtrlFanCurveZbus::new() {
Ok(ctrl) => { Ok(ctrl) => {
@@ -78,9 +91,12 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
} }
match CtrlPlatform::new( match CtrlPlatform::new(
platform,
power,
attributes,
config.clone(), config.clone(),
&cfg_path, &cfg_path,
CtrlPlatform::signal_context(&server)? CtrlPlatform::signal_context(&server)?,
) { ) {
Ok(ctrl) => { Ok(ctrl) => {
let sig_ctx = CtrlPlatform::signal_context(&server)?; let sig_ctx = CtrlPlatform::signal_context(&server)?;
@@ -96,6 +112,7 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
// Request dbus name after finishing initalizing all functions // Request dbus name after finishing initalizing all functions
server.request_name(DBUS_NAME).await?; server.request_name(DBUS_NAME).await?;
info!("Startup success, begining dbus server loop");
loop { loop {
// This is just a blocker to idle and ensure the reator reacts // This is just a blocker to idle and ensure the reator reacts
server.executor().tick().await; server.executor().tick().await;
+2 -2
View File
@@ -37,7 +37,7 @@ pub enum RogError {
SystemdUnitAction(String), SystemdUnitAction(String),
SystemdUnitWaitTimeout(String), SystemdUnitWaitTimeout(String),
Command(String, std::io::Error), Command(String, std::io::Error),
ParseRon(ron::Error) ParseRon(ron::Error),
} }
impl fmt::Display for RogError { 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::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),
} }
} }
} }
+9 -9
View File
@@ -67,7 +67,7 @@ macro_rules! task_watch_item {
&self, &self,
signal_ctxt: SignalEmitter<'static>, signal_ctxt: SignalEmitter<'static>,
) -> Result<(), RogError> { ) -> Result<(), RogError> {
use zbus::export::futures_util::StreamExt; use futures_util::StreamExt;
let ctrl = self.clone(); let ctrl = self.clone();
concat_idents::concat_idents!(watch_fn = monitor_, $name { concat_idents::concat_idents!(watch_fn = monitor_, $name {
@@ -107,7 +107,7 @@ macro_rules! task_watch_item_notify {
&self, &self,
signal_ctxt: SignalEmitter<'static>, signal_ctxt: SignalEmitter<'static>,
) -> Result<(), RogError> { ) -> Result<(), RogError> {
use zbus::export::futures_util::StreamExt; use futures_util::StreamExt;
let ctrl = self.clone(); let ctrl = self.clone();
concat_idents::concat_idents!(watch_fn = monitor_, $name { concat_idents::concat_idents!(watch_fn = monitor_, $name {
@@ -149,7 +149,7 @@ pub trait ReloadAndNotify {
fn reload_and_notify( fn reload_and_notify(
&mut self, &mut self,
signal_context: &SignalEmitter<'static>, signal_context: &SignalEmitter<'static>,
data: Self::Data data: Self::Data,
) -> impl Future<Output = Result<(), RogError>> + Send; ) -> impl Future<Output = Result<(), RogError>> + Send;
} }
@@ -159,7 +159,7 @@ pub trait ZbusRun {
fn add_to_server_helper( fn add_to_server_helper(
iface: impl Interface, iface: impl Interface,
path: &str, path: &str,
server: &mut Connection server: &mut Connection,
) -> impl Future<Output = ()> + Send { ) -> impl Future<Output = ()> + Send {
async move { async move {
server server
@@ -188,7 +188,7 @@ pub trait CtrlTask {
/// separate thread. /// separate thread.
fn create_tasks( fn create_tasks(
&self, &self,
signal: SignalEmitter<'static> signal: SignalEmitter<'static>,
) -> impl Future<Output = Result<(), RogError>> + Send; ) -> impl Future<Output = Result<(), RogError>> + Send;
// /// Create a timed repeating task // /// Create a timed repeating task
@@ -212,7 +212,7 @@ pub trait CtrlTask {
mut on_prepare_for_sleep: F1, mut on_prepare_for_sleep: F1,
mut on_prepare_for_shutdown: F2, mut on_prepare_for_shutdown: F2,
mut on_lid_change: F3, mut on_lid_change: F3,
mut on_external_power_change: F4 mut on_external_power_change: F4,
) -> impl Future<Output = ()> + Send ) -> impl Future<Output = ()> + Send
where where
F1: FnMut(bool) -> Fut1 + Send + 'static, F1: FnMut(bool) -> Fut1 + Send + 'static,
@@ -222,7 +222,7 @@ pub trait CtrlTask {
Fut1: Future<Output = ()> + Send, Fut1: Future<Output = ()> + Send,
Fut2: Future<Output = ()> + Send, Fut2: Future<Output = ()> + Send,
Fut3: Future<Output = ()> + Send, Fut3: Future<Output = ()> + Send,
Fut4: Future<Output = ()> + Send Fut4: Future<Output = ()> + Send,
{ {
async { async {
let connection = Connection::system() let connection = Connection::system()
@@ -302,10 +302,10 @@ pub trait GetSupported {
pub async fn start_tasks<T>( pub async fn start_tasks<T>(
mut zbus: T, mut zbus: T,
connection: &mut Connection, connection: &mut Connection,
signal_ctx: SignalEmitter<'static> signal_ctx: SignalEmitter<'static>,
) -> Result<(), RogError> ) -> Result<(), RogError>
where where
T: ZbusRun + Reloadable + CtrlTask + Clone T: ZbusRun + Reloadable + CtrlTask + Clone,
{ {
let zbus_clone = zbus.clone(); let zbus_clone = zbus.clone();
+2 -2
View File
@@ -19,7 +19,7 @@ use serde::Serialize;
/// implemented, the rest are intended to be free methods. /// implemented, the rest are intended to be free methods.
pub trait StdConfig pub trait StdConfig
where where
Self: Serialize + DeserializeOwned Self: Serialize + DeserializeOwned,
{ {
/// Taking over the standard `new()` to ensure things can be generic /// Taking over the standard `new()` to ensure things can be generic
fn new() -> Self; fn new() -> Self;
@@ -203,7 +203,7 @@ macro_rules! std_config_load {
/// new one created /// new one created
pub trait $trait_name<$($generic),*> pub trait $trait_name<$($generic),*>
where where
Self: $crate::StdConfig +std::fmt::Debug + DeserializeOwned + Serialize, Self: $crate::StdConfig + DeserializeOwned + Serialize,
$($generic: DeserializeOwned + Into<Self>),* $($generic: DeserializeOwned + Into<Self>),*
{ {
fn load(mut self) -> Self { fn load(mut self) -> Self {
+2 -1
View File
@@ -6,7 +6,7 @@ After=nvidia-powerd.service systemd-udevd.service
[Service] [Service]
Environment=IS_SERVICE=1 Environment=IS_SERVICE=1
Environment=RUST_LOG="info" Environment=RUST_LOG="debug"
# required to prevent init issues with hid_asus and MCU # required to prevent init issues with hid_asus and MCU
ExecStartPre=/bin/sleep 1 ExecStartPre=/bin/sleep 1
ExecStart=/usr/bin/asusd ExecStart=/usr/bin/asusd
@@ -16,3 +16,4 @@ Type=dbus
BusName=xyz.ljones.Asusd BusName=xyz.ljones.Asusd
SELinuxContext=system_u:system_r:unconfined_t:s0 SELinuxContext=system_u:system_r:unconfined_t:s0
#SELinuxContext=system_u:object_r:modules_object_t:s0 #SELinuxContext=system_u:object_r:modules_object_t:s0
TimeoutSec=10
+2 -2
View File
@@ -12,7 +12,7 @@ pub struct DMIID {
pub bios_vendor: String, pub bios_vendor: String,
pub bios_version: String, pub bios_version: String,
pub product_family: String, pub product_family: String,
pub product_name: String pub product_name: String,
} }
impl DMIID { impl DMIID {
@@ -77,7 +77,7 @@ impl DMIID {
product_name: device product_name: device
.attribute_value("product_name") .attribute_value("product_name")
.map(|s| s.to_string_lossy().to_string()) .map(|s| s.to_string_lossy().to_string())
.unwrap_or("Unknown".to_string()) .unwrap_or("Unknown".to_string()),
}); });
} }
Err("dmi not found".into()) Err("dmi not found".into())
+13 -13
View File
@@ -23,15 +23,15 @@ const PANE_LEN: usize = BLOCK_END - BLOCK_START;
/// First packet is for GA401 + GA402 /// First packet is for GA401 + GA402
pub const USB_PREFIX1: [u8; 7] = [ 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 /// Second packet is for GA401 + GA402
pub const USB_PREFIX2: [u8; 7] = [ 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 /// Third packet is for GA402 matrix
pub const USB_PREFIX3: [u8; 7] = [ 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))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
@@ -40,7 +40,7 @@ pub struct Animations {
pub boot: AnimBooting, pub boot: AnimBooting,
pub awake: AnimAwake, pub awake: AnimAwake,
pub sleep: AnimSleeping, pub sleep: AnimSleeping,
pub shutdown: AnimShutdown pub shutdown: AnimShutdown,
} }
// TODO: move this out // TODO: move this out
@@ -54,7 +54,7 @@ pub struct DeviceState {
pub off_when_unplugged: bool, pub off_when_unplugged: bool,
pub off_when_suspended: bool, pub off_when_suspended: bool,
pub off_when_lid_closed: 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"))] #[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
@@ -64,7 +64,7 @@ pub enum AnimeType {
GA402, GA402,
GU604, GU604,
#[default] #[default]
Unsupported Unsupported,
} }
impl FromStr for AnimeType { impl FromStr for AnimeType {
@@ -75,7 +75,7 @@ impl FromStr for AnimeType {
"ga401" | "GA401" => Self::GA401, "ga401" | "GA401" => Self::GA401,
"ga402" | "GA402" => Self::GA402, "ga402" | "GA402" => Self::GA402,
"gu604" | "GU604" => Self::GU604, "gu604" | "GU604" => Self::GU604,
_ => Self::Unsupported _ => Self::Unsupported,
}) })
} }
} }
@@ -98,7 +98,7 @@ impl AnimeType {
pub fn width(&self) -> usize { pub fn width(&self) -> usize {
match self { match self {
AnimeType::GU604 => 70, AnimeType::GU604 => 70,
_ => 74 _ => 74,
} }
} }
@@ -107,7 +107,7 @@ impl AnimeType {
match self { match self {
AnimeType::GA401 => 36, AnimeType::GA401 => 36,
AnimeType::GU604 => 43, AnimeType::GU604 => 43,
_ => 39 _ => 39,
} }
} }
@@ -116,7 +116,7 @@ impl AnimeType {
match self { match self {
AnimeType::GA401 => PANE_LEN * 2, AnimeType::GA401 => PANE_LEN * 2,
AnimeType::GU604 => PANE_LEN * 3, AnimeType::GU604 => PANE_LEN * 3,
_ => PANE_LEN * 3 _ => PANE_LEN * 3,
} }
} }
} }
@@ -127,7 +127,7 @@ impl AnimeType {
#[derive(Debug, Clone, Deserialize, Serialize)] #[derive(Debug, Clone, Deserialize, Serialize)]
pub struct AnimeDataBuffer { pub struct AnimeDataBuffer {
data: Vec<u8>, data: Vec<u8>,
anime: AnimeType anime: AnimeType,
} }
impl AnimeDataBuffer { impl AnimeDataBuffer {
@@ -137,7 +137,7 @@ impl AnimeDataBuffer {
AnimeDataBuffer { AnimeDataBuffer {
data: vec![0u8; len], data: vec![0u8; len],
anime anime,
} }
} }
@@ -180,7 +180,7 @@ impl TryFrom<AnimeDataBuffer> for AnimePacketType {
let mut buffers = match anime.anime { let mut buffers = match anime.anime {
AnimeType::GA401 => vec![[0; 640]; 2], 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() { for (idx, chunk) in anime.data.as_slice().chunks(PANE_LEN).enumerate() {
+10 -10
View File
@@ -20,7 +20,7 @@ impl AnimeDiagonal {
Self( Self(
anime_type, anime_type,
vec![vec![0; anime_type.width()]; anime_type.height()], vec![vec![0; anime_type.width()]; anime_type.height()],
duration duration,
) )
} }
@@ -49,7 +49,7 @@ impl AnimeDiagonal {
path: &Path, path: &Path,
duration: Option<Duration>, duration: Option<Duration>,
bright: f32, bright: f32,
anime_type: AnimeType anime_type: AnimeType,
) -> Result<Self> { ) -> Result<Self> {
let data = std::fs::read(path).map_err(|e| { let data = std::fs::read(path).map_err(|e| {
error!("Could not open {path:?}: {e:?}"); error!("Could not open {path:?}: {e:?}");
@@ -86,7 +86,7 @@ impl AnimeDiagonal {
png_pong::PngRaster::Rgba16(ras) => { png_pong::PngRaster::Rgba16(ras) => {
Self::pixels_from_16bit(ras, &mut matrix, bright, false); 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) Ok(matrix)
@@ -96,9 +96,9 @@ impl AnimeDiagonal {
ras: &pix::Raster<P>, ras: &pix::Raster<P>,
matrix: &mut AnimeDiagonal, matrix: &mut AnimeDiagonal,
bright: f32, bright: f32,
grey: bool grey: bool,
) where ) where
P: pix::el::Pixel<Chan = pix::chan::Ch8> P: pix::el::Pixel<Chan = pix::chan::Ch8>,
{ {
let width = ras.width(); let width = ras.width();
for (y, row) in ras.pixels().chunks(width as usize).enumerate() { for (y, row) in ras.pixels().chunks(width as usize).enumerate() {
@@ -121,9 +121,9 @@ impl AnimeDiagonal {
ras: &pix::Raster<P>, ras: &pix::Raster<P>,
matrix: &mut AnimeDiagonal, matrix: &mut AnimeDiagonal,
bright: f32, bright: f32,
grey: bool grey: bool,
) where ) where
P: pix::el::Pixel<Chan = pix::chan::Ch16> P: pix::el::Pixel<Chan = pix::chan::Ch16>,
{ {
let width = ras.width(); let width = ras.width();
for (y, row) in ras.pixels().chunks(width as usize).enumerate() { for (y, row) in ras.pixels().chunks(width as usize).enumerate() {
@@ -146,7 +146,7 @@ impl AnimeDiagonal {
match anime_type { match anime_type {
AnimeType::GA401 => self.to_ga401_packets(), AnimeType::GA401 => self.to_ga401_packets(),
AnimeType::GU604 => self.to_gu604_packets(), AnimeType::GU604 => self.to_gu604_packets(),
_ => self.to_ga402_packets() _ => self.to_ga402_packets(),
} }
} }
@@ -224,7 +224,7 @@ impl AnimeDiagonal {
x: usize, x: usize,
y: usize, y: usize,
start_index: &mut usize, start_index: &mut usize,
len: usize len: usize,
) { ) {
buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len)); buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len));
*start_index += len; *start_index += len;
@@ -307,7 +307,7 @@ impl AnimeDiagonal {
x: usize, x: usize,
y: usize, y: usize,
start_index: &mut usize, start_index: &mut usize,
len: usize len: usize,
) { ) {
buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len)); buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len));
*start_index += len; *start_index += len;
+2 -2
View File
@@ -24,7 +24,7 @@ pub enum AnimeError {
DataBufferLength, DataBufferLength,
PixelGifWidth(usize), PixelGifWidth(usize),
PixelGifHeight(usize), PixelGifHeight(usize),
ParseError(String) ParseError(String),
} }
impl fmt::Display for AnimeError { impl fmt::Display for AnimeError {
@@ -61,7 +61,7 @@ impl fmt::Display for AnimeError {
AnimeError::PixelGifHeight(n) => write!( AnimeError::PixelGifHeight(n) => write!(
f, f,
"The gif used for pixel-perfect gif is is taller than {n}" "The gif used for pixel-perfect gif is is taller than {n}"
) ),
} }
} }
} }
+15 -15
View File
@@ -16,7 +16,7 @@ pub struct AnimeFrame {
/// the `asusd` daemon over dbus or converted to USB packet with /// the `asusd` daemon over dbus or converted to USB packet with
/// `AnimePacketType::from(buffer)` /// `AnimePacketType::from(buffer)`
data: AnimeDataBuffer, data: AnimeDataBuffer,
delay: Duration delay: Duration,
} }
impl AnimeFrame { impl AnimeFrame {
@@ -44,7 +44,7 @@ pub enum AnimTime {
/// Run for infinite time /// Run for infinite time
Infinite, Infinite,
/// Fade in, play for, fade out /// Fade in, play for, fade out
Fade(Fade) Fade(Fade),
} }
impl Default for AnimTime { impl Default for AnimTime {
@@ -59,7 +59,7 @@ impl Default for AnimTime {
pub struct Fade { pub struct Fade {
fade_in: Duration, fade_in: Duration,
show_for: Option<Duration>, show_for: Option<Duration>,
fade_out: Duration fade_out: Duration,
} }
impl Fade { impl Fade {
@@ -67,7 +67,7 @@ impl Fade {
Self { Self {
fade_in, fade_in,
show_for, show_for,
fade_out fade_out,
} }
} }
@@ -100,7 +100,7 @@ impl AnimeGif {
file_name: &Path, file_name: &Path,
duration: AnimTime, duration: AnimTime,
brightness: f32, brightness: f32,
anime_type: AnimeType anime_type: AnimeType,
) -> Result<Self> { ) -> Result<Self> {
let mut matrix = AnimeDiagonal::new(anime_type, None); let mut matrix = AnimeDiagonal::new(anime_type, None);
@@ -142,7 +142,7 @@ impl AnimeGif {
frames.push(AnimeFrame { frames.push(AnimeFrame {
data: matrix.into_data_buffer(anime_type)?, 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)) Ok(Self(frames, duration))
@@ -154,7 +154,7 @@ impl AnimeGif {
file_name: &Path, file_name: &Path,
anime_type: AnimeType, anime_type: AnimeType,
duration: AnimTime, duration: AnimTime,
brightness: f32 brightness: f32,
) -> Result<Self> { ) -> Result<Self> {
let image = AnimeDiagonal::from_png(file_name, None, brightness, anime_type)?; let image = AnimeDiagonal::from_png(file_name, None, brightness, anime_type)?;
@@ -170,7 +170,7 @@ impl AnimeGif {
let single = AnimeFrame { let single = AnimeFrame {
data: image.into_data_buffer(anime_type)?, 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]; let frames = vec![single; frame_count as usize];
@@ -187,7 +187,7 @@ impl AnimeGif {
translation: Vec2, translation: Vec2,
duration: AnimTime, duration: AnimTime,
brightness: f32, brightness: f32,
anime_type: AnimeType anime_type: AnimeType,
) -> Result<Self> { ) -> Result<Self> {
let mut frames = Vec::new(); let mut frames = Vec::new();
let mut decoder = gif::DecodeOptions::new(); let mut decoder = gif::DecodeOptions::new();
@@ -211,7 +211,7 @@ impl AnimeGif {
brightness, brightness,
pixels, pixels,
decoder.width() as u32, decoder.width() as u32,
anime_type anime_type,
)?; )?;
while let Some(frame) = decoder.read_next_frame()? { while let Some(frame) = decoder.read_next_frame()? {
@@ -226,7 +226,7 @@ impl AnimeGif {
brightness, brightness,
pixels, pixels,
width as u32, width as u32,
anime_type anime_type,
)?; )?;
} }
for (y, row) in frame.buffer.chunks(frame.width as usize * 4).enumerate() { 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); (x + frame.left as usize) + ((y + frame.top as usize) * width as usize);
image.get_mut()[pos] = Pixel { image.get_mut()[pos] = Pixel {
color: ((px[0] as u32 + px[1] as u32 + px[2] as u32) / 3), 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 { frames.push(AnimeFrame {
data: <AnimeDataBuffer>::try_from(&image)?, data: <AnimeDataBuffer>::try_from(&image)?,
delay: Duration::from_millis(wait as u64) delay: Duration::from_millis(wait as u64),
}); });
} }
Ok(Self(frames, duration)) Ok(Self(frames, duration))
@@ -265,7 +265,7 @@ impl AnimeGif {
translation: Vec2, translation: Vec2,
duration: AnimTime, duration: AnimTime,
brightness: f32, brightness: f32,
anime_type: AnimeType anime_type: AnimeType,
) -> Result<Self> { ) -> Result<Self> {
let image = let image =
AnimeImage::from_png(file_name, scale, angle, translation, brightness, anime_type)?; AnimeImage::from_png(file_name, scale, angle, translation, brightness, anime_type)?;
@@ -282,7 +282,7 @@ impl AnimeGif {
let single = AnimeFrame { let single = AnimeFrame {
data: <AnimeDataBuffer>::try_from(&image)?, data: <AnimeDataBuffer>::try_from(&image)?,
delay: Duration::from_millis(30) delay: Duration::from_millis(30),
}; };
let frames = vec![single; frame_count as usize]; let frames = vec![single; frame_count as usize];
+3 -3
View File
@@ -18,7 +18,7 @@ const HEIGHT: usize = 55;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct AnimeGrid { pub struct AnimeGrid {
anime_type: AnimeType, anime_type: AnimeType,
data: [[u8; WIDTH]; HEIGHT] data: [[u8; WIDTH]; HEIGHT],
} }
impl AnimeGrid { impl AnimeGrid {
@@ -26,7 +26,7 @@ impl AnimeGrid {
pub fn new(anime_type: AnimeType) -> Self { pub fn new(anime_type: AnimeType) -> Self {
Self { Self {
anime_type, 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, 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, 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, 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); assert_eq!(matrix.data(), &data_cmp);
} }
+22 -22
View File
@@ -13,7 +13,7 @@ use crate::AnimeType;
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct Pixel { pub struct Pixel {
pub color: u32, pub color: u32,
pub alpha: f32 pub alpha: f32,
} }
impl Default for Pixel { impl Default for Pixel {
@@ -21,7 +21,7 @@ impl Default for Pixel {
fn default() -> Self { fn default() -> Self {
Pixel { Pixel {
color: 0, 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 /// 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 /// therefore same ID, so the identifier must be by laptop model in
/// `AnimeType`. /// `AnimeType`.
anime_type: AnimeType anime_type: AnimeType,
} }
impl AnimeImage { impl AnimeImage {
@@ -88,7 +88,7 @@ impl AnimeImage {
bright: f32, bright: f32,
pixels: Vec<Pixel>, pixels: Vec<Pixel>,
width: u32, width: u32,
anime_type: AnimeType anime_type: AnimeType,
) -> Result<Self> { ) -> Result<Self> {
if !(0.0..=1.0).contains(&bright) { if !(0.0..=1.0).contains(&bright) {
return Err(AnimeError::InvalidBrightness(bright)); return Err(AnimeError::InvalidBrightness(bright));
@@ -102,7 +102,7 @@ impl AnimeImage {
led_pos: Self::generate_image_positioning(anime_type), led_pos: Self::generate_image_positioning(anime_type),
img_pixels: pixels, img_pixels: pixels,
width, width,
anime_type anime_type,
}) })
} }
@@ -121,7 +121,7 @@ impl AnimeImage {
match anime_type { match anime_type {
AnimeType::GA401 => 0.8, AnimeType::GA401 => 0.8,
AnimeType::GU604 => 0.78, AnimeType::GU604 => 0.78,
_ => 0.77 _ => 0.77,
} }
} }
@@ -138,7 +138,7 @@ impl AnimeImage {
match anime_type { match anime_type {
AnimeType::GA401 => 0.3, AnimeType::GA401 => 0.3,
AnimeType::GU604 => 0.28, 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::GA401 => (33.0 + 0.5) * Self::scale_x(anime_type),
AnimeType::GU604 => (38.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 { match anime_type {
AnimeType::GA401 => 55, AnimeType::GA401 => 55,
AnimeType::GU604 => 62, AnimeType::GU604 => 62,
_ => 61 _ => 61,
} }
} }
@@ -257,7 +257,7 @@ impl AnimeImage {
AnimeType::GA401 => (54.0 + 1.0) * Self::scale_y(anime_type), AnimeType::GA401 => (54.0 + 1.0) * Self::scale_y(anime_type),
AnimeType::GU604 => 62.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 // 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 { AnimeType::GA401 => match y {
0 | 2 | 4 => 33, 0 | 2 | 4 => 33,
1 | 3 => 35, // Some rows are padded 1 | 3 => 35, // Some rows are padded
_ => 36 - y / 2 _ => 36 - y / 2,
}, },
AnimeType::GU604 => AnimeImage::width(anime_type, y), AnimeType::GU604 => AnimeImage::width(anime_type, y),
// GA402 does not have padding, equivalent to width // 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)); let x0 = led_from_px.mul_vec3(pos + Vec3::new(0.0, -0.5, 0.0));
const GROUP: [f32; 4] = [ 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 u in &GROUP {
for v in &GROUP { for v in &GROUP {
@@ -399,7 +399,7 @@ impl AnimeImage {
let led_from_cm = Mat3::from_scale(Vec2::new( let led_from_cm = Mat3::from_scale(Vec2::new(
1.0 / AnimeImage::scale_x(self.anime_type), 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 = let transform =
@@ -422,7 +422,7 @@ impl AnimeImage {
angle: f32, angle: f32,
translation: Vec2, translation: Vec2,
bright: f32, bright: f32,
anime_type: AnimeType anime_type: AnimeType,
) -> Result<Self> { ) -> Result<Self> {
let data = std::fs::read(path).map_err(|e| { let data = std::fs::read(path).map_err(|e| {
error!("Could not open {path:?}: {e:?}"); error!("Could not open {path:?}: {e:?}");
@@ -466,7 +466,7 @@ impl AnimeImage {
width = ras.width(); width = ras.width();
Self::pixels_from_16bit(ras, false) 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( let mut matrix = AnimeImage::new(
@@ -476,7 +476,7 @@ impl AnimeImage {
bright, bright,
pixels, pixels,
width, width,
anime_type anime_type,
)?; )?;
matrix.update(); matrix.update();
@@ -485,7 +485,7 @@ impl AnimeImage {
fn pixels_from_8bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel> fn pixels_from_8bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel>
where where
P: pix::el::Pixel<Chan = pix::chan::Ch8> P: pix::el::Pixel<Chan = pix::chan::Ch8>,
{ {
ras.pixels() ras.pixels()
.iter() .iter()
@@ -497,14 +497,14 @@ impl AnimeImage {
+ (<u8>::from(px.two()) / 3) as u32 + (<u8>::from(px.two()) / 3) as u32
+ (<u8>::from(px.three()) / 3) as u32 + (<u8>::from(px.three()) / 3) as u32
}, },
alpha: <f32>::from(px.alpha()) alpha: <f32>::from(px.alpha()),
}) })
.collect() .collect()
} }
fn pixels_from_16bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel> fn pixels_from_16bit<P>(ras: &pix::Raster<P>, grey: bool) -> Vec<Pixel>
where where
P: pix::el::Pixel<Chan = pix::chan::Ch16> P: pix::el::Pixel<Chan = pix::chan::Ch16>,
{ {
ras.pixels() ras.pixels()
.iter() .iter()
@@ -516,7 +516,7 @@ impl AnimeImage {
+ ((<u16>::from(px.two()) / 3) >> 8) as u32 + ((<u16>::from(px.two()) / 3) >> 8) as u32
+ ((<u16>::from(px.three()) / 3) >> 8) as u32 + ((<u16>::from(px.three()) / 3) >> 8) as u32
}, },
alpha: <f32>::from(px.alpha()) alpha: <f32>::from(px.alpha()),
}) })
.collect() .collect()
} }
@@ -653,7 +653,7 @@ mod tests {
Vec2::default(), Vec2::default(),
AnimTime::Infinite, AnimTime::Infinite,
1.0, 1.0,
AnimeType::GA402 AnimeType::GA402,
) )
.unwrap(); .unwrap();
matrix.frames()[0].frame(); matrix.frames()[0].frame();
+21 -21
View File
@@ -16,13 +16,13 @@ pub enum ActionLoader {
AsusAnimation { AsusAnimation {
file: PathBuf, file: PathBuf,
time: AnimTime, time: AnimTime,
brightness: f32 brightness: f32,
}, },
/// Image designed to be pixel perfect using the slanted template /// Image designed to be pixel perfect using the slanted template
AsusImage { AsusImage {
file: PathBuf, file: PathBuf,
time: AnimTime, time: AnimTime,
brightness: f32 brightness: f32,
}, },
/// Animated gif. If the file is a png a static gif is created using the /// Animated gif. If the file is a png a static gif is created using the
/// `time` properties /// `time` properties
@@ -32,7 +32,7 @@ pub enum ActionLoader {
angle: f32, angle: f32,
translation: Vec2, translation: Vec2,
time: AnimTime, time: AnimTime,
brightness: f32 brightness: f32,
}, },
Image { Image {
file: PathBuf, file: PathBuf,
@@ -40,10 +40,10 @@ pub enum ActionLoader {
angle: f32, angle: f32,
translation: Vec2, translation: Vec2,
time: AnimTime, time: AnimTime,
brightness: f32 brightness: f32,
}, },
/// A pause to be used between sequences /// 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 /// All the possible `AniMe` actions that can be used. The enum is intended to
@@ -64,7 +64,7 @@ pub enum ActionData {
/// Placeholder /// Placeholder
TimeDate, TimeDate,
/// Placeholder /// Placeholder
Matrix Matrix,
} }
impl ActionData { impl ActionData {
@@ -73,14 +73,14 @@ impl ActionData {
ActionLoader::AsusAnimation { ActionLoader::AsusAnimation {
file, file,
time, time,
brightness brightness,
} => ActionData::Animation(AnimeGif::from_diagonal_gif( } => ActionData::Animation(AnimeGif::from_diagonal_gif(
file, *time, *brightness, anime_type file, *time, *brightness, anime_type,
)?), )?),
ActionLoader::AsusImage { ActionLoader::AsusImage {
file, file,
time, time,
brightness brightness,
} => match time { } => match time {
AnimTime::Infinite => { AnimTime::Infinite => {
let image = AnimeDiagonal::from_png(file, None, *brightness, anime_type)?; let image = AnimeDiagonal::from_png(file, None, *brightness, anime_type)?;
@@ -88,8 +88,8 @@ impl ActionData {
ActionData::Image(Box::new(data)) ActionData::Image(Box::new(data))
} }
_ => ActionData::Animation(AnimeGif::from_diagonal_png( _ => ActionData::Animation(AnimeGif::from_diagonal_png(
file, anime_type, *time, *brightness file, anime_type, *time, *brightness,
)?) )?),
}, },
ActionLoader::ImageAnimation { ActionLoader::ImageAnimation {
file, file,
@@ -97,17 +97,17 @@ impl ActionData {
angle, angle,
translation, translation,
time, time,
brightness brightness,
} => { } => {
if let Some(ext) = file.extension() { if let Some(ext) = file.extension() {
if ext.to_string_lossy().to_lowercase() == "png" { if ext.to_string_lossy().to_lowercase() == "png" {
return Ok(ActionData::Animation(AnimeGif::from_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( ActionData::Animation(AnimeGif::from_gif(
file, *scale, *angle, *translation, *time, *brightness, anime_type file, *scale, *angle, *translation, *time, *brightness, anime_type,
)?) )?)
} }
ActionLoader::Image { ActionLoader::Image {
@@ -116,23 +116,23 @@ impl ActionData {
angle, angle,
translation, translation,
brightness, brightness,
time time,
} => { } => {
match time { match time {
AnimTime::Infinite => { AnimTime::Infinite => {
// If no time then create a plain static image // If no time then create a plain static image
let image = AnimeImage::from_png( 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)?; let data = <AnimeDataBuffer>::try_from(&image)?;
ActionData::Image(Box::new(data)) ActionData::Image(Box::new(data))
} }
_ => ActionData::Animation(AnimeGif::from_png( _ => 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) Ok(a)
} }
@@ -171,7 +171,7 @@ impl Sequences {
pub fn iter(&self) -> ActionIterator<'_> { pub fn iter(&self) -> ActionIterator<'_> {
ActionIterator { ActionIterator {
actions: self, actions: self,
next_idx: 0 next_idx: 0,
} }
} }
} }
@@ -179,7 +179,7 @@ impl Sequences {
/// Iteractor helper for iterating over all the actions in `Sequences` /// Iteractor helper for iterating over all the actions in `Sequences`
pub struct ActionIterator<'a> { pub struct ActionIterator<'a> {
actions: &'a Sequences, actions: &'a Sequences,
next_idx: usize next_idx: usize,
} }
impl<'a> Iterator for ActionIterator<'a> { impl<'a> Iterator for ActionIterator<'a> {
+16 -16
View File
@@ -35,7 +35,7 @@ pub enum Brightness {
Low = 1, Low = 1,
#[default] #[default]
Med = 2, Med = 2,
High = 3 High = 3,
} }
impl FromStr for Brightness { impl FromStr for Brightness {
@@ -47,7 +47,7 @@ impl FromStr for Brightness {
"Low" | "low" => Brightness::Low, "Low" | "low" => Brightness::Low,
"Med" | "med" => Brightness::Med, "Med" | "med" => Brightness::Med,
"High" | "high" => Brightness::High, "High" | "high" => Brightness::High,
_ => Brightness::Med _ => Brightness::Med,
}) })
} }
} }
@@ -58,7 +58,7 @@ impl From<u8> for Brightness {
0 => Brightness::Off, 0 => Brightness::Off,
1 => Brightness::Low, 1 => Brightness::Low,
3 => Brightness::High, 3 => Brightness::High,
_ => Brightness::Med _ => Brightness::Med,
} }
} }
} }
@@ -84,7 +84,7 @@ impl From<Brightness> for i32 {
pub enum AnimBooting { pub enum AnimBooting {
#[default] #[default]
GlitchConstruction = 0, GlitchConstruction = 0,
StaticEmergence = 1 StaticEmergence = 1,
} }
impl FromStr for AnimBooting { impl FromStr for AnimBooting {
@@ -94,7 +94,7 @@ impl FromStr for AnimBooting {
match s { match s {
"GlitchConstruction" => Ok(Self::GlitchConstruction), "GlitchConstruction" => Ok(Self::GlitchConstruction),
"StaticEmergence" => Ok(Self::StaticEmergence), "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 { match value {
0 => Self::GlitchConstruction, 0 => Self::GlitchConstruction,
1 => Self::StaticEmergence, 1 => Self::StaticEmergence,
_ => Self::default() _ => Self::default(),
} }
} }
} }
@@ -124,7 +124,7 @@ impl From<AnimBooting> for i32 {
pub enum AnimAwake { pub enum AnimAwake {
#[default] #[default]
BinaryBannerScroll = 0, BinaryBannerScroll = 0,
RogLogoGlitch = 1 RogLogoGlitch = 1,
} }
impl FromStr for AnimAwake { impl FromStr for AnimAwake {
@@ -134,7 +134,7 @@ impl FromStr for AnimAwake {
match s { match s {
"BinaryBannerScroll" => Ok(Self::BinaryBannerScroll), "BinaryBannerScroll" => Ok(Self::BinaryBannerScroll),
"RogLogoGlitch" => Ok(Self::RogLogoGlitch), "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 { match value {
0 => Self::BinaryBannerScroll, 0 => Self::BinaryBannerScroll,
1 => Self::RogLogoGlitch, 1 => Self::RogLogoGlitch,
_ => Self::default() _ => Self::default(),
} }
} }
} }
@@ -164,7 +164,7 @@ impl From<AnimAwake> for i32 {
pub enum AnimSleeping { pub enum AnimSleeping {
#[default] #[default]
BannerSwipe = 0, BannerSwipe = 0,
Starfield = 1 Starfield = 1,
} }
impl FromStr for AnimSleeping { impl FromStr for AnimSleeping {
@@ -174,7 +174,7 @@ impl FromStr for AnimSleeping {
match s { match s {
"BannerSwipe" => Ok(Self::BannerSwipe), "BannerSwipe" => Ok(Self::BannerSwipe),
"Starfield" => Ok(Self::Starfield), "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 { match value {
0 => Self::BannerSwipe, 0 => Self::BannerSwipe,
1 => Self::Starfield, 1 => Self::Starfield,
_ => Self::default() _ => Self::default(),
} }
} }
} }
@@ -204,7 +204,7 @@ impl From<AnimSleeping> for i32 {
pub enum AnimShutdown { pub enum AnimShutdown {
#[default] #[default]
GlitchOut = 0, GlitchOut = 0,
SeeYa = 1 SeeYa = 1,
} }
impl FromStr for AnimShutdown { impl FromStr for AnimShutdown {
@@ -214,7 +214,7 @@ impl FromStr for AnimShutdown {
match s { match s {
"GlitchOut" => Ok(Self::GlitchOut), "GlitchOut" => Ok(Self::GlitchOut),
"SeeYa" => Ok(Self::SeeYa), "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 { match value {
0 => Self::GlitchOut, 0 => Self::GlitchOut,
1 => Self::SeeYa, 1 => Self::SeeYa,
_ => Self::default() _ => Self::default(),
} }
} }
} }
@@ -326,7 +326,7 @@ pub const fn pkt_set_builtin_animations(
boot: AnimBooting, boot: AnimBooting,
awake: AnimAwake, awake: AnimAwake,
sleep: AnimSleeping, sleep: AnimSleeping,
shutdown: AnimShutdown shutdown: AnimShutdown,
) -> [u8; PACKET_SIZE] { ) -> [u8; PACKET_SIZE] {
let mut pkt = [0; PACKET_SIZE]; let mut pkt = [0; PACKET_SIZE];
pkt[0] = DEV_PAGE; pkt[0] = DEV_PAGE;
+5 -5
View File
@@ -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, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 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, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 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, 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, 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( let mut matrix = AnimeImage::new(
@@ -110,7 +110,7 @@ mod tests {
0.0, 0.0,
vec![Pixel::default(); 1000], vec![Pixel::default(); 1000],
100, 100,
AnimeType::GA401 AnimeType::GA401,
) )
.unwrap(); .unwrap();
matrix.edge_outline(); matrix.edge_outline();
@@ -175,7 +175,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, 0xff, 0xff, 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, 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 = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 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, 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, 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")); let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+10 -10
View File
@@ -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, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 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, 0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x2, 0x74, 0x2, 0x73, 0x2, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 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, 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, 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, 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 = [ let pkt2_check = [
0x5e, 0xc0, 0x2, 0xe7, 0x4, 0x73, 0x2, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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( let mut matrix = AnimeImage::new(
@@ -158,7 +158,7 @@ mod tests {
0.0, 0.0,
vec![Pixel::default(); 1000], vec![Pixel::default(); 1000],
100, 100,
AnimeType::GA402 AnimeType::GA402,
) )
.unwrap(); .unwrap();
matrix.edge_outline(); 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, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 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, 0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 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, 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, 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, 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 = [ let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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")); 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, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 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, 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, 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 = [ let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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")); let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+7 -7
View File
@@ -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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 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, 0xff, 0xff, 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 = [ let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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( let mut matrix = AnimeImage::new(
@@ -158,7 +158,7 @@ mod tests {
0.0, 0.0,
vec![Pixel::default(); 1000], vec![Pixel::default(); 1000],
100, 100,
AnimeType::GU604 AnimeType::GU604,
) )
.unwrap(); .unwrap();
matrix.edge_outline(); 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, 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, 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, 0x00, 0x00, 0x00, 0x00 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]; ];
let pkt1_check = [ let pkt1_check = [
0x5e, 0xc0, 0x02, 0x74, 0x02, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 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, 0x00, 0x00, 0x00, 0x00, 0xff, 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 = [ let pkt2_check = [
0x5e, 0xc0, 0x02, 0xe7, 0x04, 0x73, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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")); let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+28 -10
View File
@@ -35,6 +35,15 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "FA617NS",
product_id: "",
layout_name: "fx505d",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
( (
device_name: "FX505", device_name: "FX505",
product_id: "", product_id: "",
@@ -80,6 +89,15 @@
advanced_type: None, advanced_type: None,
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "FX617X",
product_id: "",
layout_name: "fa506i",
basic_modes: [Static, Breathe, Pulse],
basic_zones: [],
advanced_type: None,
power_zones: [Keyboard],
),
( (
device_name: "FX705D", device_name: "FX705D",
product_id: "", product_id: "",
@@ -139,10 +157,19 @@
product_id: "", product_id: "",
layout_name: "g513i", layout_name: "g513i",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse], basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse],
basic_zones: [], basic_zones: [Key1, Key2, Key3, Key4],
advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]), advanced_type: Zoned([ZonedKbLeft, ZonedKbLeftMid, ZonedKbRightMid, ZonedKbRight, LightbarRight, LightbarRightCorner, LightbarRightBottom, LightbarLeftBottom, LightbarLeftCorner, LightbarLeft]),
power_zones: [Keyboard, Lightbar], 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", device_name: "G531G",
product_id: "", product_id: "",
@@ -665,15 +692,6 @@
advanced_type: Zoned([SingleZone]), advanced_type: Zoned([SingleZone]),
power_zones: [Keyboard], power_zones: [Keyboard],
), ),
(
device_name: "GA605W",
product_id: "",
layout_name: "ga401q",
basic_modes: [Static, Breathe, RainbowCycle, RainbowWave, Pulse],
basic_zones: [],
advanced_type: Zoned([SingleZone]),
power_zones: [Keyboard],
),
( (
device_name: "GV301Q", device_name: "GV301Q",
product_id: "", product_id: "",
+3 -3
View File
@@ -54,7 +54,7 @@ pub struct LedSupportData {
#[serde(default)] #[serde(default)]
pub advanced_type: AdvancedAuraType, pub advanced_type: AdvancedAuraType,
/// If empty will default to `Keyboard` power zone /// If empty will default to `Keyboard` power zone
pub power_zones: Vec<PowerZones> pub power_zones: Vec<PowerZones>,
} }
impl LedSupportData { impl LedSupportData {
@@ -116,7 +116,7 @@ impl LedSupportFile {
basic_modes: vec![AuraModeNum::Static], basic_modes: vec![AuraModeNum::Static],
basic_zones: vec![], basic_zones: vec![],
advanced_type: AdvancedAuraType::None, advanced_type: AdvancedAuraType::None,
power_zones: vec![PowerZones::Keyboard] power_zones: vec![PowerZones::Keyboard],
} }
} }
@@ -200,7 +200,7 @@ mod tests {
power_zones: vec![ power_zones: vec![
PowerZones::Keyboard, PowerZones::Keyboard,
PowerZones::RearGlow, PowerZones::RearGlow,
] ],
}; };
assert!(ron::to_string(&led).is_ok()); assert!(ron::to_string(&led).is_ok());
+47 -47
View File
@@ -19,7 +19,7 @@ pub enum LedBrightness {
Low = 1, Low = 1,
#[default] #[default]
Med = 2, Med = 2,
High = 3 High = 3,
} }
impl LedBrightness { impl LedBrightness {
@@ -28,7 +28,7 @@ impl LedBrightness {
Self::Off => Self::Low, Self::Off => Self::Low,
Self::Low => Self::Med, Self::Low => Self::Med,
Self::Med => Self::High, Self::Med => Self::High,
Self::High => Self::Off Self::High => Self::Off,
} }
} }
@@ -37,7 +37,7 @@ impl LedBrightness {
Self::Off => Self::High, Self::Off => Self::High,
Self::Low => Self::Off, Self::Low => Self::Off,
Self::Med => Self::Low, Self::Med => Self::Low,
Self::High => Self::Med Self::High => Self::Med,
} }
} }
} }
@@ -48,7 +48,7 @@ impl From<u8> for LedBrightness {
0 => LedBrightness::Off, 0 => LedBrightness::Off,
1 => LedBrightness::Low, 1 => LedBrightness::Low,
3 => LedBrightness::High, 3 => LedBrightness::High,
_ => LedBrightness::Med _ => LedBrightness::Med,
} }
} }
} }
@@ -72,7 +72,7 @@ impl From<i32> for LedBrightness {
1 => LedBrightness::Low, 1 => LedBrightness::Low,
2 => LedBrightness::Med, 2 => LedBrightness::Med,
3 => LedBrightness::High, 3 => LedBrightness::High,
_ => LedBrightness::Med _ => LedBrightness::Med,
} }
} }
} }
@@ -82,7 +82,7 @@ impl From<i32> for LedBrightness {
pub struct Colour { pub struct Colour {
pub r: u8, pub r: u8,
pub g: u8, pub g: u8,
pub b: u8 pub b: u8,
} }
impl Default for Colour { impl Default for Colour {
@@ -110,7 +110,7 @@ impl From<&[f32; 3]> for Colour {
Self { Self {
r: (255.0 * c[0]) as u8, r: (255.0 * c[0]) as u8,
g: (255.0 * c[1]) 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.r as f32 / 255.0,
c.g 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 { Self {
r: c[0], r: c[0],
g: c[1], 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] { impl From<Colour> for [u8; 3] {
fn from(c: Colour) -> Self { 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, Low = 0xe1,
#[default] #[default]
Med = 0xeb, Med = 0xeb,
High = 0xf5 High = 0xf5,
} }
impl FromStr for Speed { impl FromStr for Speed {
@@ -165,7 +165,7 @@ impl FromStr for Speed {
"low" => Ok(Speed::Low), "low" => Ok(Speed::Low),
"med" => Ok(Speed::Med), "med" => Ok(Speed::Med),
"high" => Ok(Speed::High), "high" => Ok(Speed::High),
_ => Err(Error::ParseSpeed) _ => Err(Error::ParseSpeed),
} }
} }
} }
@@ -175,7 +175,7 @@ impl From<i32> for Speed {
match value { match value {
0 => Self::Low, 0 => Self::Low,
2 => Self::High, 2 => Self::High,
_ => Self::Med _ => Self::Med,
} }
} }
} }
@@ -185,7 +185,7 @@ impl From<Speed> for i32 {
match value { match value {
Speed::Low => 0, Speed::Low => 0,
Speed::Med => 1, Speed::Med => 1,
Speed::High => 2 Speed::High => 2,
} }
} }
} }
@@ -195,7 +195,7 @@ impl From<Speed> for u8 {
match s { match s {
Speed::Low => 0, Speed::Low => 0,
Speed::Med => 1, Speed::Med => 1,
Speed::High => 2 Speed::High => 2,
} }
} }
} }
@@ -213,7 +213,7 @@ pub enum Direction {
Right = 0, Right = 0,
Left = 1, Left = 1,
Up = 2, Up = 2,
Down = 3 Down = 3,
} }
impl FromStr for Direction { impl FromStr for Direction {
@@ -226,7 +226,7 @@ impl FromStr for Direction {
"up" => Ok(Direction::Up), "up" => Ok(Direction::Up),
"down" => Ok(Direction::Down), "down" => Ok(Direction::Down),
"left" => Ok(Direction::Left), "left" => Ok(Direction::Left),
_ => Err(Error::ParseDirection) _ => Err(Error::ParseDirection),
} }
} }
} }
@@ -237,7 +237,7 @@ impl From<i32> for Direction {
1 => Self::Left, 1 => Self::Left,
2 => Self::Up, 2 => Self::Up,
3 => Self::Down, 3 => Self::Down,
_ => Self::Right _ => Self::Right,
} }
} }
} }
@@ -270,7 +270,7 @@ pub enum AuraModeNum {
Ripple = 8, Ripple = 8,
Pulse = 10, Pulse = 10,
Comet = 11, Comet = 11,
Flash = 12 Flash = 12,
} }
impl Display for AuraModeNum { impl Display for AuraModeNum {
@@ -299,7 +299,7 @@ impl From<&AuraModeNum> for &str {
AuraModeNum::Ripple => "Ripple", AuraModeNum::Ripple => "Ripple",
AuraModeNum::Pulse => "Pulse", AuraModeNum::Pulse => "Pulse",
AuraModeNum::Comet => "Comet", AuraModeNum::Comet => "Comet",
AuraModeNum::Flash => "Flash" AuraModeNum::Flash => "Flash",
} }
} }
} }
@@ -317,7 +317,7 @@ impl From<&str> for AuraModeNum {
"Pulse" => AuraModeNum::Pulse, "Pulse" => AuraModeNum::Pulse,
"Comet" => AuraModeNum::Comet, "Comet" => AuraModeNum::Comet,
"Flash" => AuraModeNum::Flash, "Flash" => AuraModeNum::Flash,
_ => AuraModeNum::Static _ => AuraModeNum::Static,
} }
} }
} }
@@ -336,7 +336,7 @@ impl From<u8> for AuraModeNum {
10 => AuraModeNum::Pulse, 10 => AuraModeNum::Pulse,
11 => AuraModeNum::Comet, 11 => AuraModeNum::Comet,
12 => AuraModeNum::Flash, 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) /// The left part of a lightbar (typically on the front of laptop)
BarLeft = 6, BarLeft = 6,
/// The right part of a lightbar /// The right part of a lightbar
BarRight = 7 BarRight = 7,
} }
impl FromStr for AuraZone { impl FromStr for AuraZone {
@@ -400,7 +400,7 @@ impl FromStr for AuraZone {
"5" | "logo" => Ok(AuraZone::Logo), "5" | "logo" => Ok(AuraZone::Logo),
"6" | "lightbar-left" => Ok(AuraZone::BarLeft), "6" | "lightbar-left" => Ok(AuraZone::BarLeft),
"7" | "lightbar-right" => Ok(AuraZone::BarRight), "7" | "lightbar-right" => Ok(AuraZone::BarRight),
_ => Err(Error::ParseSpeed) _ => Err(Error::ParseSpeed),
} }
} }
} }
@@ -415,7 +415,7 @@ impl From<i32> for AuraZone {
5 => Self::Logo, 5 => Self::Logo,
6 => Self::BarLeft, 6 => Self::BarLeft,
7 => Self::BarRight, 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) /// One of three speeds for modes that support speed (most that animate)
pub speed: Speed, pub speed: Speed,
/// Up, down, left, right. Only Rainbow mode seems to use this /// Up, down, left, right. Only Rainbow mode seems to use this
pub direction: Direction pub direction: Direction,
} }
impl AuraEffect { impl AuraEffect {
@@ -481,7 +481,7 @@ impl Default for AuraEffect {
colour1: Colour { r: 166, g: 0, b: 0 }, colour1: Colour { r: 166, g: 0, b: 0 },
colour2: Colour { r: 0, g: 0, b: 0 }, colour2: Colour { r: 0, g: 0, b: 0 },
speed: Speed::Med, speed: Speed::Med,
direction: Direction::Right direction: Direction::Right,
} }
} }
} }
@@ -541,7 +541,7 @@ impl From<&AuraEffect> for Vec<u8> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{ 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] #[test]
@@ -552,18 +552,18 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0xff, r: 0xff,
g: 0x11, g: 0x11,
b: 0xdd b: 0xdd,
}, },
colour2: Colour::default(), colour2: Colour::default(),
speed: Speed::Med, speed: Speed::Med,
direction: Direction::Right direction: Direction::Right,
}; };
let ar = <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st); let ar = <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st);
println!("{:02x?}", ar); println!("{:02x?}", ar);
let check = [ let check = [
0x5d, 0xb3, 0x0, 0x0, 0xff, 0x11, 0xdd, 0xeb, 0x0, 0x0, 0xa6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x0, 0x0, 0xff, 0x11, 0xdd, 0xeb, 0x0, 0x0, 0xa6, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0 0x0,
]; ];
assert_eq!(ar, check); assert_eq!(ar, check);
} }
@@ -576,15 +576,15 @@ mod tests {
colour1: Colour { colour1: Colour {
r: 0xff, r: 0xff,
g: 0, g: 0,
b: 0 b: 0,
}, },
colour2: Colour { r: 0, g: 0, b: 0 }, colour2: Colour { r: 0, g: 0, b: 0 },
speed: Speed::Low, speed: Speed::Low,
direction: Direction::Left direction: Direction::Left,
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x01, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x01, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0 0x0, 0x0,
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -595,11 +595,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0xff, r: 0xff,
g: 0xff, g: 0xff,
b: 0 b: 0,
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x02, 0x00, 0xff, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x02, 0x00, 0xff, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0 0x0, 0x0,
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -610,11 +610,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0, r: 0,
g: 0xff, g: 0xff,
b: 0xff b: 0xff,
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0 0x0, 0x0,
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -625,11 +625,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0xff, r: 0xff,
g: 0x00, g: 0x00,
b: 0xff b: 0xff,
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x04, 0x00, 0xff, 0x00, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x04, 0x00, 0xff, 0x00, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0 0x0, 0x0,
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -640,11 +640,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0x2c, r: 0x2c,
g: 0xff, g: 0xff,
b: 0x00 b: 0x00,
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x05, 0x00, 0x2c, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x05, 0x00, 0x2c, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0 0x0, 0x0,
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -655,11 +655,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0xff, r: 0xff,
g: 0x00, g: 0x00,
b: 0x00 b: 0x00,
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x06, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x06, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0 0x0, 0x0,
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -670,11 +670,11 @@ mod tests {
st.colour1 = Colour { st.colour1 = Colour {
r: 0xff, r: 0xff,
g: 0x00, g: 0x00,
b: 0xcd b: 0xcd,
}; };
let capture = [ let capture = [
0x5d, 0xb3, 0x07, 0x00, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x07, 0x00, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0 0x0, 0x0,
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
@@ -684,7 +684,7 @@ mod tests {
st.mode = AuraModeNum::RainbowWave; st.mode = AuraModeNum::RainbowWave;
let capture = [ let capture = [
0x5d, 0xb3, 0x07, 0x03, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5d, 0xb3, 0x07, 0x03, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0 0x0, 0x0,
]; ];
assert_eq!( assert_eq!(
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9], <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
+1 -1
View File
@@ -11,7 +11,7 @@ pub struct InputBased {
/// - temperature /// - temperature
/// - fan speed /// - fan speed
/// - time /// - time
input: Box<dyn InputForEffect> input: Box<dyn InputForEffect>,
} }
impl EffectState for InputBased { impl EffectState for InputBased {
+2 -2
View File
@@ -19,7 +19,7 @@ pub struct Breathe {
#[serde(skip)] #[serde(skip)]
count_flipped: bool, count_flipped: bool,
#[serde(skip)] #[serde(skip)]
use_colour1: bool use_colour1: bool,
} }
impl Breathe { impl Breathe {
@@ -31,7 +31,7 @@ impl Breathe {
speed, speed,
colour: colour1, colour: colour1,
count_flipped: false, count_flipped: false,
use_colour1: true use_colour1: true,
} }
} }
} }
+8 -8
View File
@@ -13,7 +13,7 @@ pub struct DoomFlicker {
#[serde(skip)] #[serde(skip)]
count: u8, count: u8,
#[serde(skip)] #[serde(skip)]
colour: Colour colour: Colour,
} }
impl DoomFlicker { impl DoomFlicker {
@@ -24,7 +24,7 @@ impl DoomFlicker {
count: 4, count: 4,
max_percentage, max_percentage,
min_percentage, min_percentage,
start_colour: colour start_colour: colour,
} }
} }
} }
@@ -53,13 +53,13 @@ impl EffectState for DoomFlicker {
let max_light = Colour { let max_light = Colour {
r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8, 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, 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 // min light is a percentage of the set colour
let min_light = Colour { let min_light = Colour {
r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8, 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, 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 // Convert the 255 to percentage
@@ -96,7 +96,7 @@ pub struct DoomLightFlash {
#[serde(skip)] #[serde(skip)]
count: u8, count: u8,
#[serde(skip)] #[serde(skip)]
colour: Colour colour: Colour,
} }
impl DoomLightFlash { impl DoomLightFlash {
@@ -109,7 +109,7 @@ impl DoomLightFlash {
min_percentage, min_percentage,
start_colour: colour, start_colour: colour,
max_time: 32, max_time: 32,
min_time: 7 min_time: 7,
} }
} }
} }
@@ -135,13 +135,13 @@ impl EffectState for DoomLightFlash {
let max_light = Colour { let max_light = Colour {
r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8, 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, 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 // min light is a percentage of the set colour
let min_light = Colour { let min_light = Colour {
r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8, 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, 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 { if *colour == max_light {
+10 -10
View File
@@ -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, 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, 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, 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 { pub fn p_random() -> i32 {
@@ -67,7 +67,7 @@ pub(crate) trait EffectState {
#[derive(Debug, Deserialize, Serialize, Default)] #[derive(Debug, Deserialize, Serialize, Default)]
pub struct AdvancedEffects { pub struct AdvancedEffects {
effects: Vec<Effect>, effects: Vec<Effect>,
zoned: bool zoned: bool,
} }
impl AdvancedEffects { impl AdvancedEffects {
@@ -75,7 +75,7 @@ impl AdvancedEffects {
pub fn new(zoned: bool) -> Self { pub fn new(zoned: bool) -> Self {
Self { Self {
effects: Default::default(), effects: Default::default(),
zoned zoned,
} }
} }
@@ -186,7 +186,7 @@ pub enum Effect {
Static(Static), Static(Static),
Breathe(Breathe), Breathe(Breathe),
DoomFlicker(DoomFlicker), DoomFlicker(DoomFlicker),
DoomLightFlash(DoomLightFlash) DoomLightFlash(DoomLightFlash),
} }
impl Default for Effect { impl Default for Effect {
@@ -211,7 +211,7 @@ mod tests {
.push(Effect::Static(Static::new(LedCode::F, Colour { .push(Effect::Static(Static::new(LedCode::F, Colour {
r: 255, r: 255,
g: 127, g: 127,
b: 0 b: 0,
}))); })));
seq.next_state(&layout); seq.next_state(&layout);
@@ -232,14 +232,14 @@ mod tests {
Colour { Colour {
r: 255, r: 255,
g: 127, g: 127,
b: 0 b: 0,
}, },
Colour { Colour {
r: 127, r: 127,
g: 0, g: 0,
b: 255 b: 255,
}, },
Speed::Med Speed::Med,
))); )));
let s = let s =
@@ -274,10 +274,10 @@ mod tests {
Colour { Colour {
r: 255, r: 255,
g: 127, g: 127,
b: 80 b: 80,
}, },
100, 100,
10 10,
))); )));
seq.next_state(&layout); seq.next_state(&layout);
+2 -2
View File
@@ -8,14 +8,14 @@ use crate::{effect_state_impl, Colour};
pub struct Static { pub struct Static {
led: LedCode, led: LedCode,
/// The starting colour /// The starting colour
colour: Colour colour: Colour,
} }
impl Static { impl Static {
pub fn new(address: LedCode, colour: Colour) -> Self { pub fn new(address: LedCode, colour: Colour) -> Self {
Self { Self {
led: address, led: address,
colour colour,
} }
} }
} }
+2 -2
View File
@@ -8,7 +8,7 @@ pub enum Error {
ParseBrightness, ParseBrightness,
IoPath(String, std::io::Error), IoPath(String, std::io::Error),
Ron(ron::Error), Ron(ron::Error),
RonParse(ron::error::SpannedError) RonParse(ron::error::SpannedError),
} }
impl fmt::Display for Error { impl fmt::Display for Error {
@@ -21,7 +21,7 @@ impl fmt::Display for Error {
Error::ParseBrightness => write!(f, "Could not parse brightness"), Error::ParseBrightness => write!(f, "Could not parse brightness"),
Error::IoPath(path, io) => write!(f, "IO Error: {path}, {io}"), Error::IoPath(path, io) => write!(f, "IO Error: {path}, {io}"),
Error::Ron(e) => write!(f, "RON Parse Error: {e}"), 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}"),
} }
} }
} }
+5 -5
View File
@@ -164,7 +164,7 @@ pub enum LedCode {
/// To be ignored by effects /// To be ignored by effects
Spacing, Spacing,
/// To be ignored by effects /// To be ignored by effects
Blocking Blocking,
} }
impl LedCode { impl LedCode {
@@ -210,7 +210,7 @@ pub struct LedUsbPackets {
/// Wether or not this packet collection is zoned. The determines which /// Wether or not this packet collection is zoned. The determines which
/// starting bytes are used and what the indexing is for lightbar RGB /// starting bytes are used and what the indexing is for lightbar RGB
/// colours /// colours
zoned: bool zoned: bool,
} }
impl Default for LedUsbPackets { impl Default for LedUsbPackets {
@@ -244,7 +244,7 @@ impl LedUsbPackets {
} }
Self { Self {
usb_packets: set, usb_packets: set,
zoned: false zoned: false,
} }
} }
@@ -274,7 +274,7 @@ impl LedUsbPackets {
} }
Self { Self {
usb_packets: vec![pkt], usb_packets: vec![pkt],
zoned: true zoned: true,
} }
} }
@@ -633,7 +633,7 @@ impl From<&LedCode> for &str {
LedCode::ZonedKbLeft => "Left Zone (zone 1)", LedCode::ZonedKbLeft => "Left Zone (zone 1)",
LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)", LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)",
LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)", LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)",
LedCode::ZonedKbRight => "Right Zone (zone 4)" LedCode::ZonedKbRight => "Right Zone (zone 4)",
} }
} }
} }
+14 -14
View File
@@ -26,12 +26,12 @@ pub enum KeyShape {
pad_left: f32, pad_left: f32,
pad_right: f32, pad_right: f32,
pad_top: f32, pad_top: f32,
pad_bottom: f32 pad_bottom: f32,
}, },
Blank { Blank {
width: f32, width: f32,
height: f32 height: f32,
} },
} }
impl KeyShape { impl KeyShape {
@@ -41,7 +41,7 @@ impl KeyShape {
pad_left: f32, pad_left: f32,
pad_right: f32, pad_right: f32,
pad_top: f32, pad_top: f32,
pad_bottom: f32 pad_bottom: f32,
) -> Self { ) -> Self {
Self::Led { Self::Led {
width, width,
@@ -49,7 +49,7 @@ impl KeyShape {
pad_left, pad_left,
pad_right, pad_right,
pad_top, pad_top,
pad_bottom pad_bottom,
} }
} }
@@ -66,7 +66,7 @@ impl KeyShape {
pad_left, pad_left,
pad_right, pad_right,
pad_top, pad_top,
pad_bottom pad_bottom,
} => { } => {
*width *= scale; *width *= scale;
*height *= scale; *height *= scale;
@@ -97,7 +97,7 @@ pub struct KeyRow {
row: Vec<(LedCode, String)>, row: Vec<(LedCode, String)>,
/// The final data structure merged key_shapes and rows /// The final data structure merged key_shapes and rows
#[serde(skip)] #[serde(skip)]
built_row: Vec<(LedCode, KeyShape)> built_row: Vec<(LedCode, KeyShape)>,
} }
impl KeyRow { impl KeyRow {
@@ -106,7 +106,7 @@ impl KeyRow {
pad_left, pad_left,
pad_top, pad_top,
row, row,
built_row: Default::default() built_row: Default::default(),
} }
} }
@@ -132,7 +132,7 @@ impl KeyRow {
pad_bottom, pad_bottom,
.. ..
} => height + pad_top + pad_bottom, } => height + pad_top + pad_bottom,
KeyShape::Blank { height, .. } => *height KeyShape::Blank { height, .. } => *height,
}; };
if h < height { if h < height {
@@ -156,7 +156,7 @@ impl KeyRow {
pad_right, pad_right,
.. ..
} => w += width + pad_left + pad_right, } => w += width + pad_left + pad_right,
KeyShape::Blank { width, .. } => w += width KeyShape::Blank { width, .. } => w += width,
} }
} }
w w
@@ -185,7 +185,7 @@ pub struct KeyLayout {
/// Should be copied from the `LaptopLedData` as laptops may have the same /// Should be copied from the `LaptopLedData` as laptops may have the same
/// layout, but different EC features. /// layout, but different EC features.
#[serde(skip)] #[serde(skip)]
advanced_type: AdvancedAuraType advanced_type: AdvancedAuraType,
} }
impl KeyLayout { impl KeyLayout {
@@ -195,7 +195,7 @@ impl KeyLayout {
if buf.is_empty() { if buf.is_empty() {
Err(Error::IoPath( Err(Error::IoPath(
path.to_string_lossy().to_string(), path.to_string_lossy().to_string(),
std::io::ErrorKind::InvalidData.into() std::io::ErrorKind::InvalidData.into(),
)) ))
} else { } else {
let mut data = ron::from_str::<Self>(&buf)?; let mut data = ron::from_str::<Self>(&buf)?;
@@ -332,7 +332,7 @@ impl KeyLayout {
advanced_type: AdvancedAuraType::None, advanced_type: AdvancedAuraType::None,
key_shapes: HashMap::from([( key_shapes: HashMap::from([(
"regular".to_owned(), "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![ key_rows: vec![
KeyRow::new(0.1, 0.1, vec![ KeyRow::new(0.1, 0.1, vec![
@@ -422,7 +422,7 @@ impl KeyLayout {
(LedCode::PrtSc, "regular".to_owned()), (LedCode::PrtSc, "regular".to_owned()),
(LedCode::RCtrl, "regular".to_owned()), (LedCode::RCtrl, "regular".to_owned()),
]), ]),
] ],
} }
} }
} }
+1 -1
View File
@@ -16,5 +16,5 @@ pub enum AdvancedAuraType {
#[default] #[default]
None, None,
Zoned(Vec<LedCode>), Zoned(Vec<LedCode>),
PerKey PerKey,
} }
+59 -59
View File
@@ -23,7 +23,7 @@ pub struct AuraPowerState {
pub awake: bool, pub awake: bool,
pub sleep: bool, pub sleep: bool,
/// Ignored for pre-2021 and Tuf /// Ignored for pre-2021 and Tuf
pub shutdown: bool pub shutdown: bool,
} }
impl Default for AuraPowerState { impl Default for AuraPowerState {
@@ -34,7 +34,7 @@ impl Default for AuraPowerState {
boot: true, boot: true,
awake: true, awake: true,
sleep: true, sleep: true,
shutdown: true shutdown: true,
} }
} }
} }
@@ -46,7 +46,7 @@ impl AuraPowerState {
boot: true, boot: true,
awake: true, awake: true,
sleep: true, sleep: true,
shutdown: true shutdown: true,
} }
} }
@@ -140,7 +140,7 @@ impl AuraPowerState {
| ((self.sleep as u32) << (23 + 3)) | ((self.sleep as u32) << (23 + 3))
| ((self.shutdown as u32) << (23 + 4)) | ((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))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct LaptopAuraPower { pub struct LaptopAuraPower {
pub states: Vec<AuraPowerState> pub states: Vec<AuraPowerState>,
} }
impl LaptopAuraPower { impl LaptopAuraPower {
@@ -206,19 +206,19 @@ impl LaptopAuraPower {
// 3. KeyboardAndLightbar // 3. KeyboardAndLightbar
if support_data.power_zones.contains(&PowerZones::Lightbar) { if support_data.power_zones.contains(&PowerZones::Lightbar) {
Self { Self {
states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)] states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)],
} }
} else { } else {
Self { Self {
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)] states: vec![AuraPowerState::default_for(PowerZones::Keyboard)],
} }
} }
} }
AuraDeviceType::LaptopKeyboardTuf => Self { AuraDeviceType::LaptopKeyboardTuf => Self {
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)] states: vec![AuraPowerState::default_for(PowerZones::Keyboard)],
}, },
AuraDeviceType::ScsiExtDisk => todo!(), AuraDeviceType::ScsiExtDisk => todo!(),
AuraDeviceType::AnimeOrSlash => todo!() AuraDeviceType::AnimeOrSlash => todo!(),
} }
} }
@@ -266,7 +266,7 @@ impl LaptopAuraPower {
self.new_to_bytes() self.new_to_bytes()
} }
AuraDeviceType::ScsiExtDisk => todo!("scsi disk not implemented yet"), 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, Boot = 0xc31209,
Sleep = 0x300804, Sleep = 0x300804,
Keyboard = 0x080000, Keyboard = 0x080000,
Lightbar = 0x040500 Lightbar = 0x040500,
} }
impl BitOr<OldAuraPower> for OldAuraPower { impl BitOr<OldAuraPower> for OldAuraPower {
@@ -332,9 +332,9 @@ mod test {
boot: false, boot: false,
awake: true, awake: true,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}; };
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
@@ -347,9 +347,9 @@ mod test {
boot: false, boot: false,
awake: true, awake: true,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}; };
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
@@ -369,16 +369,16 @@ mod test {
boot: true, boot: true,
awake: true, awake: true,
sleep: true, sleep: true,
shutdown: false shutdown: false,
}, },
AuraPowerState { AuraPowerState {
zone: PowerZones::Lightbar, zone: PowerZones::Lightbar,
boot: true, boot: true,
awake: true, awake: true,
sleep: true, sleep: true,
shutdown: false shutdown: false,
}, },
] ],
}; };
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021); let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
@@ -394,9 +394,9 @@ mod test {
boot: true, boot: true,
awake: false, awake: false,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}); });
let boot_keyb_ = to_binary_string_post2021(&LaptopAuraPower { let boot_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -405,9 +405,9 @@ mod test {
boot: true, boot: true,
awake: false, awake: false,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}); });
let sleep_logo = to_binary_string_post2021(&LaptopAuraPower { let sleep_logo = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -416,9 +416,9 @@ mod test {
boot: false, boot: false,
awake: false, awake: false,
sleep: true, sleep: true,
shutdown: false shutdown: false,
}, },
] ],
}); });
let sleep_keyb = to_binary_string_post2021(&LaptopAuraPower { let sleep_keyb = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -427,9 +427,9 @@ mod test {
boot: false, boot: false,
awake: false, awake: false,
sleep: true, sleep: true,
shutdown: false shutdown: false,
}, },
] ],
}); });
let awake_logo = to_binary_string_post2021(&LaptopAuraPower { let awake_logo = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -438,9 +438,9 @@ mod test {
boot: false, boot: false,
awake: true, awake: true,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}); });
let awake_keyb = to_binary_string_post2021(&LaptopAuraPower { let awake_keyb = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -449,9 +449,9 @@ mod test {
boot: false, boot: false,
awake: true, awake: true,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}); });
let shut_logo_ = to_binary_string_post2021(&LaptopAuraPower { let shut_logo_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -460,9 +460,9 @@ mod test {
boot: false, boot: false,
awake: false, awake: false,
sleep: false, sleep: false,
shutdown: true shutdown: true,
}, },
] ],
}); });
let shut_keyb_ = to_binary_string_post2021(&LaptopAuraPower { let shut_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -471,9 +471,9 @@ mod test {
boot: false, boot: false,
awake: false, awake: false,
sleep: false, sleep: false,
shutdown: true shutdown: true,
}, },
] ],
}); });
let boot_bar__ = to_binary_string_post2021(&LaptopAuraPower { let boot_bar__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -482,9 +482,9 @@ mod test {
boot: true, boot: true,
awake: false, awake: false,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}); });
let awake_bar_ = to_binary_string_post2021(&LaptopAuraPower { let awake_bar_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -493,9 +493,9 @@ mod test {
boot: false, boot: false,
awake: true, awake: true,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}); });
let sleep_bar_ = to_binary_string_post2021(&LaptopAuraPower { let sleep_bar_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -504,9 +504,9 @@ mod test {
boot: false, boot: false,
awake: false, awake: false,
sleep: true, sleep: true,
shutdown: false shutdown: false,
}, },
] ],
}); });
let shut_bar__ = to_binary_string_post2021(&LaptopAuraPower { let shut_bar__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -515,9 +515,9 @@ mod test {
boot: false, boot: false,
awake: false, awake: false,
sleep: false, sleep: false,
shutdown: true shutdown: true,
}, },
] ],
}); });
let boot_lid__ = to_binary_string_post2021(&LaptopAuraPower { let boot_lid__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -526,9 +526,9 @@ mod test {
boot: true, boot: true,
awake: false, awake: false,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}); });
let awake_lid_ = to_binary_string_post2021(&LaptopAuraPower { let awake_lid_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -537,9 +537,9 @@ mod test {
boot: false, boot: false,
awake: true, awake: true,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}); });
let sleep_lid_ = to_binary_string_post2021(&LaptopAuraPower { let sleep_lid_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -548,9 +548,9 @@ mod test {
boot: false, boot: false,
awake: false, awake: false,
sleep: true, sleep: true,
shutdown: false shutdown: false,
}, },
] ],
}); });
let shut_lid__ = to_binary_string_post2021(&LaptopAuraPower { let shut_lid__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -559,9 +559,9 @@ mod test {
boot: false, boot: false,
awake: false, awake: false,
sleep: false, sleep: false,
shutdown: true shutdown: true,
}, },
] ],
}); });
let boot_rear_ = to_binary_string_post2021(&LaptopAuraPower { let boot_rear_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -570,9 +570,9 @@ mod test {
boot: true, boot: true,
awake: false, awake: false,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}); });
let awake_rear = to_binary_string_post2021(&LaptopAuraPower { let awake_rear = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -581,9 +581,9 @@ mod test {
boot: false, boot: false,
awake: true, awake: true,
sleep: false, sleep: false,
shutdown: false shutdown: false,
}, },
] ],
}); });
let sleep_rear = to_binary_string_post2021(&LaptopAuraPower { let sleep_rear = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -592,9 +592,9 @@ mod test {
boot: false, boot: false,
awake: false, awake: false,
sleep: true, sleep: true,
shutdown: false shutdown: false,
}, },
] ],
}); });
let shut_rear_ = to_binary_string_post2021(&LaptopAuraPower { let shut_rear_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![ states: vec![
@@ -603,9 +603,9 @@ mod test {
boot: false, boot: false,
awake: false, awake: false,
sleep: false, sleep: false,
shutdown: true shutdown: true,
}, },
] ],
}); });
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000"); assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
@@ -655,7 +655,7 @@ mod test {
zone: PowerZones::RearGlow, zone: PowerZones::RearGlow,
..Default::default() ..Default::default()
}, },
] ],
}); });
assert_eq!(byte1, "11111111, 00011110, 00001111, 00001111"); assert_eq!(byte1, "11111111, 00011110, 00001111, 00001111");
} }
+11 -11
View File
@@ -29,40 +29,40 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const RED: Colour = Colour { pub const RED: Colour = Colour {
r: 0xff, r: 0xff,
g: 0x00, g: 0x00,
b: 0x00 b: 0x00,
}; };
pub const GREEN: Colour = Colour { pub const GREEN: Colour = Colour {
r: 0x00, r: 0x00,
g: 0xff, g: 0xff,
b: 0x00 b: 0x00,
}; };
pub const BLUE: Colour = Colour { pub const BLUE: Colour = Colour {
r: 0x00, r: 0x00,
g: 0x00, g: 0x00,
b: 0xff b: 0xff,
}; };
pub const VIOLET: Colour = Colour { pub const VIOLET: Colour = Colour {
r: 0x9b, r: 0x9b,
g: 0x26, g: 0x26,
b: 0xb6 b: 0xb6,
}; };
pub const TEAL: Colour = Colour { pub const TEAL: Colour = Colour {
r: 0x00, r: 0x00,
g: 0x7c, g: 0x7c,
b: 0x80 b: 0x80,
}; };
pub const YELLOW: Colour = Colour { pub const YELLOW: Colour = Colour {
r: 0xff, r: 0xff,
g: 0xef, g: 0xef,
b: 0x00 b: 0x00,
}; };
pub const ORANGE: Colour = Colour { pub const ORANGE: Colour = Colour {
r: 0xff, r: 0xff,
g: 0xa4, g: 0xa4,
b: 0x00 b: 0x00,
}; };
pub const GRADIENT: [Colour; 7] = [ 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))] #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
@@ -76,7 +76,7 @@ pub enum AuraDeviceType {
ScsiExtDisk = 3, ScsiExtDisk = 3,
Ally = 4, Ally = 4,
AnimeOrSlash = 5, AnimeOrSlash = 5,
Unknown = 255 Unknown = 255,
} }
impl AuraDeviceType { impl AuraDeviceType {
@@ -110,7 +110,7 @@ impl From<&str> for AuraDeviceType {
"1abe" | "1b4c" => Self::Ally, "1abe" | "1b4c" => Self::Ally,
"19b3" | "193b" => Self::AnimeOrSlash, "19b3" | "193b" => Self::AnimeOrSlash,
"19b6" => Self::LaptopKeyboard2021, "19b6" => Self::LaptopKeyboard2021,
_ => Self::Unknown _ => Self::Unknown,
} }
} }
} }
@@ -138,5 +138,5 @@ pub enum PowerZones {
KeyboardAndLightbar = 5, KeyboardAndLightbar = 5,
/// Ally specific for creating correct packet /// Ally specific for creating correct packet
Ally = 6, Ally = 6,
None = 255 None = 255,
} }
+2 -2
View File
@@ -1,7 +1,7 @@
// Only these two packets must be 17 bytes // Only these two packets must be 17 bytes
pub const AURA_LAPTOP_LED_APPLY: [u8; 17] = [ 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] = [ 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,
]; ];
+4 -2
View File
@@ -41,6 +41,7 @@ zbus.workspace = true
dirs.workspace = true dirs.workspace = true
notify-rust.workspace = true notify-rust.workspace = true
concat-idents.workspace = true concat-idents.workspace = true
futures-util.workspace = true
versions.workspace = true versions.workspace = true
@@ -48,10 +49,11 @@ versions.workspace = true
git = "https://github.com/slint-ui/slint.git" git = "https://github.com/slint-ui/slint.git"
default-features = false default-features = false
features = [ features = [
"gettext",
"compat-1-2", "compat-1-2",
"gettext",
"accessibility",
"backend-winit-wayland", "backend-winit-wayland",
"renderer-winit-femtovg", "renderer-femtovg",
# "renderer-skia-opengl", # "renderer-skia-opengl",
] ]
+1 -3
View File
@@ -5,7 +5,6 @@ use slint_build::CompilerConfiguration;
fn main() { fn main() {
// write_locales(); // write_locales();
let root = env!("CARGO_MANIFEST_DIR"); let root = env!("CARGO_MANIFEST_DIR");
let mut main = PathBuf::from_str(root).unwrap(); let mut main = PathBuf::from_str(root).unwrap();
main.push("ui/main_window.slint"); main.push("ui/main_window.slint");
@@ -14,13 +13,12 @@ fn main() {
include.push("ui"); include.push("ui");
slint_build::print_rustc_flags().unwrap(); slint_build::print_rustc_flags().unwrap();
// slint_build::compile("ui/main_window.slint").unwrap();
slint_build::compile_with_config( slint_build::compile_with_config(
main, main,
CompilerConfiguration::new() CompilerConfiguration::new()
// .embed_resources(EmbedResourcesKind::EmbedFiles) // .embed_resources(EmbedResourcesKind::EmbedFiles)
.with_include_paths(vec![include]) .with_include_paths(vec![include])
.with_style("fluent-dark".into()) .with_style("fluent".into()),
) )
.unwrap(); .unwrap();
} }
@@ -1,7 +1,6 @@
[Desktop Entry] [Desktop Entry]
Version=1.0 Version=1.0
Type=Application Type=Application
Name=ROG Control Center Name=ROG Control Center
Comment=Make your ASUS ROG Laptop go Brrrrr! Comment=Make your ASUS ROG Laptop go Brrrrr!
Categories=Settings Categories=Settings
+1 -1
View File
@@ -23,5 +23,5 @@ pub struct CliStart {
help = "put ROGCC in layout viewing mode - this is helpful for finding existing layouts \ help = "put ROGCC in layout viewing mode - this is helpful for finding existing layouts \
that might match your laptop" that might match your laptop"
)] )]
pub layout_viewing: bool pub layout_viewing: bool,
} }
+4 -4
View File
@@ -21,7 +21,7 @@ pub struct Config {
pub fullscreen_width: u32, pub fullscreen_width: u32,
pub fullscreen_height: u32, pub fullscreen_height: u32,
// This field must be last // This field must be last
pub notifications: EnabledNotifications pub notifications: EnabledNotifications,
} }
impl Default for Config { impl Default for Config {
@@ -36,7 +36,7 @@ impl Default for Config {
fullscreen_height: 1080, fullscreen_height: 1080,
notifications: EnabledNotifications::default(), notifications: EnabledNotifications::default(),
ac_command: String::new(), 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 enable_dgpu_notifications: bool,
pub dark_mode: bool, pub dark_mode: bool,
// This field must be last // This field must be last
pub enabled_notifications: EnabledNotifications pub enabled_notifications: EnabledNotifications,
} }
impl From<Config461> for Config { impl From<Config461> for Config {
@@ -92,7 +92,7 @@ impl From<Config461> for Config {
start_fullscreen: false, start_fullscreen: false,
fullscreen_width: 1920, fullscreen_width: 1920,
fullscreen_height: 1080, fullscreen_height: 1080,
notifications: c.enabled_notifications notifications: c.enabled_notifications,
} }
} }
} }
+2 -2
View File
@@ -9,7 +9,7 @@ pub enum Error {
ConfigLockFail, ConfigLockFail,
XdgVars, XdgVars,
Zbus(zbus::Error), Zbus(zbus::Error),
Notification(notify_rust::error::Error) Notification(notify_rust::error::Error),
} }
impl fmt::Display for 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::ConfigLockFail => write!(f, "Failed to lock user config"),
Error::XdgVars => write!(f, "XDG environment vars appear unset"), Error::XdgVars => write!(f, "XDG environment vars appear unset"),
Error::Zbus(err) => write!(f, "Error: {}", err), Error::Zbus(err) => write!(f, "Error: {}", err),
Error::Notification(err) => write!(f, "Notification Error: {}", err) Error::Notification(err) => write!(f, "Notification Error: {}", err),
} }
} }
} }
+1 -1
View File
@@ -38,5 +38,5 @@ pub enum Page {
System, System,
AuraEffects, AuraEffects,
AnimeMatrix, AnimeMatrix,
FanCurves FanCurves,
} }
+123 -50
View File
@@ -1,4 +1,4 @@
use std::env::args; use std::env::{self, args};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::exit; use std::process::exit;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
@@ -17,7 +17,7 @@ use rog_control_center::slint::ComponentHandle;
use rog_control_center::tray::init_tray; use rog_control_center::tray::init_tray;
use rog_control_center::ui::setup_window; use rog_control_center::ui::setup_window;
use rog_control_center::zbus_proxies::{ 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 rog_control_center::{print_versions, MainWindow};
use tokio::runtime::Runtime; use tokio::runtime::Runtime;
@@ -32,6 +32,25 @@ async fn main() -> Result<()> {
.format_timestamp(None) .format_timestamp(None)
.init(); .init();
// 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") {
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 // Try to open a proxy and check for app state first
{ {
let user_con = zbus::blocking::Connection::session()?; let user_con = zbus::blocking::Connection::session()?;
@@ -49,7 +68,12 @@ async fn main() -> Result<()> {
let self_version = env!("CARGO_PKG_VERSION"); let self_version = env!("CARGO_PKG_VERSION");
let zbus_con = zbus::blocking::Connection::system()?; let zbus_con = zbus::blocking::Connection::system()?;
let platform_proxy = rog_dbus::zbus_platform::PlatformProxyBlocking::new(&zbus_con)?; let platform_proxy = rog_dbus::zbus_platform::PlatformProxyBlocking::new(&zbus_con)?;
let asusd_version = platform_proxy.version().unwrap(); let asusd_version = platform_proxy
.version()
.map_err(|e| {
println!("Could not get asusd version: {e:?}\nIs asusd.service running?");
})
.unwrap();
if asusd_version != self_version { if asusd_version != self_version {
println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}"); println!("Version mismatch: asusctl = {self_version}, asusd = {asusd_version}");
return Ok(()); return Ok(());
@@ -79,7 +103,7 @@ async fn main() -> Result<()> {
let board_name = dmi.board_name; let board_name = dmi.board_name;
let prod_family = dmi.product_family; let prod_family = dmi.product_family;
info!("Running on {board_name}, product: {prod_family}"); info!("Running on {board_name}, product: {prod_family}");
let is_rog_ally = prod_family == "RC71L"; let is_rog_ally = board_name == "RC71L" || board_name == "RC72L" || prod_family == "ROG Ally";
let args: Vec<String> = args().skip(1).collect(); let args: Vec<String> = args().skip(1).collect();
@@ -115,7 +139,9 @@ async fn main() -> Result<()> {
config.enable_tray_icon = false; config.enable_tray_icon = false;
config.run_in_background = false; config.run_in_background = false;
config.startup_in_background = false; config.startup_in_background = false;
config.start_fullscreen = true;
} }
config.write();
let enable_tray_icon = config.enable_tray_icon; let enable_tray_icon = config.enable_tray_icon;
let startup_in_background = config.startup_in_background; let startup_in_background = config.startup_in_background;
@@ -131,8 +157,8 @@ async fn main() -> Result<()> {
// i_slint_backend_selector::with_platform(|_| Ok(())).unwrap(); // i_slint_backend_selector::with_platform(|_| Ok(())).unwrap();
if !startup_in_background { if !startup_in_background {
if let Ok(mut lock) = app_state.lock() { if let Ok(mut app_state) = app_state.lock() {
*lock = AppState::MainWindowShouldOpen; *app_state = AppState::MainWindowShouldOpen;
} }
} }
@@ -148,54 +174,101 @@ async fn main() -> Result<()> {
thread::spawn(move || { thread::spawn(move || {
let mut state = AppState::StartingUp; let mut state = AppState::StartingUp;
loop { loop {
// save as a var, don't hold the lock the entire time or deadlocks happen if is_rog_ally {
if let Ok(lock) = app_state.lock() { let config_copy_2 = config.clone();
state = *lock; 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 let ui_copy = newui.as_weak();
sleep(Duration::from_millis(300)); newui
if state == AppState::MainWindowShouldOpen { .window()
if let Ok(mut lock) = app_state.lock() { .set_rendering_notifier(move |s, _| {
*lock = AppState::MainWindowOpen; 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();
}
})
.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;
} }
let config_copy = config.clone(); // This sleep is required to give the event loop time to react
let app_state_copy = app_state.clone(); sleep(Duration::from_millis(300));
slint::invoke_from_event_loop(move || { if state == AppState::MainWindowShouldOpen {
UI.with(|ui| { if let Ok(mut app_state) = app_state.lock() {
let app_state_copy = app_state_copy.clone(); *app_state = AppState::MainWindowOpen;
let mut ui = ui.borrow_mut(); }
if let Some(ui) = ui.as_mut() {
ui.window().show().unwrap(); let config_copy = config.clone();
ui.window().on_close_requested(move || { let app_state_copy = app_state.clone();
if let Ok(mut lock) = app_state_copy.lock() { slint::invoke_from_event_loop(move || {
*lock = AppState::MainWindowClosed; UI.with(|ui| {
} let app_state_copy = app_state_copy.clone();
slint::CloseRequestResponse::HideWindow let mut ui = ui.borrow_mut();
}); if let Some(ui) = ui.as_mut() {
} else { ui.window().show().unwrap();
let newui = setup_window(config_copy); ui.window().on_close_requested(move || {
newui.window().show().unwrap(); if let Ok(mut app_state) = app_state_copy.lock() {
newui.window().on_close_requested(move || { *app_state = AppState::MainWindowClosed;
if let Ok(mut lock) = app_state_copy.lock() { }
*lock = AppState::MainWindowClosed; slint::CloseRequestResponse::HideWindow
} });
slint::CloseRequestResponse::HideWindow } else {
}); let config_copy_2 = config_copy.clone();
ui.replace(newui); 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);
} }
});
})
.unwrap();
} else if state == AppState::QuitApp {
slint::quit_event_loop().unwrap();
exit(0);
} else if state != AppState::MainWindowOpen {
if let Ok(lock) = config.lock() {
if !lock.run_in_background {
slint::quit_event_loop().unwrap();
exit(0);
} }
} }
} }
+13 -13
View File
@@ -5,7 +5,7 @@ use rog_aura::{AuraEffect, AuraModeNum, AuraZone};
use rog_platform::platform::GpuMode; use rog_platform::platform::GpuMode;
use rog_platform::supported::{ use rog_platform::supported::{
AdvancedAura, AnimeSupportedFunctions, ChargeSupportedFunctions, LedSupportedFunctions, AdvancedAura, AnimeSupportedFunctions, ChargeSupportedFunctions, LedSupportedFunctions,
PlatformProfileFunctions, RogBiosSupportedFunctions, SupportedFunctions PlatformProfileFunctions, RogBiosSupportedFunctions, SupportedFunctions,
}; };
use rog_profiles::fan_curve_set::{CurveData, FanCurveSet}; use rog_profiles::fan_curve_set::{CurveData, FanCurveSet};
use supergfxctl::pci_device::{GfxMode, GfxPower}; use supergfxctl::pci_device::{GfxMode, GfxPower};
@@ -16,7 +16,7 @@ const NOPE: &str = "";
#[derive(Default)] #[derive(Default)]
pub struct DaemonProxyBlocking<'a> { pub struct DaemonProxyBlocking<'a> {
_phantom: &'a str _phantom: &'a str,
} }
impl<'a> DaemonProxyBlocking<'a> { impl<'a> DaemonProxyBlocking<'a> {
@@ -35,7 +35,7 @@ impl<'a> DaemonProxyBlocking<'a> {
#[derive(Default)] #[derive(Default)]
pub struct RogDbusClientBlocking<'a> { pub struct RogDbusClientBlocking<'a> {
_phantom: &'a str _phantom: &'a str,
} }
impl<'a> RogDbusClientBlocking<'a> { impl<'a> RogDbusClientBlocking<'a> {
@@ -126,16 +126,16 @@ impl Profile {
pub fn fan_curve_data(&self, _p: rog_profiles::Profile) -> Result<FanCurveSet> { pub fn fan_curve_data(&self, _p: rog_profiles::Profile) -> Result<FanCurveSet> {
let mut curve = FanCurveSet::default(); let mut curve = FanCurveSet::default();
curve.cpu.pwm = [ curve.cpu.pwm = [
30, 40, 60, 100, 140, 180, 200, 250 30, 40, 60, 100, 140, 180, 200, 250,
]; ];
curve.cpu.temp = [ curve.cpu.temp = [
20, 30, 40, 50, 70, 80, 90, 100 20, 30, 40, 50, 70, 80, 90, 100,
]; ];
curve.gpu.pwm = [ curve.gpu.pwm = [
40, 80, 100, 140, 170, 200, 230, 250 40, 80, 100, 140, 170, 200, 230, 250,
]; ];
curve.gpu.temp = [ curve.gpu.temp = [
20, 30, 40, 50, 70, 80, 90, 100 20, 30, 40, 50, 70, 80, 90, 100,
]; ];
Ok(curve) Ok(curve)
} }
@@ -204,7 +204,7 @@ impl Led {
AuraDevRog2::AwakeKeyb, AuraDevRog2::AwakeKeyb,
AuraDevRog2::SleepLogo, AuraDevRog2::SleepLogo,
AuraDevRog2::AwakeLogo, AuraDevRog2::AwakeLogo,
] ],
}) })
} }
@@ -242,11 +242,11 @@ impl Supported {
Ok(SupportedFunctions { Ok(SupportedFunctions {
anime_ctrl: AnimeSupportedFunctions(true), anime_ctrl: AnimeSupportedFunctions(true),
charge_ctrl: ChargeSupportedFunctions { charge_ctrl: ChargeSupportedFunctions {
charge_level_set: true charge_level_set: true,
}, },
platform_profile: PlatformProfileFunctions { platform_profile: PlatformProfileFunctions {
platform_profile: true, platform_profile: true,
fan_curves: true fan_curves: true,
}, },
keyboard_led: LedSupportedFunctions { keyboard_led: LedSupportedFunctions {
dev_id: AuraDevice::X19b6, dev_id: AuraDevice::X19b6,
@@ -267,7 +267,7 @@ impl Supported {
AuraZone::BarRight, AuraZone::BarRight,
AuraZone::Logo, AuraZone::Logo,
], ],
advanced_type: AdvancedAura::PerKey advanced_type: AdvancedAura::PerKey,
}, },
rog_bios_ctrl: RogBiosSupportedFunctions { rog_bios_ctrl: RogBiosSupportedFunctions {
post_sound: true, post_sound: true,
@@ -275,8 +275,8 @@ impl Supported {
panel_overdrive: true, panel_overdrive: true,
dgpu_disable: true, dgpu_disable: true,
mini_led_mode: true, mini_led_mode: true,
egpu_enable: true egpu_enable: true,
} },
}) })
} }
} }
+43 -42
View File
@@ -9,9 +9,9 @@ use std::process::Command;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::Duration; use std::time::Duration;
use futures_util::StreamExt;
use log::{debug, error, info, warn}; use log::{debug, error, info, warn};
use notify_rust::{Hint, Notification, Timeout, Urgency}; use notify_rust::{Hint, Notification, Timeout, Urgency};
use rog_dbus::zbus_platform::PlatformProxy;
use rog_platform::platform::GpuMode; use rog_platform::platform::GpuMode;
use rog_platform::power::AsusPower; use rog_platform::power::AsusPower;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -20,7 +20,6 @@ use supergfxctl::pci_device::{GfxMode, GfxPower};
use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy; use supergfxctl::zbus_proxy::DaemonProxy as SuperProxy;
use tokio::runtime::Runtime; use tokio::runtime::Runtime;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use zbus::export::futures_util::StreamExt;
use crate::config::Config; use crate::config::Config;
use crate::error::Result; use crate::error::Result;
@@ -32,7 +31,7 @@ const NOTIF_HEADER: &str = "ROG Control";
pub struct EnabledNotifications { pub struct EnabledNotifications {
pub enabled: bool, pub enabled: bool,
pub receive_notify_gfx: bool, pub receive_notify_gfx: bool,
pub receive_notify_gfx_status: bool pub receive_notify_gfx_status: bool,
} }
impl Default for EnabledNotifications { impl Default for EnabledNotifications {
@@ -40,7 +39,7 @@ impl Default for EnabledNotifications {
Self { Self {
enabled: true, enabled: true,
receive_notify_gfx: true, receive_notify_gfx: true,
receive_notify_gfx_status: true receive_notify_gfx_status: true,
} }
} }
} }
@@ -93,7 +92,7 @@ fn start_dpu_status_mon(config: Arc<Mutex<Config>>) {
pub fn start_notifications( pub fn start_notifications(
config: Arc<Mutex<Config>>, config: Arc<Mutex<Config>>,
rt: &Runtime rt: &Runtime,
) -> Result<Vec<JoinHandle<()>>> { ) -> Result<Vec<JoinHandle<()>>> {
// Setup the AC/BAT commands that will run on power status change // Setup the AC/BAT commands that will run on power status change
let config_copy = config.clone(); let config_copy = config.clone();
@@ -154,39 +153,41 @@ pub fn start_notifications(
}; };
// GPU MUX Mode notif // GPU MUX Mode notif
let enabled_notifications_copy = config.clone(); // TODO: need to get armoury attrs and iter to find
tokio::spawn(async move { // let enabled_notifications_copy = config.clone();
let conn = zbus::Connection::system().await.map_err(|e| { // tokio::spawn(async move {
error!("zbus signal: receive_notify_gpu_mux_mode: {e}"); // let conn = zbus::Connection::system().await.map_err(|e| {
e // error!("zbus signal: receive_notify_gpu_mux_mode: {e}");
})?; // e
let proxy = PlatformProxy::new(&conn).await.map_err(|e| { // })?;
error!("zbus signal: receive_notify_gpu_mux_mode: {e}"); // let proxy = PlatformProxy::new(&conn).await.map_err(|e| {
e // error!("zbus signal: receive_notify_gpu_mux_mode: {e}");
})?; // e
// })?;
let mut actual_mux_mode = GpuMode::Error; // let mut actual_mux_mode = GpuMode::Error;
if let Ok(mode) = proxy.gpu_mux_mode().await { // if let Ok(mode) = proxy.gpu_mux_mode().await {
actual_mux_mode = GpuMode::from(mode); // actual_mux_mode = GpuMode::from(mode);
} // }
info!("Started zbus signal thread: receive_notify_gpu_mux_mode"); // info!("Started zbus signal thread: receive_notify_gpu_mux_mode");
while let Some(e) = proxy.receive_gpu_mux_mode_changed().await.next().await { // while let Some(e) =
if let Ok(config) = enabled_notifications_copy.lock() { // proxy.receive_gpu_mux_mode_changed().await.next().await { if let
if !config.notifications.enabled || !config.notifications.receive_notify_gfx { // Ok(config) = enabled_notifications_copy.lock() { if
continue; // !config.notifications.enabled || !config.notifications.receive_notify_gfx {
} // continue;
} // }
if let Ok(out) = e.get().await { // }
let mode = GpuMode::from(out); // if let Ok(out) = e.get().await {
if mode == actual_mux_mode { // let mode = GpuMode::from(out);
continue; // if mode == actual_mux_mode {
} // continue;
do_mux_notification("Reboot required. BIOS GPU MUX mode set to", &mode).ok(); // }
} // do_mux_notification("Reboot required. BIOS GPU MUX mode set to",
} // &mode).ok(); }
Ok::<(), zbus::Error>(()) // }
}); // Ok::<(), zbus::Error>(())
// });
let enabled_notifications_copy = config.clone(); let enabled_notifications_copy = config.clone();
// GPU Mode change/action notif // GPU Mode change/action notif
@@ -213,7 +214,7 @@ pub fn start_notifications(
supergfxctl::actions::UserActionRequired::Reboot => { supergfxctl::actions::UserActionRequired::Reboot => {
do_mux_notification("Graphics mode change requires reboot", &mode) 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| { .map_err(|e| {
error!("zbus signal: do_gfx_action_notif: {e}"); error!("zbus signal: do_gfx_action_notif: {e}");
@@ -265,13 +266,13 @@ fn convert_gfx_mode(gfx: GfxMode) -> GpuMode {
GfxMode::Vfio => GpuMode::Vfio, GfxMode::Vfio => GpuMode::Vfio,
GfxMode::AsusEgpu => GpuMode::Egpu, GfxMode::AsusEgpu => GpuMode::Egpu,
GfxMode::AsusMuxDgpu => GpuMode::Ultimate, GfxMode::AsusMuxDgpu => GpuMode::Ultimate,
GfxMode::None => GpuMode::Error GfxMode::None => GpuMode::Error,
} }
} }
fn base_notification<T>(message: &str, data: &T) -> Notification fn base_notification<T>(message: &str, data: &T) -> Notification
where where
T: Display T: Display,
{ {
let mut notif = Notification::new(); let mut notif = Notification::new();
notif notif
@@ -289,7 +290,7 @@ fn do_gpu_status_notif(message: &str, data: &GfxPower) -> Notification {
GfxPower::Off => "asus_notif_green", GfxPower::Off => "asus_notif_green",
GfxPower::AsusDisabled => "asus_notif_white", GfxPower::AsusDisabled => "asus_notif_white",
GfxPower::AsusMuxDiscreet | GfxPower::Active => "asus_notif_red", GfxPower::AsusMuxDiscreet | GfxPower::Active => "asus_notif_red",
GfxPower::Unknown => "gpu-integrated" GfxPower::Unknown => "gpu-integrated",
}; };
notif.icon(icon); notif.icon(icon);
notif notif
@@ -330,7 +331,7 @@ fn do_gfx_action_notif(message: &str, action: GfxUserAction, mode: GpuMode) -> R
if id == "gfx-mode-session-action" { if id == "gfx-mode-session-action" {
let mut cmd = Command::new("qdbus"); let mut cmd = Command::new("qdbus");
cmd.args([ cmd.args([
"org.kde.ksmserver", "/KSMServer", "logout", "1", "0", "0" "org.kde.ksmserver", "/KSMServer", "logout", "1", "0", "0",
]); ]);
cmd.spawn().ok(); cmd.spawn().ok();
} else if id == "__closed" { } else if id == "__closed" {
@@ -374,7 +375,7 @@ fn do_mux_notification(message: &str, m: &GpuMode) -> Result<()> {
if id == "gfx-mode-session-action" { if id == "gfx-mode-session-action" {
let mut cmd = Command::new("qdbus"); let mut cmd = Command::new("qdbus");
cmd.args([ cmd.args([
"org.kde.ksmserver", "/KSMServer", "logout", "1", "1", "0" "org.kde.ksmserver", "/KSMServer", "logout", "1", "1", "0",
]); ]);
cmd.spawn().ok(); cmd.spawn().ok();
} else if id == "__closed" { } else if id == "__closed" {
+29 -17
View File
@@ -24,7 +24,7 @@ struct Icons {
rog_red: Icon, rog_red: Icon,
rog_green: Icon, rog_green: Icon,
rog_white: Icon, rog_white: Icon,
gpu_integrated: Icon gpu_integrated: Icon,
} }
static ICONS: OnceLock<Icons> = OnceLock::new(); static ICONS: OnceLock<Icons> = OnceLock::new();
@@ -32,7 +32,10 @@ static ICONS: OnceLock<Icons> = OnceLock::new();
fn read_icon(file: &Path) -> Icon { fn read_icon(file: &Path) -> Icon {
let mut path = PathBuf::from(TRAY_ICON_PATH); let mut path = PathBuf::from(TRAY_ICON_PATH);
path.push(file); 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(); let mut bytes = Vec::new();
file.read_to_end(&mut bytes).unwrap(); file.read_to_end(&mut bytes).unwrap();
@@ -48,14 +51,14 @@ fn read_icon(file: &Path) -> Icon {
Icon { Icon {
width: width as i32, width: width as i32,
height: height as i32, height: height as i32,
data: img.into_raw() data: img.into_raw(),
} }
} }
struct AsusTray { struct AsusTray {
current_title: String, current_title: String,
current_icon: Icon, current_icon: Icon,
proxy: ROGCCZbusProxyBlocking<'static> proxy: ROGCCZbusProxyBlocking<'static>,
} }
impl ksni::Tray for AsusTray { impl ksni::Tray for AsusTray {
@@ -103,7 +106,7 @@ async fn set_tray_icon_and_tip(
mode: GfxMode, mode: GfxMode,
power: GfxPower, power: GfxPower,
tray: &mut Handle<AsusTray>, tray: &mut Handle<AsusTray>,
supergfx_active: bool supergfx_active: bool,
) { ) {
if let Some(icons) = ICONS.get() { if let Some(icons) = ICONS.get() {
let icon = match power { let icon = match power {
@@ -127,7 +130,6 @@ async fn set_tray_icon_and_tip(
}; };
tray.update(|tray: &mut AsusTray| { tray.update(|tray: &mut AsusTray| {
dbg!(power);
tray.current_icon = icon; tray.current_icon = icon;
tray.current_title = format!( tray.current_title = format!(
"ROG: gpu mode = {mode:?}, gpu power = "ROG: gpu mode = {mode:?}, gpu power =
@@ -160,21 +162,23 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
let rog_red = read_icon(&PathBuf::from("asus_notif_red.png")); let rog_red = read_icon(&PathBuf::from("asus_notif_red.png"));
let tray = AsusTray { let tray_init = AsusTray {
current_title: TRAY_LABEL.to_string(), current_title: TRAY_LABEL.to_string(),
current_icon: rog_red.clone(), current_icon: rog_red.clone(),
proxy proxy,
}; };
let mut tray = tray // TODO: return an error to the UI
.spawn_without_dbus_name() let mut tray;
.await match tray_init.spawn_without_dbus_name().await {
.map_err(|e| { Ok(t) => tray = t,
Err(e) => {
log::error!( log::error!(
"Tray unable to be initialised: {e:?}. Do you have a system tray enabled?" "Tray unable to be initialised: {e:?}. Do you have a system tray enabled?"
) );
}) return;
.unwrap(); }
}
info!("Tray started"); info!("Tray started");
let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png")); let rog_blue = read_icon(&PathBuf::from("asus_notif_blue.png"));
@@ -186,7 +190,7 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
rog_red: rog_red.clone(), rog_red: rog_red.clone(),
rog_green, rog_green,
rog_white, rog_white,
gpu_integrated gpu_integrated,
}); });
let mut has_supergfx = false; let mut has_supergfx = false;
@@ -207,7 +211,15 @@ pub fn init_tray(_supported_properties: Vec<Properties>, config: Arc<Mutex<Confi
} }
} }
} }
Err(e) => warn!("Couldn't get mode form supergfxd: {e:?}") Err(e) => match e {
zbus::Error::MethodError(_, _, message) => {
warn!(
"Couldn't get mode from supergfxd: {message:?}, the supergfxd service \
may not be running or installed"
)
}
_ => warn!("Couldn't get mode from supergfxd: {e:?}"),
},
} }
info!("Started ROGTray"); info!("Started ROGTray");
+15 -15
View File
@@ -1,6 +1,6 @@
use crate::slint_generatedMainWindow::{ use crate::slint_generatedMainWindow::{
AuraDevType as SlintDeviceType, AuraPowerState as SlintAuraPowerState, AuraDevType as SlintDeviceType, AuraPowerState as SlintAuraPowerState,
LaptopAuraPower as SlintLaptopAuraPower LaptopAuraPower as SlintLaptopAuraPower,
}; };
impl From<rog_aura::AuraEffect> for crate::slint_generatedMainWindow::AuraEffect { 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, red: m.colour1.r,
green: m.colour1.g, green: m.colour1.g,
blue: m.colour1.b, blue: m.colour1.b,
alpha: 255 alpha: 255,
} }
.into(), .into(),
colour2: RgbaColor { colour2: RgbaColor {
red: m.colour2.r, red: m.colour2.r,
green: m.colour2.g, green: m.colour2.g,
blue: m.colour2.b, blue: m.colour2.b,
alpha: 255 alpha: 255,
} }
.into(), .into(),
direction: m.direction.into(), direction: m.direction.into(),
mode: m.mode.into(), mode: m.mode.into(),
speed: m.speed.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 { colour1: rog_aura::Colour {
r: c1.red, r: c1.red,
g: c1.green, g: c1.green,
b: c1.blue b: c1.blue,
}, },
colour2: rog_aura::Colour { colour2: rog_aura::Colour {
r: c2.red, r: c2.red,
g: c2.green, g: c2.green,
b: c2.blue b: c2.blue,
}, },
direction: m.direction.into(), direction: m.direction.into(),
mode: m.mode.into(), mode: m.mode.into(),
speed: m.speed.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::RearGlow => SlintPowerZones::RearGlow,
PowerZones::KeyboardAndLightbar => SlintPowerZones::KeyboardAndLightbar, PowerZones::KeyboardAndLightbar => SlintPowerZones::KeyboardAndLightbar,
PowerZones::Ally => SlintPowerZones::Ally, 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::Lid => PowerZones::Lid,
SlintPowerZones::RearGlow => PowerZones::RearGlow, SlintPowerZones::RearGlow => PowerZones::RearGlow,
SlintPowerZones::KeyboardAndLightbar => PowerZones::KeyboardAndLightbar, SlintPowerZones::KeyboardAndLightbar => PowerZones::KeyboardAndLightbar,
SlintPowerZones::Ally => PowerZones::Ally SlintPowerZones::Ally => PowerZones::Ally,
} }
} }
} }
@@ -92,7 +92,7 @@ impl From<SlintAuraPowerState> for AuraPowerState {
boot: value.boot, boot: value.boot,
awake: value.awake, awake: value.awake,
sleep: value.sleep, sleep: value.sleep,
shutdown: value.shutdown shutdown: value.shutdown,
} }
} }
} }
@@ -106,7 +106,7 @@ impl From<AuraPowerState> for SlintAuraPowerState {
sleep: value.sleep, sleep: value.sleep,
shutdown: value.shutdown, shutdown: value.shutdown,
zone, 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, sleep: value.sleep,
shutdown: value.shutdown, shutdown: value.shutdown,
zone, 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> = let converted: Vec<SlintAuraPowerState> =
value.states.iter().map(SlintAuraPowerState::from).collect(); value.states.iter().map(SlintAuraPowerState::from).collect();
Self { 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::ScsiExtDisk => Self::ScsiExtDisk,
SlintDeviceType::Unknown => Self::Unknown, SlintDeviceType::Unknown => Self::Unknown,
SlintDeviceType::Ally => Self::Ally, 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::ScsiExtDisk => SlintDeviceType::ScsiExtDisk,
AuraDeviceType::Unknown => SlintDeviceType::Unknown, AuraDeviceType::Unknown => SlintDeviceType::Unknown,
AuraDeviceType::Ally => SlintDeviceType::Ally, AuraDeviceType::Ally => SlintDeviceType::Ally,
AuraDeviceType::AnimeOrSlash => SlintDeviceType::AnimeOrSlash AuraDeviceType::AnimeOrSlash => SlintDeviceType::AnimeOrSlash,
} }
} }
} }
+14 -12
View File
@@ -1,24 +1,26 @@
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use rog_profiles::FanCurvePU; use rog_profiles::FanCurvePU;
use crate::{FanType, Profile}; use crate::{FanType, Profile};
impl From<Profile> for ThrottlePolicy { impl From<Profile> for PlatformProfile {
fn from(value: Profile) -> Self { fn from(value: Profile) -> Self {
match value { match value {
Profile::Balanced => ThrottlePolicy::Balanced, Profile::Balanced => PlatformProfile::Balanced,
Profile::Performance => ThrottlePolicy::Performance, Profile::Performance => PlatformProfile::Performance,
Profile::Quiet => ThrottlePolicy::Quiet Profile::Quiet => PlatformProfile::Quiet,
Profile::LowPower => PlatformProfile::LowPower,
} }
} }
} }
impl From<ThrottlePolicy> for Profile { impl From<PlatformProfile> for Profile {
fn from(value: ThrottlePolicy) -> Self { fn from(value: PlatformProfile) -> Self {
match value { match value {
ThrottlePolicy::Balanced => Profile::Balanced, PlatformProfile::Balanced => Profile::Balanced,
ThrottlePolicy::Performance => Profile::Performance, PlatformProfile::Performance => Profile::Performance,
ThrottlePolicy::Quiet => Profile::Quiet PlatformProfile::Quiet => Profile::Quiet,
PlatformProfile::LowPower => Profile::LowPower,
} }
} }
} }
@@ -28,7 +30,7 @@ impl From<FanType> for FanCurvePU {
match value { match value {
FanType::CPU => FanCurvePU::CPU, FanType::CPU => FanCurvePU::CPU,
FanType::Middle => FanCurvePU::MID, FanType::Middle => FanCurvePU::MID,
FanType::GPU => FanCurvePU::GPU FanType::GPU => FanCurvePU::GPU,
} }
} }
} }
@@ -38,7 +40,7 @@ impl From<FanCurvePU> for FanType {
match value { match value {
FanCurvePU::CPU => FanType::CPU, FanCurvePU::CPU => FanType::CPU,
FanCurvePU::GPU => FanType::GPU, FanCurvePU::GPU => FanType::GPU,
FanCurvePU::MID => FanType::Middle FanCurvePU::MID => FanType::Middle,
} }
} }
} }
+13 -16
View File
@@ -6,8 +6,9 @@ pub mod setup_system;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use config_traits::StdConfig; use config_traits::StdConfig;
use log::warn;
use rog_dbus::list_iface_blocking; use rog_dbus::list_iface_blocking;
use slint::{ComponentHandle, PhysicalSize, SharedString, Weak}; use slint::{ComponentHandle, SharedString, Weak};
use crate::config::Config; use crate::config::Config;
use crate::ui::setup_anime::setup_anime_page; use crate::ui::setup_anime::setup_anime_page;
@@ -26,7 +27,7 @@ macro_rules! set_ui_callbacks {
let handle_copy = $handle.as_weak(); let handle_copy = $handle.as_weak();
let proxy_copy = $proxy.clone(); let proxy_copy = $proxy.clone();
let data = $handle.global::<$data>(); let data = $handle.global::<$data>();
concat_idents::concat_idents!(on_set = on_set_, $proxy_fn { concat_idents::concat_idents!(on_set = on_cb_, $proxy_fn {
data.on_set(move |value| { data.on_set(move |value| {
let proxy_copy = proxy_copy.clone(); let proxy_copy = proxy_copy.clone();
let handle_copy = handle_copy.clone(); let handle_copy = handle_copy.clone();
@@ -49,7 +50,7 @@ macro_rules! set_ui_callbacks {
tokio::spawn(async move { tokio::spawn(async move {
let mut x = proxy_copy.receive().await; let mut x = proxy_copy.receive().await;
concat_idents::concat_idents!(set = set_, $proxy_fn { 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 { while let Some(e) = x.next().await {
if let Ok(out) = e.get().await { if let Ok(out) = e.get().await {
handle_copy.upgrade_in_event_loop(move |handle| { handle_copy.upgrade_in_event_loop(move |handle| {
@@ -67,7 +68,7 @@ pub fn show_toast(
success: SharedString, success: SharedString,
fail: SharedString, fail: SharedString,
handle: Weak<MainWindow>, handle: Weak<MainWindow>,
result: zbus::Result<()> result: zbus::Result<()>,
) { ) {
match result { match result {
Ok(_) => { Ok(_) => {
@@ -77,21 +78,16 @@ pub fn show_toast(
log::warn!("{fail}: {e}"); log::warn!("{fail}: {e}");
handle.unwrap().invoke_show_toast(fail) handle.unwrap().invoke_show_toast(fail)
}) })
.ok() .ok(),
}; };
} }
pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow { pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
slint::set_xdg_app_id("rog-control-center")
.map_err(|e| warn!("Couldn't set application ID: {e:?}"))
.ok();
let ui = MainWindow::new().unwrap(); let ui = MainWindow::new().unwrap();
if let Ok(lock) = config.try_lock() { ui.window().show().unwrap();
let fullscreen = lock.start_fullscreen;
let width = lock.fullscreen_width;
let height = lock.fullscreen_height;
if fullscreen {
ui.window().set_fullscreen(fullscreen);
ui.window().set_size(PhysicalSize { width, height });
}
};
let available = list_iface_blocking().unwrap_or_default(); let available = list_iface_blocking().unwrap_or_default();
ui.set_sidebar_items_avilable( ui.set_sidebar_items_avilable(
@@ -102,9 +98,9 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
available.contains(&"xyz.ljones.Anime".to_string()), available.contains(&"xyz.ljones.Anime".to_string()),
available.contains(&"xyz.ljones.FanCurves".to_string()), available.contains(&"xyz.ljones.FanCurves".to_string()),
true, true,
true true,
] ]
.into() .into(),
); );
ui.on_exit_app(move || { ui.on_exit_app(move || {
@@ -125,6 +121,7 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
if available.contains(&"xyz.ljones.FanCurves".to_string()) { if available.contains(&"xyz.ljones.FanCurves".to_string()) {
setup_fan_curve_page(&ui, config); setup_fan_curve_page(&ui, config);
} }
ui ui
} }
+111 -111
View File
@@ -1,7 +1,8 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use log::{error, info, warn}; use log::{error, info};
use rog_anime::Animations; use rog_anime::Animations;
use rog_dbus::find_iface_async;
use rog_dbus::zbus_anime::AnimeProxy; use rog_dbus::zbus_anime::AnimeProxy;
use slint::ComponentHandle; use slint::ComponentHandle;
@@ -12,124 +13,123 @@ use crate::{set_ui_callbacks, set_ui_props_async, AnimePageData, MainWindow};
pub fn setup_anime_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) { pub fn setup_anime_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
let handle = ui.as_weak(); let handle = ui.as_weak();
tokio::spawn(async move { tokio::spawn(async move {
let Ok(conn) = zbus::Connection::system().await.map_err(|e| warn!("{e:}")) else { let Ok(animes) = find_iface_async::<AnimeProxy>("xyz.ljones.Anime").await else {
return; info!("This device appears to have no aura interfaces");
};
let Ok(anime) = AnimeProxy::new(&conn).await.map_err(|e| warn!("{e:}")) else {
info!("This device may not have an AniMe. If not then the error can be ignored");
return; return;
}; };
set_ui_props_async!(handle, anime, AnimePageData, brightness); for anime in animes {
set_ui_props_async!(handle, anime, AnimePageData, builtins_enabled); set_ui_props_async!(handle, anime, AnimePageData, brightness);
set_ui_props_async!(handle, anime, AnimePageData, enable_display); set_ui_props_async!(handle, anime, AnimePageData, builtins_enabled);
set_ui_props_async!(handle, anime, AnimePageData, off_when_lid_closed); set_ui_props_async!(handle, anime, AnimePageData, enable_display);
set_ui_props_async!(handle, anime, AnimePageData, off_when_suspended); set_ui_props_async!(handle, anime, AnimePageData, off_when_lid_closed);
set_ui_props_async!(handle, anime, AnimePageData, off_when_unplugged); set_ui_props_async!(handle, anime, AnimePageData, off_when_suspended);
set_ui_props_async!(handle, anime, AnimePageData, off_when_unplugged);
let builtins = anime.builtin_animations().await.unwrap_or_default(); let builtins = anime.builtin_animations().await.unwrap_or_default();
handle handle
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
{ {
let global = handle.global::<AnimePageData>(); let global = handle.global::<AnimePageData>();
global.set_boot_anim(builtins.boot as i32); global.set_boot_anim(builtins.boot as i32);
global.set_awake_anim(builtins.awake as i32); global.set_awake_anim(builtins.awake as i32);
global.set_sleep_anim(builtins.sleep as i32); global.set_sleep_anim(builtins.sleep as i32);
global.set_shutdown_anim(builtins.shutdown as i32); global.set_shutdown_anim(builtins.shutdown as i32);
let handle_copy = handle.as_weak(); let handle_copy = handle.as_weak();
let anime_copy = anime.clone(); let anime_copy = anime.clone();
global.on_set_builtin_animations(move |boot, awake, sleep, shutdown| { global.on_cb_builtin_animations(move |boot, awake, sleep, shutdown| {
let handle_copy = handle_copy.clone(); let handle_copy = handle_copy.clone();
let anime_copy = anime_copy.clone(); let anime_copy = anime_copy.clone();
tokio::spawn(async move { tokio::spawn(async move {
show_toast( show_toast(
"Anime builtin animations changed".into(), "Anime builtin animations changed".into(),
"Failed to set Anime builtin animations".into(), "Failed to set Anime builtin animations".into(),
handle_copy, handle_copy,
anime_copy anime_copy
.set_builtin_animations(Animations { .set_builtin_animations(Animations {
boot: boot.into(), boot: boot.into(),
awake: awake.into(), awake: awake.into(),
sleep: sleep.into(), sleep: sleep.into(),
shutdown: shutdown.into() shutdown: shutdown.into(),
}) })
.await .await,
); );
});
}); });
});
let handle_copy = handle.as_weak(); let handle_copy = handle.as_weak();
let anime_copy = anime.clone(); let anime_copy = anime.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut x = anime_copy.receive_builtin_animations_changed().await; 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 { while let Some(e) = x.next().await {
if let Ok(out) = e.get().await { if let Ok(out) = e.get().await {
handle_copy handle_copy
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
handle handle
.global::<AnimePageData>() .global::<AnimePageData>()
.set_boot_anim(out.boot.into()); .set_boot_anim(out.boot.into());
handle handle
.global::<AnimePageData>() .global::<AnimePageData>()
.set_awake_anim(out.awake.into()); .set_awake_anim(out.awake.into());
handle handle
.global::<AnimePageData>() .global::<AnimePageData>()
.set_sleep_anim(out.sleep.into()); .set_sleep_anim(out.sleep.into());
handle handle
.global::<AnimePageData>() .global::<AnimePageData>()
.set_shutdown_anim(out.shutdown.into()); .set_shutdown_anim(out.shutdown.into());
}) })
.ok(); .ok();
}
} }
} });
}); }
}
set_ui_callbacks!(handle, set_ui_callbacks!(handle,
AnimePageData(.into()), AnimePageData(.into()),
anime.brightness(.into()), anime.brightness(.into()),
"Anime LED brightness successfully set to {}", "Anime LED brightness successfully set to {}",
"Setting Anime LED brightness failed" "Setting Anime LED brightness failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
AnimePageData(), AnimePageData(),
anime.builtins_enabled(), anime.builtins_enabled(),
"Keyboard LED mode successfully set to {}", "Keyboard LED mode successfully set to {}",
"Setting keyboard LEDmode failed" "Setting keyboard LEDmode failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
AnimePageData(), AnimePageData(),
anime.enable_display(), anime.enable_display(),
"Anime display successfully set to {}", "Anime display successfully set to {}",
"Setting Anime display failed" "Setting Anime display failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
AnimePageData(), AnimePageData(),
anime.off_when_lid_closed(), anime.off_when_lid_closed(),
"Anime off_when_lid_closed successfully set to {}", "Anime off_when_lid_closed successfully set to {}",
"Setting Anime off_when_lid_closed failed" "Setting Anime off_when_lid_closed failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
AnimePageData(), AnimePageData(),
anime.off_when_suspended(), anime.off_when_suspended(),
"Anime off_when_suspended successfully set to {}", "Anime off_when_suspended successfully set to {}",
"Setting Anime off_when_suspended failed" "Setting Anime off_when_suspended failed"
); );
set_ui_callbacks!( set_ui_callbacks!(
handle, handle,
AnimePageData(), AnimePageData(),
anime.off_when_unplugged(), anime.off_when_unplugged(),
"Anime off_when_unplugged successfully set to {}", "Anime off_when_unplugged successfully set to {}",
"Setting Anime off_when_unplugged failed" "Setting Anime off_when_unplugged failed"
); );
}) })
.map_err(|e| error!("setup_anime_page: upgrade_in_event_loop: {e:?}")) .map_err(|e| error!("setup_anime_page: upgrade_in_event_loop: {e:?}"))
.ok(); .ok();
}
}); });
} }
+8 -8
View File
@@ -9,7 +9,7 @@ use slint::{ComponentHandle, Model, RgbaColor, SharedString};
use crate::config::Config; use crate::config::Config;
use crate::ui::show_toast; use crate::ui::show_toast;
use crate::{ 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> { fn decode_hex(s: &str) -> RgbaColor<u8> {
@@ -19,7 +19,7 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
alpha: 255, alpha: 255,
red: 0, red: 0,
green: 0, green: 0,
blue: 0 blue: 0,
}; };
} }
let c: Vec<u8> = (0..s.len()) let c: Vec<u8> = (0..s.len())
@@ -30,7 +30,7 @@ fn decode_hex(s: &str) -> RgbaColor<u8> {
alpha: 255, alpha: 255,
red: *c.first().unwrap_or(&255), red: *c.first().unwrap_or(&255),
green: *c.get(1).unwrap_or(&128), green: *c.get(1).unwrap_or(&128),
blue: *c.get(2).unwrap_or(&32) blue: *c.get(2).unwrap_or(&32),
} }
} }
@@ -65,12 +65,12 @@ async fn find_aura_iface() -> Result<AuraProxy<'static>, Box<dyn std::error::Err
} }
pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) { pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
ui.global::<AuraPageData>().on_set_hex_from_colour(|c| { ui.global::<AuraPageData>().on_cb_hex_from_colour(|c| {
format!("#{:02X}{:02X}{:02X}", c.red(), c.green(), c.blue()).into() format!("#{:02X}{:02X}{:02X}", c.red(), c.green(), c.blue()).into()
}); });
ui.global::<AuraPageData>() ui.global::<AuraPageData>()
.on_set_hex_to_colour(|s| decode_hex(s.as_str()).into()); .on_cb_hex_to_colour(|s| decode_hex(s.as_str()).into());
let handle = ui.as_weak(); let handle = ui.as_weak();
tokio::spawn(async move { tokio::spawn(async move {
@@ -189,7 +189,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
.upgrade_in_event_loop(|handle| { .upgrade_in_event_loop(|handle| {
handle handle
.global::<AuraPageData>() .global::<AuraPageData>()
.on_set_led_power(move |power| { .on_cb_led_power(move |power| {
let handle_copy = handle_copy.clone(); let handle_copy = handle_copy.clone();
let proxy_copy = aura.clone(); let proxy_copy = aura.clone();
let power: LaptopAuraPower = power.into(); let power: LaptopAuraPower = power.into();
@@ -198,7 +198,7 @@ pub fn setup_aura_page(ui: &MainWindow, _states: Arc<Mutex<Config>>) {
"Aura power settings changed".into(), "Aura power settings changed".into(),
"Failed to set Aura power settings".into(), "Failed to set Aura power settings".into(),
handle_copy, 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 // spawn required since the while let never exits
tokio::spawn(async move { tokio::spawn(async move {
let mut x = proxy_copy.receive_led_mode_data_changed().await; 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 { while let Some(e) = x.next().await {
if let Ok(out) = e.get().await { if let Ok(out) = e.get().await {
handle_copy handle_copy
+13 -13
View File
@@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex};
use log::{error, info}; use log::{error, info};
use rog_dbus::zbus_fan_curves::FanCurvesProxy; use rog_dbus::zbus_fan_curves::FanCurvesProxy;
use rog_platform::platform::ThrottlePolicy; use rog_platform::platform::PlatformProfile;
use rog_profiles::fan_curve_set::CurveData; use rog_profiles::fan_curve_set::CurveData;
use slint::{ComponentHandle, Model, Weak}; use slint::{ComponentHandle, Model, Weak};
@@ -13,7 +13,7 @@ pub fn update_fan_data(
handle: Weak<MainWindow>, handle: Weak<MainWindow>,
bal: Vec<CurveData>, bal: Vec<CurveData>,
perf: Vec<CurveData>, perf: Vec<CurveData>,
quiet: Vec<CurveData> quiet: Vec<CurveData>,
) { ) {
handle handle
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
@@ -24,7 +24,7 @@ pub fn update_fan_data(
.zip(pwm.iter()) .zip(pwm.iter())
.map(|(x, y)| Node { .map(|(x, y)| Node {
x: *x as f32, x: *x as f32,
y: *y as f32 y: *y as f32,
}) })
.collect(); .collect();
tmp.as_slice().into() tmp.as_slice().into()
@@ -109,23 +109,23 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
let handle_copy = handle.clone(); let handle_copy = handle.clone();
// Do initial setup // Do initial setup
let Ok(balanced) = fans let Ok(balanced) = fans
.fan_curve_data(ThrottlePolicy::Balanced) .fan_curve_data(PlatformProfile::Balanced)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("Couldn't get balanced data: {e:}"))
else { else {
return; return;
}; };
let Ok(perf) = fans let Ok(perf) = fans
.fan_curve_data(ThrottlePolicy::Performance) .fan_curve_data(PlatformProfile::Performance)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("Couldn't get performance data: {e:}"))
else { else {
return; return;
}; };
let Ok(quiet) = fans let Ok(quiet) = fans
.fan_curve_data(ThrottlePolicy::Quiet) .fan_curve_data(PlatformProfile::Quiet)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("Couldn't get quiet data: {e:}"))
else { else {
return; return;
}; };
@@ -144,21 +144,21 @@ pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
return; return;
} }
let Ok(balanced) = fans let Ok(balanced) = fans
.fan_curve_data(ThrottlePolicy::Balanced) .fan_curve_data(PlatformProfile::Balanced)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
return; return;
}; };
let Ok(perf) = fans let Ok(perf) = fans
.fan_curve_data(ThrottlePolicy::Performance) .fan_curve_data(PlatformProfile::Performance)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
return; return;
}; };
let Ok(quiet) = fans let Ok(quiet) = fans
.fan_curve_data(ThrottlePolicy::Quiet) .fan_curve_data(PlatformProfile::Quiet)
.await .await
.map_err(|e| error!("{e:}")) .map_err(|e| error!("{e:}"))
else { else {
@@ -199,6 +199,6 @@ fn fan_data_for(fan: FanType, enabled: bool, data: Vec<Node>) -> CurveData {
fan: fan.into(), fan: fan.into(),
pwm, pwm,
temp, temp,
enabled enabled,
} }
} }
+251 -48
View File
@@ -1,26 +1,27 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use concat_idents::concat_idents; use concat_idents::concat_idents;
use log::{debug, error};
use rog_dbus::asus_armoury::AsusArmouryProxy; use rog_dbus::asus_armoury::AsusArmouryProxy;
use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking}; use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking};
use rog_platform::firmware_attributes::FirmwareAttribute; use rog_platform::asus_armoury::FirmwareAttribute;
use rog_platform::platform::Properties; use rog_platform::platform::Properties;
use slint::ComponentHandle; use slint::ComponentHandle;
use super::show_toast; use super::show_toast;
use crate::config::Config; use crate::config::Config;
use crate::zbus_proxies::find_iface_async; use crate::zbus_proxies::find_iface_async;
use crate::{set_ui_props_async, AttrMinMax, MainWindow, SystemPageData}; use crate::{set_ui_callbacks, set_ui_props_async, AttrMinMax, MainWindow, SystemPageData};
const MINMAX: AttrMinMax = AttrMinMax { const MINMAX: AttrMinMax = AttrMinMax {
min: 0, min: 0,
max: 0, max: 0,
val: -1.0 current: -1.0,
}; };
pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) { pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
let conn = zbus::blocking::Connection::system().unwrap(); let conn = zbus::blocking::Connection::system().unwrap();
let platform = PlatformProxyBlocking::new(&conn).unwrap(); let platform = PlatformProxyBlocking::builder(&conn).build().unwrap();
// let armoury_attrs = // let armoury_attrs =
// find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury").unwrap(); // find_iface::<AsusArmouryProxyBlocking>("xyz.ljones.AsusArmoury").unwrap();
@@ -28,23 +29,30 @@ pub fn setup_system_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
ui.global::<SystemPageData>() ui.global::<SystemPageData>()
.set_charge_control_end_threshold(-1.0); .set_charge_control_end_threshold(-1.0);
ui.global::<SystemPageData>() ui.global::<SystemPageData>()
.set_throttle_thermal_policy(-1); .set_charge_control_enabled(false);
ui.global::<SystemPageData>().set_platform_profile(-1);
ui.global::<SystemPageData>().set_panel_overdrive(-1); ui.global::<SystemPageData>().set_panel_overdrive(-1);
ui.global::<SystemPageData>().set_boot_sound(-1); ui.global::<SystemPageData>().set_boot_sound(-1);
ui.global::<SystemPageData>().set_mini_led_mode(-1); ui.global::<SystemPageData>().set_mini_led_mode(-1);
ui.global::<SystemPageData>().set_ppt_pl1_spl(MINMAX); ui.global::<SystemPageData>().set_ppt_pl1_spl(MINMAX);
ui.global::<SystemPageData>().set_ppt_pl2_sppt(MINMAX); ui.global::<SystemPageData>().set_ppt_pl2_sppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_pl3_fppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_fppt(MINMAX); ui.global::<SystemPageData>().set_ppt_fppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_apu_sppt(MINMAX); ui.global::<SystemPageData>().set_ppt_apu_sppt(MINMAX);
ui.global::<SystemPageData>().set_ppt_platform_sppt(MINMAX); ui.global::<SystemPageData>().set_ppt_platform_sppt(MINMAX);
ui.global::<SystemPageData>().set_nv_dynamic_boost(MINMAX); ui.global::<SystemPageData>().set_nv_dynamic_boost(MINMAX);
ui.global::<SystemPageData>().set_nv_temp_target(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(); 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) { if sys_props.contains(&Properties::ChargeControlEndThreshold) {
ui.global::<SystemPageData>() ui.global::<SystemPageData>()
.set_charge_control_end_threshold(60.0); .set_charge_control_end_threshold(60.0);
ui.global::<SystemPageData>()
.set_charge_control_enabled(true);
} }
} }
@@ -92,13 +100,13 @@ macro_rules! init_minmax_property {
tokio::spawn(async move { tokio::spawn(async move {
let min = proxy_copy.min_value().await.unwrap(); let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap(); let max = proxy_copy.max_value().await.unwrap();
let val = proxy_copy.current_value().await.unwrap() as f32; let current = proxy_copy.current_value().await.unwrap() as f32;
handle_copy handle_copy
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
concat_idents!(setter = set_, $property { concat_idents!(setter = set_, $property {
handle handle
.global::<SystemPageData>() .global::<SystemPageData>()
.setter(AttrMinMax { min, max, val }); .setter(AttrMinMax { min, max, current });
}); });
}) })
.ok(); .ok();
@@ -130,6 +138,23 @@ macro_rules! setup_callback {
}; };
} }
// For handling callbacks from UI value changes
macro_rules! setup_callback_restore_default {
($property:ident, $handle:expr, $attr:expr) => {
let proxy_copy = $attr.clone();
concat_idents!(on_callback = on_cb_default_, $property {
$handle
.global::<SystemPageData>()
.on_callback(move || {
let proxy_copy = proxy_copy.clone();
tokio::spawn(async move {
proxy_copy.restore_default().await.ok();
});
});
});
};
}
macro_rules! setup_external { macro_rules! setup_external {
($property:ident, $type:tt, $handle:expr, $attr:expr, $value:expr) => {{ ($property:ident, $type:tt, $handle:expr, $attr:expr, $value:expr) => {{
// EXTERNAL CHANGES // EXTERNAL CHANGES
@@ -138,10 +163,9 @@ macro_rules! setup_external {
concat_idents!(setter = set_, $property { concat_idents!(setter = set_, $property {
tokio::spawn(async move { tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await; 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 { while let Some(e) = x.next().await {
if let Ok(out) = e.get().await { if let Ok(out) = e.get().await {
dbg!(out);
handle_copy handle_copy
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
handle handle
@@ -157,27 +181,62 @@ macro_rules! setup_external {
} }
// For handling external value changes // For handling external value changes
macro_rules! setup_minmax_external { macro_rules! setup_value_watch {
($property:ident, $handle:expr, $attr:expr) => { ($property:ident, $handle:expr, $proxy:expr, $value_type:ident $($conv: tt)*) => {
let handle_copy = $handle.as_weak(); let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone(); let proxy_copy = $proxy.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut x = proxy_copy.receive_current_value_changed().await; let mut x = concat_idents!(recv = receive_, $value_type, _value_changed {
use zbus::export::futures_util::StreamExt; proxy_copy.recv().await
});
use futures_util::StreamExt;
while let Some(e) = x.next().await { while let Some(e) = x.next().await {
if let Ok(out) = e.get().await { if let Ok(out) = e.get().await {
concat_idents!(getter = get_, $property { concat_idents!(getter = get_, $property {
handle_copy
.upgrade_in_event_loop(move |handle| {
let mut tmp: AttrMinMax =
handle.global::<SystemPageData>().getter();
tmp.$value_type = out $($conv)*;
concat_idents!(setter = set_, $property {
handle.global::<SystemPageData>().setter(tmp);
});
})
.ok();
});
}
}
});
};
}
macro_rules! setup_minmax_external {
($property:ident, $handle:expr, $attr:expr, $platform:expr) => {
setup_value_watch!($property, $handle, $attr, current as f32);
setup_value_watch!($property, $handle, $attr, min);
setup_value_watch!($property, $handle, $attr, max);
let handle_copy = $handle.as_weak();
let proxy_copy = $attr.clone();
let platform_proxy_copy = $platform.clone();
tokio::spawn(async move {
let mut x = platform_proxy_copy.receive_platform_profile_changed().await;
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));
let min = proxy_copy.min_value().await.unwrap();
let max = proxy_copy.max_value().await.unwrap();
let current = proxy_copy.current_value().await.unwrap() as f32;
handle_copy handle_copy
.upgrade_in_event_loop(move |handle| { .upgrade_in_event_loop(move |handle| {
let mut tmp: AttrMinMax =
handle.global::<SystemPageData>().getter();
tmp.val = out as f32;
concat_idents!(setter = set_, $property { concat_idents!(setter = set_, $property {
handle.global::<SystemPageData>().setter(tmp); handle
.global::<SystemPageData>()
.setter(AttrMinMax { min, max, current });
}); });
}) })
.ok(); .ok();
});
} }
} }
}); });
@@ -207,10 +266,7 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
tokio::spawn(async move { tokio::spawn(async move {
// Create the connections/proxies here to prevent future delays in process // Create the connections/proxies here to prevent future delays in process
let conn = zbus::Connection::system().await.unwrap(); let conn = zbus::Connection::system().await.unwrap();
let platform = PlatformProxy::new(&conn).await.unwrap(); let platform = PlatformProxy::builder(&conn).build().await.unwrap();
let armoury_attrs = find_iface_async::<AsusArmouryProxy>("xyz.ljones.AsusArmoury")
.await
.unwrap();
set_ui_props_async!( set_ui_props_async!(
handle, handle,
@@ -218,69 +274,216 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
SystemPageData, SystemPageData,
charge_control_end_threshold charge_control_end_threshold
); );
set_ui_props_async!(handle, platform, SystemPageData, throttle_thermal_policy);
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_linked_epp); set_ui_props_async!(handle, platform, SystemPageData, platform_profile);
set_ui_props_async!(handle, platform, SystemPageData, throttle_balanced_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_performance_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_quiet_epp);
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_battery);
set_ui_props_async!( set_ui_props_async!(
handle, handle,
platform, platform,
SystemPageData, SystemPageData,
change_throttle_policy_on_battery platform_profile_linked_epp
); );
set_ui_props_async!(handle, platform, SystemPageData, throttle_policy_on_ac); set_ui_props_async!(handle, platform, SystemPageData, profile_balanced_epp);
set_ui_props_async!(handle, platform, SystemPageData, profile_performance_epp);
set_ui_props_async!(handle, platform, SystemPageData, profile_quiet_epp);
set_ui_props_async!( set_ui_props_async!(
handle, handle,
platform, platform,
SystemPageData, SystemPageData,
change_throttle_policy_on_ac platform_profile_on_battery
); );
set_ui_props_async!(
handle,
platform,
SystemPageData,
change_platform_profile_on_battery
);
set_ui_props_async!(handle, platform, SystemPageData, platform_profile_on_ac);
set_ui_props_async!(
handle,
platform,
SystemPageData,
change_platform_profile_on_ac
);
set_ui_props_async!(handle, platform, SystemPageData, enable_ppt_group);
let platform_copy = platform.clone();
handle
.upgrade_in_event_loop(move |handle| {
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform_copy.enable_ppt_group(as bool),
"Applied PPT group settings {}",
"Setting PPT group settings failed"
);
set_ui_callbacks!(handle,
SystemPageData(as f32),
platform_copy.charge_control_end_threshold(as u8),
"Charge limit successfully set to {}",
"Setting Charge limit failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform_copy.platform_profile(.into()),
"Throttle policy set to {}",
"Setting Throttle policy failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform_copy.profile_balanced_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform_copy.profile_performance_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform_copy.profile_quiet_epp(.into()),
"Throttle policy EPP set to {}",
"Setting Throttle policy EPP failed"
);
set_ui_callbacks!(
handle,
SystemPageData(),
platform_copy.platform_profile_linked_epp(),
"Throttle policy linked to EPP: {}",
"Setting Throttle policy linked to EPP failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform_copy.platform_profile_on_ac(.into()),
"Throttle policy on AC set to {}",
"Setting Throttle policy on AC failed"
);
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform_copy.change_platform_profile_on_ac(.into()),
"Throttle policy on AC enabled: {}",
"Setting Throttle policy on AC failed"
);
set_ui_callbacks!(handle,
SystemPageData(as i32),
platform_copy.platform_profile_on_battery(.into()),
"Throttle policy on abttery set to {}",
"Setting Throttle policy on battery failed"
);
set_ui_callbacks!(handle,
SystemPageData(as bool),
platform_copy.change_platform_profile_on_battery(.into()),
"Throttle policy on battery enabled: {}",
"Setting Throttle policy on AC failed"
);
})
.ok();
let armoury_attrs;
if let Ok(attrs) = find_iface_async::<AsusArmouryProxy>("xyz.ljones.AsusArmoury").await {
armoury_attrs = attrs;
handle
.upgrade_in_event_loop(|ui| {
ui.global::<SystemPageData>().set_asus_armoury_loaded(true)
})
.ok();
} else {
error!(
"The kernel module asus-armoury is required, if you do not have this you will \
need to either build or install a kernel which includes the patchwork. This \
driver is in process of being upstreamed"
);
return;
}
for attr in armoury_attrs { for attr in armoury_attrs {
if let Ok(value) = attr.current_value().await { if let Ok(value) = attr.current_value().await {
let name = attr.name().await.unwrap(); let name = attr.name().await.unwrap();
let platform = platform.clone();
handle handle
.upgrade_in_event_loop(move |handle| match name { .upgrade_in_event_loop(move |handle| match name {
FirmwareAttribute::ApuMem => {} FirmwareAttribute::ApuMem => {}
FirmwareAttribute::CoresPerformance => {} FirmwareAttribute::CoresPerformance => {}
FirmwareAttribute::CoresEfficiency => {} 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 => { FirmwareAttribute::PptPl1Spl => {
init_minmax_property!(ppt_pl1_spl, handle, attr); init_minmax_property!(ppt_pl1_spl, handle, attr);
setup_callback!(ppt_pl1_spl, handle, attr, i32); setup_callback!(ppt_pl1_spl, handle, attr, i32);
setup_minmax_external!(ppt_pl1_spl, handle, attr); setup_callback_restore_default!(ppt_pl1_spl, handle, attr);
setup_minmax_external!(ppt_pl1_spl, handle, attr, platform);
} }
FirmwareAttribute::PptPl2Sppt => { FirmwareAttribute::PptPl2Sppt => {
init_minmax_property!(ppt_pl2_sppt, handle, attr); init_minmax_property!(ppt_pl2_sppt, handle, attr);
setup_callback!(ppt_pl2_sppt, handle, attr, i32); setup_callback!(ppt_pl2_sppt, handle, attr, i32);
setup_minmax_external!(ppt_pl2_sppt, handle, attr); setup_callback_restore_default!(ppt_pl2_sppt, handle, attr);
setup_minmax_external!(ppt_pl2_sppt, handle, attr, platform);
} }
FirmwareAttribute::PptApuSppt => { FirmwareAttribute::PptPl3Fppt => {
init_minmax_property!(ppt_apu_sppt, handle, attr); init_minmax_property!(ppt_pl3_fppt, handle, attr);
setup_callback!(ppt_apu_sppt, handle, attr, i32); setup_callback!(ppt_pl3_fppt, handle, attr, i32);
setup_minmax_external!(ppt_apu_sppt, handle, attr); setup_callback_restore_default!(ppt_pl3_fppt, handle, attr);
} setup_minmax_external!(ppt_pl3_fppt, handle, attr, platform);
FirmwareAttribute::PptPlatformSppt => {
init_minmax_property!(ppt_platform_sppt, handle, attr);
setup_callback!(ppt_platform_sppt, handle, attr, i32);
setup_minmax_external!(ppt_platform_sppt, handle, attr);
} }
FirmwareAttribute::PptFppt => { FirmwareAttribute::PptFppt => {
init_minmax_property!(ppt_fppt, handle, attr); init_minmax_property!(ppt_fppt, handle, attr);
setup_callback!(ppt_fppt, handle, attr, i32); setup_callback!(ppt_fppt, handle, attr, i32);
setup_minmax_external!(ppt_fppt, handle, attr); setup_callback_restore_default!(ppt_fppt, handle, attr);
setup_minmax_external!(ppt_fppt, handle, attr, platform);
}
FirmwareAttribute::PptApuSppt => {
init_minmax_property!(ppt_apu_sppt, handle, attr);
setup_callback!(ppt_apu_sppt, handle, attr, i32);
setup_callback_restore_default!(ppt_apu_sppt, handle, attr);
setup_minmax_external!(ppt_apu_sppt, handle, attr, platform);
}
FirmwareAttribute::PptPlatformSppt => {
init_minmax_property!(ppt_platform_sppt, handle, attr);
setup_callback!(ppt_platform_sppt, handle, attr, i32);
setup_callback_restore_default!(ppt_platform_sppt, handle, attr);
setup_minmax_external!(ppt_platform_sppt, handle, attr, platform);
} }
FirmwareAttribute::NvDynamicBoost => { FirmwareAttribute::NvDynamicBoost => {
init_minmax_property!(nv_dynamic_boost, handle, attr); init_minmax_property!(nv_dynamic_boost, handle, attr);
setup_callback!(nv_dynamic_boost, handle, attr, i32); setup_callback!(nv_dynamic_boost, handle, attr, i32);
setup_minmax_external!(nv_dynamic_boost, handle, attr); setup_callback_restore_default!(nv_dynamic_boost, handle, attr);
setup_minmax_external!(nv_dynamic_boost, handle, attr, platform);
} }
FirmwareAttribute::NvTempTarget => { FirmwareAttribute::NvTempTarget => {
init_minmax_property!(nv_temp_target, handle, attr); init_minmax_property!(nv_temp_target, handle, attr);
setup_callback!(nv_temp_target, handle, attr, i32); setup_callback!(nv_temp_target, handle, attr, i32);
setup_minmax_external!(nv_temp_target, handle, attr); setup_callback_restore_default!(nv_temp_target, handle, attr);
setup_minmax_external!(nv_temp_target, handle, attr, platform);
} }
FirmwareAttribute::DgpuBaseTgp => {} FirmwareAttribute::DgpuBaseTgp => {}
FirmwareAttribute::DgpuTgp => {} FirmwareAttribute::DgpuTgp => {}
@@ -304,7 +507,7 @@ pub fn setup_system_page_callbacks(ui: &MainWindow, _states: Arc<Mutex<Config>>)
FirmwareAttribute::MiniLedMode => { FirmwareAttribute::MiniLedMode => {
init_property!(mini_led_mode, handle, value, i32); init_property!(mini_led_mode, handle, value, i32);
setup_callback!(mini_led_mode, handle, attr, i32); setup_callback!(mini_led_mode, handle, attr, i32);
setup_external!(mini_led_mode, i32, handle, attr, value) setup_external!(mini_led_mode, i32, handle, attr, value);
} }
FirmwareAttribute::PendingReboot => {} FirmwareAttribute::PendingReboot => {}
FirmwareAttribute::None => {} FirmwareAttribute::None => {}
+8 -8
View File
@@ -14,18 +14,18 @@ pub enum AppState {
MainWindowClosed = 2, MainWindowClosed = 2,
StartingUp = 3, StartingUp = 3,
QuitApp = 4, QuitApp = 4,
LockFailed = 5 LockFailed = 5,
} }
pub struct ROGCCZbus { pub struct ROGCCZbus {
state: Arc<Mutex<AppState>> state: Arc<Mutex<AppState>>,
} }
impl ROGCCZbus { impl ROGCCZbus {
#[allow(clippy::new_without_default)] #[allow(clippy::new_without_default)]
pub fn new() -> Self { pub fn new() -> Self {
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>> pub fn find_iface<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where where
T: ProxyImpl<'static> + From<zbus::Proxy<'static>> T: ProxyImpl<'static> + From<zbus::Proxy<'static>>,
{ {
let conn = Connection::system().unwrap(); let conn = Connection::system().unwrap();
let f = fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap(); let f = fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
@@ -99,7 +99,7 @@ where
T::builder(&conn) T::builder(&conn)
.path(path.clone())? .path(path.clone())?
.destination("xyz.ljones.Asusd")? .destination("xyz.ljones.Asusd")?
.build()? .build()?,
); );
} }
return Ok(ctrl); 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>> pub async fn find_iface_async<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
where 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 conn = zbus::Connection::system().await.unwrap();
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/") let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/")
@@ -140,11 +140,11 @@ where
.path(path.clone())? .path(path.clone())?
.destination("xyz.ljones.Asusd")? .destination("xyz.ljones.Asusd")?
.build() .build()
.await? .await?,
); );
} }
return Ok(ctrl); return Ok(ctrl);
} }
Err("No Aura interface".into()) Err("No interface".into())
} }
@@ -2,7 +2,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2025-01-12 04:36+0000\n" "POT-Creation-Date: 2025-02-15 22:50+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -12,157 +12,238 @@ msgstr ""
"Language: \n" "Language: \n"
"Plural-Forms: nplurals=1; plural=0;\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" msgctxt "SystemPageData"
msgid "Balanced" msgid "Balanced"
msgstr "" 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" msgctxt "SystemPageData"
msgid "Performance" msgid "Performance"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:19 #: rog-control-center/ui/pages/system.slint:20
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Quiet" msgid "Quiet"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:22 #: rog-control-center/ui/pages/system.slint:23
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Default" msgid "Default"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:24 #: rog-control-center/ui/pages/system.slint:25
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "BalancePerformance" msgid "BalancePerformance"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:25 #: rog-control-center/ui/pages/system.slint:26
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "BalancePower" msgid "BalancePower"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:26 #: rog-control-center/ui/pages/system.slint:27
msgctxt "SystemPageData" msgctxt "SystemPageData"
msgid "Power" msgid "Power"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:122 #: rog-control-center/ui/pages/system.slint:147
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Power settings" msgid "Power settings"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:127 #: rog-control-center/ui/pages/system.slint:152
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Charge limit" msgid "Charge limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:139 #: rog-control-center/ui/pages/system.slint:167
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy" msgid "Platform Profile"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:149 #: rog-control-center/ui/pages/system.slint:177
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Advanced" msgid "Advanced"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:167 #: rog-control-center/ui/pages/system.slint:195
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Armoury settings" msgid "Armoury settings"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:175 #: 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: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:222
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Panel Overdrive" msgid "Panel Overdrive"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:183 #: rog-control-center/ui/pages/system.slint:230
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "MiniLED Mode" msgid "MiniLED Mode"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:191 #: rog-control-center/ui/pages/system.slint:238
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "POST boot sound" msgid "POST boot sound"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:200 #: 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:259 rog-control-center/ui/pages/system.slint:266
msgctxt "ppt_group_enabled"
msgid "Enable Tuning"
msgstr ""
#: rog-control-center/ui/pages/system.slint:277 rog-control-center/ui/pages/system.slint:278
msgctxt "ppt_pl1_spl" msgctxt "ppt_pl1_spl"
msgid "PL1, sustained power limit" msgid "CPU Sustained Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:211 #: 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:295 rog-control-center/ui/pages/system.slint:296
msgctxt "ppt_pl2_sppt" msgctxt "ppt_pl2_sppt"
msgid "PL2, turbo power limit" msgid "CPU Turbo Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:222 #: 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: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: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:330 rog-control-center/ui/pages/system.slint:331
msgctxt "ppt_fppt" msgctxt "ppt_fppt"
msgid "FPPT, Fast Power Limit" msgid "Fast Package Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:233 #: 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:348 rog-control-center/ui/pages/system.slint:349
msgctxt "ppt_apu_sppt" msgctxt "ppt_apu_sppt"
msgid "SPPT, APU slow power limit" msgid "APU Sustained Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:244 #: 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:366 rog-control-center/ui/pages/system.slint:367
msgctxt "ppt_platform_sppt" msgctxt "ppt_platform_sppt"
msgid "Slow package power tracking limit" msgid "Platform Sustained Power Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:255 #: 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:384 rog-control-center/ui/pages/system.slint:385
msgctxt "nv_dynamic_boost" msgctxt "nv_dynamic_boost"
msgid "dGPU boost overclock" msgid "GPU Power Boost"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:266 #: 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:402 rog-control-center/ui/pages/system.slint:403
msgctxt "nv_temp_target" msgctxt "nv_temp_target"
msgid "dGPU temperature max" msgid "GPU Temperature Limit"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:313 #: 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:456
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Energy Performance Preference linked to Throttle Policy" msgid "Energy Performance Preference linked to Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:317 #: rog-control-center/ui/pages/system.slint:460
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Change EPP based on Throttle Policy" msgid "Change EPP based on Throttle Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:325 #: rog-control-center/ui/pages/system.slint:468
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Balanced Policy" msgid "EPP for Balanced Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:335 #: rog-control-center/ui/pages/system.slint:478
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Performance Policy" msgid "EPP for Performance Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:345 #: rog-control-center/ui/pages/system.slint:488
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "EPP for Quiet Policy" msgid "EPP for Quiet Policy"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:363 #: rog-control-center/ui/pages/system.slint:506
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy for power state" msgid "Throttle Policy for power state"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:369 #: rog-control-center/ui/pages/system.slint:512
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy on Battery" msgid "Throttle Policy on Battery"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:379 rog-control-center/ui/pages/system.slint:400 #: rog-control-center/ui/pages/system.slint:522 rog-control-center/ui/pages/system.slint:543
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Enabled" msgid "Enabled"
msgstr "" msgstr ""
#: rog-control-center/ui/pages/system.slint:390 #: rog-control-center/ui/pages/system.slint:533
msgctxt "PageSystem" msgctxt "PageSystem"
msgid "Throttle Policy on AC" msgid "Throttle Policy on AC"
msgstr "" msgstr ""
@@ -647,42 +728,47 @@ msgctxt "AuraPowerGroupOld"
msgid "Sleep" msgid "Sleep"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:51 #: rog-control-center/ui/widgets/common.slint:136
msgctxt "confirm_reset"
msgid "Are you sure you want to reset this?"
msgstr ""
#: rog-control-center/ui/main_window.slint:55
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "ROG" msgid "ROG"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:53 #: rog-control-center/ui/main_window.slint:57
msgctxt "Menu1" msgctxt "Menu1"
msgid "System Control" msgid "System Control"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:54 #: rog-control-center/ui/main_window.slint:58
msgctxt "Menu2" msgctxt "Menu2"
msgid "Keyboard Aura" msgid "Keyboard Aura"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:55 #: rog-control-center/ui/main_window.slint:59
msgctxt "Menu3" msgctxt "Menu3"
msgid "AniMe Matrix" msgid "AniMe Matrix"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:56 #: rog-control-center/ui/main_window.slint:60
msgctxt "Menu4" msgctxt "Menu4"
msgid "Fan Curves" msgid "Fan Curves"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:57 #: rog-control-center/ui/main_window.slint:61
msgctxt "Menu5" msgctxt "Menu5"
msgid "App Settings" msgid "App Settings"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:58 #: rog-control-center/ui/main_window.slint:62
msgctxt "Menu6" msgctxt "Menu6"
msgid "About" msgid "About"
msgstr "" msgstr ""
#: rog-control-center/ui/main_window.slint:70 #: rog-control-center/ui/main_window.slint:74
msgctxt "MainWindow" msgctxt "MainWindow"
msgid "Quit App" msgid "Quit App"
msgstr "" msgstr ""
+17 -13
View File
@@ -19,10 +19,14 @@ export { AppSize, AttrMinMax, SystemPageData, AnimePageData, AppSettingsPageData
export component MainWindow inherits Window { export component MainWindow inherits Window {
title: "ROG Control"; title: "ROG Control";
default-font-family: "DejaVu Sans"; always-on-top: true;
default-font-family: "Noto Sans";
default-font-size: 14px;
default-font-weight: 400;
icon: @image-url("../data/rog-control-center.png");
in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true]; in property <[bool]> sidebar_items_avilable: [true, true, true, true, true, true];
private property <bool> show-notif; private property <bool> show_notif;
private property <bool> fade-cover; private property <bool> fade_cover;
private property <bool> toast: false; private property <bool> toast: false;
private property <string> toast_text: "I show when something is waiting"; private property <string> toast_text: "I show when something is waiting";
callback show_toast(string); callback show_toast(string);
@@ -31,10 +35,10 @@ export component MainWindow inherits Window {
toast_text = text; toast_text = text;
} }
callback exit-app(); callback exit-app();
callback show-notification(bool); callback show_notification(bool);
show-notification(yes) => { show_notification(yes) => {
show-notif = yes; show_notif = yes;
fade-cover = yes; fade_cover = yes;
} }
callback external_colour_change(); callback external_colour_change();
external_colour_change() => { external_colour_change() => {
@@ -109,7 +113,7 @@ export component MainWindow inherits Window {
} }
} }
if fade-cover: Rectangle { if fade_cover: Rectangle {
x: 0px; x: 0px;
y: 0px; y: 0px;
width: root.width; width: root.width;
@@ -121,10 +125,10 @@ export component MainWindow inherits Window {
width: 100%; width: 100%;
clicked => { clicked => {
// toolbar-dropdown.close(); // toolbar-dropdown.close();
if (show-notif) { if (show_notif) {
show-notif = false; show_notif = false;
} }
fade-cover = false; fade_cover = false;
} }
} }
} }
@@ -156,7 +160,7 @@ export component MainWindow inherits Window {
} }
// // TODO: or use Dialogue // // TODO: or use Dialogue
if show-notif: Rectangle { if show_notif: Rectangle {
x: root.width / 8; x: root.width / 8;
y: root.height / 8; y: root.height / 8;
height: (root.height / 8) * 6; height: (root.height / 8) * 6;
@@ -165,7 +169,7 @@ export component MainWindow inherits Window {
height: 100%; height: 100%;
width: 100%; width: 100%;
clicked => { clicked => {
show-notif = false; show_notif = false;
exit-app(); exit-app();
} }
} }
+8 -16
View File
@@ -17,7 +17,7 @@ export component PageAbout inherits VerticalLayout {
Text { Text {
wrap: TextWrap.word-wrap; wrap: TextWrap.word-wrap;
text: "You will require these patches: https://lore.kernel.org/platform-driver-x86/20240404001652.86207-1-luke@ljones.dev/, they have been merged upstream for kernel 6.10. The main thing is that the PPT settings will apply without them, but the read/back will fail"; text: "You will require a kernel built with my work from here: https://github.com/flukejones/linux";
} }
Text { Text {
@@ -28,19 +28,7 @@ export component PageAbout inherits VerticalLayout {
} }
Text { Text {
text: "- [x] Theme the widgets"; text: "- [ ] Theme the widgets";
}
Text {
text: "- [x] Add a fullscreen mode (cli arg)";
}
Text {
text: "- [x] Disable aura items depending if mode supports or not";
}
Text {
text: "- [x] Add fan curve graph controls";
} }
Text { Text {
@@ -48,11 +36,15 @@ export component PageAbout inherits VerticalLayout {
} }
Text { Text {
text: "- [ ] Supergfx control"; text: "- [ ] Include fan speeds, temps in a bottom bar";
} }
Text { Text {
text: "- [ ] Include fan speeds, temps in a bottom bar"; text: "- [ ] Slash control";
}
Text {
text: "- [ ] Supergfx control";
} }
Text { Text {
+17 -17
View File
@@ -9,17 +9,17 @@ export global AnimePageData {
@tr("Anime Brightness" => "High"), @tr("Anime Brightness" => "High"),
]; ];
in-out property <int> brightness; in-out property <int> brightness;
callback set_brightness(int); callback cb_brightness(int);
in-out property <bool> builtins_enabled; in-out property <bool> builtins_enabled;
callback set_builtins_enabled(bool); callback cb_builtins_enabled(bool);
in-out property <bool> enable_display; in-out property <bool> enable_display;
callback set_enable_display(bool); callback cb_enable_display(bool);
in-out property <bool> off_when_lid_closed; in-out property <bool> off_when_lid_closed;
callback set_off_when_lid_closed(bool); callback cb_off_when_lid_closed(bool);
in-out property <bool> off_when_suspended; in-out property <bool> off_when_suspended;
callback set_off_when_suspended(bool); callback cb_off_when_suspended(bool);
in-out property <bool> off_when_unplugged; in-out property <bool> off_when_unplugged;
callback set_off_when_unplugged(bool); callback cb_off_when_unplugged(bool);
in-out property <[string]> boot_anim_choices: [@tr("Glitch Construction"), @tr("Static Emergence")]; in-out property <[string]> boot_anim_choices: [@tr("Glitch Construction"), @tr("Static Emergence")];
in property <int> boot_anim: 0; in property <int> boot_anim: 0;
in-out property <[string]> awake_anim_choices: [@tr("Binary Banner Scroll"), @tr("Rog Logo Glitch")]; in-out property <[string]> awake_anim_choices: [@tr("Binary Banner Scroll"), @tr("Rog Logo Glitch")];
@@ -28,7 +28,7 @@ export global AnimePageData {
in property <int> sleep_anim: 0; in property <int> sleep_anim: 0;
in-out property <[string]> shutdown_anim_choices: [@tr("Glitch Out"), @tr("See Ya")]; in-out property <[string]> shutdown_anim_choices: [@tr("Glitch Out"), @tr("See Ya")];
in property <int> shutdown_anim: 0; in property <int> shutdown_anim: 0;
callback set_builtin_animations(int, int, int, int); callback cb_builtin_animations(int, int, int, int);
} }
export component PageAnime inherits Rectangle { export component PageAnime inherits Rectangle {
@@ -53,7 +53,7 @@ export component PageAnime inherits Rectangle {
model <=> AnimePageData.brightness_names; model <=> AnimePageData.brightness_names;
selected => { selected => {
self.current_value = AnimePageData.brightness_names[AnimePageData.brightness]; self.current_value = AnimePageData.brightness_names[AnimePageData.brightness];
AnimePageData.set_brightness(AnimePageData.brightness) AnimePageData.cb_brightness(AnimePageData.brightness)
} }
} }
} }
@@ -66,7 +66,7 @@ export component PageAnime inherits Rectangle {
text: @tr("Enable display"); text: @tr("Enable display");
checked <=> AnimePageData.enable_display; checked <=> AnimePageData.enable_display;
toggled => { toggled => {
AnimePageData.set_enable_display(AnimePageData.enable_display) AnimePageData.cb_enable_display(AnimePageData.enable_display)
} }
} }
@@ -89,7 +89,7 @@ export component PageAnime inherits Rectangle {
text: @tr("Use built-in animations"); text: @tr("Use built-in animations");
checked <=> AnimePageData.builtins_enabled; checked <=> AnimePageData.builtins_enabled;
toggled => { toggled => {
AnimePageData.set_builtins_enabled(AnimePageData.builtins_enabled) AnimePageData.cb_builtins_enabled(AnimePageData.builtins_enabled)
} }
} }
@@ -152,7 +152,7 @@ export component PageAnime inherits Rectangle {
current_value: AnimePageData.boot_anim_choices[AnimePageData.boot_anim]; current_value: AnimePageData.boot_anim_choices[AnimePageData.boot_anim];
model <=> AnimePageData.boot_anim_choices; model <=> AnimePageData.boot_anim_choices;
selected => { selected => {
AnimePageData.set_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim) AnimePageData.cb_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim)
} }
} }
@@ -162,7 +162,7 @@ export component PageAnime inherits Rectangle {
current_value: AnimePageData.awake_anim_choices[AnimePageData.awake_anim]; current_value: AnimePageData.awake_anim_choices[AnimePageData.awake_anim];
model <=> AnimePageData.awake_anim_choices; model <=> AnimePageData.awake_anim_choices;
selected => { selected => {
AnimePageData.set_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim) AnimePageData.cb_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim)
} }
} }
@@ -172,7 +172,7 @@ export component PageAnime inherits Rectangle {
current_value: AnimePageData.sleep_anim_choices[AnimePageData.sleep_anim]; current_value: AnimePageData.sleep_anim_choices[AnimePageData.sleep_anim];
model <=> AnimePageData.sleep_anim_choices; model <=> AnimePageData.sleep_anim_choices;
selected => { selected => {
AnimePageData.set_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim) AnimePageData.cb_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim)
} }
} }
@@ -182,7 +182,7 @@ export component PageAnime inherits Rectangle {
current_value: AnimePageData.shutdown_anim_choices[AnimePageData.shutdown_anim]; current_value: AnimePageData.shutdown_anim_choices[AnimePageData.shutdown_anim];
model <=> AnimePageData.shutdown_anim_choices; model <=> AnimePageData.shutdown_anim_choices;
selected => { selected => {
AnimePageData.set_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim) AnimePageData.cb_builtin_animations(AnimePageData.boot_anim, AnimePageData.awake_anim, AnimePageData.sleep_anim, AnimePageData.shutdown_anim)
} }
} }
} }
@@ -225,7 +225,7 @@ export component PageAnime inherits Rectangle {
text: @tr("Off when lid closed"); text: @tr("Off when lid closed");
checked <=> AnimePageData.off_when_lid_closed; checked <=> AnimePageData.off_when_lid_closed;
toggled => { toggled => {
AnimePageData.set_off_when_lid_closed(AnimePageData.off_when_lid_closed) AnimePageData.cb_off_when_lid_closed(AnimePageData.off_when_lid_closed)
} }
} }
@@ -234,7 +234,7 @@ export component PageAnime inherits Rectangle {
text: @tr("Off when suspended"); text: @tr("Off when suspended");
checked <=> AnimePageData.off_when_suspended; checked <=> AnimePageData.off_when_suspended;
toggled => { toggled => {
AnimePageData.set_off_when_suspended(AnimePageData.off_when_suspended) AnimePageData.cb_off_when_suspended(AnimePageData.off_when_suspended)
} }
} }
@@ -243,7 +243,7 @@ export component PageAnime inherits Rectangle {
text: @tr("Off when on battery"); text: @tr("Off when on battery");
checked <=> AnimePageData.off_when_unplugged; checked <=> AnimePageData.off_when_unplugged;
toggled => { toggled => {
AnimePageData.set_off_when_unplugged(AnimePageData.off_when_unplugged) AnimePageData.cb_off_when_unplugged(AnimePageData.off_when_unplugged)
} }
} }
} }
+19 -19
View File
@@ -30,7 +30,7 @@ export component PageAura inherits Rectangle {
current_value: AuraPageData.brightness_names[self.current-index]; current_value: AuraPageData.brightness_names[self.current-index];
model <=> AuraPageData.brightness_names; model <=> AuraPageData.brightness_names;
selected => { selected => {
AuraPageData.set_brightness(AuraPageData.brightness) AuraPageData.cb_brightness(AuraPageData.brightness)
} }
} }
@@ -44,7 +44,7 @@ export component PageAura inherits Rectangle {
AuraPageData.led_mode_data.mode = AuraPageData.led_mode; AuraPageData.led_mode_data.mode = AuraPageData.led_mode;
AuraPageData.led_mode_data.mode = AuraPageData.current_available_mode; AuraPageData.led_mode_data.mode = AuraPageData.current_available_mode;
self.current_value = AuraPageData.available_mode_names[self.current-index]; self.current_value = AuraPageData.available_mode_names[self.current-index];
AuraPageData.set_led_mode(AuraPageData.current_available_mode); AuraPageData.cb_led_mode(AuraPageData.current_available_mode);
} }
} }
} }
@@ -67,14 +67,14 @@ export component PageAura inherits Rectangle {
final_colour <=> AuraPageData.color1; final_colour <=> AuraPageData.color1;
colourbox <=> AuraPageData.colorbox1; colourbox <=> AuraPageData.colorbox1;
set_hex_from_colour(c1) => { set_hex_from_colour(c1) => {
return AuraPageData.set_hex_from_colour(c1); return AuraPageData.cb_hex_from_colour(c1);
} }
hex_to_colour(s) => { hex_to_colour(s) => {
return AuraPageData.set_hex_to_colour(s); return AuraPageData.cb_hex_to_colour(s);
} }
released => { released => {
AuraPageData.led_mode_data.colour1 = AuraPageData.color1; AuraPageData.led_mode_data.colour1 = AuraPageData.color1;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data); AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -93,14 +93,14 @@ export component PageAura inherits Rectangle {
final_colour <=> AuraPageData.color2; final_colour <=> AuraPageData.color2;
colourbox <=> AuraPageData.colorbox2; colourbox <=> AuraPageData.colorbox2;
set_hex_from_colour(c1) => { set_hex_from_colour(c1) => {
return AuraPageData.set_hex_from_colour(c1); return AuraPageData.cb_hex_from_colour(c1);
} }
hex_to_colour(s) => { hex_to_colour(s) => {
return AuraPageData.set_hex_to_colour(s); return AuraPageData.cb_hex_to_colour(s);
} }
released => { released => {
AuraPageData.led_mode_data.colour2 = AuraPageData.color2; AuraPageData.led_mode_data.colour2 = AuraPageData.color2;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data); AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -129,7 +129,7 @@ export component PageAura inherits Rectangle {
model <=> AuraPageData.zone_names; model <=> AuraPageData.zone_names;
selected => { selected => {
AuraPageData.led_mode_data.zone = self.current-index; AuraPageData.led_mode_data.zone = self.current-index;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data); AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -151,7 +151,7 @@ export component PageAura inherits Rectangle {
model <=> AuraPageData.direction_names; model <=> AuraPageData.direction_names;
selected => { selected => {
AuraPageData.led_mode_data.direction = self.current-index; AuraPageData.led_mode_data.direction = self.current-index;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data); AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -173,7 +173,7 @@ export component PageAura inherits Rectangle {
model <=> AuraPageData.speed_names; model <=> AuraPageData.speed_names;
selected => { selected => {
AuraPageData.led_mode_data.speed = self.current-index; AuraPageData.led_mode_data.speed = self.current-index;
AuraPageData.set_led_mode_data(AuraPageData.led_mode_data); AuraPageData.cb_led_mode_data(AuraPageData.led_mode_data);
} }
} }
} }
@@ -218,22 +218,22 @@ export component PageAura inherits Rectangle {
boot_checked: state.boot; boot_checked: state.boot;
boot_toggled => { boot_toggled => {
AuraPageData.led_power.states[idx].boot = zone.boot_checked; AuraPageData.led_power.states[idx].boot = zone.boot_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
awake_checked: state.awake; awake_checked: state.awake;
awake_toggled => { awake_toggled => {
AuraPageData.led_power.states[idx].awake = zone.awake_checked; AuraPageData.led_power.states[idx].awake = zone.awake_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
sleep_checked: state.sleep; sleep_checked: state.sleep;
sleep_toggled => { sleep_toggled => {
AuraPageData.led_power.states[idx].sleep = zone.sleep_checked; AuraPageData.led_power.states[idx].sleep = zone.sleep_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
shutdown_checked: state.shutdown; shutdown_checked: state.shutdown;
shutdown_toggled => { shutdown_toggled => {
AuraPageData.led_power.states[idx].shutdown = zone.shutdown_checked; AuraPageData.led_power.states[idx].shutdown = zone.shutdown_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
} }
} }
@@ -271,22 +271,22 @@ export component PageAura inherits Rectangle {
zone_strings <=> AuraPageData.power_zone_names_old; zone_strings <=> AuraPageData.power_zone_names_old;
selected_zone => { selected_zone => {
AuraPageData.led_power.states[idx].zone = AuraPageData.supported_power_zones[old_zone.current_zone]; AuraPageData.led_power.states[idx].zone = AuraPageData.supported_power_zones[old_zone.current_zone];
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
boot_checked: state.boot; boot_checked: state.boot;
boot_toggled => { boot_toggled => {
AuraPageData.led_power.states[idx].boot = old_zone.boot_checked; AuraPageData.led_power.states[idx].boot = old_zone.boot_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
awake_checked: state.awake; awake_checked: state.awake;
awake_toggled => { awake_toggled => {
AuraPageData.led_power.states[idx].awake = old_zone.awake_checked; AuraPageData.led_power.states[idx].awake = old_zone.awake_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
sleep_checked: state.sleep; sleep_checked: state.sleep;
sleep_toggled => { sleep_toggled => {
AuraPageData.led_power.states[idx].sleep = old_zone.sleep_checked; AuraPageData.led_power.states[idx].sleep = old_zone.sleep_checked;
AuraPageData.set_led_power(AuraPageData.led_power); AuraPageData.cb_led_power(AuraPageData.led_power);
} }
} }
} }
+231 -88
View File
@@ -1,23 +1,24 @@
import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint"; import { SystemSlider, SystemDropdown, SystemToggle, SystemToggleInt } from "../widgets/common.slint";
import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox} from "std-widgets.slint"; import { Palette, HorizontalBox , VerticalBox, ScrollView, Slider, Button, Switch, ComboBox, GroupBox, StandardButton} from "std-widgets.slint";
export struct AttrMinMax { export struct AttrMinMax {
min: int, min: int,
max: int, max: int,
val: float, current: float,
} }
export struct AttrPossible { export struct AttrPossible {
range: [int], range: [int],
val: int, current: int,
} }
export global SystemPageData { export global SystemPageData {
in-out property <bool> charge_control_enabled: true;
in-out property <float> charge_control_end_threshold: 30; in-out property <float> charge_control_end_threshold: 30;
callback cb_charge_control_end_threshold(/* charge limit */ int); callback cb_charge_control_end_threshold(/* charge limit */ int);
in-out property <int> throttle_thermal_policy: 0; in-out property <int> platform_profile: 0;
in-out property <[string]> throttle_policy_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")]; in-out property <[string]> platform_profile_choices: [@tr("Balanced"), @tr("Performance"), @tr("Quiet")];
callback cb_throttle_thermal_policy(int); callback cb_platform_profile(int);
in-out property <[string]> energy_performance_choices: [ in-out property <[string]> energy_performance_choices: [
@tr("Default"), @tr("Default"),
@tr("Performance"), @tr("Performance"),
@@ -25,23 +26,23 @@ export global SystemPageData {
@tr("BalancePower"), @tr("BalancePower"),
@tr("Power") @tr("Power")
]; ];
in-out property <int> throttle_balanced_epp: 0; in-out property <int> profile_balanced_epp: 0;
callback cb_throttle_balanced_epp(int); callback cb_profile_balanced_epp(int);
in-out property <int> throttle_performance_epp: 0; in-out property <int> profile_performance_epp: 0;
callback cb_throttle_performance_epp(int); callback cb_profile_performance_epp(int);
in-out property <int> throttle_quiet_epp: 0; in-out property <int> profile_quiet_epp: 0;
callback cb_throttle_quiet_epp(int); callback cb_profile_quiet_epp(int);
// if the EPP should change with throttle // if the EPP should change with throttle
in-out property <bool> throttle_policy_linked_epp: true; in-out property <bool> platform_profile_linked_epp: true;
callback cb_throttle_policy_linked_epp(bool); callback cb_platform_profile_linked_epp(bool);
in-out property <int> throttle_policy_on_ac: 0; in-out property <int> platform_profile_on_ac: 0;
callback cb_throttle_policy_on_ac(int); callback cb_platform_profile_on_ac(int);
in-out property <bool> change_throttle_policy_on_ac: true; in-out property <bool> change_platform_profile_on_ac: true;
callback cb_change_throttle_policy_on_ac(bool); callback cb_change_platform_profile_on_ac(bool);
in-out property <int> throttle_policy_on_battery: 0; in-out property <int> platform_profile_on_battery: 0;
callback cb_throttle_policy_on_battery(int); callback cb_platform_profile_on_battery(int);
in-out property <bool> change_throttle_policy_on_battery: true; in-out property <bool> change_platform_profile_on_battery: true;
callback cb_change_throttle_policy_on_battery(bool); callback cb_change_platform_profile_on_battery(bool);
// //
in-out property <int> panel_overdrive; in-out property <int> panel_overdrive;
callback cb_panel_overdrive(int); callback cb_panel_overdrive(int);
@@ -49,55 +50,78 @@ export global SystemPageData {
callback cb_boot_sound(int); callback cb_boot_sound(int);
in-out property <int> mini_led_mode; in-out property <int> mini_led_mode;
callback cb_mini_led_mode(int); callback cb_mini_led_mode(int);
in-out property <bool> asus_armoury_loaded: false;
in-out property <AttrMinMax> ppt_pl1_spl: { in-out property <AttrMinMax> ppt_pl1_spl: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_pl1_spl(int); callback cb_ppt_pl1_spl(int);
callback cb_default_ppt_pl1_spl();
in-out property <AttrMinMax> ppt_pl2_sppt: { in-out property <AttrMinMax> ppt_pl2_sppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_pl2_sppt(int); callback cb_ppt_pl2_sppt(int);
callback cb_default_ppt_pl2_sppt();
in-out property <AttrMinMax> ppt_pl3_fppt: {
min: 0,
max: 100,
current: 20,
};
callback cb_ppt_pl3_fppt(int);
callback cb_default_ppt_pl3_fppt();
in-out property <AttrMinMax> ppt_fppt: { in-out property <AttrMinMax> ppt_fppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_fppt(int); callback cb_ppt_fppt(int);
callback cb_default_ppt_fppt();
in-out property <AttrMinMax> ppt_apu_sppt: { in-out property <AttrMinMax> ppt_apu_sppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_apu_sppt(int); callback cb_ppt_apu_sppt(int);
callback cb_default_ppt_apu_sppt();
in-out property <AttrMinMax> ppt_platform_sppt: { in-out property <AttrMinMax> ppt_platform_sppt: {
min: 0, min: 0,
max: 100, max: 100,
val: 20, current: 20,
}; };
callback cb_ppt_platform_sppt(int); callback cb_ppt_platform_sppt(int);
callback cb_default_ppt_platform_sppt();
in-out property <AttrMinMax> nv_dynamic_boost: { in-out property <AttrMinMax> nv_dynamic_boost: {
min: 0, min: 0,
max: 30, max: 30,
val: 5, current: 5,
}; };
callback cb_nv_dynamic_boost(int); callback cb_nv_dynamic_boost(int);
callback cb_default_nv_dynamic_boost();
in-out property <AttrMinMax> nv_temp_target: { in-out property <AttrMinMax> nv_temp_target: {
min: 0, min: 0,
max: 80, max: 80,
val: 75, current: 75,
}; };
callback cb_nv_temp_target(int); callback cb_nv_temp_target(int);
callback cb_default_nv_temp_target();
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 { export component PageSystem inherits Rectangle {
@@ -109,6 +133,7 @@ export component PageSystem inherits Rectangle {
VerticalLayout { VerticalLayout {
padding: 10px; padding: 10px;
spacing: 10px; spacing: 10px;
alignment: LayoutAlignment.start;
Rectangle { Rectangle {
background: Palette.alternate-background; background: Palette.alternate-background;
border-color: Palette.accent-background; border-color: Palette.accent-background;
@@ -127,21 +152,24 @@ export component PageSystem inherits Rectangle {
text: @tr("Charge limit"); text: @tr("Charge limit");
minimum: 20; minimum: 20;
maximum: 100; maximum: 100;
value <=> SystemPageData.charge_control_end_threshold; has_reset: false;
enabled <=> SystemPageData.charge_control_enabled;
value: SystemPageData.charge_control_end_threshold;
released => { released => {
SystemPageData.charge_control_end_threshold = self.value;
SystemPageData.cb_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold)) SystemPageData.cb_charge_control_end_threshold(Math.round(SystemPageData.charge_control_end_threshold))
} }
} }
if SystemPageData.throttle_thermal_policy != -1: HorizontalLayout { if SystemPageData.platform_profile != -1: HorizontalLayout {
spacing: 10px; spacing: 10px;
SystemDropdown { SystemDropdown {
text: @tr("Throttle Policy"); text: @tr("Platform Profile");
current_index <=> SystemPageData.throttle_thermal_policy; current_index <=> SystemPageData.platform_profile;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_thermal_policy]; current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.platform_profile_choices;
selected => { selected => {
SystemPageData.cb_throttle_thermal_policy(SystemPageData.throttle_thermal_policy) SystemPageData.cb_platform_profile(SystemPageData.platform_profile)
} }
} }
@@ -168,6 +196,25 @@ export component PageSystem inherits Rectangle {
} }
} }
if !SystemPageData.asus_armoury_loaded: Rectangle {
border-width: 3px;
border-color: red;
max-height: 30px;
VerticalBox {
Text {
text: @tr("no_asus_armoury_driver_1" => "The asus-armoury driver is not loaded");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
Text {
text: @tr("no_asus_armoury_driver_2" => "For advanced features you will require a kernel with this driver added.");
font-size: 16px;
horizontal-alignment: TextHorizontalAlignment.center;
}
}
}
HorizontalBox { HorizontalBox {
padding: 0px; padding: 0px;
spacing: 10px; spacing: 10px;
@@ -196,79 +243,175 @@ export component PageSystem inherits Rectangle {
} }
} }
if SystemPageData.ppt_pl1_spl.val != -1: SystemSlider { if SystemPageData.ppt_pl1_spl.current != -1 || SystemPageData.ppt_pl2_sppt.current != -1 || SystemPageData.nv_dynamic_boost.current != -1: HorizontalLayout {
text: @tr("ppt_pl1_spl" => "PL1, sustained power limit"); padding-right: 10px;
padding-left: 10px;
alignment: LayoutAlignment.space-between;
Rectangle {
height: 32px;
Text {
font-size: 16px;
text: @tr("ppt_warning" => "The following settings are not applied until the toggle is enabled.");
}
}
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 {
text: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit");
title: @tr("ppt_pl1_spl" => "CPU Sustained Power Limit");
help_text: @tr("ppt_pl1_spl_help" => "Long-term CPU power limit that affects sustained workload performance. Higher values may increase heat and power consumption.");
minimum: SystemPageData.ppt_pl1_spl.min; minimum: SystemPageData.ppt_pl1_spl.min;
maximum: SystemPageData.ppt_pl1_spl.max; maximum: SystemPageData.ppt_pl1_spl.max;
value: SystemPageData.ppt_pl1_spl.val; value: SystemPageData.ppt_pl1_spl.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl1_spl();
}
released => { released => {
SystemPageData.ppt_pl1_spl.val = self.value; SystemPageData.ppt_pl1_spl.current = self.value;
SystemPageData.cb_ppt_pl1_spl(Math.round(self.value)) SystemPageData.cb_ppt_pl1_spl(Math.round(self.value));
} }
} }
if SystemPageData.ppt_pl2_sppt.val != -1: SystemSlider { if SystemPageData.ppt_pl2_sppt.current != -1: SystemSlider {
text: @tr("ppt_pl2_sppt" => "PL2, turbo power limit"); text: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit");
title: @tr("ppt_pl2_sppt" => "CPU Turbo Power Limit");
help_text: @tr("ppt_pl2_sppt_help" => "Short-term CPU power limit for boost periods. Controls maximum power during brief high-performance bursts.");
minimum: SystemPageData.ppt_pl2_sppt.min; minimum: SystemPageData.ppt_pl2_sppt.min;
maximum: SystemPageData.ppt_pl2_sppt.max; maximum: SystemPageData.ppt_pl2_sppt.max;
value: SystemPageData.ppt_pl2_sppt.val; value: SystemPageData.ppt_pl2_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl2_sppt();
}
released => { released => {
SystemPageData.ppt_pl2_sppt.val = self.value; SystemPageData.ppt_pl2_sppt.current = self.value;
SystemPageData.cb_ppt_pl2_sppt(Math.round(self.value)) SystemPageData.cb_ppt_pl2_sppt(Math.round(self.value))
} }
} }
if SystemPageData.ppt_fppt.val != -1: SystemSlider { if SystemPageData.ppt_pl3_fppt.current != -1: SystemSlider {
text: @tr("ppt_fppt" => "FPPT, Fast Power Limit"); text: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit");
title: @tr("ppt_pl3_fppt" => "CPU Fast Burst Power Limit");
help_text: @tr("ppt_pl3_fppt_help" => "Ultra-short duration power limit for instantaneous CPU bursts. Affects responsiveness during sudden workload spikes.");
minimum: SystemPageData.ppt_pl3_fppt.min;
maximum: SystemPageData.ppt_pl3_fppt.max;
value: SystemPageData.ppt_pl3_fppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_pl3_fppt();
}
released => {
SystemPageData.ppt_pl3_fppt.current = self.value;
SystemPageData.cb_ppt_pl3_fppt(Math.round(self.value))
}
}
if SystemPageData.ppt_fppt.current != -1: SystemSlider {
text: @tr("ppt_fppt" => "Fast Package Power Limit");
title: @tr("ppt_fppt" => "Fast Package Power Limit");
help_text: @tr("ppt_fppt_help" => "Ultra-short duration power limit for system package. Controls maximum power during millisecond-scale load spikes.");
minimum: SystemPageData.ppt_fppt.min; minimum: SystemPageData.ppt_fppt.min;
maximum: SystemPageData.ppt_fppt.max; maximum: SystemPageData.ppt_fppt.max;
value: SystemPageData.ppt_fppt.val; value: SystemPageData.ppt_fppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_fppt();
}
released => { released => {
SystemPageData.ppt_fppt.val = self.value; SystemPageData.ppt_fppt.current = self.value;
SystemPageData.cb_ppt_fppt(Math.round(self.value)) SystemPageData.cb_ppt_fppt(Math.round(self.value))
} }
} }
if SystemPageData.ppt_apu_sppt.val != -1: SystemSlider { if SystemPageData.ppt_apu_sppt.current != -1: SystemSlider {
text: @tr("ppt_apu_sppt" => "SPPT, APU slow power limit"); text: @tr("ppt_apu_sppt" => "APU Sustained Power Limit");
title: @tr("ppt_apu_sppt" => "APU Sustained Power Limit");
help_text: @tr("ppt_apu_sppt_help" => "Long-term power limit for integrated graphics and CPU combined. Affects sustained performance of APU-based workloads.");
minimum: SystemPageData.ppt_apu_sppt.min; minimum: SystemPageData.ppt_apu_sppt.min;
maximum: SystemPageData.ppt_apu_sppt.max; maximum: SystemPageData.ppt_apu_sppt.max;
value: SystemPageData.ppt_apu_sppt.val; value: SystemPageData.ppt_apu_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_apu_sppt();
}
released => { released => {
SystemPageData.ppt_apu_sppt.val = self.value; SystemPageData.ppt_apu_sppt.current = self.value;
SystemPageData.cb_ppt_apu_sppt(Math.round(self.value)) SystemPageData.cb_ppt_apu_sppt(Math.round(self.value))
} }
} }
if SystemPageData.ppt_platform_sppt.val != -1: SystemSlider { if SystemPageData.ppt_platform_sppt.current != -1: SystemSlider {
text: @tr("ppt_platform_sppt" => "Slow package power tracking limit"); text: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit");
title: @tr("ppt_platform_sppt" => "Platform Sustained Power Limit");
help_text: @tr("ppt_platform_sppt_help" => "Overall system power limit for sustained operations. Controls total platform power consumption over extended periods.");
minimum: SystemPageData.ppt_platform_sppt.min; minimum: SystemPageData.ppt_platform_sppt.min;
maximum: SystemPageData.ppt_platform_sppt.max; maximum: SystemPageData.ppt_platform_sppt.max;
value: SystemPageData.ppt_platform_sppt.val; value: SystemPageData.ppt_platform_sppt.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_ppt_platform_sppt();
}
released => { released => {
SystemPageData.ppt_platform_sppt.val = self.value; SystemPageData.ppt_platform_sppt.current = self.value;
SystemPageData.cb_ppt_platform_sppt(Math.round(self.value)) SystemPageData.cb_ppt_platform_sppt(Math.round(self.value))
} }
} }
if SystemPageData.nv_dynamic_boost.val != -1: SystemSlider { if SystemPageData.nv_dynamic_boost.current != -1: SystemSlider {
text: @tr("nv_dynamic_boost" => "dGPU boost overclock"); text: @tr("nv_dynamic_boost" => "GPU Power Boost");
title: @tr("nv_dynamic_boost" => "GPU Power Boost");
help_text: @tr("nv_dynamic_boost_help" => "Additional power allocation for GPU dynamic boost. Higher values increase GPU performance but generate more heat.");
minimum: SystemPageData.nv_dynamic_boost.min; minimum: SystemPageData.nv_dynamic_boost.min;
maximum: SystemPageData.nv_dynamic_boost.max; maximum: SystemPageData.nv_dynamic_boost.max;
value: SystemPageData.nv_dynamic_boost.val; value: SystemPageData.nv_dynamic_boost.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_nv_dynamic_boost();
}
released => { released => {
SystemPageData.nv_dynamic_boost.val = self.value; SystemPageData.nv_dynamic_boost.current = self.value;
SystemPageData.cb_nv_dynamic_boost(Math.round(self.value)) SystemPageData.cb_nv_dynamic_boost(Math.round(self.value))
} }
} }
if SystemPageData.nv_temp_target.val != -1: SystemSlider { if SystemPageData.nv_temp_target.current != -1: SystemSlider {
text: @tr("nv_temp_target" => "dGPU temperature max"); text: @tr("nv_temp_target" => "GPU Temperature Limit");
title: @tr("nv_temp_target" => "GPU Temperature Limit");
help_text: @tr("nv_temp_target_help" => "Maximum GPU temperature threshold in Celsius. GPU will throttle to maintain temperature below this limit.");
minimum: SystemPageData.nv_temp_target.min; minimum: SystemPageData.nv_temp_target.min;
maximum: SystemPageData.nv_temp_target.max; maximum: SystemPageData.nv_temp_target.max;
value: SystemPageData.nv_temp_target.val; value: SystemPageData.nv_temp_target.current;
enabled <=> SystemPageData.enable_ppt_group;
has_reset: true;
cb_do_reset => {
SystemPageData.cb_default_nv_temp_target();
}
released => { released => {
SystemPageData.nv_temp_target.val = self.value; SystemPageData.nv_temp_target.current = self.value;
SystemPageData.cb_nv_temp_target(Math.round(self.value)) SystemPageData.cb_nv_temp_target(Math.round(self.value))
} }
} }
@@ -315,39 +458,39 @@ export component PageSystem inherits Rectangle {
SystemToggle { SystemToggle {
text: @tr("Change EPP based on Throttle Policy"); text: @tr("Change EPP based on Throttle Policy");
checked <=> SystemPageData.throttle_policy_linked_epp; checked <=> SystemPageData.platform_profile_linked_epp;
toggled => { toggled => {
SystemPageData.cb_throttle_policy_linked_epp(SystemPageData.throttle_policy_linked_epp) SystemPageData.cb_platform_profile_linked_epp(SystemPageData.platform_profile_linked_epp)
} }
} }
SystemDropdown { SystemDropdown {
text: @tr("EPP for Balanced Policy"); text: @tr("EPP for Balanced Policy");
current_index <=> SystemPageData.throttle_balanced_epp; current_index <=> SystemPageData.profile_balanced_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_balanced_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_balanced_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.cb_throttle_balanced_epp(SystemPageData.throttle_balanced_epp) SystemPageData.cb_profile_balanced_epp(SystemPageData.profile_balanced_epp)
} }
} }
SystemDropdown { SystemDropdown {
text: @tr("EPP for Performance Policy"); text: @tr("EPP for Performance Policy");
current_index <=> SystemPageData.throttle_performance_epp; current_index <=> SystemPageData.profile_performance_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_performance_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_performance_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.cb_throttle_performance_epp(SystemPageData.throttle_performance_epp) SystemPageData.cb_profile_performance_epp(SystemPageData.profile_performance_epp)
} }
} }
SystemDropdown { SystemDropdown {
text: @tr("EPP for Quiet Policy"); text: @tr("EPP for Quiet Policy");
current_index <=> SystemPageData.throttle_quiet_epp; current_index <=> SystemPageData.profile_quiet_epp;
current_value: SystemPageData.energy_performance_choices[SystemPageData.throttle_quiet_epp]; current_value: SystemPageData.energy_performance_choices[SystemPageData.profile_quiet_epp];
model <=> SystemPageData.energy_performance_choices; model <=> SystemPageData.energy_performance_choices;
selected => { selected => {
SystemPageData.cb_throttle_quiet_epp(SystemPageData.throttle_quiet_epp) SystemPageData.cb_profile_quiet_epp(SystemPageData.profile_quiet_epp)
} }
} }
} }
@@ -367,19 +510,19 @@ export component PageSystem inherits Rectangle {
spacing: 10px; spacing: 10px;
SystemDropdown { SystemDropdown {
text: @tr("Throttle Policy on Battery"); text: @tr("Throttle Policy on Battery");
current_index <=> SystemPageData.throttle_policy_on_battery; current_index <=> SystemPageData.platform_profile_on_battery;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_battery]; current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile_on_battery];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.platform_profile_choices;
selected => { selected => {
SystemPageData.cb_throttle_policy_on_battery(SystemPageData.throttle_policy_on_battery) SystemPageData.cb_platform_profile_on_battery(SystemPageData.platform_profile_on_battery)
} }
} }
SystemToggle { SystemToggle {
text: @tr("Enabled"); text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_battery; checked <=> SystemPageData.change_platform_profile_on_battery;
toggled => { toggled => {
SystemPageData.cb_change_throttle_policy_on_battery(SystemPageData.change_throttle_policy_on_battery); SystemPageData.cb_change_platform_profile_on_battery(SystemPageData.change_platform_profile_on_battery);
} }
} }
} }
@@ -388,19 +531,19 @@ export component PageSystem inherits Rectangle {
spacing: 10px; spacing: 10px;
SystemDropdown { SystemDropdown {
text: @tr("Throttle Policy on AC"); text: @tr("Throttle Policy on AC");
current_index <=> SystemPageData.throttle_policy_on_ac; current_index <=> SystemPageData.platform_profile_on_ac;
current_value: SystemPageData.throttle_policy_choices[SystemPageData.throttle_policy_on_ac]; current_value: SystemPageData.platform_profile_choices[SystemPageData.platform_profile_on_ac];
model <=> SystemPageData.throttle_policy_choices; model <=> SystemPageData.platform_profile_choices;
selected => { selected => {
SystemPageData.cb_throttle_policy_on_ac(SystemPageData.throttle_policy_on_ac) SystemPageData.cb_platform_profile_on_ac(SystemPageData.platform_profile_on_ac)
} }
} }
SystemToggle { SystemToggle {
text: @tr("Enabled"); text: @tr("Enabled");
checked <=> SystemPageData.change_throttle_policy_on_ac; checked <=> SystemPageData.change_platform_profile_on_ac;
toggled => { toggled => {
SystemPageData.cb_change_throttle_policy_on_ac(SystemPageData.change_throttle_policy_on_ac); SystemPageData.cb_change_platform_profile_on_ac(SystemPageData.change_platform_profile_on_ac);
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More