Fix not always reading reports, do proper solution with timer later
Signed-off-by: fly <merspieler@alwaysdata.com>
This commit is contained in:
parent
971b151d03
commit
6903ebdadf
1 changed files with 10 additions and 6 deletions
|
@ -5,6 +5,7 @@
|
|||
// Silence certain clippy warnings
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(clippy::needless_late_init)]
|
||||
#![allow(clippy::needless_return)]
|
||||
|
||||
mod device;
|
||||
|
||||
|
@ -133,7 +134,7 @@ fn main() -> ! {
|
|||
pa2: gpioa.pa2.into_analog(&mut gpioa.crl),
|
||||
};
|
||||
|
||||
let mut last = get_report(&mut input_pins, &mut adc1, &cal);
|
||||
// let mut last = get_report(&mut input_pins, &mut adc1, &cal);
|
||||
|
||||
// ====================== PWM setup =================
|
||||
let mut afio = p.AFIO.constrain();
|
||||
|
@ -144,23 +145,26 @@ fn main() -> ! {
|
|||
pwm.enable(Channel::C1);
|
||||
let pwm_max = pwm.get_max_duty(); //48000 in our case
|
||||
|
||||
// ====================== Timer setup ===============
|
||||
// let timer = Instant;
|
||||
// let mut last_report_sent = timer.elapsed();
|
||||
|
||||
// ====================== Main loop =================
|
||||
loop {
|
||||
let report = get_report(&mut input_pins, &mut adc1, &cal);
|
||||
if report != last {
|
||||
// TODO figure out timer and only send in like 1ms intervals or on change
|
||||
// if report != last {
|
||||
match consumer.device().write_report(&report) {
|
||||
Err(UsbHidError::WouldBlock) => {}
|
||||
Ok(_) => {
|
||||
last = report;
|
||||
// last = report;
|
||||
}
|
||||
Err(e) => {
|
||||
core::panic!("Failed to write consumer report: {:?}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
// TODO figure out why we only land here after we've sent a report
|
||||
if usb_dev.poll(&mut [&mut consumer]) {
|
||||
match consumer.device().read_report() {
|
||||
Err(UsbHidError::WouldBlock) => {}
|
||||
|
@ -305,7 +309,7 @@ fn load_calibration(flash: &mut FlashWriter) -> Calibration {
|
|||
let dummy = bytes_of(&cal);
|
||||
let dummy2 = &data[3..][..dummy.len()];
|
||||
let dummy3 = bytes_of_mut(&mut cal);
|
||||
dummy3.copy_from_slice(&dummy2);
|
||||
dummy3.copy_from_slice(dummy2);
|
||||
return cal;
|
||||
},
|
||||
Err(_e) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue