Files
asusctl/rog-anime/src/diagonal.rs
Luke D. Jones ff76c356c5 First pass of Anime update for new matrix display
Co-authored with @I-Al-Istannen

Part of #189
2022-07-15 20:37:30 +12:00

391 lines
20 KiB
Rust

use std::{path::Path, time::Duration};
use crate::{
data::{AnimeDataBuffer, ANIME_GA401_DATA_LEN},
error::AnimeError,
AnimeType, ANIME_GA402_DATA_LEN,
};
const WIDTH: usize = 74;
// TODO: Change for GA402
const HEIGHT: usize = 36;
/// Mostly intended to be used with ASUS gifs, but can be used for other purposes (like images)
#[derive(Debug, Clone)]
pub struct AnimeDiagonal([[u8; WIDTH]; HEIGHT], Option<Duration>);
impl Default for AnimeDiagonal {
#[inline]
fn default() -> Self {
Self::new(None)
}
}
impl AnimeDiagonal {
#[inline]
pub fn new(duration: Option<Duration>) -> Self {
Self([[0u8; WIDTH]; HEIGHT], duration)
}
#[inline]
pub fn get_mut(&mut self) -> &mut [[u8; WIDTH]; HEIGHT] {
&mut self.0
}
/// Get a full diagonal row where `x` `y` is the starting point and `len` is the length of data.
fn get_row(&self, x: usize, y: usize, len: usize) -> Vec<u8> {
let mut buf = Vec::with_capacity(len);
for i in 0..len {
let val = self.0[HEIGHT - y - i - 1][x + i];
buf.push(val);
}
buf
}
/// Generate the base image from inputs. The result can be displayed as is or
/// updated via scale, position, or angle then displayed again after `update()`.
#[inline]
pub fn from_png(
path: &Path,
duration: Option<Duration>,
bright: f32,
) -> Result<Self, AnimeError> {
let data = std::fs::read(path)?;
let data = std::io::Cursor::new(data);
let decoder = png_pong::Decoder::new(data)?.into_steps();
let png_pong::Step { raster, delay: _ } = decoder.last().ok_or(AnimeError::NoFrames)??;
let mut matrix = AnimeDiagonal::new(duration);
match raster {
png_pong::PngRaster::Gray8(ras) => {
Self::pixels_from_8bit(ras, &mut matrix, bright, true)
}
png_pong::PngRaster::Graya8(ras) => {
Self::pixels_from_8bit(ras, &mut matrix, bright, true)
}
png_pong::PngRaster::Rgb8(ras) => {
Self::pixels_from_8bit(ras, &mut matrix, bright, false)
}
png_pong::PngRaster::Rgba8(ras) => {
Self::pixels_from_8bit(ras, &mut matrix, bright, false)
}
png_pong::PngRaster::Gray16(ras) => {
Self::pixels_from_16bit(ras, &mut matrix, bright, true)
}
png_pong::PngRaster::Rgb16(ras) => {
Self::pixels_from_16bit(ras, &mut matrix, bright, false)
}
png_pong::PngRaster::Graya16(ras) => {
Self::pixels_from_16bit(ras, &mut matrix, bright, true)
}
png_pong::PngRaster::Rgba16(ras) => {
Self::pixels_from_16bit(ras, &mut matrix, bright, false)
}
_ => return Err(AnimeError::Format),
};
Ok(matrix)
}
fn pixels_from_8bit<P>(ras: pix::Raster<P>, matrix: &mut AnimeDiagonal, bright: f32, grey: bool)
where
P: pix::el::Pixel<Chan = pix::chan::Ch8>,
{
let width = ras.width();
for (y, row) in ras.pixels().chunks(width as usize).enumerate() {
for (x, px) in row.iter().enumerate() {
let v = if grey {
<u8>::from(px.one()) as f32
} else {
(<u8>::from(px.one()) / 3) as f32
+ (<u8>::from(px.two()) / 3) as f32
+ (<u8>::from(px.three()) / 3) as f32
};
matrix.0[y][x] = (v * bright) as u8;
}
}
}
fn pixels_from_16bit<P>(
ras: pix::Raster<P>,
matrix: &mut AnimeDiagonal,
bright: f32,
grey: bool,
) where
P: pix::el::Pixel<Chan = pix::chan::Ch16>,
{
let width = ras.width();
for (y, row) in ras.pixels().chunks(width as usize).enumerate() {
for (x, px) in row.iter().enumerate() {
let v = if grey {
(<u16>::from(px.one()) >> 8) as f32
} else {
((<u16>::from(px.one()) / 3) >> 8) as f32
+ ((<u16>::from(px.two()) / 3) >> 8) as f32
+ ((<u16>::from(px.three()) / 3) >> 8) as f32
};
matrix.0[y][x] = (v * bright) as u8;
}
}
}
/// Convert to a data buffer that can be sent over dbus
#[inline]
pub fn into_data_buffer(&self, anime_type: AnimeType) -> AnimeDataBuffer {
match anime_type {
AnimeType::GA401 => self.into_ga401_packets(),
AnimeType::GA402 => self.into_ga402_packets(),
}
}
/// Do conversion from the nested Vec in AnimeMatrix to the two required
/// packets suitable for sending over USB
fn into_ga401_packets(&self) -> AnimeDataBuffer {
let mut buf = vec![0u8; ANIME_GA401_DATA_LEN];
buf[1..=32].copy_from_slice(&self.get_row(0, 3, 32));
buf[34..=66].copy_from_slice(&self.get_row(0, 2, 33));
buf[69..=101].copy_from_slice(&self.get_row(1, 2, 33)); // ?!
buf[102..=134].copy_from_slice(&self.get_row(1, 1, 33));
buf[137..=169].copy_from_slice(&self.get_row(2, 1, 33));
buf[170..=202].copy_from_slice(&self.get_row(2, 0, 33));
buf[204..=236].copy_from_slice(&self.get_row(3, 0, 33));
buf[237..=268].copy_from_slice(&self.get_row(4, 0, 32));
buf[270..=301].copy_from_slice(&self.get_row(5, 0, 32));
buf[302..=332].copy_from_slice(&self.get_row(6, 0, 31));
buf[334..=364].copy_from_slice(&self.get_row(7, 0, 31));
buf[365..=394].copy_from_slice(&self.get_row(8, 0, 30));
buf[396..=425].copy_from_slice(&self.get_row(9, 0, 30));
buf[426..=454].copy_from_slice(&self.get_row(10, 0, 29));
buf[456..=484].copy_from_slice(&self.get_row(11, 0, 29));
buf[485..=512].copy_from_slice(&self.get_row(12, 0, 28));
buf[514..=541].copy_from_slice(&self.get_row(13, 0, 28));
buf[542..=568].copy_from_slice(&self.get_row(14, 0, 27));
buf[570..=596].copy_from_slice(&self.get_row(15, 0, 27));
buf[597..=622].copy_from_slice(&self.get_row(16, 0, 26));
buf[624..=649].copy_from_slice(&self.get_row(17, 0, 26));
buf[650..=674].copy_from_slice(&self.get_row(18, 0, 25));
buf[676..=700].copy_from_slice(&self.get_row(19, 0, 25));
buf[701..=724].copy_from_slice(&self.get_row(20, 0, 24));
buf[726..=749].copy_from_slice(&self.get_row(21, 0, 24));
buf[750..=772].copy_from_slice(&self.get_row(22, 0, 23));
buf[774..=796].copy_from_slice(&self.get_row(23, 0, 23));
buf[797..=818].copy_from_slice(&self.get_row(24, 0, 22));
buf[820..=841].copy_from_slice(&self.get_row(25, 0, 22));
buf[842..=862].copy_from_slice(&self.get_row(26, 0, 21));
buf[864..=884].copy_from_slice(&self.get_row(27, 0, 21));
buf[885..=904].copy_from_slice(&self.get_row(28, 0, 20));
buf[906..=925].copy_from_slice(&self.get_row(29, 0, 20));
buf[926..=944].copy_from_slice(&self.get_row(30, 0, 19));
buf[946..=964].copy_from_slice(&self.get_row(31, 0, 19));
buf[965..=982].copy_from_slice(&self.get_row(32, 0, 18));
buf[984..=1001].copy_from_slice(&self.get_row(33, 0, 18));
buf[1002..=1018].copy_from_slice(&self.get_row(34, 0, 17));
buf[1020..=1036].copy_from_slice(&self.get_row(35, 0, 17));
buf[1037..=1052].copy_from_slice(&self.get_row(36, 0, 16));
buf[1054..=1069].copy_from_slice(&self.get_row(37, 0, 16));
buf[1070..=1084].copy_from_slice(&self.get_row(38, 0, 15));
buf[1086..=1100].copy_from_slice(&self.get_row(39, 0, 15));
buf[1101..=1114].copy_from_slice(&self.get_row(40, 0, 14));
buf[1116..=1129].copy_from_slice(&self.get_row(41, 0, 14));
buf[1130..=1142].copy_from_slice(&self.get_row(42, 0, 13));
buf[1144..=1156].copy_from_slice(&self.get_row(43, 0, 13));
buf[1157..=1168].copy_from_slice(&self.get_row(44, 0, 12));
buf[1170..=1181].copy_from_slice(&self.get_row(45, 0, 12));
buf[1182..=1192].copy_from_slice(&self.get_row(46, 0, 11));
buf[1194..=1204].copy_from_slice(&self.get_row(47, 0, 11));
buf[1205..=1214].copy_from_slice(&self.get_row(48, 0, 10));
buf[1216..=1225].copy_from_slice(&self.get_row(49, 0, 10));
buf[1226..=1234].copy_from_slice(&self.get_row(50, 0, 9));
buf[1236..=1244].copy_from_slice(&self.get_row(51, 0, 9));
AnimeDataBuffer::from_vec(crate::AnimeType::GA401, buf)
}
fn into_ga402_packets(&self) -> AnimeDataBuffer {
let mut buf = vec![0u8; ANIME_GA402_DATA_LEN];
let mut start_index: usize = 0;
fn copy_slice(
buf: &mut Vec<u8>,
anime: &AnimeDiagonal,
x: usize,
y: usize,
start_index: &mut usize,
len: usize,
) {
buf[*start_index..*start_index + len].copy_from_slice(&anime.get_row(x, y, len));
*start_index += len;
}
let b = &mut buf;
let a = &self;
copy_slice(b, a, 0, 5, &mut start_index, 34);
copy_slice(b, a, 1, 5, &mut start_index, 34);
copy_slice(b, a, 1, 4, &mut start_index, 34);
copy_slice(b, a, 2, 4, &mut start_index, 34);
copy_slice(b, a, 2, 3, &mut start_index, 34);
copy_slice(b, a, 3, 3, &mut start_index, 34);
copy_slice(b, a, 3, 2, &mut start_index, 34);
copy_slice(b, a, 4, 2, &mut start_index, 34);
copy_slice(b, a, 4, 1, &mut start_index, 34);
copy_slice(b, a, 5, 1, &mut start_index, 34);
copy_slice(b, a, 5, 0, &mut start_index, 34);
copy_slice(b, a, 6, 0, &mut start_index, 34);
copy_slice(b, a, 7, 0, &mut start_index, 33);
copy_slice(b, a, 8, 0, &mut start_index, 33);
copy_slice(b, a, 9, 0, &mut start_index, 32);
copy_slice(b, a, 10, 0, &mut start_index, 32);
copy_slice(b, a, 11, 0, &mut start_index, 31);
copy_slice(b, a, 12, 0, &mut start_index, 31);
copy_slice(b, a, 13, 0, &mut start_index, 30);
copy_slice(b, a, 14, 0, &mut start_index, 30);
copy_slice(b, a, 15, 0, &mut start_index, 29);
copy_slice(b, a, 16, 0, &mut start_index, 29);
copy_slice(b, a, 17, 0, &mut start_index, 28);
copy_slice(b, a, 18, 0, &mut start_index, 28);
copy_slice(b, a, 19, 0, &mut start_index, 27);
copy_slice(b, a, 20, 0, &mut start_index, 27);
copy_slice(b, a, 21, 0, &mut start_index, 26);
copy_slice(b, a, 22, 0, &mut start_index, 26);
copy_slice(b, a, 23, 0, &mut start_index, 25);
copy_slice(b, a, 24, 0, &mut start_index, 25);
copy_slice(b, a, 25, 0, &mut start_index, 24);
copy_slice(b, a, 26, 0, &mut start_index, 24);
copy_slice(b, a, 27, 0, &mut start_index, 23);
copy_slice(b, a, 28, 0, &mut start_index, 23);
copy_slice(b, a, 29, 0, &mut start_index, 22);
copy_slice(b, a, 30, 0, &mut start_index, 22);
copy_slice(b, a, 31, 0, &mut start_index, 21);
copy_slice(b, a, 32, 0, &mut start_index, 21);
copy_slice(b, a, 33, 0, &mut start_index, 20);
copy_slice(b, a, 34, 0, &mut start_index, 20);
copy_slice(b, a, 35, 0, &mut start_index, 19);
copy_slice(b, a, 36, 0, &mut start_index, 19);
copy_slice(b, a, 37, 0, &mut start_index, 18);
copy_slice(b, a, 38, 0, &mut start_index, 18);
copy_slice(b, a, 39, 0, &mut start_index, 17);
copy_slice(b, a, 40, 0, &mut start_index, 17);
copy_slice(b, a, 41, 0, &mut start_index, 16);
copy_slice(b, a, 42, 0, &mut start_index, 16);
copy_slice(b, a, 43, 0, &mut start_index, 15);
copy_slice(b, a, 44, 0, &mut start_index, 15);
copy_slice(b, a, 45, 0, &mut start_index, 14);
copy_slice(b, a, 46, 0, &mut start_index, 14);
copy_slice(b, a, 47, 0, &mut start_index, 13);
copy_slice(b, a, 48, 0, &mut start_index, 13);
copy_slice(b, a, 49, 0, &mut start_index, 12);
copy_slice(b, a, 50, 0, &mut start_index, 12);
copy_slice(b, a, 51, 0, &mut start_index, 11);
copy_slice(b, a, 52, 0, &mut start_index, 11);
copy_slice(b, a, 53, 0, &mut start_index, 10);
copy_slice(b, a, 54, 0, &mut start_index, 10);
copy_slice(b, a, 55, 0, &mut start_index, 9);
AnimeDataBuffer::from_vec(crate::AnimeType::GA402, buf)
}
}
#[cfg(test)]
mod tests {
use std::path::PathBuf;
use crate::{AnimeDiagonal, AnimePacketType};
#[test]
fn ga401_diagonal_packet_check() {
let pkt0_check = [
0x5e, 0xc0, 0x2, 0x1, 0x0, 0x73, 0x2, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,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 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
];
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("test/ga401-diagonal.png");
let matrix = AnimeDiagonal::from_png(&path, None, 255.0).unwrap();
let data = matrix.into_data_buffer(crate::AnimeType::GA401);
let pkt = AnimePacketType::from(data);
assert_eq!(pkt[0], pkt0_check);
assert_eq!(pkt[1], pkt1_check);
}
}