pub(crate) const SMARTGESTURE_ENABLE_COMMAND: [u8; 9] =
[0x00, 0xC9, 0x47, 0x24, 0x04, 0x01, 0x00, 0x00, 0x3C];
pub(crate) const SMARTGESTURE_DISABLE_COMMAND: [u8; 9] =
[0x00, 0xC9, 0x47, 0x24, 0x04, 0x00, 0x00, 0x00, 0x57];
pub(crate) const AUTOSTART_ENABLE_COMMAND: [u8; 9] =
[0x00, 0xC9, 0x47, 0x24, 0x01, 0x01, 0x00, 0x00, 0x3F];
pub(crate) const AUTOSTART_DISABLE_COMMAND: [u8; 9] =
[0x00, 0xC9, 0x47, 0x24, 0x01, 0x00, 0x00, 0x00, 0x54];
#[must_use]
pub const fn smartgesture_command(enabled: bool) -> &'static [u8] {
if enabled { &SMARTGESTURE_ENABLE_COMMAND } else { &SMARTGESTURE_DISABLE_COMMAND }
}
#[must_use]
pub const fn autostart_command(enabled: bool) -> &'static [u8] {
if enabled { &AUTOSTART_ENABLE_COMMAND } else { &AUTOSTART_DISABLE_COMMAND }
}
#[cfg(test)]
mod tests {
use super::{
AUTOSTART_DISABLE_COMMAND, AUTOSTART_ENABLE_COMMAND, SMARTGESTURE_DISABLE_COMMAND,
SMARTGESTURE_ENABLE_COMMAND, autostart_command, smartgesture_command,
};
#[test]
fn smartgesture_command_selects_correct_constant() {
assert_eq!(smartgesture_command(true), &SMARTGESTURE_ENABLE_COMMAND);
assert_eq!(smartgesture_command(false), &SMARTGESTURE_DISABLE_COMMAND);
}
#[test]
fn autostart_command_selects_correct_constant() {
assert_eq!(autostart_command(true), &AUTOSTART_ENABLE_COMMAND);
assert_eq!(autostart_command(false), &AUTOSTART_DISABLE_COMMAND);
}
#[test]
fn keeps_smartgesture_commands_stable() {
assert_eq!(
SMARTGESTURE_ENABLE_COMMAND,
[0x00, 0xC9, 0x47, 0x24, 0x04, 0x01, 0x00, 0x00, 0x3C]
);
assert_eq!(
SMARTGESTURE_DISABLE_COMMAND,
[0x00, 0xC9, 0x47, 0x24, 0x04, 0x00, 0x00, 0x00, 0x57]
);
}
#[test]
fn keeps_autostart_commands_stable() {
assert_eq!(
AUTOSTART_ENABLE_COMMAND,
[0x00, 0xC9, 0x47, 0x24, 0x01, 0x01, 0x00, 0x00, 0x3F]
);
assert_eq!(
AUTOSTART_DISABLE_COMMAND,
[0x00, 0xC9, 0x47, 0x24, 0x01, 0x00, 0x00, 0x00, 0x54]
);
}
}