Archived
1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
keybrd/src/Debug.cpp

49 lines
1.3 KiB
C++
Raw Normal View History

2016-05-09 14:05:08 +00:00
#include "Debug.h"
2016-07-18 02:03:03 +00:00
void Debug::printMicrosecondsPerScan()
2016-05-09 14:05:08 +00:00
{
2016-07-18 02:26:00 +00:00
static unsigned long nextTime = 0;
static unsigned int scanCount = 0;
2016-05-09 14:05:08 +00:00
if (millis() >= nextTime)
{
Keyboard.print(1000000/scanCount); //print microseconds per scan
Keyboard.write(',');
scanCount = 0;
nextTime = millis() + 1000; //print every second
}
scanCount++;
}
2016-07-18 02:03:03 +00:00
void Debug::printScansPerSecond()
2016-05-09 14:05:08 +00:00
{
2016-07-18 02:26:00 +00:00
static unsigned long nextTime = 0;
static unsigned int scanCount = 0;
2016-05-09 14:05:08 +00:00
if (millis() >= nextTime)
{
Keyboard.print(scanCount); //print scans per second
Keyboard.write(',');
scanCount = 0;
nextTime = millis() + 1000; //print every second
}
scanCount++;
}
2016-07-18 02:03:03 +00:00
//Sometimes OS takes 6 seconds to recongnize keyboard.
//wait_for_OS() will blink LED and count up once per second for specified number of seconds.
2016-09-25 03:58:54 +00:00
void Debug::wait_for_OS(LEDInterface& led, const uint8_t seconds)
2016-07-18 02:03:03 +00:00
{
for (uint8_t elapsed = 0; elapsed < seconds; elapsed++)
{
//print seconds elapsed
Keyboard.print(elapsed);
Keyboard.print(F(" "));
//blink LED
led.on();
delay(500);
led.off();
delay(500);
}
}