From fee4294923f9d0ba73d33c09791c148c591dc869 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Tue, 15 Aug 2023 12:59:42 +0200 Subject: [PATCH] More testing --- src/main.rs | 14 +++++++++++++- src/mouse_sensor/wrapper.rs | 8 ++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 65a45b7..382d344 100644 --- a/src/main.rs +++ b/src/main.rs @@ -141,7 +141,19 @@ fn main() -> ! { // serial.send_text(" - "); // serial.send_number(0x02, 10); - // custom_hid::serial().send_number(mouse_sensor.product_id_2(), 10); + // custom_hid::serial().send_number(mouse_sensor.spi_device.product_id_2(), 10); + + custom_hid::serial().send_text("verify ids:"); + custom_hid::serial().send_text(if mouse_sensor.verify_product_id_1() { + "PID1 true" + } else { + "PID1 false" + }); + custom_hid::serial().send_text(if mouse_sensor.verify_product_id_2() { + "PID2 true" + } else { + "PID2 false" + }); }); } diff --git a/src/mouse_sensor/wrapper.rs b/src/mouse_sensor/wrapper.rs index 39511b3..706a782 100644 --- a/src/mouse_sensor/wrapper.rs +++ b/src/mouse_sensor/wrapper.rs @@ -13,7 +13,7 @@ pub struct MouseSensor where L: FnMut(&str), { - spi_device: SpiMouseSensor, + pub spi_device: SpiMouseSensor, led: Pin, } @@ -68,19 +68,19 @@ where me } - fn verify_product_id_1(&mut self) -> bool { + pub fn verify_product_id_1(&mut self) -> bool { const DEFAULT_VALUE: u8 = 0x30; DEFAULT_VALUE == self.spi_device.product_id_1() } - fn verify_product_id_2(&mut self) -> bool { + pub fn verify_product_id_2(&mut self) -> bool { const DEFAULT_VALUE: u8 = 0x02; DEFAULT_VALUE == self.spi_device.product_id_2() } - pub fn motion_detected(&mut self) -> (bool, bool, bool) { + fn motion_detected(&mut self) -> (bool, bool, bool) { let reg = self.spi_device.motion_status(); let motion = (reg & 0b10000000) != 0;