Implemented button
This commit is contained in:
parent
c0283eefd8
commit
64a7b8c5ff
|
@ -51,6 +51,7 @@ pub struct App {
|
||||||
disp_rst: gpioa::PA1<Output<PushPull>>,
|
disp_rst: gpioa::PA1<Output<PushPull>>,
|
||||||
max_cs: gpioa::PA9<Output<PushPull>>,
|
max_cs: gpioa::PA9<Output<PushPull>>,
|
||||||
qei: AppQEI,
|
qei: AppQEI,
|
||||||
|
button: gpiob::PB3<Input<Floating>>,
|
||||||
|
|
||||||
selected_profile: usize,
|
selected_profile: usize,
|
||||||
}
|
}
|
||||||
|
@ -84,13 +85,14 @@ pub fn setup(cp: cortex_m::peripheral::Peripherals, dp: stm32::Peripherals) -> A
|
||||||
let gpiob = dp.GPIOB.split(&mut rcc.apb2);
|
let gpiob = dp.GPIOB.split(&mut rcc.apb2);
|
||||||
let mut afio = dp.AFIO.constrain(&mut rcc.apb2);
|
let mut afio = dp.AFIO.constrain(&mut rcc.apb2);
|
||||||
|
|
||||||
let (_, _, pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4);
|
let (_, pb3, pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4);
|
||||||
|
|
||||||
let qei = Timer::tim3(dp.TIM3, &clocks, &mut rcc.apb1).qei(
|
let qei = Timer::tim3(dp.TIM3, &clocks, &mut rcc.apb1).qei(
|
||||||
(pb4, gpiob.pb5),
|
(pb4, gpiob.pb5),
|
||||||
&mut afio.mapr,
|
&mut afio.mapr,
|
||||||
qei::QeiOptions::default(),
|
qei::QeiOptions::default(),
|
||||||
);
|
);
|
||||||
|
let button = pb3;
|
||||||
|
|
||||||
// SPI1
|
// SPI1
|
||||||
let sck = gpioa.pa5.into_alternate_push_pull(&mut gpioa.crl);
|
let sck = gpioa.pa5.into_alternate_push_pull(&mut gpioa.crl);
|
||||||
|
@ -128,6 +130,7 @@ pub fn setup(cp: cortex_m::peripheral::Peripherals, dp: stm32::Peripherals) -> A
|
||||||
disp_rst: rst,
|
disp_rst: rst,
|
||||||
max_cs: max_cs,
|
max_cs: max_cs,
|
||||||
qei: qei,
|
qei: qei,
|
||||||
|
button: button,
|
||||||
|
|
||||||
selected_profile: 0,
|
selected_profile: 0,
|
||||||
}
|
}
|
||||||
|
@ -203,8 +206,9 @@ impl App {
|
||||||
.draw(&mut disp)
|
.draw(&mut disp)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let mut press_count = 0;
|
||||||
let mut needs_redraw = true;
|
let mut needs_redraw = true;
|
||||||
loop {
|
while press_count < 5 {
|
||||||
if needs_redraw {
|
if needs_redraw {
|
||||||
for i in 0..profiles::REFLOW_PROFILES.len() {
|
for i in 0..profiles::REFLOW_PROFILES.len() {
|
||||||
let rect = Rectangle::new(
|
let rect = Rectangle::new(
|
||||||
|
@ -231,12 +235,23 @@ impl App {
|
||||||
needs_redraw = false;
|
needs_redraw = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.delay.delay_ms(100u16);
|
self.delay.delay_ms(10u16);
|
||||||
let new_selection = ((self.qei.count() as usize) / 4) % profiles::REFLOW_PROFILES.len();
|
let new_selection = ((self.qei.count() as usize) / 4) % profiles::REFLOW_PROFILES.len();
|
||||||
if new_selection != self.selected_profile {
|
if new_selection != self.selected_profile {
|
||||||
self.selected_profile = new_selection;
|
self.selected_profile = new_selection;
|
||||||
needs_redraw = true;
|
needs_redraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !needs_redraw && self.button.is_low().unwrap() {
|
||||||
|
press_count += 1;
|
||||||
|
} else {
|
||||||
|
press_count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure the button has been released, before continuing to the next stage
|
||||||
|
while !self.button.is_high().unwrap() {
|
||||||
|
self.delay.delay_ms(10u16);
|
||||||
}
|
}
|
||||||
|
|
||||||
let (spi, disp_dc, disp_rst) = disp.release();
|
let (spi, disp_dc, disp_rst) = disp.release();
|
||||||
|
|
|
@ -34,7 +34,7 @@ impl ReflowProfile {
|
||||||
|
|
||||||
pub const REFLOW_PROFILES: [ReflowProfile; 4] = [
|
pub const REFLOW_PROFILES: [ReflowProfile; 4] = [
|
||||||
ReflowProfile {
|
ReflowProfile {
|
||||||
name: "Profile 1",
|
name: "Too Hot",
|
||||||
points: [
|
points: [
|
||||||
ProfilePoint {
|
ProfilePoint {
|
||||||
time: 0f32,
|
time: 0f32,
|
||||||
|
@ -63,7 +63,7 @@ pub const REFLOW_PROFILES: [ReflowProfile; 4] = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
ReflowProfile {
|
ReflowProfile {
|
||||||
name: "Profile 2",
|
name: "To Cold",
|
||||||
points: [
|
points: [
|
||||||
ProfilePoint {
|
ProfilePoint {
|
||||||
time: 0f32,
|
time: 0f32,
|
||||||
|
@ -92,7 +92,7 @@ pub const REFLOW_PROFILES: [ReflowProfile; 4] = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
ReflowProfile {
|
ReflowProfile {
|
||||||
name: "Empty ",
|
name: "About Okay",
|
||||||
points: [
|
points: [
|
||||||
ProfilePoint {
|
ProfilePoint {
|
||||||
time: 0f32,
|
time: 0f32,
|
||||||
|
|
Loading…
Reference in New Issue