project_mech-keyboard/firmware/main/main.ino
2018-09-28 19:32:53 +01:00

128 lines
3.1 KiB
C++

#include <FastLED.h>
#include <Keyboard.h>
#include <Keypad.h>
//Declarations LED
#define NUM_LED 4
#define LED_PIN 7
CRGB led[NUM_LED];
char currentRGB = i;
//Declarations KEYPAD
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','a','b'},
{'c','d','e','f'}
};
byte rowPins[ROWS] = {13, 5, 10, 9};
byte colPins[COLS] = {8, 6, 12, 4};
Keypad kpd = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
char ctrlKey = KEY_LEFT_CTRL;
void setAll(int red, int grn, int blu){
for (int i = 0; i < NUM_LED; i++){
led[i] = CRGB(red, grn, blu);
}
FastLED.show();}
void setQ(int red, int grn, int blu){led[0] = CRGB(red, grn, blu);}
void setW(int red, int grn, int blu){led[1] = CRGB(red, grn, blu);}
void setA(int red, int grn, int blu){led[2] = CRGB(red, grn, blu);}
void setS(int red, int grn, int blu){led[3] = CRGB(red, grn, blu);}
void show(){FastLED.show();}
void fmf1() {setAll(125, 241, 255);show();}
void fmf2() {setAll(255, 0, 255);show();}
void fmf3() {
switch (currentRGB) {
case "i":
setQ(255, 0, 63);setW(255, 246, 0);setA(0, 128, 0);setS(255, 0, 63);show();currentRGB = "r";
break;
case "o":
setAll(0, 0, 255);show();currentRGB = "i";
break;
default:
setAll(0, 0, 0);show();currentRGB = "o";
break;
}
void fmfky() {Keyboard.print("Fuck You");}
void fmshl() {Keyboard.println("ssh root@192.168.1.85");}
void fmshg() {Keyboard.println("ssh -p 9999 root@git64.ddns.net");}
void fmgdr() {Keyboard.print(":/mnt/GIT/gitFolder/");}
void fmezg() {Keyboard.println("ezgit");}
void fmsbr() {Keyboard.println("cd;source .bashrc;cd -");}
void fmszr() {Keyboard.println("cd;source .zshrc;cd -");}
void fmclb() {Keyboard.press(ctrlKey);delay(20);Keyboard.press(98);delay(20);Keyboard.releaseAll();}
void fmglp() {Keyboard.println("git log --pretty --color --graph --oneline --decorate --histogram");}
void fmcbh() {Keyboard.press(ctrlKey);delay(20);Keyboard.press(98);delay(20);Keyboard.releaseAll();delay(5);Keyboard.print("h");}
void fmcbv() {Keyboard.press(ctrlKey);delay(20);Keyboard.press(98);delay(20);Keyboard.releaseAll();delay(5);Keyboard.print("v");}
void fmcbs() {Keyboard.press(ctrlKey);delay(20);Keyboard.press(98);delay(20);Keyboard.releaseAll();delay(5);Keyboard.print("s");}
void fmexr() {Keyboard.println("exit");delay(5);}
void setup() {
FastLED.addLeds<NEOPIXEL, LED_PIN>(led, NUM_LED);
setAll(0, 0, 255);
Keyboard.begin();
pinMode(ledpin,OUTPUT);
digitalWrite(ledpin, HIGH);
setAll(100, 0, 0)
}
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;
}
delay(100);
}
}