]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/tests/mbed/ticker_mfun/main.cpp
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / tests / mbed / ticker_mfun / main.cpp
1 #include "mbed.h"
2
3 Ticker tick;
4 DigitalOut led(LED1);
5
6 namespace {
7 const int MS_INTERVALS = 1000;
8 }
9
10 class TickerHandler {
11 public:
12 TickerHandler(const int _ms_intervals) : m_ticker_count(0), m_ms_intervals(_ms_intervals) {
13 }
14
15 void print_char(char c = '*')
16 {
17 printf("%c", c);
18 fflush(stdout);
19 }
20
21 void togglePin(void)
22 {
23 if (ticker_count >= MS_INTERVALS) {
24 print_char();
25 ticker_count = 0;
26 led = !led; // Blink
27 }
28 ticker_count++;
29 }
30
31 protected:
32 int m_ticker_count;
33 };
34
35 int main()
36 {
37 TickerHandler th;
38
39 tick.attach_us(th, TickerHandler::togglePin, 1000);
40 while (1);
41 }
Imprint / Impressum