More testing

This commit is contained in:
hodasemi 2023-08-15 12:59:42 +02:00
parent 3de86913df
commit fee4294923
2 changed files with 17 additions and 5 deletions

View file

@ -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"
});
});
}

View file

@ -13,7 +13,7 @@ pub struct MouseSensor<L>
where
L: FnMut(&str),
{
spi_device: SpiMouseSensor<L>,
pub spi_device: SpiMouseSensor<L>,
led: Pin<Gpio25, PushPullOutput>,
}
@ -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;