| 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 | |