project_mech-keyboard/firmware/keyboard/keyboard.ino
2018-09-28 00:13:09 +01:00

114 lines
2.8 KiB
C++

#include <Keyboard.h>
#include <Keypad.h>
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','a','b'},
{'c','d','e','f'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {13, 5, 10, 9};
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = {8, 6, 12, 4};
// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#define ledpin 11
char ctrlKey = KEY_LEFT_GUI;
void setup() {
Keyboard.begin();
pinMode(ledpin,OUTPUT);
digitalWrite(ledpin, HIGH);
// Serial.begin(9600);
}
//funcs:
void fmf1() {}
void fmf2() {}
void fmf3() {}
void fmfky() {Keyboard.print("Fuck You");}
void fmshl() {Keyboard.print("ssh root@192.168.1.999");}
void fmshg() {Keyboard.print("ssh -p 16969 root@225.225.225.999");}
void fmgdr() {Keyboard.print(":/mnt/GIT/gitFolder/");}
void fmezg() {Keyboard.print("ezgit");}//Keyboard.printlnm("ezgit");
void fmsbr() {Keyboard.print("source ~/.bashrc");}
void fmszr() {Keyboard.print("source ~/.zshrc");}
void fmclb() {Keyboard.press(ctrlKey);delay(5);Keyboard.press("b");delay(5);Keyboard.releaseAll();}
void fmglp() {Keyboard.print("git log --pretty --color --graph --oneline --decorate --histogram");}
void fmcbh() {Keyboard.press(ctrlKey);delay(5);Keyboard.press("b");delay(5);Keyboard.releaseAll();delay(5);Keyboard.print("h");}
void fmcbv() {Keyboard.press(ctrlKey);delay(5);Keyboard.press("b");delay(5);Keyboard.releaseAll();delay(5);Keyboard.print("v");}
void fmcbs() {Keyboard.press(ctrlKey);delay(5);Keyboard.press("b");delay(5);Keyboard.releaseAll();delay(5);Keyboard.print("s");}
void fmexr() {Keyboard.print("exit");delay(5);}//ln
void loop() {
char key = kpd.getKey();
if(key) {
switch (key) {
case '0':
fmf1();
break;
case '1':
fmf2();
break;
case '2':
fmf3();
break;
case '3':
fmfky();
break;
case '4':
fmshl();
break;
case '5':
fmshg();
break;
case '6':
fmgdr();
break;
case '7':
fmezg();
break;
case '8':
fmsbr();
break;
case '9':
fmszr();
break;
case 'a':
fmclb();
break;
case 'b':
fmglp();
break;
case 'c':
fmcbh();
break;
case 'd':
fmcbv();
break;
case 'e':
fmcbs();
break;
case 'f':
fmexr();
break;
// default:
// Serial.println(key);
}
delay(100);
}
}