Integrate hand gateway and spatial force rendering

This commit is contained in:
lenn
2026-06-29 18:55:42 +08:00
parent f30ebcf20b
commit d4f160af75
14 changed files with 1041 additions and 98 deletions

View File

@@ -26,13 +26,17 @@ pub fn calc_crc8_itu(c: &[u8]) -> u8 {
crc8_itu_alg.checksum(c)
}
pub fn calc_crc8_itu_xor55(c: &[u8]) -> u8 {
calc_crc8_itu(c) ^ 0x55
}
pub fn elapsed_millis(start_at: Instant) -> u64 {
start_at.elapsed().as_millis() as u64
}
#[cfg(test)]
mod test {
use crate::serial_core::utils::{calc_crc8_itu, calc_crc8_smbus};
use crate::serial_core::utils::{calc_crc8_itu, calc_crc8_itu_xor55, calc_crc8_smbus};
#[test]
fn test_crc8_itu() {
@@ -51,4 +55,10 @@ mod test {
let checksum = calc_crc8_smbus(req_vec.as_slice());
assert_eq!(checksum, 0x2F);
}
#[test]
fn test_crc8_itu_xor55() {
let req_vec = vec![0x55, 0xAA, 0x07, 0x00, 0x01, 0x01, 0xFF, 0xFF, 0xFF, 0xFF];
assert_eq!(calc_crc8_itu_xor55(req_vec.as_slice()), 0xFD);
}
}