keybrd library is an open source library for creating custom-keyboard firmware.
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.

Debug.cpp 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "Debug.h"
  2. void Debug::printMicrosecondsPerScan()
  3. {
  4. if (millis() >= nextTime)
  5. {
  6. Keyboard.print(1000000/scanCount); //print microseconds per scan
  7. Keyboard.write(',');
  8. scanCount = 0;
  9. nextTime = millis() + 1000; //print every second
  10. }
  11. scanCount++;
  12. }
  13. void Debug::printScansPerSecond()
  14. {
  15. if (millis() >= nextTime)
  16. {
  17. Keyboard.print(scanCount); //print scans per second
  18. Keyboard.write(',');
  19. scanCount = 0;
  20. nextTime = millis() + 1000; //print every second
  21. }
  22. scanCount++;
  23. }
  24. //Sometimes OS takes 6 seconds to recongnize keyboard.
  25. //wait_for_OS() will blink LED and count up once per second for specified number of seconds.
  26. void Debug::wait_for_OS(LED& led, const uint8_t seconds)
  27. {
  28. for (uint8_t elapsed = 0; elapsed < seconds; elapsed++)
  29. {
  30. //print seconds elapsed
  31. Keyboard.print(elapsed);
  32. Keyboard.print(F(" "));
  33. //blink LED
  34. led.on();
  35. delay(500);
  36. led.off();
  37. delay(500);
  38. }
  39. }