check for button press once per loop

pico-v0.1
alanbjohnston 4 years ago committed by GitHub
parent 74605d9579
commit 21a4bfa739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -141,6 +141,13 @@ void loop() {
config_radio();
}
// check for button press
if (digitalRead(MAIN_PB_PIN) == PRESSED) // pushbutton is pressed
process_pushbutton();
if (BOOTSEL) // boot selector button is pressed on Pico
process_bootsel();
// Calculate loop time
Serial.print("\nLoop time: ");
Serial.println(millis() - startSleep);
@ -2480,12 +2487,6 @@ void sleep(float time) { // sleeps for intervals more than 0.01 milli seconds
while ((micros() - startSleep) < time_us) {
// busy_wait_us(100);
delayMicroseconds(100);
// check for button press upon coming out of sleep
if (digitalRead(MAIN_PB_PIN) == PRESSED) // pushbutton is pressed
process_pushbutton();
if (BOOTSEL) // boot selector button is pressed on Pico
process_bootsel();
}
}

Loading…
Cancel
Save

Powered by TurnKey Linux.