]> git.gir.st - tmk_keyboard.git/blob - keyboard/mbed_onekey/main.cpp
1df940aa9781045a922015ec3cc729a8ef066246
[tmk_keyboard.git] / keyboard / mbed_onekey / main.cpp
1 #include "mbed.h"
2 #include "HIDKeyboard.h"
3 #include "debug.h"
4 #include "timer.h"
5
6 /*
7 //#define DEBUG
8 #ifdef DEBUG
9 Serial ser(UART_TX, UART_RX);
10 #define dprintf(fmt, ...) ser.printf(fmt, ## __VA_ARGS__)
11 #else
12 #define dprintf(fmt, ...)
13 #endif
14 */
15
16
17 // button and LEDs
18 DigitalIn isp(P0_1);
19 DigitalOut led_red(P0_20);
20 DigitalOut led_green(P0_21);
21
22 //USBKeyboard
23 HIDKeyboard keyboard;
24
25
26 int main(void) {
27 //isp.mode(PullUp);
28 //led_red = 0;
29 //led_green = 0;
30 debug_enable = true;
31 dprintf("HIDKeyboard:\r\n");
32
33 timer_init();
34 xprintf("timer: %i\r\n", timer_read());
35
36 report_keyboard_t report = { 2, 0, 4, }; //a
37 report_keyboard_t report_off = { 0 };
38
39 bool last_isp = isp;
40 uint32_t last_timer;
41 while (1) {
42 //keyboard.mediaControl(KEY_VOLUME_DOWN);
43 //keyboard.printf("Hello World from Mbed\r\n");
44 //keyboard.keyCode('s', KEY_CTRL);
45 //keyboard.keyCode(KEY_CAPS_LOCK);
46
47 //led_green = !led_green;
48 //leds = keyboard.lockStatus();
49 //ser.putc(ser.getc());
50
51 if (last_isp == isp) continue;
52 if (isp == 0) {
53 led_red = 0; // on
54 xprintf("timer: %i\r\n", timer_read32());
55 xprintf("diff: %i\r\n", timer_elapsed32(last_timer));
56 //keyboard.sendReport(report);
57 } else {
58 led_red = 1; // off
59 //keyboard.sendReport(report_off);
60 }
61 last_isp = isp;
62 last_timer = timer_read();
63 //led_green = !led_green;
64 //wait(0.5);
65 }
66 }
Imprint / Impressum