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);
// test_radio();
if ((mode == FSK) || (mode == BPSK)) {
// if (!wifi)
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(MAIN_LED_BLUE, LOW);
// delay(3000); // check for button press
sleep(0.2); // 2.845); // 3.0); if (digitalRead(MAIN_PB_PIN) == PRESSED) // pushbutton is pressed
process_pushbutton();
if (BOOTSEL) // boot selector button is pressed on Pico
process_bootsel();
// if (!wifi) if (prompt) {
digitalWrite(LED_BUILTIN, HIGH); // Serial.println("Need to prompt for input!");
digitalWrite(MAIN_LED_BLUE, HIGH); prompt_for_input();
prompt = false;
} }
// check to see if the mode has changed // check to see if the mode has changed
@ -321,18 +314,25 @@ void loop() {
sampleTime = (unsigned int) millis(); sampleTime = (unsigned int) millis();
} }
serial_input(); // 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();
// check for button press // delay(2000);
if (digitalRead(MAIN_PB_PIN) == PRESSED) // pushbutton is pressed // test_radio();
process_pushbutton();
if (BOOTSEL) // boot selector button is pressed on Pico
process_bootsel();
if (prompt) { if ((mode == FSK) || (mode == BPSK)) {
// Serial.println("Need to prompt for input!"); // if (!wifi)
prompt_for_input(); digitalWrite(LED_BUILTIN, LOW);
prompt = false; 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.