From 74605d9579d75d3fdd478cd72a4c174fbc5e61b9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Fri, 15 Jul 2022 09:56:00 -0400 Subject: [PATCH] check for button press upon coming out of sleep --- cubesatsim/cubesatsim.ino | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 5c80ccac..f4225384 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2480,11 +2480,19 @@ 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(); } } void process_pushbutton() { - + +// Serial.println("PB pressed!"); + int release = FALSE; digitalWrite(LED_BUILTIN, HIGH); // make sure built in LED is on before starting to blink @@ -2578,6 +2586,8 @@ void process_pushbutton() { void process_bootsel() { +// Serial.println("BOOTSEL pressed!"); + int release = FALSE; digitalWrite(LED_BUILTIN, HIGH); // make sure built in LED is on before blinking @@ -2783,12 +2793,12 @@ bool TimerHandler0(struct repeating_timer *t) { Serial.println((micros() - micro_timer)/bufLen); micro_timer = micros(); } - if (digitalRead(MAIN_PB_PIN) == PRESSED) // pushbutton is pressed -// Serial.println("PB pressed!"); +/* + if (digitalRead(MAIN_PB_PIN) == PRESSED) // pushbutton is pressed process_pushbutton(); - if (BOOTSEL) // boot selector button is pressed on Pico + if (BOOTSEL) // boot selector button is pressed on Pico process_bootsel(); - +*/ return true; }