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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

main.cpp 866B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "MK20D5.h"
  2. #include "wait.h"
  3. #include "gpio_api.h"
  4. #include "PinNames.h"
  5. #include "matrix.h"
  6. #include "timer.h"
  7. #include "action.h"
  8. #include "keycode.h"
  9. #include "host.h"
  10. #include "host_driver.h"
  11. #include "mbed_driver.h"
  12. int main() {
  13. gpio_t led;
  14. gpio_init_out(&led, PTA19);
  15. uint16_t t = 0;
  16. host_set_driver(&mbed_driver);
  17. keyboard_init();
  18. while(1) {
  19. keyboard_task();
  20. bool matrix_on = false;
  21. matrix_scan();
  22. for (int i = 0; i < MATRIX_ROWS; i++) {
  23. if (matrix_get_row(i)) {
  24. matrix_on = true;
  25. break;
  26. }
  27. }
  28. if (matrix_on)
  29. gpio_write(&led, 1);
  30. else {
  31. if (timer_elapsed(t) > 500) {
  32. gpio_write(&led, !gpio_read(&led));
  33. t = timer_read();
  34. }
  35. }
  36. }
  37. }