mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
anime: initial system config work
This commit is contained in:
@@ -16,7 +16,7 @@ pub enum AnimeError {
|
||||
/// The input was incorrect size, expected size is `IncorrectSize(width, height)`
|
||||
IncorrectSize(u32, u32),
|
||||
#[cfg(feature = "dbus")]
|
||||
Zbus(fdo::Error)
|
||||
Zbus(fdo::Error),
|
||||
}
|
||||
|
||||
impl fmt::Display for AnimeError {
|
||||
@@ -68,4 +68,4 @@ impl From<AnimeError> for fdo::Error {
|
||||
fn from(err: AnimeError) -> Self {
|
||||
fdo::Error::Failed(format!("{}", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,4 @@ pub use sequencer::*;
|
||||
pub mod error;
|
||||
|
||||
/// Provides const methods to create the USB HID control packets
|
||||
pub mod usb;
|
||||
pub mod usb;
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::{
|
||||
use glam::Vec2;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::{error::AnimeError, AnimeDataBuffer, AnimeGif, AnimeImage, AnimTime};
|
||||
use crate::{error::AnimeError, AnimTime, AnimeDataBuffer, AnimeGif, AnimeImage};
|
||||
|
||||
/// All the possible AniMe actions that can be used. This enum is intended to be
|
||||
/// a helper for loading up `ActionData`.
|
||||
@@ -40,7 +40,7 @@ pub enum AnimeAction {
|
||||
|
||||
/// All the possible AniMe actions that can be used. The enum is intended to be
|
||||
/// used in a array allowing the user to cycle through a series of actions.
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub enum ActionData {
|
||||
/// Full gif sequence. Immutable.
|
||||
Animation(AnimeGif),
|
||||
@@ -58,6 +58,50 @@ pub enum ActionData {
|
||||
Matrix,
|
||||
}
|
||||
|
||||
impl ActionData {
|
||||
pub fn from_anime_action(action: &AnimeAction) -> Result<ActionData, AnimeError> {
|
||||
let a = match action {
|
||||
AnimeAction::AsusAnimation {
|
||||
file,
|
||||
time: duration,
|
||||
brightness,
|
||||
} => ActionData::Animation(AnimeGif::create_diagonal_gif(
|
||||
&file,
|
||||
*duration,
|
||||
*brightness,
|
||||
)?),
|
||||
AnimeAction::ImageAnimation {
|
||||
file,
|
||||
scale,
|
||||
angle,
|
||||
translation,
|
||||
time: duration,
|
||||
brightness,
|
||||
} => ActionData::Animation(AnimeGif::create_png_gif(
|
||||
&file,
|
||||
*scale,
|
||||
*angle,
|
||||
*translation,
|
||||
*duration,
|
||||
*brightness,
|
||||
)?),
|
||||
AnimeAction::Image {
|
||||
file,
|
||||
scale,
|
||||
angle,
|
||||
translation,
|
||||
brightness,
|
||||
} => {
|
||||
let image = AnimeImage::from_png(&file, *scale, *angle, *translation, *brightness)?;
|
||||
let data = <AnimeDataBuffer>::from(&image);
|
||||
ActionData::Image(Box::new(data))
|
||||
}
|
||||
AnimeAction::Pause(duration) => ActionData::Pause(*duration),
|
||||
};
|
||||
Ok(a)
|
||||
}
|
||||
}
|
||||
|
||||
/// An optimised precomputed set of actions that the user can cycle through
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Sequences(Vec<ActionData>);
|
||||
|
||||
@@ -24,7 +24,7 @@ pub const fn pkts_for_init() -> [[u8; PACKET_SIZE]; 2] {
|
||||
let mut count = 0;
|
||||
while count < INIT_STR.len() {
|
||||
packets[0][count] = INIT_STR[count];
|
||||
count +=1;
|
||||
count += 1;
|
||||
}
|
||||
//
|
||||
packets[1][0] = DEV_PAGE; // write it to be sure?
|
||||
|
||||
Reference in New Issue
Block a user