move button check and new mode check before loop

pico-button-loop
alanbjohnston 3 years ago committed by GitHub
parent 9ace4a4a88
commit 4513d4323e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

Loading…
Cancel
Save

Powered by TurnKey Linux.