Add second timer for pushbutton read

pico-v0.1
alanbjohnston 3 years ago committed by GitHub
parent f83f777ef2
commit a096297b75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -85,6 +85,8 @@ void setup() {
// program Transceiver board
config_radio();
start_button_isr();
sampleTime = (unsigned int) millis();
ready = TRUE; // flag for core1 to start looping
@ -142,7 +144,12 @@ void loop() {
config_telem();
config_radio();
}
// Calculate loop time
Serial.print("\nLoop time: ");
Serial.println(millis() - startSleep);
}
bool TimerHandler1(struct repeating_timer *t) {
// check for button press
if (digitalRead(MAIN_PB_PIN) == PRESSED) // pushbutton is pressed
@ -150,9 +157,7 @@ void loop() {
if (BOOTSEL) // boot selector button is pressed on Pico
process_bootsel();
// Calculate loop time
Serial.print("\nLoop time: ");
Serial.println(millis() - startSleep);
return(true);
}
@ -2904,3 +2909,17 @@ void start_isr() {
}
void start_button_isr() {
Serial.println("Starting pushbutton ISR");
if (ITimer1.attachInterruptInterval(10000, TimerHandler1))
{
Serial.print(F("Starting ITimer1 OK, micros() = "));
Serial.println(micros());
}
else
Serial.println(F("Can't set ITimer1. Select another Timer, freq. or timer"));
}

Loading…
Cancel
Save

Powered by TurnKey Linux.