From 352cc5e2cbfdae46c0d5690ff7f31f9c813c8d79 Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 3 Jun 2020 22:49:36 +1200 Subject: [PATCH] Final data format and conversion for AniMe --- aura/examples/animatrix.rs | 22 +++++++++++----------- aura/src/anime_matrix.rs | 21 ++++++++++----------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/aura/examples/animatrix.rs b/aura/examples/animatrix.rs index 57962a9b..daa15451 100644 --- a/aura/examples/animatrix.rs +++ b/aura/examples/animatrix.rs @@ -3,19 +3,19 @@ use rog_aura::{AniMeDbusWriter, AniMeMatrix, AniMePacketType}; fn main() { let mut writer = AniMeDbusWriter::new().unwrap(); - loop { - for brightness in 0x01..0xFF { - let mut matrix = AniMeMatrix::new(); - matrix.fill_with(brightness); + // loop { + // for brightness in 0xFE..0xFF { + // let mut matrix = AniMeMatrix::new(); + // matrix.fill_with(brightness); - let mut matrix: AniMePacketType = AniMePacketType::from(matrix); - // println!("{:?}", matrix[0].to_vec()); - // println!("{:?}", matrix[1].to_vec()); + // let mut matrix: AniMePacketType = AniMePacketType::from(matrix); + // // println!("{:?}", matrix[0].to_vec()); + // // println!("{:?}", matrix[1].to_vec()); - writer.write_image(&mut matrix).unwrap(); - } - break; - } + // writer.write_image(&mut matrix).unwrap(); + // } + // break; + // } // Try an outline, top and right let mut matrix = AniMeMatrix::new(); diff --git a/aura/src/anime_matrix.rs b/aura/src/anime_matrix.rs index a0b509fe..5f34359c 100644 --- a/aura/src/anime_matrix.rs +++ b/aura/src/anime_matrix.rs @@ -1,4 +1,4 @@ -pub const WIDTH: usize = 34; +pub const WIDTH: usize = 34; // Width is definitely 34 items pub const HEIGHT: usize = 56; pub type AniMeBufferType = [[u8; WIDTH]; HEIGHT]; pub type AniMePacketType = [[u8; 640]; 2]; @@ -41,25 +41,27 @@ impl From for AniMePacketType { let mut block1_done = false; let mut phys_row_len = WIDTH - 1; // not taking in to account starting at 0 - let mut total = 0; for (count, row) in anime.0.iter().enumerate() { // Write the top block of LEDs (first 7 rows) - if count <= 6 { + if count < 6 { for x in row.iter() { write_block[write_index] = *x; write_index += 1; - total += 1; } - println!("{:X?}", row.to_vec()); } else { - if count == 7 { + // Two offsets to correct the below with + if count == 6 { phys_row_len -= 1; } + if count == 7 { + phys_row_len += 1; + } + // Switch to next block (looks like ) if count % 2 != 0 { - phys_row_len -= 2; + phys_row_len -= 2; // if count 7, -= 1 } else { - phys_row_len += 1; + phys_row_len += 1; // if count 6, 0 } let index = row.len() - phys_row_len; @@ -71,16 +73,13 @@ impl From for AniMePacketType { write_block = &mut buffers[1]; write_index = BLOCK_START; } - total += 1; //println!("{:?}", write_block.to_vec()); write_block[write_index] = row[n]; write_index += 1; } - println!("{:X?}", row[index..].to_vec()); } } - dbg!(total); buffers } }