From 4513d4323e94f932e1918f0b1f072f228df51c29 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Nov 2022 08:40:02 -0500 Subject: [PATCH] move button check and new mode check before loop --- cubesatsim/cubesatsim.ino | 60 +++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 0992f539..accbb3b3 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -283,25 +283,18 @@ void loop() { else Serial.println("Unknown mode!"); -// while ((millis() - sampleTime) < ((unsigned int)samplePeriod)) // - 250)) // was 250 100 - while ((millis() - sampleTime) < ((unsigned int)frameTime)) // - 250)) // was 250 100 - sleep(0.01); // was 0.1 sec - sampleTime = (unsigned int) millis(); + serial_input(); -// delay(2000); -// test_radio(); - - if ((mode == FSK) || (mode == BPSK)) { -// if (!wifi) - digitalWrite(LED_BUILTIN, LOW); - digitalWrite(MAIN_LED_BLUE, LOW); - - // delay(3000); - sleep(0.2); // 2.845); // 3.0); - -// if (!wifi) - digitalWrite(LED_BUILTIN, HIGH); - digitalWrite(MAIN_LED_BLUE, HIGH); +// 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(); + + if (prompt) { +// Serial.println("Need to prompt for input!"); + prompt_for_input(); + prompt = false; } // check to see if the mode has changed @@ -319,20 +312,27 @@ void loop() { config_telem(); config_radio(); sampleTime = (unsigned int) millis(); - } - - serial_input(); + } -// 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(); +// while ((millis() - sampleTime) < ((unsigned int)samplePeriod)) // - 250)) // was 250 100 + while ((millis() - sampleTime) < ((unsigned int)frameTime)) // - 250)) // was 250 100 + sleep(0.01); // was 0.1 sec + sampleTime = (unsigned int) millis(); - if (prompt) { -// Serial.println("Need to prompt for input!"); - prompt_for_input(); - prompt = false; +// delay(2000); +// test_radio(); + + if ((mode == FSK) || (mode == BPSK)) { +// if (!wifi) + digitalWrite(LED_BUILTIN, LOW); + digitalWrite(MAIN_LED_BLUE, LOW); + + // delay(3000); + sleep(0.2); // 2.845); // 3.0); + +// if (!wifi) + digitalWrite(LED_BUILTIN, HIGH); + digitalWrite(MAIN_LED_BLUE, HIGH); } // Calculate loop time