This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Key { | |
byte id; | |
boolean pressed; | |
uint8_t bounceKey; | |
Key(byte id) : id(id), pressed(false), bounceKey(NOT_BOUNCING) {}; | |
} | |
boolean toggleKey(struct Key *key) { | |
key->bounceKey = checkStillBouncing(key->bounceKey); | |
if(key->bounceKey == NOT_BOUNCING){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void scanKeys(){ | |
//iterate over columns | |
for(int currentColumn = 0; currentColumn < COL_COUNT; currentColumn ++){ | |
digitalWrite(cols[currentColumn],HIGH); | |
//scan rows | |
for(int y = 0; y < ROW_COUNT; y++){ | |
Key* key = keyMatrix[currentColumn][y]; | |
if(key != NOKEY){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//arbitrary number to signal that a | |
//key is not bouncing | |
const uint8_t NOT_BOUNCING = 20; | |
//how many ms a key is expected to bounce | |
const uint8_t BOUNCE_TIME = 10; | |
//how many bouncing keys can be handled | |
//in parallel | |
const uint8_t MAX_BOUNCING = 5; | |
//the index where the last bouncing key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
TheTasTaTur - bt config | |
Author: | |
Dirk Porsche | |
Shiggy Enterprises UG (haftungsbeschränkt) | |
All Rights reserved | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum keyCodes { | |
KC__ = 0, | |
KC_ErrorRollOver, | |
KC_POSTfail, | |
KC_ErrorUndefined, | |
// ... | |
KC_N, | |
KC_O, | |
KC_P, | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//discover correct keyCodes | |
static void calcKeyCodes(){ | |
//a special case for caps lock | |
//switch caps lock and submit | |
if((modifiers[0] & M2L->keyCode) && (modifiers[0] & M2R->keyCode)){ | |
modifiers[0] = 0x00; | |
keyCodes[0] = KC_CAPSLOCK; | |
keyCodeIndex = 1; | |
if(!capslock){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void sendKeyState(){ | |
if(stateChanged){ | |
calcKeyCodes(); | |
byte hidReport[REPORT_LENGTH] = {0xFD,0x09,0x01,modifiers[0],0x00,0x00,0x00,0x00,0x00,0x00,0x00}; | |
for(int i = 0; i < keyCodeIndex; i++){ | |
hidReport[5 + i] = keyCodes[i]; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte leftSideData[5]={0}; | |
uint8_t receivingIndex = 0; | |
boolean receiving = false; | |
const byte WAITING=0xE1,PULLUP=B10101010,PRE=0x5E,ADDR=0x10,NOTHING=0xFE,ERROR=0x77; | |
int receiveState = WAITING; | |
void loop(){ | |
byte in = receivePackage(); | |
if(in != NOTHING){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const byte CARRIER=B10101010,PRE=0x5E,ADDR=0x10; | |
const byte START = 0xD0; | |
const byte STOP = 0xDF; | |
static void sendKeyState(){ | |
if(stateChanged){ | |
sendPackage(START); | |
for(int i = 0; i < pressedKeyIndex; i++){ | |
sendPackage(pressedKeys[i]->id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte leftSideData[MAX_LEFTSIDE_KEYS]={0}; | |
uint8_t receivingIndex = 0; | |
boolean receiving = false; | |
const byte CARRIER=B10101010,PRE=0x5E,ADDR=0x10,NOTHING=0xFE,ERROR=0x77; | |
int receiveState = CARRIER; | |
const byte START = 0xD0; | |
const byte STOP = 0xDF; |
OlderNewer