Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 1.6KB

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