mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Add "Unknown" to (not really) supported AniMe list
Intention is to allow users to at least control the power state of the device (turn off) if the phyciscal display isn't yet supported. Partial address of #354
This commit is contained in:
@@ -38,6 +38,7 @@ pub struct AnimePowerStates {
|
||||
pub enum AnimeType {
|
||||
GA401,
|
||||
GA402,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl AnimeType {
|
||||
@@ -45,6 +46,7 @@ impl AnimeType {
|
||||
pub fn width(&self) -> usize {
|
||||
match self {
|
||||
AnimeType::GA401 | AnimeType::GA402 => 74,
|
||||
AnimeType::Unknown => 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +55,7 @@ impl AnimeType {
|
||||
match self {
|
||||
AnimeType::GA401 => 36,
|
||||
AnimeType::GA402 => 39,
|
||||
AnimeType::Unknown => 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +64,7 @@ impl AnimeType {
|
||||
match self {
|
||||
AnimeType::GA401 => PANE_LEN * 2,
|
||||
AnimeType::GA402 => PANE_LEN * 3,
|
||||
AnimeType::Unknown => 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,6 +129,7 @@ impl TryFrom<AnimeDataBuffer> for AnimePacketType {
|
||||
let mut buffers = match anime.anime {
|
||||
AnimeType::GA401 => vec![[0; 640]; 2],
|
||||
AnimeType::GA402 => vec![[0; 640]; 3],
|
||||
AnimeType::Unknown => vec![[0; 640]; 1],
|
||||
};
|
||||
|
||||
for (idx, chunk) in anime.data.as_slice().chunks(PANE_LEN).enumerate() {
|
||||
|
||||
@@ -139,6 +139,7 @@ impl AnimeDiagonal {
|
||||
match anime_type {
|
||||
AnimeType::GA401 => self.to_ga401_packets(),
|
||||
AnimeType::GA402 => self.to_ga402_packets(),
|
||||
AnimeType::Unknown => self.to_unknown_packets(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,6 +289,11 @@ impl AnimeDiagonal {
|
||||
|
||||
AnimeDataBuffer::from_vec(crate::AnimeType::GA402, buf)
|
||||
}
|
||||
|
||||
fn to_unknown_packets(&self) -> Result<AnimeDataBuffer> {
|
||||
let buf = vec![0u8; AnimeType::Unknown.data_length()];
|
||||
AnimeDataBuffer::from_vec(crate::AnimeType::Unknown, buf)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -118,6 +118,7 @@ impl AnimeImage {
|
||||
match anime_type {
|
||||
AnimeType::GA401 => 0.8,
|
||||
AnimeType::GA402 => 0.77,
|
||||
AnimeType::Unknown => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +134,7 @@ impl AnimeImage {
|
||||
match anime_type {
|
||||
AnimeType::GA401 => 0.3,
|
||||
AnimeType::GA402 => 0.283,
|
||||
AnimeType::Unknown => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +175,7 @@ impl AnimeImage {
|
||||
// and then their offset grows by one every two rows
|
||||
(y + 1) / 2 - 5
|
||||
}
|
||||
AnimeType::Unknown => 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +209,7 @@ impl AnimeImage {
|
||||
}
|
||||
39 - y / 2
|
||||
}
|
||||
AnimeType::Unknown => 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +219,7 @@ impl AnimeImage {
|
||||
// 33.0 = Longest row LED count (physical) plus half-pixel offset
|
||||
AnimeType::GA401 => (33.0 + 0.5) * Self::scale_x(anime_type),
|
||||
AnimeType::GA402 => (35.0 + 0.5) * Self::scale_x(anime_type),
|
||||
AnimeType::Unknown => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,6 +228,7 @@ impl AnimeImage {
|
||||
match anime_type {
|
||||
AnimeType::GA401 => 55,
|
||||
AnimeType::GA402 => 61,
|
||||
AnimeType::Unknown => 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,6 +239,7 @@ impl AnimeImage {
|
||||
AnimeType::GA401 => (54.0 + 1.0) * Self::scale_y(anime_type),
|
||||
// GA402 may not have dead pixels and require only the physical LED count
|
||||
AnimeType::GA402 => 61.0 * Self::scale_y(anime_type),
|
||||
AnimeType::Unknown => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,6 +253,7 @@ impl AnimeImage {
|
||||
},
|
||||
// GA402 does not have padding, equivalent to width
|
||||
AnimeType::GA402 => AnimeImage::width(anime_type, y),
|
||||
AnimeType::Unknown => 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ pub fn get_anime_type() -> Result<AnimeType, AnimeError> {
|
||||
} else if board_name.contains("GA402R") {
|
||||
return Ok(AnimeType::GA402);
|
||||
}
|
||||
Err(AnimeError::UnsupportedDevice)
|
||||
log::warn!("AniMe Matrix device found but not yet supported");
|
||||
Ok(AnimeType::Unknown)
|
||||
}
|
||||
|
||||
/// Get the two device initialization packets. These are required for device
|
||||
|
||||
Reference in New Issue
Block a user