MCPcopy Create free account
hub / github.com/andysworkshop/stm32plus / run

Method run

examples/button/button.cpp:50–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49 public:
50 void run() {
51
52 // initialise the ports
53
54 GpioD<DefaultDigitalOutputFeature<13> > pd;
55 GpioA<DefaultDigitalInputFeature<0> > pa;
56
57 // lights off (this LED is active high, i.e. PD13 is a source)
58
59 pd[13].reset();
60
61 // create the button class with parameters
62
63 AutoRepeatPushButton button(pa[0],BUTTON_PRESSED_HIGH,INITIAL_DELAY_MS,REPEAT_DELAY_MS);
64
65 // main loop
66
67 for(;;) {
68
69 // sample the button and swith the LED on (HIGH) or off (LOW)
70
71 if(button.getState()==PushButton::Pressed) {
72
73 // switch the LED on for 10ms
74
75 pd[13].set();
76 MillisecondTimer::delay(10);
77 }
78 else
79 pd[13].reset();
80 }
81 }
82};
83
84

Callers 1

mainFunction · 0.45

Calls 3

resetMethod · 0.45
getStateMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected