Proper fix of laptop mode conversion bug

This commit is contained in:
Luke
2020-07-05 13:33:45 +12:00
parent a4c5b2754e
commit 98ffa817e6
6 changed files with 40 additions and 20 deletions

View File

@@ -234,6 +234,7 @@ impl From<&AuraModes> for u8 {
AuraModes::Comet(_) => COMET,
AuraModes::Flash(_) => FLASH,
AuraModes::MultiStatic(_) => MULTISTATIC,
AuraModes::RGB(_) => RGB,
_ => panic!("Invalid mode"),
}
}
@@ -279,6 +280,7 @@ impl From<u8> for AuraModes {
COMET => AuraModes::Comet(SingleColour::default()),
FLASH => AuraModes::Flash(SingleColour::default()),
MULTISTATIC => AuraModes::MultiStatic(MultiColour::default()),
RGB => AuraModes::RGB(vec![]),
_ => panic!("Invalid mode byte"),
}
}

View File

@@ -151,8 +151,7 @@ impl From<&AuraModes> for [u8; LED_MSG_LEN] {
AuraModes::Pulse(_) => msg[3] = 0x0a,
AuraModes::Comet(_) => msg[3] = 0x0b,
AuraModes::Flash(_) => msg[3] = 0x0c,
AuraModes::MultiStatic(_) => msg[3] = 0x0d,
_ => print!("Mode not convertable to array: {}", <&str>::from(mode)),
_ => panic!("Mode not convertable to 1D array: {}", <&str>::from(mode)),
}
match mode {
@@ -195,7 +194,7 @@ impl From<&AuraModes> for [u8; LED_MSG_LEN] {
msg[5] = settings.colour.1;
msg[6] = settings.colour.2;
}
_ => panic!("Mode not convertable to array"),
_ => panic!("Mode not convertable to 1D array: {}", <&str>::from(mode)),
}
msg
}
@@ -240,7 +239,7 @@ impl From<&AuraModes> for [[u8; LED_MSG_LEN]; 4] {
msg[3][5] = settings.colour4.1;
msg[3][6] = settings.colour4.2;
}
_ => panic!("Mode not convertable to array"),
_ => panic!("Mode not convertable to 2D array: {}", <&str>::from(mode)),
}
msg
}