From 3e172895e7128861adce87781c90ca409c0adb43 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:15:16 -0400 Subject: [PATCH 01/96] added get_serial_char() --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 37764857..3bad14fe 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -182,6 +182,7 @@ void load_files(); void show_dir(); void serial_input(); void get_serial_string(); +void get_serial_char(); #ifndef STASSID #define STASSID "Pico" From 9acdb2e472d29654a9505ce04b530698f1710fb8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:25:43 -0400 Subject: [PATCH 02/96] added get_serial_char and simulated telemetry prompt --- cubesatsim/cubesatsim.ino | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 572cd3d1..bcec071e 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3802,7 +3802,20 @@ void prompt_for_input() { break; case PROMPT_SIM: - + if (sim_mode == TRUE) + Serial.println("Simulted Telemetry mode is currently on") + else + Serial.println("Simulted Telemetry mode is currently off") + Serial.println("Do you want Simulated Telemetry on (y/n)"); + get_serial_char(); + if ((serial_string == 'y') || (serial_string == 'Y')) { + Serial.println("Setting Simulated telemetry to on"); + sim_mode = true; + } else if ((serial_string == 'n') || (serial_string == 'N')) { + Serial.println("Setting Simulated telemetry to off"); + sim_mode = false; + } else + Serial.println("No change to Simulated Telemetry mode"); break; case PROMPT_LAT: @@ -3834,9 +3847,23 @@ void get_serial_string() { serial_string[i++] = input; Serial.write(input); } - } + } sleep(0.1); } serial_string[i] = 0; Serial.println(" "); } + +void get_serial_char() { + unsigned int elapsed_time = (unsigned int) millis(); + while (((millis() - elapsed_time) < 20000) && (Serial.available() < 1) { } + if (Serial.available() > 0) { + serial_string[0] = Serial.read(); // get character + Serial.write(input); + serial_string[1] = 0; + Serial.println(" "); + } else + { + serial_string[0] = 0; // timeout - no character + } +} From 1719241318bd3124ccca2db163a5543b606a16ce Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:26:59 -0400 Subject: [PATCH 03/96] missing ; --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index bcec071e..0b75c495 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3803,7 +3803,7 @@ void prompt_for_input() { case PROMPT_SIM: if (sim_mode == TRUE) - Serial.println("Simulted Telemetry mode is currently on") + Serial.println("Simulted Telemetry mode is currently on"); else Serial.println("Simulted Telemetry mode is currently off") Serial.println("Do you want Simulated Telemetry on (y/n)"); From 4691e0884339e4878e355cd3bd84893f7b867e83 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:29:22 -0400 Subject: [PATCH 04/96] again --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 0b75c495..6cf2048b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3805,7 +3805,7 @@ void prompt_for_input() { if (sim_mode == TRUE) Serial.println("Simulted Telemetry mode is currently on"); else - Serial.println("Simulted Telemetry mode is currently off") + Serial.println("Simulted Telemetry mode is currently off"); Serial.println("Do you want Simulated Telemetry on (y/n)"); get_serial_char(); if ((serial_string == 'y') || (serial_string == 'Y')) { From ec7b90714872292a5569d413107455b03d27bec3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:30:29 -0400 Subject: [PATCH 05/96] fixed serial_string --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 6cf2048b..10ff7457 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3808,10 +3808,10 @@ void prompt_for_input() { Serial.println("Simulted Telemetry mode is currently off"); Serial.println("Do you want Simulated Telemetry on (y/n)"); get_serial_char(); - if ((serial_string == 'y') || (serial_string == 'Y')) { + if ((serial_string[0] == 'y') || (serial_string[0] == 'Y')) { Serial.println("Setting Simulated telemetry to on"); sim_mode = true; - } else if ((serial_string == 'n') || (serial_string == 'N')) { + } else if ((serial_string[0] == 'n') || (serial_string[0] == 'N')) { Serial.println("Setting Simulated telemetry to off"); sim_mode = false; } else From 46b6b20cd05ac2f936c2c063cd2baaaf26043657 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:31:47 -0400 Subject: [PATCH 06/96] fixed ( --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 10ff7457..a50bcaa0 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3856,7 +3856,7 @@ void get_serial_string() { void get_serial_char() { unsigned int elapsed_time = (unsigned int) millis(); - while (((millis() - elapsed_time) < 20000) && (Serial.available() < 1) { } + while ((millis() - elapsed_time) < 20000) && (Serial.available() < 1)) { } if (Serial.available() > 0) { serial_string[0] = Serial.read(); // get character Serial.write(input); From 354537bf2c4b0bd4a3fcd78347e5c5b185379835 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:33:47 -0400 Subject: [PATCH 07/96] typos --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a50bcaa0..e4cdbcdc 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3856,10 +3856,10 @@ void get_serial_string() { void get_serial_char() { unsigned int elapsed_time = (unsigned int) millis(); - while ((millis() - elapsed_time) < 20000) && (Serial.available() < 1)) { } + while (((millis() - elapsed_time) < 20000) && (Serial.available() < 1)) { } if (Serial.available() > 0) { serial_string[0] = Serial.read(); // get character - Serial.write(input); + Serial.write(serial_string[0]); serial_string[1] = 0; Serial.println(" "); } else From c24ab5d0dee7c92685edbe88edcd073d5507f9c8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:37:03 -0400 Subject: [PATCH 08/96] turned serial input on --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index e4cdbcdc..a2e8eb19 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -263,7 +263,7 @@ void loop() { bool TimerHandler1(struct repeating_timer *t) { -// serial_input(); + serial_input(); // check for button press if (digitalRead(MAIN_PB_PIN) == PRESSED) // pushbutton is pressed From 54d5595eb528332053631cd06bfb70aac66f70fb Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:46:29 -0400 Subject: [PATCH 09/96] added latitude and longitude --- cubesatsim/cubesatsim.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 3bad14fe..c5c27e84 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -320,6 +320,8 @@ int buffer_size; long micro_timer; int ready = FALSE; bool cw_stop = false; +float latitude = ; +float latitude = 39.027702f, longitude = -77.078064f; #define PRESSED 0 #define HELD 0 From 6d21812e721e938bf310cf46061b07654bd7f1ba Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:56:08 -0400 Subject: [PATCH 10/96] added latitude update --- cubesatsim/cubesatsim.ino | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a2e8eb19..c24aa9c0 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -1,5 +1,5 @@ /* - * Transmits CubeSat Telemetry at 434.9MHz in AFSK, FSK, or CW format + * Transmits CubeSat Telemetry at 432.25MHz in AFSK, FSK, BPSK, or CW format * * Copyright Alan B. Johnston * @@ -3819,7 +3819,18 @@ void prompt_for_input() { break; case PROMPT_LAT: - + + Serial.println("Changing the latitude and longitude - only used for APRS telemetry"); + Serial.println("Hitting return keeps the current value."); + Serial.print("Current value of latitude is "); + Serial.println(latitude); + Serial.println("Enter latitude (decimal degrees, positive is north): "); + get_serial_string(); + float result = atof(serial_string); + if (float != 0.0) { + Serial.print("Latitude updated to "); + Serial.print(result); + latitude = result; break; case PROMPT_QUERY: From c124fc0de8d63e84bc4f124994eba34e26a90b5d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:58:17 -0400 Subject: [PATCH 11/96] removed extra latitude and longitude --- cubesatsim/cubesatsim.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index c5c27e84..3bad14fe 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -320,8 +320,6 @@ int buffer_size; long micro_timer; int ready = FALSE; bool cw_stop = false; -float latitude = ; -float latitude = 39.027702f, longitude = -77.078064f; #define PRESSED 0 #define HELD 0 From 933b146d5db96b3c0810c8d526c4a464b04db303 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 07:59:19 -0400 Subject: [PATCH 12/96] typo on float --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c24aa9c0..343f2833 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3827,7 +3827,7 @@ void prompt_for_input() { Serial.println("Enter latitude (decimal degrees, positive is north): "); get_serial_string(); float result = atof(serial_string); - if (float != 0.0) { + if (result != 0.0) { Serial.print("Latitude updated to "); Serial.print(result); latitude = result; From f058f585d32545076aa1de6218d89a50ab55b837 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 08:02:57 -0400 Subject: [PATCH 13/96] missing } --- cubesatsim/cubesatsim.ino | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 343f2833..7364b1bb 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3826,11 +3826,12 @@ void prompt_for_input() { Serial.println(latitude); Serial.println("Enter latitude (decimal degrees, positive is north): "); get_serial_string(); - float result = atof(serial_string); - if (result != 0.0) { + float float_result = atof(serial_string); + if (float_result != 0.0) { Serial.print("Latitude updated to "); - Serial.print(result); - latitude = result; + Serial.print(float_result); + latitude = float_result; + } break; case PROMPT_QUERY: From 9b54ddba7c3cee0cd32f62099bf17c8e883da5a1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 08:06:12 -0400 Subject: [PATCH 14/96] fixed variable initialization in case --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 7364b1bb..492b9a1e 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3758,6 +3758,7 @@ void serial_input() { } void prompt_for_input() { + float float_result; while (Serial.available() > 0) // clear any characters in serial input buffer Serial.read(); @@ -3826,7 +3827,7 @@ void prompt_for_input() { Serial.println(latitude); Serial.println("Enter latitude (decimal degrees, positive is north): "); get_serial_string(); - float float_result = atof(serial_string); + float_result = atof(serial_string); if (float_result != 0.0) { Serial.print("Latitude updated to "); Serial.print(float_result); From f5d1665ba9223d62be9715f0c08f150c65bc6e88 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 08:10:43 -0400 Subject: [PATCH 15/96] added longitude --- cubesatsim/cubesatsim.ino | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 492b9a1e..9d3cde5b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3832,7 +3832,23 @@ void prompt_for_input() { Serial.print("Latitude updated to "); Serial.print(float_result); latitude = float_result; - } + } else + Serial.print("Latitude not updated"); + Serial.print("Current value of longitude is "); + Serial.println(longitude); + Serial.println("Enter longitude (decimal degrees, positive is east): "); + get_serial_string(); + float_result = atof(serial_string); + if (float_result != 0.0) { + Serial.print("Longitude updated to "); + Serial.print(float_result); + longitude = float_result; + } else + Serial.print("Longitude not updated"); + + latitude = toAprsFormat(latitude); + longitude = toAprsFormat(longitude); + break; case PROMPT_QUERY: From 7839457828db52ff9981fb0cea3c6919a13ea995 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 08:16:43 -0400 Subject: [PATCH 16/96] added void get_serial_clear_buffer() --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 3bad14fe..32d06058 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -183,6 +183,7 @@ void show_dir(); void serial_input(); void get_serial_string(); void get_serial_char(); +void get_serial_clear_buffer(); #ifndef STASSID #define STASSID "Pico" From 35eded0065dc4a995d499bf75ab8974460f0e7db Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 08:17:30 -0400 Subject: [PATCH 17/96] clear serial input buffer for multiple prompts --- cubesatsim/cubesatsim.ino | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 9d3cde5b..732dc7e8 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3823,6 +3823,7 @@ void prompt_for_input() { Serial.println("Changing the latitude and longitude - only used for APRS telemetry"); Serial.println("Hitting return keeps the current value."); + Serial.print("Current value of latitude is "); Serial.println(latitude); Serial.println("Enter latitude (decimal degrees, positive is north): "); @@ -3830,10 +3831,12 @@ void prompt_for_input() { float_result = atof(serial_string); if (float_result != 0.0) { Serial.print("Latitude updated to "); - Serial.print(float_result); + Serial.println(float_result); latitude = float_result; } else Serial.print("Latitude not updated"); + + get_serial_clear_buffer(); Serial.print("Current value of longitude is "); Serial.println(longitude); Serial.println("Enter longitude (decimal degrees, positive is east): "); @@ -3841,7 +3844,7 @@ void prompt_for_input() { float_result = atof(serial_string); if (float_result != 0.0) { Serial.print("Longitude updated to "); - Serial.print(float_result); + Serial.println(float_result); longitude = float_result; } else Serial.print("Longitude not updated"); @@ -3896,3 +3899,10 @@ void get_serial_char() { serial_string[0] = 0; // timeout - no character } } + +void get_serial_clear_buffer() { +// Serial.println("Emptying serial input buffer"); + while (Serial.available() > 0) + Serial.read(); + +} From 73a22cf889110894b87fd716ea562238b65406b9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 08:28:45 -0400 Subject: [PATCH 18/96] added lat and lon to aprs --- cubesatsim/cubesatsim.ino | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 732dc7e8..f524d965 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -251,7 +251,7 @@ void loop() { } if (prompt) { - Serial.println("Need to prompt for input!"); +// Serial.println("Need to prompt for input!"); prompt_for_input(); prompt = false; } @@ -472,14 +472,31 @@ void config_telem() { set_pin(AUDIO_OUT_PIN); -// char callsign[] = "W3ZM"; set_callsign(callsign); - char lat_default[] = "0610.55S"; - char lon_default[] = "10649.62E"; + + char lat_string[64]; + char lon_string[64]; + char sym_ovl_default = 'H'; char sym_tab_default = 'a'; char icon[] = "Ha"; - set_lat_lon_icon(lat_default, lon_default, icon); + +// latitude = toAprsFormat(latitude); +// longitude = toAprsFormat(longitude); + // sprintf(header_str2b, "=%7.2f%c%c%c%08.2f%cShi hi ",4003.79,'N',0x5c,0x5c,07534.33,'W'); // add APRS lat and long + if (latitude > 0) + sprintf(lat_string, "%7.2f%c", toAprsFormat(latitude), 'N'); // lat + else + sprintf(lat_string, "%7.2f%c", toAprsFormat(latitude) * (-1.0), 'S'); // lat + if (longitude > 0) + sprintf(lon_string, "%08.2f%c", toAprsFormat(longitude), 'E'); // long + else + sprintf(lon_string, "%08.2f%c", toAprsFormat(longitude) * (-1.0), 'W'); // long + + print_string(lat_string); + print_string(lon_string); + + set_lat_lon_icon(lat_string, lon_string, icon); samplePeriod = 5000; frameTime = 5000; @@ -3834,7 +3851,7 @@ void prompt_for_input() { Serial.println(float_result); latitude = float_result; } else - Serial.print("Latitude not updated"); + Serial.println("Latitude not updated"); get_serial_clear_buffer(); Serial.print("Current value of longitude is "); @@ -3847,10 +3864,7 @@ void prompt_for_input() { Serial.println(float_result); longitude = float_result; } else - Serial.print("Longitude not updated"); - - latitude = toAprsFormat(latitude); - longitude = toAprsFormat(longitude); + Serial.println("Longitude not updated"); break; From e7f409a504cbdad3c4657803cb9e381348785c05 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 08:36:55 -0400 Subject: [PATCH 19/96] added set_lat_lon() --- cubesatsim/cubesatsim.ino | 54 ++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index f524d965..4453dddd 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -474,29 +474,7 @@ void config_telem() { set_callsign(callsign); - char lat_string[64]; - char lon_string[64]; - - char sym_ovl_default = 'H'; - char sym_tab_default = 'a'; - char icon[] = "Ha"; - -// latitude = toAprsFormat(latitude); -// longitude = toAprsFormat(longitude); - // sprintf(header_str2b, "=%7.2f%c%c%c%08.2f%cShi hi ",4003.79,'N',0x5c,0x5c,07534.33,'W'); // add APRS lat and long - if (latitude > 0) - sprintf(lat_string, "%7.2f%c", toAprsFormat(latitude), 'N'); // lat - else - sprintf(lat_string, "%7.2f%c", toAprsFormat(latitude) * (-1.0), 'S'); // lat - if (longitude > 0) - sprintf(lon_string, "%08.2f%c", toAprsFormat(longitude), 'E'); // long - else - sprintf(lon_string, "%08.2f%c", toAprsFormat(longitude) * (-1.0), 'W'); // long - - print_string(lat_string); - print_string(lon_string); - - set_lat_lon_icon(lat_string, lon_string, icon); + set_lat_lon(); samplePeriod = 5000; frameTime = 5000; @@ -3865,6 +3843,8 @@ void prompt_for_input() { longitude = float_result; } else Serial.println("Longitude not updated"); + if (mode == AFSK) + set_lat_lon(); break; @@ -3920,3 +3900,31 @@ void get_serial_clear_buffer() { Serial.read(); } + +void set_lat_lon() { +// Serial.println("Setting lat and lon for APRS"); + char lat_string[64]; + char lon_string[64]; + + char sym_ovl_default = 'H'; + char sym_tab_default = 'a'; + char icon[] = "Ha"; + +// latitude = toAprsFormat(latitude); +// longitude = toAprsFormat(longitude); + // sprintf(header_str2b, "=%7.2f%c%c%c%08.2f%cShi hi ",4003.79,'N',0x5c,0x5c,07534.33,'W'); // add APRS lat and long + if (latitude > 0) + sprintf(lat_string, "%7.2f%c", toAprsFormat(latitude), 'N'); // lat + else + sprintf(lat_string, "%7.2f%c", toAprsFormat(latitude) * (-1.0), 'S'); // lat + if (longitude > 0) + sprintf(lon_string, "%08.2f%c", toAprsFormat(longitude), 'E'); // long + else + sprintf(lon_string, "%08.2f%c", toAprsFormat(longitude) * (-1.0), 'W'); // long + +// print_string(lat_string); +// print_string(lon_string); + + set_lat_lon_icon(lat_string, lon_string, icon); + +} From ba10303ccb893063029e3b24366d186d74792d77 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 08:37:16 -0400 Subject: [PATCH 20/96] added set_lat_lon --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 32d06058..6a95b10f 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -184,6 +184,7 @@ void serial_input(); void get_serial_string(); void get_serial_char(); void get_serial_clear_buffer(); +void set_lat_lon(); #ifndef STASSID #define STASSID "Pico" From 2d05f1b5ddb218d2e58e6c56d5714d288260945f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 08:43:05 -0400 Subject: [PATCH 21/96] added 0 in lat sprintf --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 4453dddd..24dfd64a 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3914,9 +3914,9 @@ void set_lat_lon() { // longitude = toAprsFormat(longitude); // sprintf(header_str2b, "=%7.2f%c%c%c%08.2f%cShi hi ",4003.79,'N',0x5c,0x5c,07534.33,'W'); // add APRS lat and long if (latitude > 0) - sprintf(lat_string, "%7.2f%c", toAprsFormat(latitude), 'N'); // lat + sprintf(lat_string, "%07.2f%c", toAprsFormat(latitude), 'N'); // lat else - sprintf(lat_string, "%7.2f%c", toAprsFormat(latitude) * (-1.0), 'S'); // lat + sprintf(lat_string, "%07.2f%c", toAprsFormat(latitude) * (-1.0), 'S'); // lat if (longitude > 0) sprintf(lon_string, "%08.2f%c", toAprsFormat(longitude), 'E'); // long else From 790d9310b97cfd6c7114130a6b9840dddee04a35 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 08:51:39 -0400 Subject: [PATCH 22/96] changed icon --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 24dfd64a..2e3490e3 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3906,9 +3906,9 @@ void set_lat_lon() { char lat_string[64]; char lon_string[64]; - char sym_ovl_default = 'H'; - char sym_tab_default = 'a'; - char icon[] = "Ha"; + char sym_ovl_default = '\\'; \\'H'; + char sym_tab_default = 'S'; \\ 'a'; + char icon[] = "\\S"; \\Ha"; // latitude = toAprsFormat(latitude); // longitude = toAprsFormat(longitude); From 3659bca5746e12afeb932e5ef8cac32f22b44a95 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 08:53:37 -0400 Subject: [PATCH 23/96] \ typo --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 2e3490e3..b63bd094 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3906,9 +3906,9 @@ void set_lat_lon() { char lat_string[64]; char lon_string[64]; - char sym_ovl_default = '\\'; \\'H'; - char sym_tab_default = 'S'; \\ 'a'; - char icon[] = "\\S"; \\Ha"; + char sym_ovl_default = '\\'; //'H'; + char sym_tab_default = 'S'; // 'a'; + char icon[] = "\\S"; //Ha"; // latitude = toAprsFormat(latitude); // longitude = toAprsFormat(longitude); From 2948ea635f820e8c66f3491142d539527ca542ac Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 11:04:44 -0400 Subject: [PATCH 24/96] added payload_command --- cubesatsim/cubesatsim.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 6a95b10f..9886217e 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -112,6 +112,9 @@ #define PROMPT_HELP 6 #define PROMPT_RESTART 7 +#define PAYLOAD_QUERY 1 +#define PAYLOAD_RESET 2 +#define PAYLOAD_CLEAR 3 volatile int prompt = false; char serial_string[128]; @@ -322,6 +325,7 @@ int buffer_size; long micro_timer; int ready = FALSE; bool cw_stop = false; +int payload_command = false; #define PRESSED 0 #define HELD 0 From 8ffed8573fdd1a03986aa098ef9b9f1df03c6a0d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 11:10:13 -0400 Subject: [PATCH 25/96] added debug_mode --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 9886217e..83219aca 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -326,6 +326,7 @@ long micro_timer; int ready = FALSE; bool cw_stop = false; int payload_command = false; +bool debug_mode = false; #define PRESSED 0 #define HELD 0 From 6d3dc9237804d133b0a4b60d0c7cb07f7ee3b64b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 11:12:26 -0400 Subject: [PATCH 26/96] added PROMPT_DEBUG --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 83219aca..024d3a2a 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -111,6 +111,7 @@ #define PROMPT_QUERY 5 #define PROMPT_HELP 6 #define PROMPT_RESTART 7 +#define PROMPT_DEBUG 8 #define PAYLOAD_QUERY 1 #define PAYLOAD_RESET 2 From f493369050fffb5ec33fed9bac99b4558795e4ce Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 11:13:46 -0400 Subject: [PATCH 27/96] added debug_mode and reset --- cubesatsim/cubesatsim.ino | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index b63bd094..a4eb8320 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3738,7 +3738,12 @@ void serial_input() { Serial.println("Query payload sensors"); prompt = PROMPT_QUERY; break; - + + case 'd': + Serial.println("Change debug mode"); + prompt = PROMPT_DEBUG; + break; + default: Serial.println("Not a command\n"); @@ -3849,17 +3854,38 @@ void prompt_for_input() { break; case PROMPT_QUERY: - + Serial.println("Querying payload sensors"); + payload_command = PAYLOAD_QUERY; break; case PROMPT_RESET: + Serial.println("Do you want to Reset the Reset Count (r) or Reset the Payload (p)?"); + Serial.println("Enter r or p"); + get_serial_char(); + if ((serial_string[0] == 'r') || (serial_string[0] == 'R')) { + Serial.println("Resetting Reset Count"); +// sim_mode = true; + } else if ((serial_string[0] == 'p') || (serial_string[0] == 'P')) { + Serial.println("Resetting the Payload"); + payload_command = PAYLOAD_RESET; + } else + Serial.println("No action"); break; case PROMPT_RESTART: Serial.println("Restart not yet implemented"); break; } - + + + case PROMPT_DEBUG: + Serial.print("Changing Debug Mode to "); + debug_mode = !debug_mode; + if (debug_mode) + Serial.println("on"); + else + Serial.println("off"); + break; } void get_serial_string() { From 741cf588f09ed791ebc80528f05db6a69e8eac9d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 11:16:47 -0400 Subject: [PATCH 28/96] misplaced } --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a4eb8320..09157369 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3875,8 +3875,7 @@ void prompt_for_input() { case PROMPT_RESTART: Serial.println("Restart not yet implemented"); - break; } - + break; case PROMPT_DEBUG: Serial.print("Changing Debug Mode to "); @@ -3886,6 +3885,7 @@ void prompt_for_input() { else Serial.println("off"); break; + } } void get_serial_string() { From 287cc59810b7164aaca51923a66fc87ccd4ff7e6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 11:21:56 -0400 Subject: [PATCH 29/96] implemented debug mode --- cubesatsim/cubesatsim.ino | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 09157369..aea2a4c5 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -257,8 +257,10 @@ void loop() { } // Calculate loop time - Serial.print("\nLoop time: "); - Serial.println(millis() - startSleep); + if (debug_mode) { + Serial.print("\nLoop time: "); + Serial.println(millis() - startSleep); + } } bool TimerHandler1(struct repeating_timer *t) { @@ -1191,9 +1193,11 @@ void get_tlm_fox() { } // Serial.println("CC"); } - Serial.println(" "); - Serial.print("get_fox_tlm returning with counter: "); - Serial.println(ctr); + if (debug_mode) { + Serial.println(" "); + Serial.print("get_fox_tlm returning with counter: "); + Serial.println(ctr); + } if (firstTime) { Serial.println(" "); firstTime = FALSE; @@ -3294,11 +3298,13 @@ bool TimerHandler0(struct repeating_timer *t) { // Serial.print("\nR"); // Serial.print(" "); // Serial.println(millis()); - Serial.print("R Microseconds: "); - Serial.println((micros() - micro_timer)/bufLen); - micro_timer = micros(); - } + if (debug_mode) { + Serial.print("R Microseconds: "); + Serial.println((micros() - micro_timer)/bufLen); + } + micro_timer = micros(); } +} /* if (digitalRead(MAIN_PB_PIN) == PRESSED) // pushbutton is pressed process_pushbutton(); From 85d95b15083d094cd6d859f8782e3b5fc0d9f93c Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 11:37:15 -0400 Subject: [PATCH 30/96] implemented reset count --- cubesatsim/cubesatsim.ino | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index aea2a4c5..c59a74fc 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2333,7 +2333,8 @@ void read_payload() sprintf(str, "XS %.1f 0.0\n", Temp); strcat(payload_str, str); - print_string(payload_str); + if (debug_mode) + print_string(payload_str); /* if (result == 'R') { @@ -3869,8 +3870,19 @@ void prompt_for_input() { Serial.println("Enter r or p"); get_serial_char(); if ((serial_string[0] == 'r') || (serial_string[0] == 'R')) { - Serial.println("Resetting Reset Count"); -// sim_mode = true; + Serial.println("Reset count is now 0"); + Serial.println("Storing initial reset count in EEPROM"); + +// reset_flag = 0xA07; +// EEPROM.put(16, reset_flag); + reset_count = 0; + EEPROM.put(20, reset_count + 1); + if (EEPROM.commit()) { + Serial.println("EEPROM successfully committed"); + } else { + Serial.println("ERROR! EEPROM commit failed"); + } + } else if ((serial_string[0] == 'p') || (serial_string[0] == 'P')) { Serial.println("Resetting the Payload"); payload_command = PAYLOAD_RESET; From a1d870f3c613bb3c09d889fe861eec167ce3723a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 14:33:53 -0400 Subject: [PATCH 31/96] config simulated telem when change, payload query --- cubesatsim/cubesatsim.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c59a74fc..af829cf1 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2333,9 +2333,11 @@ void read_payload() sprintf(str, "XS %.1f 0.0\n", Temp); strcat(payload_str, str); - if (debug_mode) + if ((debug_mode) || (payload_command == PAYLOAD_QUERY) { + payload_command = false; print_string(payload_str); - + } + /* if (result == 'R') { Serial.println("OK"); @@ -3818,7 +3820,7 @@ void prompt_for_input() { get_serial_char(); if ((serial_string[0] == 'y') || (serial_string[0] == 'Y')) { Serial.println("Setting Simulated telemetry to on"); - sim_mode = true; + config_simulated_telem(); } else if ((serial_string[0] == 'n') || (serial_string[0] == 'N')) { Serial.println("Setting Simulated telemetry to off"); sim_mode = false; From 8f76eb518160b92d57076fadcc555b5fd3f31fe7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 14:43:41 -0400 Subject: [PATCH 32/96] added voltage_read --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 024d3a2a..5d890ff0 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -328,6 +328,7 @@ int ready = FALSE; bool cw_stop = false; int payload_command = false; bool debug_mode = false; +bool voltage_read = false; #define PRESSED 0 #define HELD 0 From 4c6face930f0f295356a8fdb6ff1e6baa138b7e8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 14:50:43 -0400 Subject: [PATCH 33/96] added ina219_started --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 5d890ff0..9d881c57 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -329,6 +329,7 @@ bool cw_stop = false; int payload_command = false; bool debug_mode = false; bool voltage_read = false; +bool ina219_started = false; #define PRESSED 0 #define HELD 0 From 04a4fd0a7b6eaaf318afa306327d7003a29030f7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 14:52:30 -0400 Subject: [PATCH 34/96] changed to BPF_PIN --- cubesatsim/cubesatsim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 9d881c57..ec5e9e6e 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -51,7 +51,7 @@ #define RX2 9 // Serial2 to ESP32-CAM receive data #define MAIN_PB_PIN 10 // Main board PB pushbutton pin #define TXC_PIN 11 // Transceiver Board is present -#define LPF_PIN 12 // BPF is installed +#define BPF_PIN 12 // BPF is installed #define PI_3V3_PIN 13 // 3.3V supply used to detect Pi Zero #define BPSK_PWM_A_PIN 14 // was 6 // PWM Output Phase A to switch #define BPSK_PWM_B_PIN 15 // was 7 // PWM Output Phase B to switch From 726830816566b833e0f1d9bab8959638034ded2a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 14:56:20 -0400 Subject: [PATCH 35/96] added PROMPT_VOLTAGE --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index ec5e9e6e..4e0a9810 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -112,6 +112,7 @@ #define PROMPT_HELP 6 #define PROMPT_RESTART 7 #define PROMPT_DEBUG 8 +#define PROMPT_VOLTAGE 9 #define PAYLOAD_QUERY 1 #define PAYLOAD_RESET 2 From f29764d1af02f06315055cdef516c30faa1e524a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 14:59:35 -0400 Subject: [PATCH 36/96] added v read ina219 sensors --- cubesatsim/cubesatsim.ino | 164 ++++++++++++++++++++++++-------------- 1 file changed, 102 insertions(+), 62 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index af829cf1..11518cdc 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -326,8 +326,9 @@ void send_aprs_packet() { strcpy(str, tlm_str); strcat(str, payload_str); set_status(str); - - Serial.println("Sending APRS packet!"); + + if (debug) + Serial.println("Sending APRS packet!"); transmit_on(); send_packet(_FIXPOS_STATUS); transmit_off(); @@ -337,27 +338,30 @@ void send_cw() { char de[] = " DE "; char telem[1000]; char space[] = " "; - - Serial.println("Sending CW packet!"); + + if (debug_mode) + Serial.println("Sending CW packet!"); strcpy(telem, de); strcat(telem, callsign); strcat(telem, space); strcat(telem, tlm_str); // don't send payload since it isn't encoded and has "." print_string(telem); - Serial.println(strlen(telem)); +// Serial.println(strlen(telem)); transmit_string(telem); } void transmit_on() { if ((mode == SSTV) || (mode == AFSK)) { // this isn't quite right for APRS - should only do when sending APRS packet - Serial.println("Transmit on!"); + if (debug_mode) + Serial.println("Transmit on!"); digitalWrite(MAIN_LED_BLUE, HIGH); digitalWrite(PTT_PIN, LOW); } - else if (mode == BPSK) { - Serial.println("Transmit on!"); + else if (mode == BPSK) { + if (debug_mode) + Serial.println("Transmit on!"); pwm_set_gpio_level(BPSK_PWM_A_PIN, (config.top + 1) * 0.5); pwm_set_gpio_level(BPSK_PWM_B_PIN, (config.top + 1) * 0.5); } @@ -365,13 +369,14 @@ void transmit_on() { // Serial.println("Transmit on!"); cw_stop = false; } - else + else Serial.println("No transmit!"); } void transmit_off() { digitalWrite(PTT_PIN, HIGH); - Serial.println("Transmit off!"); + if (debug_mode) + Serial.println("Transmit off!"); digitalWrite(MAIN_LED_BLUE, LOW); // ITimer0.stopTimer(); // stop BPSK ISR timer if (mode == BPSK) { @@ -489,7 +494,8 @@ void config_telem() { bufLen = 1000; } // clearing min and max values - Serial.println("Clearing min and max telemetry values"); + if (debug_mode) + Serial.println("Clearing min and max telemetry values"); for (int i = 0; i < 9; i++) { voltage_min[i] = 1000.0; @@ -585,7 +591,8 @@ void generate_simulated_telem() { if ((time_stamp - eclipse_time) > period) { eclipse = (eclipse == 1) ? 0 : 1; eclipse_time = time_stamp; - Serial.println("\n\nSwitching eclipse mode! \n\n"); + if (debug_mode) + Serial.println("\n\nSwitching eclipse mode! \n\n"); } double Xi = eclipse * amps_max[0] * (float) sin(2.0 * 3.14 * time_stamp / (46.0 * rotation_speed)) + rnd_float(-2, 2); @@ -773,7 +780,8 @@ void get_tlm_fox() { { // Serial.println("Starting"); if (loop_count % 32 == 0) { // was 8 /// was loop now loop_count - Serial.println("Sending MIN frame"); + if (debug_mode) + Serial.println("Sending MIN frame"); frm_type = 0x03; for (int count1 = 0; count1 < 17; count1++) { if (count1 < 3) @@ -787,7 +795,8 @@ void get_tlm_fox() { } } if ((loop_count + 16) % 32 == 0) { // was 8 - Serial.println("Sending MAX frame"); + if (debug_mode) + Serial.println("Sending MAX frame"); frm_type = 0x02; for (int count1 = 0; count1 < 17; count1++) { if (count1 < 3) @@ -1230,9 +1239,11 @@ void write_wave(int i, short int *buffer) // ctr = ctr - BUFFER_SIZE; if (ctr > bufLen) { ctr = ctr - bufLen; - Serial.print("\r"); - Serial.print(" "); - Serial.println(millis()); + if (debug_mode) { +// Serial.print("\r"); +// Serial.print(" "); + Serial.println(millis()); + } } } @@ -2024,13 +2035,14 @@ void read_ina219() busvoltage = ina219_1_0x40.getBusVoltage_V(); current_mA = ina219_1_0x40.getCurrent_mA(); loadvoltage = busvoltage + (shuntvoltage / 1000); - - Serial.print("1 0x40 Voltage: "); - Serial.print(loadvoltage); - Serial.print("V Current: "); - Serial.print(current_mA); - Serial.println(" mA"); + if ((debug_mode) || (voltage_read)) { + Serial.print("1 0x40 Voltage: "); + Serial.print(loadvoltage); + Serial.print("V Current: "); + Serial.print(current_mA); + Serial.println(" mA"); + } voltage[0] = loadvoltage; current[0] = current_mA; @@ -2038,13 +2050,14 @@ void read_ina219() busvoltage = ina219_1_0x41.getBusVoltage_V(); current_mA = ina219_1_0x41.getCurrent_mA(); loadvoltage = busvoltage + (shuntvoltage / 1000); - - Serial.print("1 0x41 Voltage: "); - Serial.print(loadvoltage); - Serial.print("V Current: "); - Serial.print(current_mA); - Serial.println(" mA"); + if ((debug_mode) || (voltage_read)) { + Serial.print("1 0x41 Voltage: "); + Serial.print(loadvoltage); + Serial.print("V Current: "); + Serial.print(current_mA); + Serial.println(" mA"); + } voltage[1] = loadvoltage; current[1] = current_mA; @@ -2052,13 +2065,14 @@ void read_ina219() busvoltage = ina219_1_0x44.getBusVoltage_V(); current_mA = ina219_1_0x44.getCurrent_mA(); loadvoltage = busvoltage + (shuntvoltage / 1000); - + + if ((debug_mode) || (voltage_read)) { Serial.print("1 0x44 Voltage: "); Serial.print(loadvoltage); Serial.print("V Current: "); Serial.print(current_mA); Serial.println(" mA"); - + } voltage[2] = loadvoltage; current[2] = current_mA; @@ -2066,13 +2080,14 @@ void read_ina219() busvoltage = ina219_1_0x45.getBusVoltage_V(); current_mA = ina219_1_0x45.getCurrent_mA(); loadvoltage = busvoltage + (shuntvoltage / 1000); - + + if ((debug_mode) || (voltage_read)) { Serial.print("1 0x45 Voltage: "); Serial.print(loadvoltage); Serial.print("V Current: "); Serial.print(current_mA); Serial.println(" mA"); - + } voltage[3] = loadvoltage; current[3] = current_mA; } @@ -2082,13 +2097,14 @@ void read_ina219() busvoltage = ina219_2_0x40.getBusVoltage_V(); current_mA = ina219_2_0x40.getCurrent_mA(); loadvoltage = busvoltage + (shuntvoltage / 1000); - + + if ((debug_mode) || (voltage_read)) { Serial.print("2 0x40 Voltage: "); Serial.print(loadvoltage); Serial.print("V Current: "); Serial.print(current_mA); Serial.println(" mA"); - + } voltage[4] = loadvoltage; current[4] = current_mA; @@ -2096,13 +2112,14 @@ void read_ina219() busvoltage = ina219_2_0x41.getBusVoltage_V(); current_mA = ina219_2_0x41.getCurrent_mA(); loadvoltage = busvoltage + (shuntvoltage / 1000); - + + if ((debug_mode) || (voltage_read)) { Serial.print("2 0x41 Voltage: "); Serial.print(loadvoltage); Serial.print("V Current: "); Serial.print(current_mA); Serial.println(" mA"); - + } voltage[5] = loadvoltage; current[5] = current_mA; @@ -2110,13 +2127,14 @@ void read_ina219() busvoltage = ina219_2_0x44.getBusVoltage_V(); current_mA = ina219_2_0x44.getCurrent_mA(); loadvoltage = busvoltage + (shuntvoltage / 1000); - + + if ((debug_mode) || (voltage_read)) { Serial.print("2 0x44 Voltage: "); Serial.print(loadvoltage); Serial.print("V Current: "); Serial.print(current_mA); Serial.println(" mA"); - + } voltage[6] = loadvoltage; current[6] = current_mA; @@ -2124,16 +2142,18 @@ void read_ina219() busvoltage = ina219_2_0x45.getBusVoltage_V(); current_mA = ina219_2_0x45.getCurrent_mA(); loadvoltage = busvoltage + (shuntvoltage / 1000); - + + if ((debug_mode) || (voltage_read)) { Serial.print("2 0x45 Voltage: "); Serial.print(loadvoltage); Serial.print("V Current: "); Serial.print(current_mA); Serial.println(" mA"); - + } voltage[7] = loadvoltage; current[7] = current_mA; - } + } + voltage_read = false; } void read_sensors() @@ -2761,6 +2781,7 @@ void led_set(int ledPin, bool state) } void start_ina219() { + ina219_started = true; // check if Pi is present by 3.3V voltage pinMode(PI_3V3_PIN, INPUT); Serial.print("Pi 3.3V: "); @@ -2826,15 +2847,16 @@ void start_pwm() { bpsk_pin_slice_A = pwm_gpio_to_slice_num(BPSK_PWM_A_PIN); bpsk_pin_slice_B = pwm_gpio_to_slice_num(BPSK_PWM_B_PIN); - - Serial.print(pwm_gpio_to_slice_num(BPSK_PWM_A_PIN)); - Serial.print(" "); - Serial.print(pwm_gpio_to_channel(BPSK_PWM_A_PIN)); - Serial.print(" "); - Serial.print(pwm_gpio_to_slice_num(BPSK_PWM_B_PIN)); - Serial.print(" "); - Serial.print(pwm_gpio_to_channel(BPSK_PWM_B_PIN)); - Serial.println(" "); + if (debug_mode) { + Serial.print(pwm_gpio_to_slice_num(BPSK_PWM_A_PIN)); + Serial.print(" "); + Serial.print(pwm_gpio_to_channel(BPSK_PWM_A_PIN)); + Serial.print(" "); + Serial.print(pwm_gpio_to_slice_num(BPSK_PWM_B_PIN)); + Serial.print(" "); + Serial.print(pwm_gpio_to_channel(BPSK_PWM_B_PIN)); + Serial.println(" "); + } /* // Setup PWM interrupt to fire when PWM cycle is complete pwm_clear_irq(bpsk_pin_slice); @@ -3230,13 +3252,13 @@ void config_gpio() { // set input pins and read pinMode(MAIN_PB_PIN, INPUT_PULLUP); // Read Main Board push button pinMode(TXC_PIN, INPUT_PULLUP); // Read TXC to see if present - pinMode(LPF_PIN, INPUT_PULLUP); // Read LPF to see if present + pinMode(BPF_PIN, INPUT_PULLUP); // Read LPF to see if present // pinMode(SQUELCH, INPUT); // Squelch from TXC - if (digitalRead(LPF_PIN) == FALSE) - Serial.println("LPF present"); + if (digitalRead(BPF_PIN) == FALSE) + Serial.println("BPF present"); else - Serial.println("LPF not present"); + Serial.println("BPF not present"); if (digitalRead(TXC_PIN) == FALSE) Serial.println("TXC present"); @@ -3333,7 +3355,8 @@ void start_isr() { if (ITimer0.attachInterruptInterval(827, TimerHandler0)) // was 828 // if (ITimer0.attachInterruptInterval(1667, TimerHandler0)) { - Serial.print(F("Starting ITimer0 OK, micros() = ")); Serial.println(micros()); + if (debug_mode) + Serial.print(F("Starting ITimer0 OK, micros() = ")); Serial.println(micros()); timer0_on = true; } else @@ -3352,7 +3375,8 @@ void start_button_isr() { if (ITimer1.attachInterruptInterval(10000, TimerHandler1)) { - Serial.print(F("Starting ITimer1 OK, micros() = ")); + if (debug_mode) + Serial.print(F("Starting ITimer1 OK, micros() = ")); Serial.println(micros()); } else @@ -3529,7 +3553,8 @@ void transmit_callsign(char *callsign) { void transmit_string(char *string) { int j = 0; - Serial.println("Transmit on"); + if (debug_mode) + Serial.println("Transmit on"); digitalWrite(PD_PIN, HIGH); // Enable SR_FRS digitalWrite(MAIN_LED_BLUE, HIGH); digitalWrite(PTT_PIN, LOW); @@ -3545,7 +3570,8 @@ void transmit_string(char *string) { j++; } } - Serial.println("Transmit off"); + if (debug_mode) + Serial.println("Transmit off"); digitalWrite(MAIN_LED_BLUE, LOW); digitalWrite(PTT_PIN, HIGH); digitalWrite(PD_PIN, LOW); // disable SR_FRS @@ -3742,7 +3768,13 @@ void serial_input() { Serial.println("Change the Latitude and Longitude"); prompt = PROMPT_LAT; break; - + + case 'v': + case 'V': + Serial.println("Read INA219 voltage and current"); + prompt = PROMPT_VOLTAGE; + break; + case '?': Serial.println("Query payload sensors"); prompt = PROMPT_QUERY; @@ -3787,7 +3819,8 @@ void prompt_for_input() { Serial.println("t Simulated Telemetry"); Serial.println("r Resets Count, or payload & EEPROM"); Serial.println("l Lat and Long"); - Serial.println("? Query sensors\n"); + Serial.println("? Query sensors"); + Serial.println("v Read INA219 voltage and current\n"); break; case PROMPT_CALLSIGN: @@ -3866,7 +3899,14 @@ void prompt_for_input() { Serial.println("Querying payload sensors"); payload_command = PAYLOAD_QUERY; break; - + + case PROMPT_VOLTAGE: + Serial.println("Querying INA219 voltage and current sensors"); + if (!ina219_started) + start_ina219(); + read_ina219(); + break; + case PROMPT_RESET: Serial.println("Do you want to Reset the Reset Count (r) or Reset the Payload (p)?"); Serial.println("Enter r or p"); From 70c992e70f34b956df76331ac1332641bed1af57 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 15:03:57 -0400 Subject: [PATCH 37/96] change debug to debug_mode --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 11518cdc..58a80356 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -327,7 +327,7 @@ void send_aprs_packet() { strcat(str, payload_str); set_status(str); - if (debug) + if (debug_mode) Serial.println("Sending APRS packet!"); transmit_on(); send_packet(_FIXPOS_STATUS); From b3d335d5d15fceba14a7568c9d58ed9107f86b28 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 15:09:54 -0400 Subject: [PATCH 38/96] missing ) --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 58a80356..a14994d7 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2353,7 +2353,7 @@ void read_payload() sprintf(str, "XS %.1f 0.0\n", Temp); strcat(payload_str, str); - if ((debug_mode) || (payload_command == PAYLOAD_QUERY) { + if ((debug_mode) || (payload_command == PAYLOAD_QUERY)) { payload_command = false; print_string(payload_str); } From 2bb650dcbbbf2a1c9fac1c7701f9ae8d78bcbadf Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 15:52:16 -0400 Subject: [PATCH 39/96] added destination APCSS and debug for send_packet --- cubesatsim/cubesatsim.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a14994d7..9629782f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -330,7 +330,7 @@ void send_aprs_packet() { if (debug_mode) Serial.println("Sending APRS packet!"); transmit_on(); - send_packet(_FIXPOS_STATUS); + send_packet(_FIXPOS_STATUS, debug); transmit_off(); } @@ -478,8 +478,10 @@ void config_telem() { Serial.println("Configuring for AFSK\n"); set_pin(AUDIO_OUT_PIN); - - set_callsign(callsign); + + const char destination[] = "APCSS"; + + set_callsign(callsign, destination); set_lat_lon(); From c708e4311037d2974162f88064e62170ce7d61f5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 15:53:00 -0400 Subject: [PATCH 40/96] changed debug to debug_mode --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 9629782f..bf324081 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -330,7 +330,7 @@ void send_aprs_packet() { if (debug_mode) Serial.println("Sending APRS packet!"); transmit_on(); - send_packet(_FIXPOS_STATUS, debug); + send_packet(_FIXPOS_STATUS, debug_mode); transmit_off(); } From 85774ce5b3592246d3f3796f12dac731c0075773 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 15:59:34 -0400 Subject: [PATCH 41/96] fix destination --- cubesatsim/cubesatsim.ino | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index bf324081..df34ff23 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -479,8 +479,7 @@ void config_telem() { set_pin(AUDIO_OUT_PIN); - const char destination[] = "APCSS"; - + char destination[] = "APCSS"; set_callsign(callsign, destination); set_lat_lon(); @@ -3838,8 +3837,10 @@ void prompt_for_input() { if (strlen(serial_string) > 0) { strcpy(callsign, serial_string); - if (mode == AFSK) - set_callsign(callsign); + if (mode == AFSK) { + char destination[] = "APCSS"; + set_callsign(callsign, destination); + } Serial.println("Callsign updated!"); } else Serial.println("Callsign not updated!"); From 606c9f0bc6db202216778b28cabce2258f59657b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 16:06:01 -0400 Subject: [PATCH 42/96] debug mode sstv --- cubesatsim/cubesatsim.ino | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index df34ff23..bf842406 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -192,27 +192,32 @@ void loop() { strcpy(image_file, sstv2_filename); - } - Serial.print("\nSending SSTV image "); - print_string(image_file); + } + if (debug_mode) { + Serial.print("\nSending SSTV image "); + print_string(image_file); + } // send_sstv("/cam.raw"); // send_sstv(image_file); char output_file[] = "/cam.bin"; jpeg_decode(image_file, output_file); - - Serial.println("Start transmit!!!"); + + if (debug_mode) + Serial.println("Start transmit!!!"); digitalWrite(PTT_PIN, LOW); // start transmit digitalWrite(MAIN_LED_BLUE, HIGH); scottie1_transmit_file(output_file); - - Serial.println("Stop transmit!"); + + if (debug_mode) + Serial.println("Stop transmit!"); digitalWrite(PTT_PIN, HIGH); // stop transmit digitalWrite(MAIN_LED_BLUE, LOW); - Serial.println("\nImage sent!"); + if (debug_mode) + Serial.println("\nImage sent!"); } else Serial.println("Unknown mode!"); From 247079097611ea63eb5a68f19448cded01a1872d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 16:22:42 -0400 Subject: [PATCH 43/96] added debug_mode to sstv --- cubesatsim/cubesatsim.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index bf842406..1af125fc 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -202,14 +202,14 @@ void loop() { // send_sstv(image_file); char output_file[] = "/cam.bin"; - jpeg_decode(image_file, output_file); + jpeg_decode(image_file, output_file, debug_mode); if (debug_mode) Serial.println("Start transmit!!!"); digitalWrite(PTT_PIN, LOW); // start transmit digitalWrite(MAIN_LED_BLUE, HIGH); - scottie1_transmit_file(output_file); + scottie1_transmit_file(output_file, debug_mode); if (debug_mode) Serial.println("Stop transmit!"); From f1606a9e7a243e8a400a4e4291b9327fdf7d580b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:01:11 -0400 Subject: [PATCH 44/96] test with v0.1 hardware --- cubesatsim/cubesatsim.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 1af125fc..112d59ad 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2787,6 +2787,7 @@ void led_set(int ledPin, bool state) } void start_ina219() { +#define PI_3V3_PIN 9 // for v0.1 hardware ina219_started = true; // check if Pi is present by 3.3V voltage pinMode(PI_3V3_PIN, INPUT); From 185c224b53566693ab511bd1ec63316ebdc49643 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:10:31 -0400 Subject: [PATCH 45/96] Create pico-get-jpeg-serial.ino --- .../examples/pico-get-jpeg-serial.ino | 228 ++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 cubesatsim/pico-get-jpeg-serial/examples/pico-get-jpeg-serial.ino diff --git a/cubesatsim/pico-get-jpeg-serial/examples/pico-get-jpeg-serial.ino b/cubesatsim/pico-get-jpeg-serial/examples/pico-get-jpeg-serial.ino new file mode 100644 index 00000000..925cdec4 --- /dev/null +++ b/cubesatsim/pico-get-jpeg-serial/examples/pico-get-jpeg-serial.ino @@ -0,0 +1,228 @@ +#include +#include + +bool finished = false; + +char buffer[100001]; +int index1 = 0; +char start_flag[] = "3d99de816e5ad7742b61a37c39141783"; +char end_flag[] = "f681a5c52351befe0e3524eb1a40f14b7803317a"; +int flag_count = 0; +int start_flag_detected = false; +int start_flag_complete = false; +int end_flag_detected = false; +int jpeg_start = 0; +FastCRC8 CRC8; + +//#define DEBUG + +#define PICOW true +int led_pin = LED_BUILTIN; + +void setup() { + + // put your setup code here, to run once: + +if (PICOW) + led_pin = STEM_LED2_PIN; + + Serial.begin(115200); + + delay(5000); + + pinMode(led_pin, OUTPUT); + + digitalWrite(led_pin, LOW); + delay(500); + digitalWrite(led_pin, HIGH); + delay(500); + digitalWrite(led_pin, LOW); + delay(500); + digitalWrite(led_pin, HIGH); + delay(500); + if (PICOW) + digitalWrite(led_pin, LOW); + + delay(2000); + + Serial2.setRX(9); + delay(100); + Serial2.setTX(8); + delay(100); + Serial2.begin(115200); + + Serial.println("Starting"); + + LittleFS.begin(); +} + +void show_dir() { + int count = 0; + Dir dir = LittleFS.openDir("/"); +// or Dir dir = LittleFS.openDir("/data"); + Serial.println(">"); + while (dir.next()) { + count++; + Serial.print(count); + Serial.print(" "); + Serial.print(dir.fileName()); + // if(dir.fileSize()) { + File f = dir.openFile("r"); + Serial.print(" "); + Serial.println(f.size()); + // } else + // Serial.println(" "); + } + Serial.println(">"); +} + +void write_jpg() { +/* + Serial.println("---------------"); + Serial.println(buffer[jpeg_start], HEX); + Serial.println(buffer[jpeg_start + 1], HEX); + Serial.println(buffer[jpeg_start + 2], HEX); + Serial.println(buffer[jpeg_start + 3], HEX); +*/ + if ((buffer[jpeg_start] == 0xff) && (buffer[jpeg_start + 1] == 0xd8) + && (buffer[index1 - 2] == 0xff) && (buffer[index1 - 1] == 0xd9)) { + + Serial.println("Received a JPEG! Writing to file."); + File i = LittleFS.open("/cam.jpg", "w+"); + if (i) { + i.write(&buffer[jpeg_start], (size_t) (index1 - jpeg_start)); + finished = true; + } else + Serial.println("Error opening cam.jpg"); + +// Serial.println("---------------"); + i.close(); +// } + } else + Serial.println("Not a JPEG"); + + show_dir(); +/* + delay(2000); + + char read_values[2]; + File i = LittleFS.open("/cam.jpg", "r"); + while (i.available()) { + i.readBytes(read_values, 1); + char hexValue[5]; + sprintf(hexValue, "%02X", read_values[0]); + Serial.print(hexValue); + } + i.close(); + Serial.println("\n\n finished read"); + + */ +} + +void loop() { + + char input_file[] = "/cam.jpg"; + char output_file[] = "/cam.bin"; + + get_image_file(); + + Serial.println("Got image from ESP-32-CAM!"); + + delay(1000); + +} + + +void get_image_file() { + finished = false; + while (!finished) { + // put your main code here, to run repeatedly: + if (Serial2.available()) { // If anything comes in Serial2 + byte octet = Serial2.read(); + + if (start_flag_complete) { +// Serial.println("Start flag complete detected"); + buffer[index1++] = octet; + if (octet == end_flag[flag_count]) { // looking for end flag +// if (end_flag_detected) { + flag_count++; +// Serial.println("Found part of end flag!"); + if (flag_count >= strlen(end_flag)) { // complete image +/// buffer[index1++] = octet; + Serial.println("\nFound end flag"); +// Serial.println(octet, HEX); + while(!Serial2.available()) { } // Wait for another byte +// octet = Serial2.read(); +// buffer[index1++] = octet; +// Serial.println(octet, HEX); +// while(!Serial2.available()) { } // Wait for another byte + int received_crc = Serial2.read(); +// buffer[index1++] = octet; + + Serial.print("\nFile length: "); + Serial.println(index1 - (int)strlen(end_flag)); +// index1 -= 1; // 40; +// Serial.println(buffer[index1 - 1], HEX); +// int received_crc = buffer[index1]; +// index1 -= 1; + + uint8_t * data = (uint8_t *) &buffer[0]; +#ifdef DEBUG + Serial.println("\nCRC cacluation data:"); + Serial.println(buffer[0], HEX); + Serial.println(buffer[index1 - 1], HEX); + Serial.println(index1); + Serial.println(received_crc, HEX); + #endif + int calculated_crc = CRC8.smbus(data, index1); + // Serial.println(calculated_crc, HEX); + if (received_crc == calculated_crc) + Serial.println("CRC check succeeded!"); + else + Serial.println("CRC check failed!"); + + index1 -= 40; + write_jpg(); + index1 = 0; + start_flag_complete = false; + start_flag_detected = false; // get ready for next image + end_flag_detected = false; + flag_count = 0; +// delay(6000); + } + } else { + flag_count = 0; + } + /// buffer[index1++] = octet; + +#ifdef DEBUG + char hexValue[5]; + if (octet != 0x66) { + sprintf(hexValue, "%02X", octet); + Serial.print(hexValue); + } else { +// Serial.println("\n********************************************* Got a 66!"); + Serial.print("66"); + } +// Serial.write(octet); +#endif + if (index1 > 100000) + index1 = 0; +// } + } else if (octet == start_flag[flag_count]) { // looking for start flag + start_flag_detected = true; + flag_count++; +// Serial.println("Found part of start flag! "); + if (flag_count >= strlen(start_flag)) { + flag_count = 0; + start_flag_complete = true; + Serial.println("Found start flag!\n"); + } + } else { // not the flag, keep looking + start_flag_detected = false; + flag_count = 0; + // Serial.println("Resetting. Not start flag."); + } + } + } +} From 43e8bceddd575b61cacbf85a123dd2e207332fc3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:11:33 -0400 Subject: [PATCH 46/96] Create pico-get-jpeg-serial.h --- .../pico-get-jpeg-serial.h | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h diff --git a/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h b/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h new file mode 100644 index 00000000..20d3e0b5 --- /dev/null +++ b/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h @@ -0,0 +1,21 @@ +#include +#include + +bool finished = false; + +char buffer[100001]; +int index1 = 0; +char start_flag[] = "3d99de816e5ad7742b61a37c39141783"; +char end_flag[] = "f681a5c52351befe0e3524eb1a40f14b7803317a"; +int flag_count = 0; +int start_flag_detected = false; +int start_flag_complete = false; +int end_flag_detected = false; +int jpeg_start = 0; +FastCRC8 CRC8; + +//#define DEBUG + +//#define PICOW true +int led_pin = LED_BUILTIN; + From a96afe45a22b456ecbada4f6291002abaf815e44 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:13:26 -0400 Subject: [PATCH 47/96] Update and rename pico-get-jpeg-serial.ino to pico-get-jpeg-serial.cpp --- ...eg-serial.ino => pico-get-jpeg-serial.cpp} | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) rename cubesatsim/pico-get-jpeg-serial/{pico-get-jpeg-serial.ino => pico-get-jpeg-serial.cpp} (93%) diff --git a/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.ino b/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.cpp similarity index 93% rename from cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.ino rename to cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.cpp index 925cdec4..12d83125 100644 --- a/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.ino +++ b/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.cpp @@ -1,24 +1,6 @@ -#include -#include - -bool finished = false; - -char buffer[100001]; -int index1 = 0; -char start_flag[] = "3d99de816e5ad7742b61a37c39141783"; -char end_flag[] = "f681a5c52351befe0e3524eb1a40f14b7803317a"; -int flag_count = 0; -int start_flag_detected = false; -int start_flag_complete = false; -int end_flag_detected = false; -int jpeg_start = 0; -FastCRC8 CRC8; - -//#define DEBUG - -#define PICOW true -int led_pin = LED_BUILTIN; +#include "pico-get-jpeg-serial.h" +/* void setup() { // put your setup code here, to run once: @@ -75,6 +57,7 @@ void show_dir() { } Serial.println(">"); } +*/ void write_jpg() { /* @@ -119,6 +102,7 @@ void write_jpg() { */ } +/* void loop() { char input_file[] = "/cam.jpg"; @@ -131,7 +115,7 @@ void loop() { delay(1000); } - +*/ void get_image_file() { finished = false; From 2d03e67ff098b0dde64b020759a8a8c71769d4fa Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:15:42 -0400 Subject: [PATCH 48/96] changed back to v0.2 hardware, added include for pico-get-jpeg-serial --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 112d59ad..ef8f0dd8 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -39,6 +39,7 @@ #include "hardware/adc.h" #include "SSTV-Arduino-Scottie1-Library.h" #include "LittleFS.h" +#include "pico-get-jpeg-serial/pico-get-jpeg-serial.h" // jpg files to be stored in flash storage on Pico (FS 512kB setting) #include "sstv1.h" @@ -2787,7 +2788,7 @@ void led_set(int ledPin, bool state) } void start_ina219() { -#define PI_3V3_PIN 9 // for v0.1 hardware +//#define PI_3V3_PIN 9 // for v0.1 hardware ina219_started = true; // check if Pi is present by 3.3V voltage pinMode(PI_3V3_PIN, INPUT); From 56283ca0a83d4b91f47c63f7cae0cbfee5d21717 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:17:37 -0400 Subject: [PATCH 49/96] added get_image_file(); --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index ef8f0dd8..4328500f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -188,7 +188,7 @@ void loop() { } else { // get jpeg from camera in future - + get_image_file(); From 0ad2706505a005e8ba4b99b67cc9be9214707dc1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:18:47 -0400 Subject: [PATCH 50/96] added void get_image_file() declaration --- cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h b/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h index 20d3e0b5..f25cda5e 100644 --- a/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h +++ b/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h @@ -19,3 +19,4 @@ FastCRC8 CRC8; //#define PICOW true int led_pin = LED_BUILTIN; +void get_image_file(); From 31269fb0cb200ca042314f011892a3d71706f5c8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:24:08 -0400 Subject: [PATCH 51/96] set filename to cam.jpg --- cubesatsim/cubesatsim.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 4328500f..0048f25d 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -189,10 +189,10 @@ void loop() { // get jpeg from camera in future get_image_file(); + char camera_file[] = "/cam.jpg"; + strcpy(image_file, camera_file); - - - strcpy(image_file, sstv2_filename); +// strcpy(image_file, sstv2_filename); } if (debug_mode) { Serial.print("\nSending SSTV image "); From 97b501fbec93b6efd4d6341ac9a9682da6f3eede Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:26:36 -0400 Subject: [PATCH 52/96] removed buffer declaration --- cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h b/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h index f25cda5e..c8363370 100644 --- a/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h +++ b/cubesatsim/pico-get-jpeg-serial/pico-get-jpeg-serial.h @@ -3,7 +3,7 @@ bool finished = false; -char buffer[100001]; +//char buffer[100001]; int index1 = 0; char start_flag[] = "3d99de816e5ad7742b61a37c39141783"; char end_flag[] = "f681a5c52351befe0e3524eb1a40f14b7803317a"; From dacb6083eb44bf8739ee282faa2356ee733bcf27 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:29:34 -0400 Subject: [PATCH 53/96] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 0048f25d..efd07e8b 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -41,6 +41,8 @@ #include "LittleFS.h" #include "pico-get-jpeg-serial/pico-get-jpeg-serial.h" +extern void get_image_file(); + // jpg files to be stored in flash storage on Pico (FS 512kB setting) #include "sstv1.h" #include "sstv2.h" From 5718e5691f770e2d056c0adf67d2cbb2323beb8b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:44:35 -0400 Subject: [PATCH 54/96] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index efd07e8b..6d9ad5a2 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -39,9 +39,7 @@ #include "hardware/adc.h" #include "SSTV-Arduino-Scottie1-Library.h" #include "LittleFS.h" -#include "pico-get-jpeg-serial/pico-get-jpeg-serial.h" - -extern void get_image_file(); +#include "pico-get-jpeg-serial.h" // jpg files to be stored in flash storage on Pico (FS 512kB setting) #include "sstv1.h" From 914b5bc2f1c7100c5c5959190b3e36af2fe6c302 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:45:10 -0400 Subject: [PATCH 55/96] Create pico-get-jpeg-serial.cpp --- cubesatsim/pico-get-jpeg-serial.cpp | 212 ++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 cubesatsim/pico-get-jpeg-serial.cpp diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp new file mode 100644 index 00000000..12d83125 --- /dev/null +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -0,0 +1,212 @@ +#include "pico-get-jpeg-serial.h" + +/* +void setup() { + + // put your setup code here, to run once: + +if (PICOW) + led_pin = STEM_LED2_PIN; + + Serial.begin(115200); + + delay(5000); + + pinMode(led_pin, OUTPUT); + + digitalWrite(led_pin, LOW); + delay(500); + digitalWrite(led_pin, HIGH); + delay(500); + digitalWrite(led_pin, LOW); + delay(500); + digitalWrite(led_pin, HIGH); + delay(500); + if (PICOW) + digitalWrite(led_pin, LOW); + + delay(2000); + + Serial2.setRX(9); + delay(100); + Serial2.setTX(8); + delay(100); + Serial2.begin(115200); + + Serial.println("Starting"); + + LittleFS.begin(); +} + +void show_dir() { + int count = 0; + Dir dir = LittleFS.openDir("/"); +// or Dir dir = LittleFS.openDir("/data"); + Serial.println(">"); + while (dir.next()) { + count++; + Serial.print(count); + Serial.print(" "); + Serial.print(dir.fileName()); + // if(dir.fileSize()) { + File f = dir.openFile("r"); + Serial.print(" "); + Serial.println(f.size()); + // } else + // Serial.println(" "); + } + Serial.println(">"); +} +*/ + +void write_jpg() { +/* + Serial.println("---------------"); + Serial.println(buffer[jpeg_start], HEX); + Serial.println(buffer[jpeg_start + 1], HEX); + Serial.println(buffer[jpeg_start + 2], HEX); + Serial.println(buffer[jpeg_start + 3], HEX); +*/ + if ((buffer[jpeg_start] == 0xff) && (buffer[jpeg_start + 1] == 0xd8) + && (buffer[index1 - 2] == 0xff) && (buffer[index1 - 1] == 0xd9)) { + + Serial.println("Received a JPEG! Writing to file."); + File i = LittleFS.open("/cam.jpg", "w+"); + if (i) { + i.write(&buffer[jpeg_start], (size_t) (index1 - jpeg_start)); + finished = true; + } else + Serial.println("Error opening cam.jpg"); + +// Serial.println("---------------"); + i.close(); +// } + } else + Serial.println("Not a JPEG"); + + show_dir(); +/* + delay(2000); + + char read_values[2]; + File i = LittleFS.open("/cam.jpg", "r"); + while (i.available()) { + i.readBytes(read_values, 1); + char hexValue[5]; + sprintf(hexValue, "%02X", read_values[0]); + Serial.print(hexValue); + } + i.close(); + Serial.println("\n\n finished read"); + + */ +} + +/* +void loop() { + + char input_file[] = "/cam.jpg"; + char output_file[] = "/cam.bin"; + + get_image_file(); + + Serial.println("Got image from ESP-32-CAM!"); + + delay(1000); + +} +*/ + +void get_image_file() { + finished = false; + while (!finished) { + // put your main code here, to run repeatedly: + if (Serial2.available()) { // If anything comes in Serial2 + byte octet = Serial2.read(); + + if (start_flag_complete) { +// Serial.println("Start flag complete detected"); + buffer[index1++] = octet; + if (octet == end_flag[flag_count]) { // looking for end flag +// if (end_flag_detected) { + flag_count++; +// Serial.println("Found part of end flag!"); + if (flag_count >= strlen(end_flag)) { // complete image +/// buffer[index1++] = octet; + Serial.println("\nFound end flag"); +// Serial.println(octet, HEX); + while(!Serial2.available()) { } // Wait for another byte +// octet = Serial2.read(); +// buffer[index1++] = octet; +// Serial.println(octet, HEX); +// while(!Serial2.available()) { } // Wait for another byte + int received_crc = Serial2.read(); +// buffer[index1++] = octet; + + Serial.print("\nFile length: "); + Serial.println(index1 - (int)strlen(end_flag)); +// index1 -= 1; // 40; +// Serial.println(buffer[index1 - 1], HEX); +// int received_crc = buffer[index1]; +// index1 -= 1; + + uint8_t * data = (uint8_t *) &buffer[0]; +#ifdef DEBUG + Serial.println("\nCRC cacluation data:"); + Serial.println(buffer[0], HEX); + Serial.println(buffer[index1 - 1], HEX); + Serial.println(index1); + Serial.println(received_crc, HEX); + #endif + int calculated_crc = CRC8.smbus(data, index1); + // Serial.println(calculated_crc, HEX); + if (received_crc == calculated_crc) + Serial.println("CRC check succeeded!"); + else + Serial.println("CRC check failed!"); + + index1 -= 40; + write_jpg(); + index1 = 0; + start_flag_complete = false; + start_flag_detected = false; // get ready for next image + end_flag_detected = false; + flag_count = 0; +// delay(6000); + } + } else { + flag_count = 0; + } + /// buffer[index1++] = octet; + +#ifdef DEBUG + char hexValue[5]; + if (octet != 0x66) { + sprintf(hexValue, "%02X", octet); + Serial.print(hexValue); + } else { +// Serial.println("\n********************************************* Got a 66!"); + Serial.print("66"); + } +// Serial.write(octet); +#endif + if (index1 > 100000) + index1 = 0; +// } + } else if (octet == start_flag[flag_count]) { // looking for start flag + start_flag_detected = true; + flag_count++; +// Serial.println("Found part of start flag! "); + if (flag_count >= strlen(start_flag)) { + flag_count = 0; + start_flag_complete = true; + Serial.println("Found start flag!\n"); + } + } else { // not the flag, keep looking + start_flag_detected = false; + flag_count = 0; + // Serial.println("Resetting. Not start flag."); + } + } + } +} From d51635a751bcbba5e01729e366a32ae9c15d4a98 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:46:37 -0400 Subject: [PATCH 56/96] Create pico-get-jpeg-serial.h --- cubesatsim/pico-get-jpeg-serial.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cubesatsim/pico-get-jpeg-serial.h diff --git a/cubesatsim/pico-get-jpeg-serial.h b/cubesatsim/pico-get-jpeg-serial.h new file mode 100644 index 00000000..03dfcc0d --- /dev/null +++ b/cubesatsim/pico-get-jpeg-serial.h @@ -0,0 +1,26 @@ +#ifndef PICO_GET_JPEG_SERIAL +#define PICO_GET_JPEG_SERIAL + +#include +#include + +bool finished = false; + +//char buffer[100001]; +int index1 = 0; +char start_flag[] = "3d99de816e5ad7742b61a37c39141783"; +char end_flag[] = "f681a5c52351befe0e3524eb1a40f14b7803317a"; +int flag_count = 0; +int start_flag_detected = false; +int start_flag_complete = false; +int end_flag_detected = false; +int jpeg_start = 0; +FastCRC8 CRC8; + +//#define DEBUG + +//#define PICOW true +int led_pin = LED_BUILTIN; + +void get_image_file(); +#endif From 7452a24566d5dddafc1b0a7da620c6caee68686b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:49:43 -0400 Subject: [PATCH 57/96] changed from buffer to buffer2 --- cubesatsim/pico-get-jpeg-serial.cpp | 34 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index 12d83125..c9a4eada 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -62,18 +62,18 @@ void show_dir() { void write_jpg() { /* Serial.println("---------------"); - Serial.println(buffer[jpeg_start], HEX); - Serial.println(buffer[jpeg_start + 1], HEX); - Serial.println(buffer[jpeg_start + 2], HEX); - Serial.println(buffer[jpeg_start + 3], HEX); + Serial.println(buffer2[jpeg_start], HEX); + Serial.println(buffer2[jpeg_start + 1], HEX); + Serial.println(buffer2[jpeg_start + 2], HEX); + Serial.println(buffer2[jpeg_start + 3], HEX); */ - if ((buffer[jpeg_start] == 0xff) && (buffer[jpeg_start + 1] == 0xd8) - && (buffer[index1 - 2] == 0xff) && (buffer[index1 - 1] == 0xd9)) { + if ((buffer2[jpeg_start] == 0xff) && (buffer2[jpeg_start + 1] == 0xd8) + && (buffer2[index1 - 2] == 0xff) && (buffer2[index1 - 1] == 0xd9)) { Serial.println("Received a JPEG! Writing to file."); File i = LittleFS.open("/cam.jpg", "w+"); if (i) { - i.write(&buffer[jpeg_start], (size_t) (index1 - jpeg_start)); + i.write(&buffer2[jpeg_start], (size_t) (index1 - jpeg_start)); finished = true; } else Serial.println("Error opening cam.jpg"); @@ -126,35 +126,35 @@ void get_image_file() { if (start_flag_complete) { // Serial.println("Start flag complete detected"); - buffer[index1++] = octet; + buffer2[index1++] = octet; if (octet == end_flag[flag_count]) { // looking for end flag // if (end_flag_detected) { flag_count++; // Serial.println("Found part of end flag!"); if (flag_count >= strlen(end_flag)) { // complete image -/// buffer[index1++] = octet; +/// buffer2[index1++] = octet; Serial.println("\nFound end flag"); // Serial.println(octet, HEX); while(!Serial2.available()) { } // Wait for another byte // octet = Serial2.read(); -// buffer[index1++] = octet; +// buffer2[index1++] = octet; // Serial.println(octet, HEX); // while(!Serial2.available()) { } // Wait for another byte int received_crc = Serial2.read(); -// buffer[index1++] = octet; +// buffer2[index1++] = octet; Serial.print("\nFile length: "); Serial.println(index1 - (int)strlen(end_flag)); // index1 -= 1; // 40; -// Serial.println(buffer[index1 - 1], HEX); -// int received_crc = buffer[index1]; +// Serial.println(buffer2[index1 - 1], HEX); +// int received_crc = buffer2[index1]; // index1 -= 1; - uint8_t * data = (uint8_t *) &buffer[0]; + uint8_t * data = (uint8_t *) &buffer2[0]; #ifdef DEBUG Serial.println("\nCRC cacluation data:"); - Serial.println(buffer[0], HEX); - Serial.println(buffer[index1 - 1], HEX); + Serial.println(buffer2[0], HEX); + Serial.println(buffer2[index1 - 1], HEX); Serial.println(index1); Serial.println(received_crc, HEX); #endif @@ -177,7 +177,7 @@ void get_image_file() { } else { flag_count = 0; } - /// buffer[index1++] = octet; + /// buffer2[index1++] = octet; #ifdef DEBUG char hexValue[5]; From 6efa6b566375fe17c0de2b21261b6ce8841c8afd Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:50:07 -0400 Subject: [PATCH 58/96] added buffer2 --- cubesatsim/pico-get-jpeg-serial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/pico-get-jpeg-serial.h b/cubesatsim/pico-get-jpeg-serial.h index 03dfcc0d..b22f5d5d 100644 --- a/cubesatsim/pico-get-jpeg-serial.h +++ b/cubesatsim/pico-get-jpeg-serial.h @@ -6,7 +6,7 @@ bool finished = false; -//char buffer[100001]; +char buffer2[100001]; int index1 = 0; char start_flag[] = "3d99de816e5ad7742b61a37c39141783"; char end_flag[] = "f681a5c52351befe0e3524eb1a40f14b7803317a"; From e4eec4b5c9f5b4cdbdb739a53e10245dbac60bb1 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:51:54 -0400 Subject: [PATCH 59/96] commented back in show_dir --- cubesatsim/pico-get-jpeg-serial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index c9a4eada..fd72845b 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -37,7 +37,7 @@ if (PICOW) LittleFS.begin(); } - +*/ void show_dir() { int count = 0; Dir dir = LittleFS.openDir("/"); @@ -57,7 +57,7 @@ void show_dir() { } Serial.println(">"); } -*/ + void write_jpg() { /* From 319bd32af7b1bfa29956014d3c3f0befb531755f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:53:58 -0400 Subject: [PATCH 60/96] Delete pico-get-jpeg-serial.h --- cubesatsim/pico-get-jpeg-serial.h | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 cubesatsim/pico-get-jpeg-serial.h diff --git a/cubesatsim/pico-get-jpeg-serial.h b/cubesatsim/pico-get-jpeg-serial.h deleted file mode 100644 index b22f5d5d..00000000 --- a/cubesatsim/pico-get-jpeg-serial.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef PICO_GET_JPEG_SERIAL -#define PICO_GET_JPEG_SERIAL - -#include -#include - -bool finished = false; - -char buffer2[100001]; -int index1 = 0; -char start_flag[] = "3d99de816e5ad7742b61a37c39141783"; -char end_flag[] = "f681a5c52351befe0e3524eb1a40f14b7803317a"; -int flag_count = 0; -int start_flag_detected = false; -int start_flag_complete = false; -int end_flag_detected = false; -int jpeg_start = 0; -FastCRC8 CRC8; - -//#define DEBUG - -//#define PICOW true -int led_pin = LED_BUILTIN; - -void get_image_file(); -#endif From 3b0b6b9070c135a36cf77b8f9c32a9045e062df5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:54:35 -0400 Subject: [PATCH 61/96] merged from .h --- cubesatsim/pico-get-jpeg-serial.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index fd72845b..dee1407f 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -1,4 +1,25 @@ -#include "pico-get-jpeg-serial.h" +#include +#include + +bool finished = false; + +char buffer2[100001]; +int index1 = 0; +char start_flag[] = "3d99de816e5ad7742b61a37c39141783"; +char end_flag[] = "f681a5c52351befe0e3524eb1a40f14b7803317a"; +int flag_count = 0; +int start_flag_detected = false; +int start_flag_complete = false; +int end_flag_detected = false; +int jpeg_start = 0; +FastCRC8 CRC8; + +//#define DEBUG + +//#define PICOW true +int led_pin = LED_BUILTIN; + +void get_image_file(); /* void setup() { From d90fcac9a6c34474652e510689cf8ffb6dd41390 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:55:32 -0400 Subject: [PATCH 62/96] removed .h --- cubesatsim/cubesatsim.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 6d9ad5a2..18099acb 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -39,7 +39,6 @@ #include "hardware/adc.h" #include "SSTV-Arduino-Scottie1-Library.h" #include "LittleFS.h" -#include "pico-get-jpeg-serial.h" // jpg files to be stored in flash storage on Pico (FS 512kB setting) #include "sstv1.h" From b623059d3468311bce1afe5e9ea17312da2a1b78 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 22:57:23 -0400 Subject: [PATCH 63/96] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 18099acb..c0934691 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -61,6 +61,8 @@ WiFiClient client; byte green_led_counter = 0; char call[] = "AMSAT"; // put your callsign here +extern void get_image_file(); + void setup() { set_sys_clock_khz(133000, true); From a0ee24bd7f8b6dcd48bf056db55c8dd23f0a6c92 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 20 Aug 2022 23:00:07 -0400 Subject: [PATCH 64/96] changed show_dir to 2 --- cubesatsim/pico-get-jpeg-serial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index dee1407f..5b517406 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -59,7 +59,7 @@ if (PICOW) LittleFS.begin(); } */ -void show_dir() { +void show_dir2() { int count = 0; Dir dir = LittleFS.openDir("/"); // or Dir dir = LittleFS.openDir("/data"); @@ -105,7 +105,7 @@ void write_jpg() { } else Serial.println("Not a JPEG"); - show_dir(); + show_dir2(); /* delay(2000); From dabecd123826e15e4f4ee2d5069f59595e74f03e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 07:18:59 -0400 Subject: [PATCH 65/96] get_image_file debugging --- cubesatsim/cubesatsim.ino | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c0934691..6f4fd347 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -183,17 +183,18 @@ void loop() { else if (mode == SSTV) { char image_file[128]; - if (first_time_sstv) { +// if (first_time_sstv) { + if (false) { // turn this off for now strcpy(image_file, sstv1_filename); first_time_sstv = false; } else { - - // get jpeg from camera in future - get_image_file(); + Serial.println("Getting image file"); + get_image_file(); + Serial.println("Got image file"); char camera_file[] = "/cam.jpg"; strcpy(image_file, camera_file); -// strcpy(image_file, sstv2_filename); +// strcpy(image_file, sstv2_filename); // 2nd stored image } if (debug_mode) { Serial.print("\nSending SSTV image "); From e95cd19292ebfa4873c5adaccd7bab8dc112e91b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 07:24:54 -0400 Subject: [PATCH 66/96] added GET_IMAGE_DEBUG prints --- cubesatsim/pico-get-jpeg-serial.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index 5b517406..5975d7b2 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -14,6 +14,8 @@ int end_flag_detected = false; int jpeg_start = 0; FastCRC8 CRC8; +#define GET_IMAGE_DEBUG + //#define DEBUG //#define PICOW true @@ -139,6 +141,10 @@ void loop() { */ void get_image_file() { + +#ifdef GET_IMAGE_DEBUG + Serial.println("Starting get_image_file"); + #endif finished = false; while (!finished) { // put your main code here, to run repeatedly: @@ -151,7 +157,9 @@ void get_image_file() { if (octet == end_flag[flag_count]) { // looking for end flag // if (end_flag_detected) { flag_count++; -// Serial.println("Found part of end flag!"); +#ifdef GET_IMAGE_DEBUG + Serial.println("Found part of end flag!"); +#endif if (flag_count >= strlen(end_flag)) { // complete image /// buffer2[index1++] = octet; Serial.println("\nFound end flag"); @@ -172,7 +180,7 @@ void get_image_file() { // index1 -= 1; uint8_t * data = (uint8_t *) &buffer2[0]; -#ifdef DEBUG +#ifdef GET_IMAGE_DEBUG Serial.println("\nCRC cacluation data:"); Serial.println(buffer2[0], HEX); Serial.println(buffer2[index1 - 1], HEX); @@ -200,7 +208,7 @@ void get_image_file() { } /// buffer2[index1++] = octet; -#ifdef DEBUG +#ifdef GET_IMAGE_DEBUG char hexValue[5]; if (octet != 0x66) { sprintf(hexValue, "%02X", octet); From 7e41753566876247f406f0f917cf0dcdda802a4f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 07:31:26 -0400 Subject: [PATCH 67/96] added start_camera and changed to get_camera_image --- cubesatsim/pico-get-jpeg-serial.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index 5975d7b2..0601f878 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -21,20 +21,21 @@ FastCRC8 CRC8; //#define PICOW true int led_pin = LED_BUILTIN; -void get_image_file(); +void get_camera_image(); +void start_camera(); -/* -void setup() { +void start_camera() { - // put your setup code here, to run once: + // setup for ESP32-CAM -if (PICOW) - led_pin = STEM_LED2_PIN; +//if (PICOW) +// led_pin = STEM_LED2_PIN; Serial.begin(115200); - delay(5000); +// delay(5000); +/* pinMode(led_pin, OUTPUT); digitalWrite(led_pin, LOW); @@ -49,18 +50,18 @@ if (PICOW) digitalWrite(led_pin, LOW); delay(2000); - +*/ Serial2.setRX(9); delay(100); Serial2.setTX(8); delay(100); Serial2.begin(115200); - - Serial.println("Starting"); - +#ifdef GET_IMAGE_DEBUG + Serial.println("Started Serial2 to camera"); +#endif LittleFS.begin(); } -*/ + void show_dir2() { int count = 0; Dir dir = LittleFS.openDir("/"); @@ -140,7 +141,7 @@ void loop() { } */ -void get_image_file() { +void get_camera_image() { #ifdef GET_IMAGE_DEBUG Serial.println("Starting get_image_file"); From 8e30de7a534c7519b4356bffe25d6e7739c9cfe9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 07:33:30 -0400 Subject: [PATCH 68/96] changed to get_camera_image --- cubesatsim/cubesatsim.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 6f4fd347..c2960689 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -61,7 +61,8 @@ WiFiClient client; byte green_led_counter = 0; char call[] = "AMSAT"; // put your callsign here -extern void get_image_file(); +extern void get_camera_image(); +extern void start_camera(); void setup() { @@ -133,6 +134,7 @@ void setup() { */ // start_button_isr(); setup_sstv(); + start_camera(); start_isr(); start_pwm(); @@ -189,7 +191,7 @@ void loop() { first_time_sstv = false; } else { Serial.println("Getting image file"); - get_image_file(); + get_camera_image(); Serial.println("Got image file"); char camera_file[] = "/cam.jpg"; strcpy(image_file, camera_file); From 15563b885ed0e55d2ea7edaab461f3bb997ba3fc Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 07:41:32 -0400 Subject: [PATCH 69/96] reset values at the start --- cubesatsim/pico-get-jpeg-serial.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index 0601f878..b5142c89 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -143,6 +143,13 @@ void loop() { void get_camera_image() { + index1 = 0; + flag_count = 0; + start_flag_detected = false; + start_flag_complete = false; + end_flag_detected = false; + jpeg_start = 0; + #ifdef GET_IMAGE_DEBUG Serial.println("Starting get_image_file"); #endif From ad57ca019a869ae755e70e29a8a2776516bbe231 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 07:49:58 -0400 Subject: [PATCH 70/96] turn off debug --- cubesatsim/pico-get-jpeg-serial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index b5142c89..baed0dee 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -14,7 +14,7 @@ int end_flag_detected = false; int jpeg_start = 0; FastCRC8 CRC8; -#define GET_IMAGE_DEBUG +//#define GET_IMAGE_DEBUG //#define DEBUG From 7702d0a0375d3210b30d21b3f16137e073c2bc9f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 08:11:44 -0400 Subject: [PATCH 71/96] made start_camera and get_camera_image bool --- cubesatsim/pico-get-jpeg-serial.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index baed0dee..1b1713ae 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -1,3 +1,11 @@ +// Pico code to get camera image from ESP32-CAM running the esp32-cam-send-jpeg-serial software +// +// run start_camera() once to initialize. Also runs get_camera_image and returns true if got an image +// +// run get_camera_image() to get image. If returns true, an image was recevied. If false, +// the CAMERA_TIMEOUT milli second timeout was reached - might indicate no camera +// + #include #include @@ -13,6 +21,7 @@ int start_flag_complete = false; int end_flag_detected = false; int jpeg_start = 0; FastCRC8 CRC8; +#define CAMERA_TIMEOUT 6000 // Camera timeout in milli seconds //#define GET_IMAGE_DEBUG @@ -21,10 +30,10 @@ FastCRC8 CRC8; //#define PICOW true int led_pin = LED_BUILTIN; -void get_camera_image(); -void start_camera(); +bool get_camera_image(); +bool start_camera(); -void start_camera() { +bool start_camera() { // setup for ESP32-CAM @@ -60,6 +69,8 @@ void start_camera() { Serial.println("Started Serial2 to camera"); #endif LittleFS.begin(); + + return(get_camera_image()); } void show_dir2() { @@ -141,7 +152,7 @@ void loop() { } */ -void get_camera_image() { +bool get_camera_image() { index1 = 0; flag_count = 0; @@ -154,8 +165,10 @@ void get_camera_image() { Serial.println("Starting get_image_file"); #endif finished = false; - while (!finished) { - // put your main code here, to run repeatedly: + + unsigned long time_start = millis(); + while ((!finished) && ((millis() - time_start) < CAMERA_TIMEOUT)) { + if (Serial2.available()) { // If anything comes in Serial2 byte octet = Serial2.read(); @@ -246,4 +259,5 @@ void get_camera_image() { } } } + return(finished); } From 9dabdfab879820631fe29322dbe26b133f81325f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 08:14:13 -0400 Subject: [PATCH 72/96] added camera_detected --- cubesatsim/cubesatsim.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 4e0a9810..1b5c1387 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -331,6 +331,7 @@ int payload_command = false; bool debug_mode = false; bool voltage_read = false; bool ina219_started = false; +bool camera_detected = false; #define PRESSED 0 #define HELD 0 From cc64cef990275440ba48dff89952657e26057a16 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 08:16:48 -0400 Subject: [PATCH 73/96] added camera_detected --- cubesatsim/cubesatsim.ino | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c2960689..c791cb89 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -61,8 +61,8 @@ WiFiClient client; byte green_led_counter = 0; char call[] = "AMSAT"; // put your callsign here -extern void get_camera_image(); -extern void start_camera(); +extern bool get_camera_image(); +extern bool start_camera(); void setup() { @@ -133,8 +133,15 @@ void setup() { } */ // start_button_isr(); + setup_sstv(); - start_camera(); + if (start_camera()) { + camera_detected = true; + Serial.println("Camera detected!"); + } else + camera_detected = false; + Serial.println("No camera detected!"); + } start_isr(); start_pwm(); @@ -185,18 +192,19 @@ void loop() { else if (mode == SSTV) { char image_file[128]; -// if (first_time_sstv) { - if (false) { // turn this off for now + if (first_time_sstv) { +// if (false) { // turn this off for now strcpy(image_file, sstv1_filename); first_time_sstv = false; } else { - Serial.println("Getting image file"); - get_camera_image(); - Serial.println("Got image file"); - char camera_file[] = "/cam.jpg"; - strcpy(image_file, camera_file); - -// strcpy(image_file, sstv2_filename); // 2nd stored image + if (camera_detected) { + Serial.println("Getting image file"); + get_camera_image(); +// Serial.println("Got image file"); + char camera_file[] = "/cam.jpg"; + strcpy(image_file, camera_file); + } else + strcpy(image_file, sstv2_filename); // 2nd stored image } if (debug_mode) { Serial.print("\nSending SSTV image "); From 2e0fd719aa74344c83d44797b7f1723857103f81 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 08:18:11 -0400 Subject: [PATCH 74/96] typo { --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c791cb89..87b7d3be 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -138,7 +138,7 @@ void setup() { if (start_camera()) { camera_detected = true; Serial.println("Camera detected!"); - } else + } else { camera_detected = false; Serial.println("No camera detected!"); } From 06e06d8b56e4159173cbc68454e53558b9ec3258 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 08:25:01 -0400 Subject: [PATCH 75/96] increased timeout to 12 sec, dir only in debug mode --- cubesatsim/pico-get-jpeg-serial.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cubesatsim/pico-get-jpeg-serial.cpp b/cubesatsim/pico-get-jpeg-serial.cpp index 1b1713ae..833b4719 100644 --- a/cubesatsim/pico-get-jpeg-serial.cpp +++ b/cubesatsim/pico-get-jpeg-serial.cpp @@ -21,7 +21,7 @@ int start_flag_complete = false; int end_flag_detected = false; int jpeg_start = 0; FastCRC8 CRC8; -#define CAMERA_TIMEOUT 6000 // Camera timeout in milli seconds +#define CAMERA_TIMEOUT 12000 // Camera timeout in milli seconds //#define GET_IMAGE_DEBUG @@ -118,8 +118,9 @@ void write_jpg() { // } } else Serial.println("Not a JPEG"); - +#ifdef GET_IMAGE_DEBUG show_dir2(); +#endif /* delay(2000); From 04df085036122595eaf4707693b099728c6298e8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 16:17:21 -0400 Subject: [PATCH 76/96] print input menu at start --- cubesatsim/cubesatsim.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 87b7d3be..565a641a 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -159,6 +159,9 @@ void setup() { ready = TRUE; // flag for core1 to start looping + prompt = PROMPT_HELP; // display input help menu + prompt_for_input(); + Serial.print("s"); Serial.print(" "); Serial.println(millis()); @@ -3711,7 +3714,7 @@ void serial_input() { switch(result) { case 'h': case 'H': - Serial.println("Help"); + // Serial.println("Help"); prompt = PROMPT_HELP; /* Serial.println("\nChange settings by typing the letter:"); @@ -3761,7 +3764,7 @@ void serial_input() { case 'i': case 'I': - Serial.println("Restart CubeSatsim software"); +// Serial.println("Restart CubeSatsim software"); prompt = PROMPT_RESTART; break; From 92fbdcd5d5519dc37984c58a26a5b9c5999b8e31 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 16:27:20 -0400 Subject: [PATCH 77/96] cleanup --- cubesatsim/cubesatsim.ino | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 565a641a..f5e4de9f 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -75,8 +75,12 @@ void setup() { pinMode(LED_BUILTIN, OUTPUT); blinkTimes(1); - sleep(5.0); - + sleep(5.0); + +// otherwise, run CubeSatSim Pico code + + Serial.println("\n\nCubeSatSim Pico v0.14 starting...\n\n"); + config_gpio(); EEPROM.begin(512); @@ -87,9 +91,6 @@ void setup() { // detect Pi Zero using 3.3V // if Pi is present, run Payload OK software -// otherwise, run CubeSatSim Pico code - - Serial.println("\n\nCubeSatSim Pico v0.13 starting...\n\n"); load_files(); /* @@ -414,7 +415,7 @@ void config_telem() { frameCnt = 1; - Serial.println("v1 Present with UHF BPF\n"); + // Serial.println("v1 Present with UHF BPF\n"); txLed = 2; txLedOn = HIGH; txLedOff = LOW; @@ -440,15 +441,15 @@ void config_telem() { sample_rate = 200; // samples = S_RATE / bitRate; samples = sample_rate / bitRate; - Serial.println(samples); +// Serial.println(samples); bufLen = (frameCnt * (syncBits + 10 * (headerLen + rsFrames * (rsFrameLen + parityLen))) * samples); - Serial.println(bufLen); +// Serial.println(bufLen); samplePeriod = (int) (((float)((syncBits + 10 * (headerLen + rsFrames * (rsFrameLen + parityLen)))) / (float) bitRate) * 1000 - 500); sleepTime = 0.1; - Serial.println(samplePeriod); +// Serial.println(samplePeriod); frameTime = ((float)((float)bufLen / (samples * frameCnt * bitRate))) * 1000; // frame time in ms - Serial.println(frameTime); +// Serial.println(frameTime); // printf("\n FSK Mode, %d bits per frame, %d bits per second, %d ms per frame, %d ms sample period\n", // bufLen / (samples * frameCnt), bitRate, frameTime, samplePeriod); memset(buffer, 0xa5, sizeof(buffer)); @@ -469,19 +470,19 @@ void config_telem() { sample_rate = 1200; // samples = S_RATE / bitRate; samples = sample_rate / bitRate; - Serial.println(samples); +// Serial.println(samples); // bufLen = (frameCnt * (syncBits + 10 * (headerLen + rsFrames * (rsFrameLen + parityLen))) * samples); // * 2; // 2 * bufLen = 5751; // instead of 5841 - Serial.println(bufLen); +// Serial.println(bufLen); // samplePeriod = ((float)((syncBits + 10 * (headerLen + rsFrames * (rsFrameLen + parityLen))))/(float)bitRate) * 1000 - 500; samplePeriod = ((float)((syncBits + 10 * (headerLen + rsFrames * (rsFrameLen + parityLen))))/(float)bitRate) * 1000; // - 500; // samplePeriod = 3000; // sleepTime = 3.0; //samplePeriod = 2200; // reduce dut to python and sensor querying delays sleepTime = 2.2f; - Serial.println(samplePeriod); + // Serial.println(samplePeriod); frameTime = ((float)((float)bufLen / (samples * frameCnt * bitRate))) * 1000; // frame time in ms - Serial.println(frameTime); +// Serial.println(frameTime); // printf("\n BPSK Mode, bufLen: %d, %d bits per frame, %d bits per second, %d ms per frame %d ms sample period\n", // bufLen, bufLen / (samples * frameCnt), bitRate, frameTime, samplePeriod); @@ -3843,7 +3844,8 @@ void prompt_for_input() { Serial.println("r Resets Count, or payload & EEPROM"); Serial.println("l Lat and Long"); Serial.println("? Query sensors"); - Serial.println("v Read INA219 voltage and current\n"); + Serial.println("v Read INA219 voltage and current\n"); + Serial.println("d Change debug mode\n"); break; case PROMPT_CALLSIGN: From 6e124433630aaa126f997b579881a83d5198b3b4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 16:30:09 -0400 Subject: [PATCH 78/96] fix help menu --- cubesatsim/cubesatsim.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index f5e4de9f..dfb482ba 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3844,7 +3844,7 @@ void prompt_for_input() { Serial.println("r Resets Count, or payload & EEPROM"); Serial.println("l Lat and Long"); Serial.println("? Query sensors"); - Serial.println("v Read INA219 voltage and current\n"); + Serial.println("v Read INA219 voltage and current"); Serial.println("d Change debug mode\n"); break; @@ -3973,6 +3973,7 @@ void prompt_for_input() { Serial.println("off"); break; } + prompt = false; } void get_serial_string() { From 3847899e0e7225b24ee4e390996b1f6797388b6d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 16:35:12 -0400 Subject: [PATCH 79/96] added PICO_0V1 flag for v0.1 hardware --- cubesatsim/cubesatsim.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index dfb482ba..0b793655 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -57,6 +57,12 @@ WiFiServer server(port); WiFiClient client; //#define PICO_W // define if Pico W board. Otherwise, compilation fail for Pico or runtime fail if compile as Pico W +#define PICO_0V1 // define for Pico v0.1 hardware + +#ifdef PICO_0v1 +#define BPF_PIN 8 // BPF is installed for v0.1 Pico +#define PI_3V3_PIN 9 // 3.3V supply used to detect Pi Zero for v0.1 Pico +#endif byte green_led_counter = 0; char call[] = "AMSAT"; // put your callsign here From aa2c929ed2431ca635603af2eb67a43df864b94f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 16:37:09 -0400 Subject: [PATCH 80/96] typo in PICO_0V1 --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 0b793655..3f63b05d 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -59,7 +59,7 @@ WiFiClient client; //#define PICO_W // define if Pico W board. Otherwise, compilation fail for Pico or runtime fail if compile as Pico W #define PICO_0V1 // define for Pico v0.1 hardware -#ifdef PICO_0v1 +#ifdef PICO_0V1 #define BPF_PIN 8 // BPF is installed for v0.1 Pico #define PI_3V3_PIN 9 // 3.3V supply used to detect Pi Zero for v0.1 Pico #endif From 4a9e7a1e4455d7e54f9ac86e3bab5a66f4b3be87 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 16:44:25 -0400 Subject: [PATCH 81/96] added voltage_read for v prompt --- cubesatsim/cubesatsim.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 3f63b05d..4b5827bf 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3937,6 +3937,7 @@ void prompt_for_input() { Serial.println("Querying INA219 voltage and current sensors"); if (!ina219_started) start_ina219(); + voltage_read = true; read_ina219(); break; From 1c99305a2136018017bbde5d7c2c44deb1a3d556 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 16:54:17 -0400 Subject: [PATCH 82/96] start ina219 when simulated telemetry is turned off --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 4b5827bf..f83d4268 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3890,6 +3890,8 @@ void prompt_for_input() { } else if ((serial_string[0] == 'n') || (serial_string[0] == 'N')) { Serial.println("Setting Simulated telemetry to off"); sim_mode = false; + if (!ina219_started) + start_ina219(); } else Serial.println("No change to Simulated Telemetry mode"); break; From f3a17a57606a512069711afa013df308a12168d2 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 16:57:51 -0400 Subject: [PATCH 83/96] cleanup --- cubesatsim/cubesatsim.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index f83d4268..73d56005 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -85,7 +85,7 @@ void setup() { // otherwise, run CubeSatSim Pico code - Serial.println("\n\nCubeSatSim Pico v0.14 starting...\n\n"); + Serial.println("CubeSatSim Pico v0.14 starting...\n"); config_gpio(); @@ -2814,14 +2814,14 @@ void start_ina219() { ina219_started = true; // check if Pi is present by 3.3V voltage pinMode(PI_3V3_PIN, INPUT); - Serial.print("Pi 3.3V: "); - Serial.println(digitalRead(PI_3V3_PIN)); +// Serial.print("Pi 3.3V: "); +// Serial.println(digitalRead(PI_3V3_PIN)); if (digitalRead(PI_3V3_PIN) == LOW) { - Serial.println("Powering INA219s through 3.3V pin"); + Serial.println("Pi Zero not present, powering INA219s through 3.3V pin"); pinMode(PI_3V3_PIN, OUTPUT); digitalWrite(PI_3V3_PIN, HIGH); } else { - Serial.println("Not powering INA219s since 3.3V is present"); + Serial.println("Not powering INA219s since Pi Zero is present"); // pinMode(MAIN_INA219, OUTPUT); // digitalWrite(MAIN_INA219, HIGH); } From 64e799efef92e83713e8d40d97dbbbdfb56ad7b9 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 22:03:48 -0400 Subject: [PATCH 84/96] added PICO_0V1 to pinout --- cubesatsim/cubesatsim.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 1b5c1387..111b7817 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -47,12 +47,20 @@ #define SCL2 5 // I2C 2 Clock #define BPSK_CONTROL_A 6 // was 16 // control for Phase A to switch #define BPSK_CONTROL_B 7 // was 15 // control for Phase A to switch + +#ifdef PICO_0V1 +#define BPF_PIN 8 // BPF is installed for v0.1 Pico +#define PI_3V3_PIN 9 // 3.3V supply used to detect Pi Zero for v0.1 Pico +#else +#define BPF_PIN 12 // BPF is installed +#define PI_3V3_PIN 13 // 3.3V supply used to detect Pi Zero +#endif + #define TX2 8 // Serial2 to ESP32-CAM transmit data #define RX2 9 // Serial2 to ESP32-CAM receive data #define MAIN_PB_PIN 10 // Main board PB pushbutton pin #define TXC_PIN 11 // Transceiver Board is present -#define BPF_PIN 12 // BPF is installed -#define PI_3V3_PIN 13 // 3.3V supply used to detect Pi Zero + #define BPSK_PWM_A_PIN 14 // was 6 // PWM Output Phase A to switch #define BPSK_PWM_B_PIN 15 // was 7 // PWM Output Phase B to switch #define SWTX_PIN 16 // was 14 SR_FRS_05W Transmit Pico software serial port From 7904c2a2f9cf98dd43dc58f937afbf6d41d5f2d3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 22:04:28 -0400 Subject: [PATCH 85/96] moved PICO_0V1 defines to .h --- cubesatsim/cubesatsim.ino | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 73d56005..97ee26ef 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -18,6 +18,8 @@ // This code is an Arduino sketch for the Raspberry Pi Pico // based on the Raspberry Pi Code +#define PICO_0V1 // define for Pico v0.1 hardware + #include "cubesatsim.h" #include "DumbTXSWS.h" #include @@ -57,12 +59,6 @@ WiFiServer server(port); WiFiClient client; //#define PICO_W // define if Pico W board. Otherwise, compilation fail for Pico or runtime fail if compile as Pico W -#define PICO_0V1 // define for Pico v0.1 hardware - -#ifdef PICO_0V1 -#define BPF_PIN 8 // BPF is installed for v0.1 Pico -#define PI_3V3_PIN 9 // 3.3V supply used to detect Pi Zero for v0.1 Pico -#endif byte green_led_counter = 0; char call[] = "AMSAT"; // put your callsign here From c9892e776b655d081463cf3a9c72241471c5b0c4 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 22:07:49 -0400 Subject: [PATCH 86/96] changed 12 and 13 for v0.1 --- cubesatsim/cubesatsim.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.h b/cubesatsim/cubesatsim.h index 111b7817..bacf397a 100644 --- a/cubesatsim/cubesatsim.h +++ b/cubesatsim/cubesatsim.h @@ -51,13 +51,16 @@ #ifdef PICO_0V1 #define BPF_PIN 8 // BPF is installed for v0.1 Pico #define PI_3V3_PIN 9 // 3.3V supply used to detect Pi Zero for v0.1 Pico +#define TX2 12 // Serial2 to ESP32-CAM transmit data +#define RX2 13 // Serial2 to ESP32-CAM receive data #else +#define TX2 8 // Serial2 to ESP32-CAM transmit data +#define RX2 9 // Serial2 to ESP32-CAM receive data #define BPF_PIN 12 // BPF is installed #define PI_3V3_PIN 13 // 3.3V supply used to detect Pi Zero #endif -#define TX2 8 // Serial2 to ESP32-CAM transmit data -#define RX2 9 // Serial2 to ESP32-CAM receive data + #define MAIN_PB_PIN 10 // Main board PB pushbutton pin #define TXC_PIN 11 // Transceiver Board is present From 8f4470d9e8ee237b505d50d13019ca0ccade77ea Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 22:13:22 -0400 Subject: [PATCH 87/96] prints --- cubesatsim/cubesatsim.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 97ee26ef..12eb63e2 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2806,7 +2806,9 @@ void led_set(int ledPin, bool state) } void start_ina219() { -//#define PI_3V3_PIN 9 // for v0.1 hardware +//#define PI_3V3_PIN 9 // for v0.1 hardware + Serial.println("Starting INA219"); + Serial.println(PI_3V3_PIN); ina219_started = true; // check if Pi is present by 3.3V voltage pinMode(PI_3V3_PIN, INPUT); @@ -3295,8 +3297,8 @@ void config_gpio() { // Serial.println(digitalRead(SQUELCH)); - Serial.print("Pi 3.3V: "); - Serial.println(digitalRead(PI_3V3_PIN)); +// Serial.print("Pi 3.3V: "); +// Serial.println(digitalRead(PI_3V3_PIN)); // set anlog inputs and read Serial.print("Diode voltage (temperature): "); From 2c6ca1ef600de49df49362e8b1fd3e14a3e8277e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 22:16:56 -0400 Subject: [PATCH 88/96] force GPIO 9 high for ina219 read --- cubesatsim/cubesatsim.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 12eb63e2..a1e9ae20 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2050,6 +2050,8 @@ void test_radio() void read_ina219() { + digitalWrite(9, HIGH); + float shuntvoltage = 0; float busvoltage = 0; float current_mA = 0; From 6c031e8227e2173a376802af85e20a74b710f507 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 22:37:08 -0400 Subject: [PATCH 89/96] Update cubesatsim.ino --- cubesatsim/cubesatsim.ino | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a1e9ae20..8bf750bf 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2050,8 +2050,9 @@ void test_radio() void read_ina219() { - digitalWrite(9, HIGH); - +#ifdef PICO_0V1 + digitalWrite(PI_3V3_PIN, HIGH); +#endif float shuntvoltage = 0; float busvoltage = 0; float current_mA = 0; From 6d6395a5b37acf5645a094a84bea2af18ddc1c27 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Aug 2022 06:55:58 -0400 Subject: [PATCH 90/96] force 3.3V high --- cubesatsim/cubesatsim.ino | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 8bf750bf..86503778 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -19,7 +19,7 @@ // based on the Raspberry Pi Code #define PICO_0V1 // define for Pico v0.1 hardware - +3 #include "cubesatsim.h" #include "DumbTXSWS.h" #include @@ -107,7 +107,11 @@ void setup() { } } */ -// configure STEM Payload sensors +// configure STEM Payload sensors + + pinMode(PI_3V3_PIN, OUTPUT); + digitalWrite(PI_3V3_PIN, HIGH); + start_payload(); // above code not working, so forcing it read_reset_count(); From feb5b430ce1b34cf086b8ea779b94b7a5674c99d Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Aug 2022 06:58:08 -0400 Subject: [PATCH 91/96] stray 3 --- cubesatsim/cubesatsim.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 86503778..f9caead2 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -19,7 +19,7 @@ // based on the Raspberry Pi Code #define PICO_0V1 // define for Pico v0.1 hardware -3 + #include "cubesatsim.h" #include "DumbTXSWS.h" #include From c2749f0e9e7ad0ec83232138a6bc76be0c94cac3 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Aug 2022 07:04:01 -0400 Subject: [PATCH 92/96] print nothing if reading ina219 sensors with nothing there --- cubesatsim/cubesatsim.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index f9caead2..7cb2ea16 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2054,6 +2054,9 @@ void test_radio() void read_ina219() { + if (voltage_read && !i2c_bus1 && !i2c_bus3) + Serial.println("Nothing to read"); + #ifdef PICO_0V1 digitalWrite(PI_3V3_PIN, HIGH); #endif From e493eeac06c26abfa4e1d7c20e244a4edf966976 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Aug 2022 07:17:44 -0400 Subject: [PATCH 93/96] don't check 3.3V on Pico 0.1 board --- cubesatsim/cubesatsim.ino | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 7cb2ea16..1e8b288d 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2056,10 +2056,11 @@ void read_ina219() { if (voltage_read && !i2c_bus1 && !i2c_bus3) Serial.println("Nothing to read"); - +/* #ifdef PICO_0V1 digitalWrite(PI_3V3_PIN, HIGH); #endif +*/ float shuntvoltage = 0; float busvoltage = 0; float current_mA = 0; @@ -2818,8 +2819,10 @@ void led_set(int ledPin, bool state) void start_ina219() { //#define PI_3V3_PIN 9 // for v0.1 hardware Serial.println("Starting INA219"); - Serial.println(PI_3V3_PIN); +// Serial.println(PI_3V3_PIN); ina219_started = true; + +#ifndef PICO_0V1 // check if Pi is present by 3.3V voltage pinMode(PI_3V3_PIN, INPUT); // Serial.print("Pi 3.3V: "); @@ -2830,9 +2833,13 @@ void start_ina219() { digitalWrite(PI_3V3_PIN, HIGH); } else { Serial.println("Not powering INA219s since Pi Zero is present"); -// pinMode(MAIN_INA219, OUTPUT); -// digitalWrite(MAIN_INA219, HIGH); } +#else + Serial.println("Powering INA219s through 3.3V pin"); + pinMode(PI_3V3_PIN, OUTPUT); + digitalWrite(PI_3V3_PIN, HIGH); +#endif + sleep(0.1); i2c_bus1 = ina219_1_0x40.begin(); // check i2c bus 1 ina219_1_0x41.begin(); From 7a268c9dca64b419d7b409585a9ce5e4c6a6359a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Aug 2022 07:37:54 -0400 Subject: [PATCH 94/96] added payload reset --- cubesatsim/cubesatsim.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index 1e8b288d..a372b3ad 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -2274,7 +2274,7 @@ void start_payload() { float zOffset; EEPROM.get(0, flag); - if (flag == 0xA07) + if ((flag == 0xA07) && (payload_command != PAYLOAD_RESET)) { Serial.println("Reading gyro offsets from EEPROM\n"); @@ -2291,6 +2291,8 @@ void start_payload() { } else { + payload_command = false; + Serial.println("Calculating gyro offsets and storing in EEPROM\n"); mpu6050.calcGyroOffsets(true); @@ -3978,7 +3980,8 @@ void prompt_for_input() { } else if ((serial_string[0] == 'p') || (serial_string[0] == 'P')) { Serial.println("Resetting the Payload"); - payload_command = PAYLOAD_RESET; + payload_command = PAYLOAD_RESET; + start_payload(); } else Serial.println("No action"); From 3696b597c3523da8b9658abb67656ccb6808b993 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Aug 2022 07:44:29 -0400 Subject: [PATCH 95/96] transmit LED on/off for CW ID --- cubesatsim/cubesatsim.ino | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index a372b3ad..c8425722 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -3575,6 +3575,10 @@ void configure_wifi() { } void transmit_cw(int freq, float duration) { // freq in Hz, duration in milliseconds + if (!wifi) + digitalWrite(LED_BUILTIN, HIGH); // Transmit LED on + digitalWrite(MAIN_LED_BLUE, HIGH); + unsigned long start = micros(); unsigned long duration_us = duration * 1000; float period_us = (0.5E6) / (float)(freq); @@ -3586,6 +3590,9 @@ void transmit_cw(int freq, float duration) { // freq in Hz, duration in millise sleep(min(time_left, period_us) / 1.0E6); } digitalWrite(AUDIO_OUT_PIN, LOW); + if (!wifi) + digitalWrite(LED_BUILTIN, LOW); // Transmit LED off + digitalWrite(MAIN_LED_BLUE, LOW); } void transmit_callsign(char *callsign) { From 4ef476272bbafdd0246e586d0ee37032cf9fd8c5 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Mon, 22 Aug 2022 07:54:47 -0400 Subject: [PATCH 96/96] reset sample time after mode change. built in LED on/off for SSTV mode --- cubesatsim/cubesatsim.ino | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cubesatsim/cubesatsim.ino b/cubesatsim/cubesatsim.ino index c8425722..e7a4cd48 100644 --- a/cubesatsim/cubesatsim.ino +++ b/cubesatsim/cubesatsim.ino @@ -230,6 +230,8 @@ void loop() { if (debug_mode) Serial.println("Start transmit!!!"); digitalWrite(PTT_PIN, LOW); // start transmit + if (!wifi) + digitalWrite(LED_BUILTIN, HIGH); digitalWrite(MAIN_LED_BLUE, HIGH); scottie1_transmit_file(output_file, debug_mode); @@ -237,6 +239,8 @@ void loop() { if (debug_mode) Serial.println("Stop transmit!"); digitalWrite(PTT_PIN, HIGH); // stop transmit + if (!wifi) + digitalWrite(LED_BUILTIN, HIGH); digitalWrite(MAIN_LED_BLUE, LOW); if (debug_mode) @@ -276,6 +280,7 @@ void loop() { sleep(0.5); config_telem(); config_radio(); + sampleTime = (unsigned int) millis(); } if (prompt) {