cleaner code
This commit is contained in:
@@ -5,12 +5,7 @@
|
||||
#error should be running at 8MHz
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
pinMode(A0, INPUT_PULLUP);
|
||||
Keyboard.begin();
|
||||
Serial.begin(9600);
|
||||
Serial.setTimeout(50);
|
||||
}
|
||||
#define PIN A0
|
||||
|
||||
void goto_bootloader() {
|
||||
cli();
|
||||
@@ -35,21 +30,42 @@ void check_blcmd() {
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
while (digitalRead(A0) == HIGH) {
|
||||
check_blcmd();
|
||||
delay(100);
|
||||
}
|
||||
|
||||
Keyboard.press(KEY_F14);
|
||||
Keyboard.releaseAll();
|
||||
|
||||
while (digitalRead(A0) != HIGH) {
|
||||
check_blcmd();
|
||||
delay(100);
|
||||
}
|
||||
void toggle() {}
|
||||
|
||||
void turned_on() {
|
||||
Keyboard.press(KEY_F15);
|
||||
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