Move led_writer to a main loop due to strange mpsc behaviour

This commit is contained in:
Luke
2020-06-11 20:09:18 +12:00
parent 93c6b28409
commit bf3588e516
10 changed files with 65 additions and 63 deletions

View File

@@ -11,6 +11,12 @@ use yansi_term::Colour::RGB;
/// See the examples for ways to write an image to `AniMeMatrix` format.
pub struct AniMeMatrix(AniMeBufferType);
impl Default for AniMeMatrix {
fn default() -> Self {
Self::new()
}
}
impl AniMeMatrix {
pub fn new() -> Self {
AniMeMatrix([[0u8; WIDTH]; HEIGHT])
@@ -127,7 +133,7 @@ impl From<AniMeMatrix> for AniMePacketType {
}
let index = row.len() - prog_row_len;
for n in index..row.len() {
for n in row.iter().skip(index) {
// Require a special case to catch the correct end-of-packet which is
// 6 bytes from the end
if write_index == BLOCK_END && !block1_done {
@@ -136,8 +142,7 @@ impl From<AniMeMatrix> for AniMePacketType {
write_index = BLOCK_START;
}
//println!("{:?}", write_block.to_vec());
write_block[write_index] = row[n];
write_block[write_index] = *n;
write_index += 1;
}
}