On device LED controls reactivated
Signed-off-by: fly <merspieler@alwaysdata.com>
This commit is contained in:
parent
15b21f6f32
commit
2c7db2f6de
1 changed files with 9 additions and 8 deletions
|
@ -77,7 +77,7 @@ fn main() -> ! {
|
|||
let c1 = gpioa.pa0.into_alternate_push_pull(&mut gpioa.crl);
|
||||
let mut pwm = p.TIM2.pwm_hz::<Tim2NoRemap, _, _>(c1, &mut afio.mapr, 1.kHz(), &clocks);
|
||||
pwm.enable(Channel::C1);
|
||||
// let pwm_max = pwm.get_max_duty() as u16; //48000 in our case
|
||||
let pwm_max = pwm.get_max_duty() as u16; //48000 in our case
|
||||
|
||||
loop {
|
||||
let report = get_report(&mut input_pins, &mut adc1);
|
||||
|
@ -98,12 +98,11 @@ fn main() -> ! {
|
|||
// TODO get value and set PWM
|
||||
//pwm.set_duty(Channel::C1, pwm_duty);
|
||||
|
||||
// // Get data from pots
|
||||
// let data: u16 = adc1.read(&mut ch0).unwrap();
|
||||
// let mut pwm_val = data as f32 / 0xfff as f32;
|
||||
//
|
||||
// let mut outBuf = ryu::Buffer::new();
|
||||
// let mut ret = outBuf.format(pwm_val).as_bytes();
|
||||
// Get data from pots
|
||||
let data: u16 = adc1.read(&mut input_pins.pa1).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(
|
||||
|
@ -113,8 +112,10 @@ fn get_report(
|
|||
|
||||
let integLT: u16 = adc1.read(&mut pins.pa1).unwrap();
|
||||
let floodLT: u16 = adc1.read(&mut pins.pa2).unwrap();
|
||||
let retX: i8 = ((integLT / 16) as i16 -127) as i8;
|
||||
let retY: i8 = ((floodLT / 16) as i16 -127) as i8;
|
||||
let buttons: u8 = 0;
|
||||
|
||||
let report = JoystickReport {x: (integLT / 16) as i8, y: (floodLT / 16) as i8, buttons};
|
||||
let report = JoystickReport {x: retX, y: retY, buttons};
|
||||
report
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue