-
Notifications
You must be signed in to change notification settings - Fork 2
/
Shifter.ino
56 lines (52 loc) · 1.12 KB
/
Shifter.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
bool shift_flag = false;
void detechShift(){
int gauge = 0;
while(!shift_flag
&& digitalRead(sw_pins[2]) == LOW){
gauge++;
if(gauge > 1000){
Serial.println('S');
shiftbuff++; //buffering
lastbtt_shift = millis();
break;
}
}
gauge = 0;
if(digitalRead(sw_pins[2]) == LOW){
shift_flag = true;
}else{
shift_flag = false;
}
}
void shiftEnter(){
if((millis() - lastbtt_shift) > bp_span *4
&& shiftbuff > 0){
Serial.print("sss ");
Serial.print(shiftbuff);
shiftAct(shiftbuff);
Serial.println(" sss");
shiftbuff = 0;
}
}
bool caps = false;
void shiftAct(byte b){
if(b == 1){
Keyboard.press(129);
sh_cap = true;
}else if(b == 2){
if(!caps){
Keyboard.press(129);
caps = !caps;
}else{
Keyboard.release(129);
caps = !caps;
}
}else if(b == 3){
silent = !silent;
if(!silent) switchon();
}else if(b == 4){
Keyboard.print("your username");
}else if(b == 5){
Keyboard.print("your password");
}
}