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 else
Serial.println("Unknown mode!"); Serial.println("Unknown mode!");
// while ((millis() - sampleTime) < ((unsigned int)samplePeriod)) // - 250)) // was 250 100 serial_input();
while ((millis() - sampleTime) < ((unsigned int)frameTime)) // - 250)) // was 250 100
sleep(0.01); // was 0.1 sec
sampleTime = (unsigned int) millis();
// delay(2000); // check for button press
// test_radio(); if (digitalRead(MAIN_PB_PIN) == PRESSED) // pushbutton is pressed
process_pushbutton();
if ((mode == FSK) || (mode == BPSK)) { if (BOOTSEL) // boot selector button is pressed on Pico
// if (!wifi) process_bootsel();
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(MAIN_LED_BLUE, LOW); if (prompt) {
// Serial.println("Need to prompt for input!");
// delay(3000); prompt_for_input();
sleep(0.2); // 2.845); // 3.0); prompt = false;
// if (!wifi)
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(MAIN_LED_BLUE, HIGH);
} }
// check to see if the mode has changed // check to see if the mode has changed
@ -319,20 +312,27 @@ void loop() {
config_telem(); config_telem();
config_radio(); config_radio();
sampleTime = (unsigned int) millis(); sampleTime = (unsigned int) millis();
} }
serial_input();
// check for button press // while ((millis() - sampleTime) < ((unsigned int)samplePeriod)) // - 250)) // was 250 100
if (digitalRead(MAIN_PB_PIN) == PRESSED) // pushbutton is pressed while ((millis() - sampleTime) < ((unsigned int)frameTime)) // - 250)) // was 250 100
process_pushbutton(); sleep(0.01); // was 0.1 sec
if (BOOTSEL) // boot selector button is pressed on Pico sampleTime = (unsigned int) millis();
process_bootsel();
if (prompt) { // delay(2000);
// Serial.println("Need to prompt for input!"); // test_radio();
prompt_for_input();
prompt = false; 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 // Calculate loop time

Loading…
Cancel
Save

Powered by TurnKey Linux.