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

@ -140,6 +140,13 @@ void loop() {
config_telem();
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: ");
@ -2479,13 +2486,7 @@ void sleep(float time) { // sleeps for intervals more than 0.01 milli seconds
unsigned long startSleep = micros();
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();
delayMicroseconds(100);
}
}

Loading…
Cancel
Save

Powered by TurnKey Linux.