cleaner code
This commit is contained in:
@@ -5,12 +5,7 @@
|
|||||||
#error should be running at 8MHz
|
#error should be running at 8MHz
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setup() {
|
#define PIN A0
|
||||||
pinMode(A0, INPUT_PULLUP);
|
|
||||||
Keyboard.begin();
|
|
||||||
Serial.begin(9600);
|
|
||||||
Serial.setTimeout(50);
|
|
||||||
}
|
|
||||||
|
|
||||||
void goto_bootloader() {
|
void goto_bootloader() {
|
||||||
cli();
|
cli();
|
||||||
@@ -35,21 +30,42 @@ void check_blcmd() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void toggle() {}
|
||||||
while (digitalRead(A0) == HIGH) {
|
|
||||||
check_blcmd();
|
|
||||||
delay(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
Keyboard.press(KEY_F14);
|
|
||||||
Keyboard.releaseAll();
|
|
||||||
|
|
||||||
while (digitalRead(A0) != HIGH) {
|
|
||||||
check_blcmd();
|
|
||||||
delay(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void turned_on() {
|
||||||
Keyboard.press(KEY_F15);
|
Keyboard.press(KEY_F15);
|
||||||
Keyboard.releaseAll();
|
Keyboard.releaseAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void turned_off() {
|
||||||
|
Keyboard.press(KEY_F14);
|
||||||
|
Keyboard.releaseAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
pinMode(PIN, INPUT_PULLUP);
|
||||||
|
Keyboard.begin();
|
||||||
|
Serial.begin(9600);
|
||||||
|
Serial.setTimeout(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
static bool last_state = 0;
|
||||||
|
|
||||||
|
bool current_state = digitalRead(PIN);
|
||||||
|
|
||||||
|
if (last_state != current_state) {
|
||||||
|
toggle();
|
||||||
|
if (current_state)
|
||||||
|
turned_on();
|
||||||
|
else
|
||||||
|
turned_off();
|
||||||
|
last_state = current_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
check_blcmd();
|
||||||
|
delay(100);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user