xealousbrown.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Copyright 2019 Alex Ong
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "xealousbrown.h"
  17. void matrix_init_kb(void) {
  18. // put your keyboard start-up code here
  19. // runs once when the firmware starts up
  20. matrix_init_user();
  21. }
  22. #ifdef BENCHMARK_MATRIX
  23. # include "timer.h"
  24. # include <stdint.h>
  25. # include <stdbool.h>
  26. # include "wait.h"
  27. # include "util.h"
  28. # include "matrix.h"
  29. # include "quantum.h"
  30. static int scans = 0;
  31. static uint16_t last_print_out = 0;
  32. static int last_timer = 0;
  33. void matrix_scan_user(void) {
  34. scans++;
  35. uint16_t timer = timer_read();
  36. if (timer != last_timer && timer != last_timer + 1) {
  37. print("MS:\n");
  38. print_dec(timer);
  39. print("->");
  40. print_dec(last_timer);
  41. print("\n");
  42. }
  43. last_timer = timer;
  44. if ((timer % 1000 == 0) && (timer != last_print_out)) {
  45. print("Benchmark:");
  46. print("\n");
  47. print_dec(timer);
  48. print("\n");
  49. print_dec(scans);
  50. print("\n");
  51. print("-------");
  52. scans = 0;
  53. last_print_out = timer;
  54. }
  55. }
  56. #endif