mirror of
https://github.com/skogaby/OpeNITHM.git
synced 2026-10-13 01:38:24 +03:00
Updates to match PCB
Changed pin names to match schematic and PCB per mickabrig7 Changed default pins numbers to match PCB Added ability to use digitalRead for IR sensors Changes tabs to 2 spaces (consistent with Arduino standard) Fixes build for 32U4 based processors (SerialOutput.h/.cpp is untested)
This commit is contained in:
+50
-50
@@ -1,51 +1,51 @@
|
||||
#ifdef USB
|
||||
|
||||
#include "USBOutput.h"
|
||||
|
||||
char bottomRow[] = {'a', 'z', 's', 'x', 'd', 'c', 'f', 'v', 'g', 'b', 'h', 'n', 'j', 'm', 'k', ','};
|
||||
char topRow[] = {'1', 'q', '2', 'w', '3', 'e', '4', 'r', '5', 't', '6', 'y', '7', 'u', '8', 'i'};
|
||||
|
||||
void USBOutput::sendKeyEvent(int key, bool pressed, bool doublePressed)
|
||||
{
|
||||
if(pressed){
|
||||
if(doublePressed){
|
||||
NKROKeyboard.write(topRow[key]);
|
||||
}
|
||||
else{
|
||||
NKROKeyboard.press(bottomRow[key]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
NKROKeyboard.release(bottomRow[key]);
|
||||
}
|
||||
}
|
||||
|
||||
void USBOutput::sendSensorEvent(float position)
|
||||
{
|
||||
// Send hand up / hand down key
|
||||
if(position > lastPosition){
|
||||
NKROKeyboard.write(KEY_PAGE_UP);
|
||||
}
|
||||
if(position < lastPosition){
|
||||
NKROKeyboard.write(KEY_PAGE_DOWN);
|
||||
}
|
||||
|
||||
// Send hand seen / unseen key
|
||||
if(position > 0.05f){
|
||||
NKROKeyboard.press(KEY_HOME);
|
||||
}
|
||||
else{
|
||||
NKROKeyboard.release(KEY_HOME);
|
||||
}
|
||||
|
||||
// Send hand moved key
|
||||
NKROKeyboard.write(KEY_END);
|
||||
|
||||
}
|
||||
|
||||
USBOutput::USBOutput(){
|
||||
NKROKeyboard.begin();
|
||||
lastPosition = 0;
|
||||
}
|
||||
#ifdef USB
|
||||
|
||||
#endif
|
||||
#include "USBOutput.h"
|
||||
|
||||
char bottomRow[] = {'a', 'z', 's', 'x', 'd', 'c', 'f', 'v', 'g', 'b', 'h', 'n', 'j', 'm', 'k', ','};
|
||||
char topRow[] = {'1', 'q', '2', 'w', '3', 'e', '4', 'r', '5', 't', '6', 'y', '7', 'u', '8', 'i'};
|
||||
|
||||
void USBOutput::sendKeyEvent(int key, bool pressed, bool doublePressed)
|
||||
{
|
||||
if(pressed){
|
||||
if(doublePressed){
|
||||
NKROKeyboard.write(topRow[key]);
|
||||
}
|
||||
else{
|
||||
NKROKeyboard.press(bottomRow[key]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
NKROKeyboard.release(bottomRow[key]);
|
||||
}
|
||||
}
|
||||
|
||||
void USBOutput::sendSensorEvent(float position)
|
||||
{
|
||||
// Send hand up / hand down key
|
||||
if(position > lastPosition){
|
||||
NKROKeyboard.write(KEY_PAGE_UP);
|
||||
}
|
||||
if(position < lastPosition){
|
||||
NKROKeyboard.write(KEY_PAGE_DOWN);
|
||||
}
|
||||
|
||||
// Send hand seen / unseen key
|
||||
if(position > 0.05f){
|
||||
NKROKeyboard.press(KEY_HOME);
|
||||
}
|
||||
else{
|
||||
NKROKeyboard.release(KEY_HOME);
|
||||
}
|
||||
|
||||
// Send hand moved key
|
||||
NKROKeyboard.write(KEY_END);
|
||||
|
||||
}
|
||||
|
||||
USBOutput::USBOutput(){
|
||||
NKROKeyboard.begin();
|
||||
lastPosition = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user