From cc64cef990275440ba48dff89952657e26057a16 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sun, 21 Aug 2022 08:16:48 -0400 Subject: [PATCH] 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 ");