More testing
This commit is contained in:
parent
3de86913df
commit
fee4294923
2 changed files with 17 additions and 5 deletions
14
src/main.rs
14
src/main.rs
|
@ -141,7 +141,19 @@ fn main() -> ! {
|
||||||
// serial.send_text(" - ");
|
// serial.send_text(" - ");
|
||||||
// serial.send_number(0x02, 10);
|
// 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"
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub struct MouseSensor<L>
|
||||||
where
|
where
|
||||||
L: FnMut(&str),
|
L: FnMut(&str),
|
||||||
{
|
{
|
||||||
spi_device: SpiMouseSensor<L>,
|
pub spi_device: SpiMouseSensor<L>,
|
||||||
|
|
||||||
led: Pin<Gpio25, PushPullOutput>,
|
led: Pin<Gpio25, PushPullOutput>,
|
||||||
}
|
}
|
||||||
|
@ -68,19 +68,19 @@ where
|
||||||
me
|
me
|
||||||
}
|
}
|
||||||
|
|
||||||
fn verify_product_id_1(&mut self) -> bool {
|
pub fn verify_product_id_1(&mut self) -> bool {
|
||||||
const DEFAULT_VALUE: u8 = 0x30;
|
const DEFAULT_VALUE: u8 = 0x30;
|
||||||
|
|
||||||
DEFAULT_VALUE == self.spi_device.product_id_1()
|
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;
|
const DEFAULT_VALUE: u8 = 0x02;
|
||||||
|
|
||||||
DEFAULT_VALUE == self.spi_device.product_id_2()
|
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 reg = self.spi_device.motion_status();
|
||||||
|
|
||||||
let motion = (reg & 0b10000000) != 0;
|
let motion = (reg & 0b10000000) != 0;
|
||||||
|
|
Loading…
Reference in a new issue