mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Added working implementation of the G14 Slash ledstrip
This commit is contained in:
@@ -4,11 +4,10 @@ use serde_derive::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
#[cfg(feature = "dbus")]
|
||||
use zbus::zvariant::Type;
|
||||
use zbus::zvariant::{OwnedValue, Value};
|
||||
|
||||
use crate::error::SlashError;
|
||||
|
||||
#[typeshare]
|
||||
#[cfg_attr(feature = "dbus", derive(Type), zvariant(signature = "s"))]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub enum SlashType {
|
||||
GA403,
|
||||
@@ -26,8 +25,8 @@ impl FromStr for SlashType {
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
// #[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Debug, PartialEq, Eq, Copy, Clone, Deserialize, Serialize)]
|
||||
pub enum SlashMode {
|
||||
Bounce = 0x10,
|
||||
Slash = 0x12,
|
||||
@@ -46,6 +45,12 @@ pub enum SlashMode {
|
||||
Buzzer = 0x44,
|
||||
}
|
||||
|
||||
impl Default for SlashMode {
|
||||
fn default() -> Self {
|
||||
SlashMode::Flow
|
||||
}
|
||||
}
|
||||
|
||||
impl SlashMode {
|
||||
pub const fn to_string(&self) -> &str
|
||||
{
|
||||
@@ -67,6 +72,28 @@ impl SlashMode {
|
||||
SlashMode::Buzzer => "Buzzer",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_string(value: &str) -> Self
|
||||
{
|
||||
match value {
|
||||
"Bounce" => SlashMode::Bounce,
|
||||
"Slash" => SlashMode::Slash,
|
||||
"Loading" => SlashMode::Loading,
|
||||
"BitStream" => SlashMode::BitStream,
|
||||
"Transmission" => SlashMode::Transmission,
|
||||
"Flow" => SlashMode::Flow,
|
||||
"Flux" => SlashMode::Flux,
|
||||
"Phantom" => SlashMode::Phantom,
|
||||
"Spectrum" => SlashMode::Spectrum,
|
||||
"Hazard" => SlashMode::Hazard,
|
||||
"Interfacing" => SlashMode::Interfacing,
|
||||
"Ramp" => SlashMode::Ramp,
|
||||
"GameOver" => SlashMode::GameOver,
|
||||
"Start" => SlashMode::Start,
|
||||
"Buzzer" => SlashMode::Buzzer,
|
||||
_ => SlashMode::Bounce
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn list() -> [&'static str; 15] {
|
||||
[
|
||||
@@ -89,9 +116,6 @@ impl SlashMode {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO: move this out
|
||||
#[typeshare]
|
||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||
#[typeshare]
|
||||
@@ -100,6 +124,6 @@ pub struct DeviceState {
|
||||
pub slash_enabled: bool,
|
||||
pub slash_brightness: u8,
|
||||
pub slash_interval: u8,
|
||||
pub slash_mode: u8,
|
||||
pub slash_mode: SlashMode,
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
use dmi_id::DMIID;
|
||||
#[cfg(feature = "dbus")]
|
||||
use crate::error::SlashError;
|
||||
use crate::SlashType;
|
||||
use crate::{SlashMode, SlashType};
|
||||
|
||||
const PACKET_SIZE: usize = 128;
|
||||
const DEV_PAGE: u8 = 0x5e;
|
||||
@@ -76,7 +76,7 @@ pub const fn pkt_save() -> SlashUsbPacket {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn pkt_set_mode(mode: u8) -> [SlashUsbPacket; 2] {
|
||||
pub const fn pkt_set_mode(mode: SlashMode) -> [SlashUsbPacket; 2] {
|
||||
let mut pkt1 = [0;PACKET_SIZE];
|
||||
pkt1[0] = DEV_PAGE;
|
||||
pkt1[1] = 0x02;
|
||||
@@ -91,7 +91,7 @@ pub const fn pkt_set_mode(mode: u8) -> [SlashUsbPacket; 2] {
|
||||
pkt2[3] = 0x00;
|
||||
pkt2[4] = 0x0C;
|
||||
pkt2[5] = 0x01;
|
||||
pkt2[6] = mode;
|
||||
pkt2[6] = mode as u8;
|
||||
pkt2[7] = 0x02;
|
||||
pkt2[8] = 0x19;
|
||||
pkt2[9] = 0x03;
|
||||
|
||||
Reference in New Issue
Block a user