add keyboard source code

This commit is contained in:
cuu
2023-06-14 13:46:28 +12:00
parent 5b69e9c831
commit 17269a8c72
24 changed files with 1850 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
#ifndef TICKWAITER_H
#define TICKWAITER_H
#include <cstdint>
#include "math.h"
template<uint32_t TargetInterval>
class TickWaiter {
public:
uint8_t waitForNextTick() {
const auto last = this->last;
const auto now = millis();
this->last = now;
const auto delta = getDelta(last, now, 255);
if (delta >= TargetInterval) {
return delta;
}
delay(TargetInterval - delta);
const auto now2 = millis();
return getDelta(last, now2, 255);
}
private:
uint32_t last = 0;
};
#endif