anime: prep rog-anime for publish, rename *all* AniMe~ to Anime

This commit is contained in:
Luke D Jones
2021-04-11 10:46:05 +12:00
parent e515741efa
commit 0657c6cc74
29 changed files with 476 additions and 383 deletions

View File

@@ -18,6 +18,6 @@ yansi-term = "^0.1"
[dev-dependencies]
tinybmp = "^0.2.3"
glam = "*"
glam = "0.14.0"
rog_dbus = { path = "../rog-dbus" }
gif = "^0.11.2"

View File

@@ -1,6 +1,6 @@
use std::{env, error::Error, path::Path, process::exit};
use rog_anime::{AniMeDataBuffer, AniMeDiagonal};
use rog_anime::{AnimeDataBuffer, AnimeDiagonal};
use rog_dbus::AuraDbusClient;
fn main() -> Result<(), Box<dyn Error>> {
@@ -14,12 +14,12 @@ fn main() -> Result<(), Box<dyn Error>> {
}
let matrix =
AniMeDiagonal::from_png(Path::new(&args[1]), None, args[2].parse::<f32>().unwrap())?;
AnimeDiagonal::from_png(Path::new(&args[1]), None, args[2].parse::<f32>().unwrap())?;
client
.proxies()
.anime()
.write(<AniMeDataBuffer>::from(&matrix))
.write(<AnimeDataBuffer>::from(&matrix))
.unwrap();
Ok(())

View File

@@ -1,6 +1,6 @@
use std::{thread::sleep, time::Duration};
use rog_anime::{AniMeDataBuffer, AniMeDiagonal};
use rog_anime::{AnimeDataBuffer, AnimeDiagonal};
use rog_dbus::AuraDbusClient;
// In usable data:
@@ -12,7 +12,7 @@ fn main() {
let (client, _) = AuraDbusClient::new().unwrap();
for step in (2..50).rev() {
let mut matrix = AniMeDiagonal::new(None);
let mut matrix = AnimeDiagonal::new(None);
for c in (0..60).into_iter().step_by(step) {
for i in matrix.get_mut().iter_mut() {
i[c] = 50;
@@ -25,7 +25,7 @@ fn main() {
}
}
let m = <AniMeDataBuffer>::from(&matrix);
let m = <AnimeDataBuffer>::from(&matrix);
client.proxies().anime().write(m).unwrap();
sleep(Duration::from_millis(300));
}

View File

@@ -1,4 +1,4 @@
use rog_anime::{AniMeDataBuffer, AniMeGrid};
use rog_anime::{AnimeDataBuffer, AnimeGrid};
use rog_dbus::AuraDbusClient;
// In usable data:
@@ -8,7 +8,7 @@ use rog_dbus::AuraDbusClient;
fn main() {
let (client, _) = AuraDbusClient::new().unwrap();
let mut matrix = AniMeGrid::new(None);
let mut matrix = AnimeGrid::new(None);
let tmp = matrix.get_mut();
let mut i = 0;
@@ -38,7 +38,7 @@ fn main() {
}
}
let matrix = <AniMeDataBuffer>::from(matrix);
let matrix = <AnimeDataBuffer>::from(matrix);
client.proxies().anime().write(matrix).unwrap();
}

View File

@@ -1,4 +1,4 @@
use rog_anime::AniMeDataBuffer;
use rog_anime::AnimeDataBuffer;
use rog_dbus::AuraDbusClient;
// In usable data:
@@ -6,7 +6,7 @@ use rog_dbus::AuraDbusClient;
fn main() {
let (client, _) = AuraDbusClient::new().unwrap();
let mut matrix = AniMeDataBuffer::new();
let mut matrix = AnimeDataBuffer::new();
matrix.get_mut()[1] = 100; // start = 1
for n in matrix.get_mut()[2..32].iter_mut() {
*n = 250;

View File

@@ -1,7 +1,7 @@
use std::{env, error::Error, path::Path, process::exit};
use rog_anime::{
AniMeDataBuffer, {AniMeImage, Vec2},
AnimeDataBuffer, {AnimeImage, Vec2},
};
use rog_dbus::AuraDbusClient;
@@ -15,7 +15,7 @@ fn main() -> Result<(), Box<dyn Error>> {
exit(-1);
}
let matrix = AniMeImage::from_png(
let matrix = AnimeImage::from_png(
Path::new(&args[1]),
args[2].parse::<f32>().unwrap(),
args[3].parse::<f32>().unwrap(),
@@ -29,7 +29,7 @@ fn main() -> Result<(), Box<dyn Error>> {
client
.proxies()
.anime()
.write(<AniMeDataBuffer>::from(&matrix))
.write(<AnimeDataBuffer>::from(&matrix))
.unwrap();
Ok(())

View File

@@ -3,7 +3,7 @@ use std::{
};
use rog_anime::{
AniMeDataBuffer, {AniMeImage, Vec2},
AnimeDataBuffer, {AnimeImage, Vec2},
};
use rog_dbus::AuraDbusClient;
@@ -17,7 +17,7 @@ fn main() -> Result<(), Box<dyn Error>> {
exit(-1);
}
let mut matrix = AniMeImage::from_png(
let mut matrix = AnimeImage::from_png(
Path::new(&args[1]),
args[2].parse::<f32>().unwrap(),
args[3].parse::<f32>().unwrap(),
@@ -38,7 +38,7 @@ fn main() -> Result<(), Box<dyn Error>> {
client
.proxies()
.anime()
.write(<AniMeDataBuffer>::from(&matrix))
.write(<AnimeDataBuffer>::from(&matrix))
.unwrap();
sleep(Duration::from_micros(500));
}

View File

@@ -3,18 +3,18 @@ use rog_types::error::AuraError;
use std::str::FromStr;
#[derive(Copy, Clone, Debug)]
pub enum AniMeStatusValue {
pub enum AnimeStatusValue {
On,
Off,
}
impl FromStr for AniMeStatusValue {
impl FromStr for AnimeStatusValue {
type Err = AuraError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let s = s.to_lowercase();
match s.as_str() {
"on" => Ok(AniMeStatusValue::On),
"off" => Ok(AniMeStatusValue::Off),
"on" => Ok(AnimeStatusValue::On),
"off" => Ok(AnimeStatusValue::Off),
_ => {
print!("Invalid argument, must be one of: on, off");
Err(AuraError::ParseAnime)
@@ -22,17 +22,17 @@ impl FromStr for AniMeStatusValue {
}
}
}
impl From<AniMeStatusValue> for bool {
fn from(value: AniMeStatusValue) -> Self {
impl From<AnimeStatusValue> for bool {
fn from(value: AnimeStatusValue) -> Self {
match value {
AniMeStatusValue::On => true,
AniMeStatusValue::Off => false,
AnimeStatusValue::On => true,
AnimeStatusValue::Off => false,
}
}
}
#[derive(Options)]
pub struct AniMeLeds {
pub struct AnimeLeds {
#[options(help = "print help message")]
help: bool,
#[options(
@@ -44,37 +44,37 @@ pub struct AniMeLeds {
)]
led_brightness: u8,
}
impl AniMeLeds {
impl AnimeLeds {
pub fn led_brightness(&self) -> u8 {
self.led_brightness
}
}
#[derive(Options)]
pub struct AniMeCommand {
pub struct AnimeCommand {
#[options(help = "print help message")]
pub help: bool,
#[options(
meta = "",
help = "turn on/off the panel (accept/reject write requests)"
)]
pub turn: Option<AniMeStatusValue>,
pub turn: Option<AnimeStatusValue>,
#[options(meta = "", help = "turn on/off the panel at boot (with Asus effect)")]
pub boot: Option<AniMeStatusValue>,
pub boot: Option<AnimeStatusValue>,
#[options(command)]
pub command: Option<AniMeActions>,
pub command: Option<AnimeActions>,
}
#[derive(Options)]
pub enum AniMeActions {
pub enum AnimeActions {
#[options(help = "change all leds brightness")]
Leds(AniMeLeds),
Leds(AnimeLeds),
#[options(help = "display an 8bit greyscale png")]
Image(AniMeImage),
Image(AnimeImage),
}
#[derive(Options)]
pub struct AniMeImage {
pub struct AnimeImage {
#[options(help = "print help message")]
pub help: bool,
#[options(meta = "", help = "full path to the png to display")]

View File

@@ -2,9 +2,9 @@ mod anime_cli;
mod aura_cli;
use crate::aura_cli::{LedBrightness, SetAuraBuiltin};
use anime_cli::{AniMeActions, AniMeCommand};
use anime_cli::{AnimeActions, AnimeCommand};
use gumdrop::{Opt, Options};
use rog_anime::{AniMeDataBuffer, AniMeImage, Vec2, ANIME_DATA_LEN};
use rog_anime::{AnimeDataBuffer, AnimeImage, Vec2, ANIME_DATA_LEN};
use rog_dbus::AuraDbusClient;
use rog_types::{
aura_modes::{self, AuraEffect, AuraModeNum},
@@ -49,7 +49,7 @@ enum CliCommand {
#[options(help = "Set the graphics mode")]
Graphics(GraphicsCommand),
#[options(name = "anime", help = "Manage AniMe Matrix")]
AniMe(AniMeCommand),
Anime(AnimeCommand),
#[options(help = "Change bios settings")]
Bios(BiosCommand),
}
@@ -145,7 +145,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some(CliCommand::LedMode(mode)) => handle_led_mode(&dbus, &supported.keyboard_led, &mode)?,
Some(CliCommand::Profile(cmd)) => handle_profile(&dbus, &supported.fan_cpu_ctrl, &cmd)?,
Some(CliCommand::Graphics(cmd)) => do_gfx(&dbus, &supported.rog_bios_ctrl, cmd)?,
Some(CliCommand::AniMe(cmd)) => {
Some(CliCommand::Anime(cmd)) => {
if (cmd.command.is_none() && cmd.boot.is_none() && cmd.turn.is_none()) || cmd.help {
println!("Missing arg or command\n\n{}", cmd.self_usage());
if let Some(lst) = cmd.self_command_list() {
@@ -160,13 +160,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
if let Some(action) = cmd.command {
match action {
AniMeActions::Leds(anime_leds) => {
let data = AniMeDataBuffer::from_vec(
AnimeActions::Leds(anime_leds) => {
let data = AnimeDataBuffer::from_vec(
[anime_leds.led_brightness(); ANIME_DATA_LEN].to_vec(),
);
dbus.proxies().anime().write(data)?;
}
AniMeActions::Image(image) => {
AnimeActions::Image(image) => {
if image.help_requested() {
println!("Missing arg or command\n\n{}", image.self_usage());
if let Some(lst) = image.self_command_list() {
@@ -175,7 +175,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
std::process::exit(1);
}
let matrix = AniMeImage::from_png(
let matrix = AnimeImage::from_png(
Path::new(&image.path),
image.scale,
image.angle,
@@ -185,7 +185,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
dbus.proxies()
.anime()
.write(<AniMeDataBuffer>::from(&matrix))
.write(<AnimeDataBuffer>::from(&matrix))
.unwrap();
}
}