mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Merge branch 'fluke/anime-cli' into 'main'
Fluke/anime cli See merge request asus-linux/asus-nb-ctrl!46
This commit is contained in:
185
Cargo.lock
generated
185
Cargo.lock
generated
@@ -1,5 +1,7 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "adler"
|
name = "adler"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
@@ -74,15 +76,6 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "async-lock"
|
|
||||||
version = "2.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1996609732bde4a9988bc42125f55f2af5f3c36370e27c778d5191a4a1b63bfb"
|
|
||||||
dependencies = [
|
|
||||||
"event-listener",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atty"
|
name = "atty"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
@@ -229,7 +222,7 @@ dependencies = [
|
|||||||
"sysfs-class",
|
"sysfs-class",
|
||||||
"toml",
|
"toml",
|
||||||
"udev",
|
"udev",
|
||||||
"zbus 2.0.0-beta.3",
|
"zbus",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -303,12 +296,6 @@ dependencies = [
|
|||||||
"synstructure",
|
"synstructure",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "event-listener"
|
|
||||||
version = "2.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@@ -433,18 +420,7 @@ checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.9.0+wasi-snapshot-preview1",
|
"wasi",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "getrandom"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 1.0.0",
|
|
||||||
"libc",
|
|
||||||
"wasi 0.10.2+wasi-snapshot-preview1",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -495,12 +471,6 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hex"
|
|
||||||
version = "0.4.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "humantime"
|
name = "humantime"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
@@ -583,14 +553,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "logind-zbus"
|
name = "logind-zbus"
|
||||||
version = "0.6.1"
|
version = "0.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6671f6cf88b63e9d63009f4f6f8826fcc265c51a9977e4c7dc1263d743e0dfbb"
|
checksum = "dca64bea11e365933e0c4a1a9342f0122d1d2822a09c87dab0e1d314adb353a2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"zbus 2.0.0-beta.3",
|
"zbus",
|
||||||
"zbus_macros 2.0.0-beta.3",
|
"zbus_macros",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
"zvariant_derive",
|
"zvariant_derive",
|
||||||
]
|
]
|
||||||
@@ -655,18 +625,6 @@ dependencies = [
|
|||||||
"void",
|
"void",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nix"
|
|
||||||
version = "0.19.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.2.1",
|
|
||||||
"cc",
|
|
||||||
"cfg-if 1.0.0",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nom"
|
name = "nom"
|
||||||
version = "5.1.2"
|
version = "5.1.2"
|
||||||
@@ -686,7 +644,7 @@ dependencies = [
|
|||||||
"mac-notification-sys",
|
"mac-notification-sys",
|
||||||
"serde",
|
"serde",
|
||||||
"winrt-notification",
|
"winrt-notification",
|
||||||
"zbus 1.8.0",
|
"zbus",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
"zvariant_derive",
|
"zvariant_derive",
|
||||||
]
|
]
|
||||||
@@ -805,12 +763,6 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ppv-lite86"
|
|
||||||
version = "0.2.10"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-crate"
|
name = "proc-macro-crate"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
@@ -880,46 +832,6 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand"
|
|
||||||
version = "0.8.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"rand_chacha",
|
|
||||||
"rand_core",
|
|
||||||
"rand_hc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_chacha"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
|
||||||
dependencies = [
|
|
||||||
"ppv-lite86",
|
|
||||||
"rand_core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_core"
|
|
||||||
version = "0.6.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom 0.2.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rand_hc"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.1.57"
|
version = "0.1.57"
|
||||||
@@ -932,7 +844,7 @@ version = "0.3.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
|
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.1.16",
|
"getrandom",
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
"rust-argon2",
|
"rust-argon2",
|
||||||
]
|
]
|
||||||
@@ -976,8 +888,8 @@ dependencies = [
|
|||||||
"rog_fan_curve",
|
"rog_fan_curve",
|
||||||
"rog_types",
|
"rog_types",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"zbus 1.8.0",
|
"zbus",
|
||||||
"zbus_macros 1.8.0",
|
"zbus_macros",
|
||||||
"zvariant",
|
"zvariant",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1084,27 +996,12 @@ dependencies = [
|
|||||||
"syn 1.0.64",
|
"syn 1.0.64",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha1"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "slotmap"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ab3003725ae562cf995f3dc82bb99e70926e09000396816765bb6d7adbe740b1"
|
|
||||||
dependencies = [
|
|
||||||
"version_check",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smart-default"
|
name = "smart-default"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
@@ -1312,12 +1209,6 @@ version = "0.9.0+wasi-snapshot-preview1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasi"
|
|
||||||
version = "0.10.2+wasi-snapshot-preview1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "weezl"
|
name = "weezl"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
@@ -1406,9 +1297,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zbus"
|
name = "zbus"
|
||||||
version = "1.8.0"
|
version = "1.9.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "40b4d4aa39daed4e32aed75f0c37b969184949a0fdfd5f2e1277abfda61f02a8"
|
checksum = "2326acc379a3ac4e34b794089f5bdb17086bf29a5fdf619b7b4cc772dc2e9dad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-io",
|
"async-io",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
@@ -1417,61 +1308,21 @@ dependencies = [
|
|||||||
"fastrand",
|
"fastrand",
|
||||||
"futures",
|
"futures",
|
||||||
"nb-connect",
|
"nb-connect",
|
||||||
"nix 0.17.0",
|
"nix",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"polling",
|
"polling",
|
||||||
"scoped-tls",
|
"scoped-tls",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_repr",
|
"serde_repr",
|
||||||
"zbus_macros 1.8.0",
|
"zbus_macros",
|
||||||
"zvariant",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zbus"
|
|
||||||
version = "2.0.0-beta.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3e1e656194618d167524f97e88ff9bf87f2b1e8bf58f357b2a7abfdff8cc85c9"
|
|
||||||
dependencies = [
|
|
||||||
"async-io",
|
|
||||||
"async-lock",
|
|
||||||
"byteorder",
|
|
||||||
"derivative",
|
|
||||||
"enumflags2",
|
|
||||||
"event-listener",
|
|
||||||
"futures-core",
|
|
||||||
"futures-sink",
|
|
||||||
"futures-util",
|
|
||||||
"hex",
|
|
||||||
"nix 0.19.1",
|
|
||||||
"once_cell",
|
|
||||||
"rand",
|
|
||||||
"scoped-tls",
|
|
||||||
"serde",
|
|
||||||
"serde_repr",
|
|
||||||
"sha1",
|
|
||||||
"slotmap",
|
|
||||||
"zbus_macros 2.0.0-beta.3",
|
|
||||||
"zvariant",
|
"zvariant",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zbus_macros"
|
name = "zbus_macros"
|
||||||
version = "1.8.0"
|
version = "1.9.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "87cc141cda72384bef359badf1808e391d3968f9299e8f3c3cbb78dafa1e0930"
|
checksum = "a482c56029e48681b89b92b5db3c446db0915e8dd1052c0328a574eda38d5f93"
|
||||||
dependencies = [
|
|
||||||
"proc-macro-crate",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote 1.0.9",
|
|
||||||
"syn 1.0.64",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zbus_macros"
|
|
||||||
version = "2.0.0-beta.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fcd4cb372bc2cade3f2323e4104112dceb6819f5dd9afa98515b4e821d232932"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{env, fs::File, path::Path, thread::sleep, time::Duration};
|
use std::{env, path::Path, thread::sleep};
|
||||||
|
|
||||||
use rog_anime::AniMeSequence;
|
use rog_anime::AniMeBlock;
|
||||||
use rog_dbus::AuraDbusClient;
|
use rog_dbus::AuraDbusClient;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -14,7 +14,7 @@ fn main() {
|
|||||||
|
|
||||||
let path = Path::new(&args[1]);
|
let path = Path::new(&args[1]);
|
||||||
let brightness = args[2].parse::<f32>().unwrap();
|
let brightness = args[2].parse::<f32>().unwrap();
|
||||||
let gif = AniMeSequence::gif(path, brightness).unwrap();
|
let gif = AniMeBlock::asus_gif(path, brightness).unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
for frame in gif.get_animation().unwrap().frames() {
|
for frame in gif.get_animation().unwrap().frames() {
|
||||||
|
|||||||
39
asusctl/examples/animatrix-png-gif.rs
Normal file
39
asusctl/examples/animatrix-png-gif.rs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
use std::{env, path::Path, thread::sleep};
|
||||||
|
|
||||||
|
use glam::Vec2;
|
||||||
|
use rog_anime::AniMeBlock;
|
||||||
|
use rog_dbus::AuraDbusClient;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let (client, _) = AuraDbusClient::new().unwrap();
|
||||||
|
|
||||||
|
let args: Vec<String> = env::args().into_iter().collect();
|
||||||
|
if args.len() != 7 {
|
||||||
|
println!("Usage: <filepath> <scale> <angle> <x pos> <y pos> <brightness>");
|
||||||
|
println!("e.g, asusctl/examples/file.gif 0.9 0.4 0.0 0.0 0.8");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let gif = AniMeBlock::image_gif(
|
||||||
|
Path::new(&args[1]),
|
||||||
|
args[2].parse::<f32>().unwrap(),
|
||||||
|
args[3].parse::<f32>().unwrap(),
|
||||||
|
Vec2::new(
|
||||||
|
args[4].parse::<f32>().unwrap(),
|
||||||
|
args[5].parse::<f32>().unwrap(),
|
||||||
|
),
|
||||||
|
args[6].parse::<f32>().unwrap(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
for frame in gif.get_animation().unwrap().frames() {
|
||||||
|
client
|
||||||
|
.proxies()
|
||||||
|
.anime()
|
||||||
|
.write(frame.frame().clone())
|
||||||
|
.unwrap();
|
||||||
|
sleep(frame.delay());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,24 +9,21 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
let (client, _) = AuraDbusClient::new().unwrap();
|
let (client, _) = AuraDbusClient::new().unwrap();
|
||||||
|
|
||||||
let args: Vec<String> = env::args().into_iter().collect();
|
let args: Vec<String> = env::args().into_iter().collect();
|
||||||
if args.len() != 8 {
|
if args.len() != 7 {
|
||||||
println!("Usage: <filepath> <x scale> <y scale> <angle> <x pos> <y pos> <brightness>");
|
println!("Usage: <filepath> <scale> <angle> <x pos> <y pos> <brightness>");
|
||||||
println!("e.g, asusctl/examples/doom_large.png 0.9 0.9 0.4 0.0 0.0,0.8");
|
println!("e.g, asusctl/examples/doom_large.png 0.9 0.4 0.0 0.0 0.8");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
let matrix = AniMeImage::from_png(
|
let matrix = AniMeImage::from_png(
|
||||||
Path::new(&args[1]),
|
Path::new(&args[1]),
|
||||||
|
args[2].parse::<f32>().unwrap(),
|
||||||
|
args[3].parse::<f32>().unwrap(),
|
||||||
Vec2::new(
|
Vec2::new(
|
||||||
args[2].parse::<f32>().unwrap(),
|
args[4].parse::<f32>().unwrap(),
|
||||||
args[3].parse::<f32>().unwrap(),
|
|
||||||
),
|
|
||||||
args[4].parse::<f32>().unwrap(),
|
|
||||||
Vec2::new(
|
|
||||||
args[5].parse::<f32>().unwrap(),
|
args[5].parse::<f32>().unwrap(),
|
||||||
args[6].parse::<f32>().unwrap(),
|
|
||||||
),
|
),
|
||||||
args[7].parse::<f32>().unwrap(),
|
args[6].parse::<f32>().unwrap(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
client
|
client
|
||||||
|
|||||||
@@ -11,25 +11,21 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
let (client, _) = AuraDbusClient::new().unwrap();
|
let (client, _) = AuraDbusClient::new().unwrap();
|
||||||
|
|
||||||
let args: Vec<String> = env::args().into_iter().collect();
|
let args: Vec<String> = env::args().into_iter().collect();
|
||||||
if args.len() != 8 {
|
if args.len() != 7 {
|
||||||
println!("Usage: <filepath> <x scale> <y scale> <angle> <x pos> <y pos> <brightness>");
|
println!("Usage: <filepath> <scale> <angle> <x pos> <y pos> <brightness>");
|
||||||
println!("e.g, asusctl/examples/doom_large.bmp 0.9 0.9 0.4 0.0 0.0, 0.8");
|
println!("e.g, asusctl/examples/doom_large.png 0.9 0.4 0.0 0.0 0.8");
|
||||||
println!("All args except path and fineness are floats");
|
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut matrix = AniMeImage::from_png(
|
let mut matrix = AniMeImage::from_png(
|
||||||
Path::new(&args[1]),
|
Path::new(&args[1]),
|
||||||
|
args[2].parse::<f32>().unwrap(),
|
||||||
|
args[3].parse::<f32>().unwrap(),
|
||||||
Vec2::new(
|
Vec2::new(
|
||||||
args[2].parse::<f32>().unwrap(),
|
args[4].parse::<f32>().unwrap(),
|
||||||
args[3].parse::<f32>().unwrap(),
|
|
||||||
),
|
|
||||||
args[4].parse::<f32>().unwrap(),
|
|
||||||
Vec2::new(
|
|
||||||
args[5].parse::<f32>().unwrap(),
|
args[5].parse::<f32>().unwrap(),
|
||||||
args[6].parse::<f32>().unwrap(),
|
|
||||||
),
|
),
|
||||||
args[7].parse::<f32>().unwrap(),
|
args[6].parse::<f32>().unwrap(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
let matrix = AniMeImage::from_png(
|
let matrix = AniMeImage::from_png(
|
||||||
Path::new(&image.path),
|
Path::new(&image.path),
|
||||||
Vec2::new(image.scale, image.scale),
|
image.scale,
|
||||||
image.angle,
|
image.angle,
|
||||||
Vec2::new(image.x_pos, image.y_pos),
|
Vec2::new(image.x_pos, image.y_pos),
|
||||||
image.bright,
|
image.bright,
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ udev = "^0.6"
|
|||||||
log = "^0.4"
|
log = "^0.4"
|
||||||
env_logger = "^0.8"
|
env_logger = "^0.8"
|
||||||
|
|
||||||
zbus = "^2.0.0-beta.3"
|
zbus = "^1.9.1"
|
||||||
zvariant = "^2.5"
|
zvariant = "^2.6"
|
||||||
logind-zbus = "*"
|
logind-zbus = "^0.7.1"
|
||||||
|
|
||||||
# serialisation
|
# serialisation
|
||||||
serde = "^1.0"
|
serde = "^1.0"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const ON_OFF: u8 = 0x04;
|
|||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
use rog_anime::{AniMeDataBuffer, AniMePacketType};
|
use rog_anime::{AniMeDataBuffer, AniMePacketType};
|
||||||
use rusb::{Device, DeviceHandle};
|
use rusb::{Device, DeviceHandle};
|
||||||
|
use zvariant::ObjectPath;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use zbus::dbus_interface;
|
use zbus::dbus_interface;
|
||||||
@@ -51,7 +52,7 @@ pub trait Dbus {
|
|||||||
impl crate::ZbusAdd for CtrlAnimeDisplay {
|
impl crate::ZbusAdd for CtrlAnimeDisplay {
|
||||||
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
||||||
server
|
server
|
||||||
.at("/org/asuslinux/Anime", self)
|
.at(&ObjectPath::from_str_unchecked("/org/asuslinux/Anime"), self)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
warn!("CtrlAnimeDisplay: add_to_server {}", err);
|
warn!("CtrlAnimeDisplay: add_to_server {}", err);
|
||||||
err
|
err
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use crate::{config::Config, error::RogError, GetSupported};
|
|||||||
//use crate::dbus::DbusEvents;
|
//use crate::dbus::DbusEvents;
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
use zvariant::ObjectPath;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -63,7 +64,7 @@ impl CtrlCharge {
|
|||||||
impl crate::ZbusAdd for CtrlCharge {
|
impl crate::ZbusAdd for CtrlCharge {
|
||||||
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
||||||
server
|
server
|
||||||
.at("/org/asuslinux/Charge", self)
|
.at(&ObjectPath::from_str_unchecked("/org/asuslinux/Charge"), self)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
warn!("CtrlCharge: add_to_server {}", err);
|
warn!("CtrlCharge: add_to_server {}", err);
|
||||||
err
|
err
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use crate::{config::Config, GetSupported};
|
|||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use rog_types::profile::{FanLevel, Profile, ProfileEvent};
|
use rog_types::profile::{FanLevel, Profile, ProfileEvent};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
use zvariant::ObjectPath;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -180,7 +181,7 @@ impl DbusFanAndCpu {
|
|||||||
impl crate::ZbusAdd for DbusFanAndCpu {
|
impl crate::ZbusAdd for DbusFanAndCpu {
|
||||||
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
||||||
server
|
server
|
||||||
.at("/org/asuslinux/Profile", self)
|
.at(&ObjectPath::from_str_unchecked("/org/asuslinux/Profile"), self)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
warn!("DbusFanAndCpu: add_to_server {}", err);
|
warn!("DbusFanAndCpu: add_to_server {}", err);
|
||||||
err
|
err
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use logind_zbus::{
|
|||||||
ManagerProxy, SessionProxy,
|
ManagerProxy, SessionProxy,
|
||||||
};
|
};
|
||||||
use rog_types::gfx_vendors::{GfxPower, GfxRequiredUserAction, GfxVendors};
|
use rog_types::gfx_vendors::{GfxPower, GfxRequiredUserAction, GfxVendors};
|
||||||
|
use zvariant::ObjectPath;
|
||||||
use std::{io::Write, ops::Add, path::Path, time::Instant};
|
use std::{io::Write, ops::Add, path::Path, time::Instant};
|
||||||
use std::{iter::FromIterator, thread::JoinHandle};
|
use std::{iter::FromIterator, thread::JoinHandle};
|
||||||
use std::{process::Command, thread::sleep, time::Duration};
|
use std::{process::Command, thread::sleep, time::Duration};
|
||||||
@@ -78,7 +79,7 @@ impl Dbus for CtrlGraphics {
|
|||||||
impl ZbusAdd for CtrlGraphics {
|
impl ZbusAdd for CtrlGraphics {
|
||||||
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
||||||
server
|
server
|
||||||
.at("/org/asuslinux/Gfx", self)
|
.at(&ObjectPath::from_str_unchecked("/org/asuslinux/Gfx"), self)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
warn!("GFX: CtrlGraphics: add_to_server {}", err);
|
warn!("GFX: CtrlGraphics: add_to_server {}", err);
|
||||||
err
|
err
|
||||||
@@ -495,7 +496,7 @@ impl CtrlGraphics {
|
|||||||
sessions: &[SessionInfo],
|
sessions: &[SessionInfo],
|
||||||
) -> Result<bool, RogError> {
|
) -> Result<bool, RogError> {
|
||||||
for session in sessions {
|
for session in sessions {
|
||||||
let session_proxy = SessionProxy::new(&connection, session)?;
|
let session_proxy = SessionProxy::new(connection, session)?;
|
||||||
if session_proxy.get_class()? == SessionClass::User {
|
if session_proxy.get_class()? == SessionClass::User {
|
||||||
match session_proxy.get_type()? {
|
match session_proxy.get_type()? {
|
||||||
SessionType::X11 | SessionType::Wayland | SessionType::MIR => {
|
SessionType::X11 | SessionType::Wayland | SessionType::MIR => {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use rog_types::{
|
|||||||
aura_modes::{AuraEffect, AuraModeNum, LedBrightness},
|
aura_modes::{AuraEffect, AuraModeNum, LedBrightness},
|
||||||
LED_MSG_LEN,
|
LED_MSG_LEN,
|
||||||
};
|
};
|
||||||
|
use zvariant::ObjectPath;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -82,7 +83,7 @@ trait Dbus {
|
|||||||
impl crate::ZbusAdd for DbusKbdBacklight {
|
impl crate::ZbusAdd for DbusKbdBacklight {
|
||||||
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
||||||
server
|
server
|
||||||
.at("/org/asuslinux/Led", self)
|
.at(&ObjectPath::from_str_unchecked("/org/asuslinux/Led"), self)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
error!("DbusKbdBacklight: add_to_server {}", err);
|
error!("DbusKbdBacklight: add_to_server {}", err);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::{config::Config, error::RogError, GetSupported};
|
use crate::{config::Config, error::RogError, GetSupported};
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
use zvariant::ObjectPath;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
@@ -101,7 +102,7 @@ impl CtrlRogBios {
|
|||||||
impl crate::ZbusAdd for CtrlRogBios {
|
impl crate::ZbusAdd for CtrlRogBios {
|
||||||
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
||||||
server
|
server
|
||||||
.at("/org/asuslinux/RogBios", self)
|
.at(&ObjectPath::from_str_unchecked("/org/asuslinux/RogBios"), self)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
warn!("CtrlRogBios: add_to_server {}", err);
|
warn!("CtrlRogBios: add_to_server {}", err);
|
||||||
err
|
err
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use log::warn;
|
use log::warn;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use zbus::dbus_interface;
|
use zbus::dbus_interface;
|
||||||
|
use zvariant::ObjectPath;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ctrl_anime::{AnimeSupportedFunctions, CtrlAnimeDisplay},
|
ctrl_anime::{AnimeSupportedFunctions, CtrlAnimeDisplay},
|
||||||
@@ -30,7 +31,7 @@ impl SupportedFunctions {
|
|||||||
impl crate::ZbusAdd for SupportedFunctions {
|
impl crate::ZbusAdd for SupportedFunctions {
|
||||||
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
fn add_to_server(self, server: &mut zbus::ObjectServer) {
|
||||||
server
|
server
|
||||||
.at("/org/asuslinux/Supported", self)
|
.at(&ObjectPath::from_str_unchecked("/org/asuslinux/Supported"), self)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
warn!("SupportedFunctions: add_to_server {}", err);
|
warn!("SupportedFunctions: add_to_server {}", err);
|
||||||
err
|
err
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ use daemon::ctrl_rog_bios::CtrlRogBios;
|
|||||||
use std::convert::Into;
|
use std::convert::Into;
|
||||||
use zbus::fdo;
|
use zbus::fdo;
|
||||||
use zbus::Connection;
|
use zbus::Connection;
|
||||||
|
use zvariant::ObjectPath;
|
||||||
|
|
||||||
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut logger = env_logger::Builder::new();
|
let mut logger = env_logger::Builder::new();
|
||||||
@@ -157,7 +158,7 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
|
|||||||
// TODO: implement messaging between threads to check fails
|
// TODO: implement messaging between threads to check fails
|
||||||
// These tasks generally read a sys path or file to check for a
|
// These tasks generally read a sys path or file to check for a
|
||||||
// change
|
// change
|
||||||
let _handle = std::thread::Builder::new()
|
let handle = std::thread::Builder::new()
|
||||||
.name("asusd watch".to_string())
|
.name("asusd watch".to_string())
|
||||||
.spawn(move || loop {
|
.spawn(move || loop {
|
||||||
std::thread::sleep(std::time::Duration::from_millis(100));
|
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||||
@@ -174,7 +175,7 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
object_server
|
object_server
|
||||||
.with("/org/asuslinux/Charge", |obj: &CtrlCharge| {
|
.with(&ObjectPath::from_str_unchecked("/org/asuslinux/Charge"), |obj: &CtrlCharge| {
|
||||||
let x = obj.limit();
|
let x = obj.limit();
|
||||||
obj.notify_charge(x as u8)
|
obj.notify_charge(x as u8)
|
||||||
})
|
})
|
||||||
@@ -184,8 +185,11 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
|
|||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
if let Err(err) = &handle {
|
||||||
|
error!("{}", err);
|
||||||
|
}
|
||||||
if let Err(err) = object_server.try_handle_next() {
|
if let Err(err) = object_server.try_handle_next() {
|
||||||
eprintln!("{}", err);
|
error!("{}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
data/anime/custom/nyancat_zombie.gif
Normal file
BIN
data/anime/custom/nyancat_zombie.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
BIN
data/anime/custom/sonic-run.gif
Normal file
BIN
data/anime/custom/sonic-run.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 152 KiB |
BIN
data/anime/custom/sonic-wait.gif
Normal file
BIN
data/anime/custom/sonic-wait.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
@@ -1,7 +1,8 @@
|
|||||||
|
use glam::Vec2;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use std::{fs::File, path::Path, time::Duration};
|
use std::{fs::File, path::Path, time::Duration};
|
||||||
|
|
||||||
use crate::{error::AnimeError, AniMeDataBuffer, AniMeDiagonal};
|
use crate::{error::AnimeError, AniMeDataBuffer, AniMeDiagonal, AniMeImage, Pixel};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct AniMeFrame {
|
pub struct AniMeFrame {
|
||||||
@@ -25,8 +26,8 @@ impl AniMeFrame {
|
|||||||
pub struct AniMeGif(Vec<AniMeFrame>);
|
pub struct AniMeGif(Vec<AniMeFrame>);
|
||||||
|
|
||||||
impl AniMeGif {
|
impl AniMeGif {
|
||||||
pub fn new(file_name: &Path, brightness: f32) -> Result<Self, AnimeError> {
|
/// Create an animation using the 74x36 ASUS gif format
|
||||||
let mut frames = Vec::new();
|
pub fn create_diagonal_gif(file_name: &Path, brightness: f32) -> Result<Self, AnimeError> {
|
||||||
let mut matrix = AniMeDiagonal::new();
|
let mut matrix = AniMeDiagonal::new();
|
||||||
|
|
||||||
let mut decoder = gif::DecodeOptions::new();
|
let mut decoder = gif::DecodeOptions::new();
|
||||||
@@ -36,8 +37,12 @@ impl AniMeGif {
|
|||||||
let file = File::open(file_name)?;
|
let file = File::open(file_name)?;
|
||||||
let mut decoder = decoder.read_info(file)?;
|
let mut decoder = decoder.read_info(file)?;
|
||||||
|
|
||||||
|
let mut frames = Vec::with_capacity(decoder.buffer_size());
|
||||||
while let Some(frame) = decoder.read_next_frame()? {
|
while let Some(frame) = decoder.read_next_frame()? {
|
||||||
let wait = frame.delay * 10;
|
let wait = frame.delay * 10;
|
||||||
|
if matches!(frame.dispose, gif::DisposalMethod::Background) {
|
||||||
|
frames = Vec::new();
|
||||||
|
}
|
||||||
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() {
|
||||||
for (x, px) in row.chunks(4).enumerate() {
|
for (x, px) in row.chunks(4).enumerate() {
|
||||||
if px[3] != 255 {
|
if px[3] != 255 {
|
||||||
@@ -57,6 +62,69 @@ impl AniMeGif {
|
|||||||
Ok(Self(frames))
|
Ok(Self(frames))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create an animation using a gif of any size. This method must precompute the
|
||||||
|
/// result.
|
||||||
|
pub fn create_png_gif(
|
||||||
|
file_name: &Path,
|
||||||
|
scale: f32,
|
||||||
|
angle: f32,
|
||||||
|
translation: Vec2,
|
||||||
|
brightness: f32,
|
||||||
|
) -> Result<Self, AnimeError> {
|
||||||
|
let mut frames = Vec::new();
|
||||||
|
|
||||||
|
let mut decoder = gif::DecodeOptions::new();
|
||||||
|
// Configure the decoder such that it will expand the image to RGBA.
|
||||||
|
decoder.set_color_output(gif::ColorOutput::RGBA);
|
||||||
|
// Read the file header
|
||||||
|
let file = File::open(file_name)?;
|
||||||
|
let mut decoder = decoder.read_info(file)?;
|
||||||
|
|
||||||
|
let height = decoder.height();
|
||||||
|
let width = decoder.width();
|
||||||
|
let pixels: Vec<Pixel> =
|
||||||
|
vec![Pixel::default(); (decoder.width() as u32 * decoder.height() as u32) as usize];
|
||||||
|
let mut image = AniMeImage::new(
|
||||||
|
Vec2::new(scale, scale),
|
||||||
|
angle,
|
||||||
|
translation,
|
||||||
|
brightness,
|
||||||
|
pixels,
|
||||||
|
decoder.width() as u32,
|
||||||
|
);
|
||||||
|
|
||||||
|
while let Some(frame) = decoder.read_next_frame()? {
|
||||||
|
let wait = frame.delay * 10;
|
||||||
|
if matches!(frame.dispose, gif::DisposalMethod::Background) {
|
||||||
|
let pixels: Vec<Pixel> =
|
||||||
|
vec![Pixel::default(); (width as u32 * height as u32) as usize];
|
||||||
|
image =
|
||||||
|
AniMeImage::new(Vec2::new(scale,scale), angle, translation, brightness, pixels, width as u32);
|
||||||
|
}
|
||||||
|
for (y, row) in frame.buffer.chunks(frame.width as usize * 4).enumerate() {
|
||||||
|
for (x, px) in row.chunks(4).enumerate() {
|
||||||
|
if px[3] != 255 {
|
||||||
|
// should be t but not in some gifs? What, ASUS, what?
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let pos =
|
||||||
|
(x + frame.left as usize) + ((y + frame.top as usize) * width as usize);
|
||||||
|
image.get_mut()[pos] = Pixel {
|
||||||
|
color: ((px[0] as u32 + px[1] as u32 + px[2] as u32) / 3),
|
||||||
|
alpha: 1.0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
image.update();
|
||||||
|
|
||||||
|
frames.push(AniMeFrame {
|
||||||
|
data: <AniMeDataBuffer>::from(&image),
|
||||||
|
delay: Duration::from_millis(wait as u64),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Ok(Self(frames))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn frames(&self) -> &[AniMeFrame] {
|
pub fn frames(&self) -> &[AniMeFrame] {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,19 @@ use crate::{
|
|||||||
|
|
||||||
const LED_PIXEL_LEN: usize = 1244;
|
const LED_PIXEL_LEN: usize = 1244;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
struct Pixel {
|
pub(crate) struct Pixel {
|
||||||
color: u32,
|
pub color: u32,
|
||||||
alpha: f32,
|
pub alpha: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Pixel {
|
||||||
|
fn default() -> Self {
|
||||||
|
Pixel {
|
||||||
|
color: 0,
|
||||||
|
alpha: 0.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A single LED position and brightness. The intention of this struct
|
/// A single LED position and brightness. The intention of this struct
|
||||||
@@ -64,7 +73,7 @@ pub struct AniMeImage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AniMeImage {
|
impl AniMeImage {
|
||||||
const fn new(
|
pub(crate) const fn new(
|
||||||
scale: Vec2,
|
scale: Vec2,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
translation: Vec2,
|
translation: Vec2,
|
||||||
@@ -131,6 +140,10 @@ impl AniMeImage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_mut(&mut self) -> &mut [Pixel] {
|
||||||
|
&mut self.img_pixels
|
||||||
|
}
|
||||||
|
|
||||||
/// Really only used to generate the output for including as a full const in `LED_IMAGE_POSITIONS`
|
/// Really only used to generate the output for including as a full const in `LED_IMAGE_POSITIONS`
|
||||||
pub fn generate() -> Vec<Option<Led>> {
|
pub fn generate() -> Vec<Option<Led>> {
|
||||||
(0..AniMeImage::height())
|
(0..AniMeImage::height())
|
||||||
@@ -172,18 +185,10 @@ impl AniMeImage {
|
|||||||
for v in GROUP.iter() {
|
for v in GROUP.iter() {
|
||||||
let sample = x0 + *u * du + *v * dv;
|
let sample = x0 + *u * du + *v * dv;
|
||||||
|
|
||||||
let mut y = sample.y as i32;
|
let x = sample.x as i32;
|
||||||
if y > height - 1 {
|
let y = sample.y as i32;
|
||||||
y = height - 1
|
if x > width - 1 || y > height - 1 || x < 0 || y < 0 {
|
||||||
} else if y < 0 {
|
continue;
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut x = sample.x as i32;
|
|
||||||
if x > width - 1 {
|
|
||||||
x = width - 1;
|
|
||||||
} else if x < 0 {
|
|
||||||
x = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let p = self.img_pixels[(x + (y * width)) as usize];
|
let p = self.img_pixels[(x + (y * width)) as usize];
|
||||||
@@ -230,7 +235,7 @@ impl AniMeImage {
|
|||||||
/// updated via scale, position, or angle then displayed again after `update()`.
|
/// updated via scale, position, or angle then displayed again after `update()`.
|
||||||
pub fn from_png(
|
pub fn from_png(
|
||||||
path: &Path,
|
path: &Path,
|
||||||
scale: Vec2,
|
scale: f32,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
translation: Vec2,
|
translation: Vec2,
|
||||||
bright: f32,
|
bright: f32,
|
||||||
@@ -256,7 +261,7 @@ impl AniMeImage {
|
|||||||
_ => return Err(AnimeError::Format),
|
_ => return Err(AnimeError::Format),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut matrix = AniMeImage::new(scale, angle, translation, bright, pixels, width);
|
let mut matrix = AniMeImage::new(Vec2::new(scale, scale), angle, translation, bright, pixels, width);
|
||||||
|
|
||||||
matrix.update();
|
matrix.update();
|
||||||
Ok(matrix)
|
Ok(matrix)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ pub mod error;
|
|||||||
// packet data
|
// packet data
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub enum AniMeSequence {
|
pub enum AniMeBlock {
|
||||||
/// Full gif sequence. Immutable.
|
/// Full gif sequence. Immutable.
|
||||||
Animation(AniMeGif),
|
Animation(AniMeGif),
|
||||||
/// Basic image, can have properties changed
|
/// Basic image, can have properties changed
|
||||||
@@ -37,15 +37,15 @@ pub enum AniMeSequence {
|
|||||||
Pause(Duration),
|
Pause(Duration),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AniMeSequence {
|
impl AniMeBlock {
|
||||||
pub fn gif(file: &Path, brightness: f32) -> Result<Self, AnimeError> {
|
pub fn asus_gif(file: &Path, brightness: f32) -> Result<Self, AnimeError> {
|
||||||
let frames = AniMeGif::new(file, brightness)?;
|
let frames = AniMeGif::create_diagonal_gif(file, brightness)?;
|
||||||
Ok(Self::Animation(frames))
|
Ok(Self::Animation(frames))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn png(
|
pub fn png(
|
||||||
file: &Path,
|
file: &Path,
|
||||||
scale: Vec2,
|
scale: f32,
|
||||||
angle: f32,
|
angle: f32,
|
||||||
translation: Vec2,
|
translation: Vec2,
|
||||||
brightness: f32,
|
brightness: f32,
|
||||||
@@ -55,16 +55,34 @@ impl AniMeSequence {
|
|||||||
Ok(Self::Image(Box::new(data)))
|
Ok(Self::Image(Box::new(data)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn image_gif(
|
||||||
|
file: &Path,
|
||||||
|
scale: f32,
|
||||||
|
angle: f32,
|
||||||
|
translation: Vec2,
|
||||||
|
brightness: f32,
|
||||||
|
) -> Result<Self, AnimeError> {
|
||||||
|
let frames = AniMeGif::create_png_gif(file, scale, angle, translation, brightness)?;
|
||||||
|
Ok(Self::Animation(frames))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_animation(&self) -> Option<&AniMeGif> {
|
pub fn get_animation(&self) -> Option<&AniMeGif> {
|
||||||
match self {
|
match self {
|
||||||
AniMeSequence::Animation(anim) => Some(anim),
|
AniMeBlock::Animation(anim) => Some(anim),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_image(&self) -> Option<&AniMeDataBuffer> {
|
pub fn get_image(&self) -> Option<&AniMeDataBuffer> {
|
||||||
match self {
|
match self {
|
||||||
AniMeSequence::Image(image) => Some(image),
|
AniMeBlock::Image(image) => Some(image),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_pause(&self) -> Option<Duration> {
|
||||||
|
match self {
|
||||||
|
AniMeBlock::Pause(pause) => Some(*pause),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user