From 506a3bcf9b6f39d782e515cd1c981a7681fa120f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 27 Nov 2022 10:49:11 -0500 Subject: [PATCH] add setup1 and loop1 --- cubesatsim/cubesatsim.ino | 43 +++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 203016ba..383587b0 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -305,7 +305,7 @@ void loop() { digitalWrite(MAIN_LED_BLUE, HIGH); } - +/* serial_input(); // check for button press @@ -336,7 +336,7 @@ void loop() { config_radio(); sampleTime = (unsigned int) millis(); } - +*/ // Calculate loop time if (debug_mode) { Serial.print("\nLoop time: "); @@ -3226,7 +3226,7 @@ void pwm_interrupt_handler() { } */ -/* /// +/**/ void setup1() { Serial.begin(9600); sleep(5.0); @@ -3243,10 +3243,40 @@ void setup1() { } void loop1() { - Serial.print("l1 "); + + 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(); + + // check to see if the mode has changed + if (mode != new_mode) { + Serial.println("Changing mode"); +/// if (mode == SSTV) { +/// ITimer1.detachInterrupt(); +/// start_button_isr(); // restart button isr +/// } + mode = new_mode; // change modes if button pressed + write_mode(); + if (new_mode != CW) + transmit_callsign(callsign); + sleep(0.5); + config_telem(); + config_radio(); + sampleTime = (unsigned int) millis(); + } + + sleep(1.0); + +/* + Serial.print("l1 "); Serial.print(wav_position); Serial.print(" "); - + + if (mode == FSK) { tx_bit = (buffer[wav_position++] > 0) ? HIGH: LOW; @@ -3284,9 +3314,10 @@ void loop1() { // if (pb_value == PRESSED) if (digitalRead(MAIN_PB_PIN) == PRESSED) process_pushbutton(); +*/ } -*/// +/**/// /* void sleep(float time) { // sleeps for intervals more than 0.1 seconds