1
0
Fork 0

Working LED control!

Signed-off-by: fly <merspieler@alwaysdata.com>
This commit is contained in:
fly 2024-04-11 03:45:24 +02:00
parent 0bdb9ab4ec
commit 43bccaf380

View file

@ -112,7 +112,8 @@ fn main() -> ! {
match consumer.device().read_report() {
Err(UsbHidError::WouldBlock) => {}
Ok(output) => {
last_output = output;
let pwm_val = output.int as u16 * 188;
pwm.set_duty(Channel::C1, pwm_val);
}
Err(e) => {
core::panic!("Failed to write consumer report: {:?}", e)
@ -121,18 +122,16 @@ fn main() -> ! {
}
// Get data from pots
let data: u16 = adc1.read(&mut input_pins.pa2).unwrap();
let mut pwm_val = data as f32 / 0xfff as f32;
let pwm_duty = (pwm_max as f32 * pwm_val as f32) as u16;
pwm.set_duty(Channel::C1, pwm_duty);
// let data: u16 = adc1.read(&mut input_pins.pa2).unwrap();
// let mut pwm_val = data as f32 / 0xfff as f32;
// let pwm_duty = (pwm_max as f32 * pwm_val as f32) as u16;
// pwm.set_duty(Channel::C1, pwm_duty);
}
}
fn get_report(pins: &mut MyPins, adc1: &mut adc::Adc<pac::ADC1>) -> CustomInputReport {
let integLT: u16 = adc1.read(&mut pins.pa1).unwrap();
let floodLT: u16 = adc1.read(&mut pins.pa2).unwrap();
let retX = integLT * 16;
let retY = floodLT * 16;
let buttons: u16 = 0;