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;
}
}

View File

@@ -211,10 +211,10 @@ impl From<SetAuraBuiltin> for [[u8; LED_MSG_LEN]; 4] {
#[inline]
fn from(mode: SetAuraBuiltin) -> Self {
let mut msg = [[0u8; LED_MSG_LEN]; 4];
for i in 0..4 {
msg[i][0] = 0x5d;
msg[i][1] = 0xb3;
msg[i][2] = i as u8 + 1;
for (i, row) in msg.iter_mut().enumerate() {
row[0] = 0x5d;
row[1] = 0xb3;
row[2] = i as u8 + 1;
}
match mode {