-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMinusEinsEnterSlashButton.ino
87 lines (80 loc) · 1.87 KB
/
MinusEinsEnterSlashButton.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "DigiKeyboard.h"
unsigned int pos = 0;
unsigned int ticks = 0;
unsigned int antiscreensaver = 0;
uint16_t rst = 0;
bool tick_flag = false;
void setup(){
// this is generally not necessary but with some older systems it seems to prevent missing the first character after a delay:
DigiKeyboard.sendKeyStroke(0);
pinMode(0, INPUT_PULLUP); //button
pinMode(1, OUTPUT); //LED
pinMode(2, OUTPUT); //RESET
}
void loop(){
if (digitalRead(0) == LOW){
switch (rst){
case 0 ... 99:
pos = 100;
digitalWrite(1, LOW);
break;
case 100:
pos = 0;
break;
case 300:
digitalWrite(1, HIGH);
delay(50);
digitalWrite(2, HIGH);
delay(3000);
digitalWrite(2, LOW);
}
rst++;
}else{
rst = 0;
}
if (tick_flag){
antiscreensaver++;
if (antiscreensaver >= 3600){
antiscreensaver = 0;
DigiKeyboard.sendKeyStroke(85); //NUM_MULTIPLY
}
if (pos >0){
if ((pos >= 50) or (pos%2 == 1)){
digitalWrite(1, HIGH);
}else{
digitalWrite(1, LOW);
}
switch(pos){
case 98:
DigiKeyboard.sendKeyStroke(86); // NUM_MINUS
break;
case 95:
DigiKeyboard.sendKeyStroke(86); // NUM_MINUS
break;
case 75:
// DigiKeyboard.sendKeyStroke(89); // NUM_1
DigiKeyboard.sendKeyStroke(30); // KEY_1
break;
case 60:
DigiKeyboard.sendKeyStroke(88); // NUM_ENTER
break;
case 1:
DigiKeyboard.sendKeyStroke(84); // NUM_SLASH
break;
}
pos--;
}else{
digitalWrite(1, LOW);
if (antiscreensaver % 200 == 1){
DigiKeyboard.sendKeyStroke(0);
}
}
tick_flag = 0;
}
delay(5);
ticks++;
if (ticks >= 10){
tick_flag = true;
ticks = 0;
}
}