From 4a63ea34dae499683f23f317e6089e17ef055074 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Sun, 8 May 2022 22:36:53 -0500 Subject: [PATCH 01/25] Update Standby.cpp --- Standby.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/Standby.cpp b/Standby.cpp index b1e51d8..7583f95 100644 --- a/Standby.cpp +++ b/Standby.cpp @@ -1,11 +1,61 @@ + #include "Common.h" #include "Hardware.h" #include "States.h" namespace States -{ +{ void Standby() { - // do standby + // Offset altitude reading by average calculated + + // Container Telemetry: BMP 308 @ 1Hz, GPS @ 1Hz + Common::GPS_Data gps_data; + Common::Sensor_Data sensor_data; + Hardware::read_gps(gps_data); + Hardware::read_sensors(sensor_data); + + // Build the packet with the data + String packet; + Common::build_packet(packet, "Standby", "N", mission_start_time, sensor_data); + + // Send the container packet down to the ground station + Hardware::mtx.lock(); + Hardware::ground_packets.enqueue(packet); + Hardware::payload_packets.enqueue("0"); + Hardware::mtx.unlock(); + + // Detect Acceleration + // The plan to detect acceleration is to keep a queue of maybe 20 altitude readings, + // derive it once for velocity, and derive it again for acceleration + int altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]); + + // We'll check to see if there are enough altitudes stored to calculate acceleration: + if (altitude_length >= 3) + { + for (int i = 0, i < 2, i++) + { + Common::velocities.push_back(Common::altitudes[i + 1] - Common::altitudes[i]); + if (i > 0) + { + Common::acceleration = Common::velocities[i + 1] - Common::velocities[i]; + } + } + Common::altitudes.pop_back(); + } + Common::altitudes.push_back(gps_data.altitude); + + // Now we'll actually switch the state + if (Common::acceleration >= 18 or Common::altitudes[-1] >= 10) + { + States::EE_STATE = 2; + EEPROM.put(Common::ST_ADDR, 2); + } + + // I'm guessing that this part is to account for delay of sending??? + if (Common::TELEMETRY_DELAY > (millis() - start)) + { + delay(Common::TELEMETRY_DELAY - (millis() - start)); + } } } From 04e90cd5ef70b716c590fef073616572f535ac37 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Sun, 8 May 2022 22:38:27 -0500 Subject: [PATCH 02/25] Update Common.h --- Common.h | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/Common.h b/Common.h index 6cac646..469bdf1 100644 --- a/Common.h +++ b/Common.h @@ -6,39 +6,46 @@ #include #include #include +#include #define GPS_SERIAL Serial1 #define GROUND_XBEE_SERIAL Serial7 #define PAYLOAD_XBEE_SERIAL Serial8 -namespace Common { +namespace Common +{ static elapsedMillis milli; - const unsigned long TELEMETRY_DELAY = 1000; //1hz - + const unsigned long TELEMETRY_DELAY = 1000; // 1hz + const byte VOLTAGE_PIN = 23; const byte BMP_SCL = 24; const byte BMP_SDA = 25; const byte PARA_SERVO_PIN = 41; const byte CAMERA_PIN = 3; const byte AUDIO_BEACON_PIN = 2; - + const float SEA_LEVEL = 1014.6f; - + static bool SIM_ACTIVATE = false; static bool SIM_ENABLE = false; static int SIM_PRESSURE = 0; const static uint16_t TEAM_ID = 1051; const static uint16_t LEAP_SECONDS = 18; - + static uint16_t BA_ADDR = 0; static uint16_t PC_ADDR = 4; static uint16_t ST_ADDR = 6; - + static float EE_BASE_ALTITUDE = 0; static uint16_t EE_PACKET_COUNT = 0; static String lastCMD = "None"; - + + // List to track acceleration measurements: + std::vector altitudes[3]; + std::vector velocities[2]; + float acceleration = 0f; + struct GPS_Data { uint16_t hours; @@ -50,7 +57,7 @@ namespace Common { float altitude; byte sats; }; - + struct Sensor_Data { float vbat; @@ -60,13 +67,14 @@ namespace Common { static int millisecond() { - if (milli >= 1000) milli -= 1000; + if (milli >= 1000) + milli -= 1000; return milli; } - - static void build_packet(String& packet, const String& state, const char tp_released, const GPS_Data &gps, const Sensor_Data &sensors) + + static void build_packet(String &packet, const String &state, const char tp_released, const GPS_Data &gps, const Sensor_Data &sensors) { - packet = TEAM_ID + ","; //0 + packet = TEAM_ID + ","; // 0 packet += String(hour()) + ":" + String(minute()) + ":" + String(second()) + "." + String(millisecond()) + ","; packet += String(EE_PACKET_COUNT) + ","; if (SIM_ACTIVATE && SIM_ENABLE) @@ -74,13 +82,13 @@ namespace Common { else packet += "F,"; packet += tp_released + ","; - packet += String(sensors.altitude) + ","; + packet += String(sensors.altitude) + ","; packet += String(sensors.temperature) + ","; packet += String(sensors.vbat) + ","; packet += String(gps.hours) + ":" + String(gps.minutes) + ":" + String(gps.seconds) + "." + String(gps.milliseconds) + ","; - packet += String(gps.latitude) + ","; - packet += String(gps.longitude) + ","; - packet += String(gps.altitude) + ","; + packet += String(gps.latitude) + ","; + packet += String(gps.longitude) + ","; + packet += String(gps.altitude) + ","; packet += String(gps.sats) + ","; packet += state + ","; packet += lastCMD + "\n"; From dad9a94862bf4ceb45f800f776ffb1d758d1fd6c Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Sun, 8 May 2022 22:58:51 -0500 Subject: [PATCH 03/25] Newly improved, but still queue --- Standby.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Standby.cpp b/Standby.cpp index 7583f95..f198917 100644 --- a/Standby.cpp +++ b/Standby.cpp @@ -46,7 +46,7 @@ namespace States Common::altitudes.push_back(gps_data.altitude); // Now we'll actually switch the state - if (Common::acceleration >= 18 or Common::altitudes[-1] >= 10) + if (Common::acceleration >= 18 || Common::altitudes[altitude_length - 1] >= 10) { States::EE_STATE = 2; EEPROM.put(Common::ST_ADDR, 2); From af68e9ea31a2e690ccae3f8cb8bd32df6ad88a16 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 10 May 2022 18:07:58 -0500 Subject: [PATCH 04/25] Change the acceleration condition to a solely altitude based one --- Standby.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Standby.cpp b/Standby.cpp index f198917..ef4572d 100644 --- a/Standby.cpp +++ b/Standby.cpp @@ -29,24 +29,21 @@ namespace States // The plan to detect acceleration is to keep a queue of maybe 20 altitude readings, // derive it once for velocity, and derive it again for acceleration int altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]); + float sum = 0; // We'll check to see if there are enough altitudes stored to calculate acceleration: if (altitude_length >= 3) { for (int i = 0, i < 2, i++) { - Common::velocities.push_back(Common::altitudes[i + 1] - Common::altitudes[i]); - if (i > 0) - { - Common::acceleration = Common::velocities[i + 1] - Common::velocities[i]; - } + sum = sum + Common::altitudes[i]; } - Common::altitudes.pop_back(); + Common::altitudes.erase(0); } Common::altitudes.push_back(gps_data.altitude); // Now we'll actually switch the state - if (Common::acceleration >= 18 || Common::altitudes[altitude_length - 1] >= 10) + if ((sum / 3) >= 10) { States::EE_STATE = 2; EEPROM.put(Common::ST_ADDR, 2); From c369f1759c421a216c9f666c6ab628036559144d Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 10 May 2022 18:09:23 -0500 Subject: [PATCH 05/25] Update Flight.cpp --- Flight.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/Flight.cpp b/Flight.cpp index 2eaf066..ac83aac 100644 --- a/Flight.cpp +++ b/Flight.cpp @@ -3,9 +3,52 @@ #include "States.h" namespace States -{ +{ void Flight() { - // do flight + // Container Telemetry: BMP 308 @ 1Hz, GPS @ 1Hz + Common::GPS_Data gps_data; + Common::Sensor_Data sensor_data; + Hardware::read_gps(gps_data); + Hardware::read_sensors(sensor_data); + + // Build the packet with the data + String packet; + Common::build_packet(packet, "Flight", "N", mission_start_time, sensor_data); + + // Send the container packet down to the ground station + Hardware::mtx.lock(); + Hardware::ground_packets.enqueue(packet); + Hardware::payload_packets.enqueue("0"); + Hardware::mtx.unlock(); + + // Now we're going to monitor the altitude readings and detect when altitude begins to decrease + int altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]); + + // We'll check to see if there are enough altitudes stored to calculate velocity + // NOTE: time isn't taken into account for the measurement, so technically there are no units + // The following was my logic for getting the altitude vector down to a length of two. It looks ugly but I think it works. + + if (altitude_length > 2) + { + do + { + Common::altitudes.erase(0) + altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]) + } while (altitude_length > 1) + } + Common::altitudes.push_back(gps_data.altitude); + + if (altitude_length == 2) + { + Common::vertical_velocity = Common::altitudes[1] - Common::altitudes[0] Common::altitudes.pop_back(); + } + + // Now we'll actually switch the state + if (Common::vertical_velocity < 0) + { + States::EE_STATE = 3; + EEPROM.put(Common::ST_ADDR, 3); + } } } From 3ad0018191a9a436a5c21ec9c1ecc4d8e8c90d2a Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 10 May 2022 18:20:59 -0500 Subject: [PATCH 06/25] Add semicolon --- Flight.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Flight.cpp b/Flight.cpp index ac83aac..6cc3196 100644 --- a/Flight.cpp +++ b/Flight.cpp @@ -41,7 +41,8 @@ namespace States if (altitude_length == 2) { - Common::vertical_velocity = Common::altitudes[1] - Common::altitudes[0] Common::altitudes.pop_back(); + Common::vertical_velocity = Common::altitudes[1] - Common::altitudes[0]; + Common::altitudes.pop_back(); } // Now we'll actually switch the state From 09e1087aa707651bb42de819f0686e708f5b7bbe Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 10 May 2022 18:47:21 -0500 Subject: [PATCH 07/25] Update Rapid.cpp --- Rapid.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/Rapid.cpp b/Rapid.cpp index ecc7c3c..bbb8083 100644 --- a/Rapid.cpp +++ b/Rapid.cpp @@ -3,9 +3,52 @@ #include "States.h" namespace States -{ +{ void Rapid() { - // do rapid + float sum = 0; + // Release drogue chute + if (!Common::drogue_chute_deployed) + { + Hardware::deploy_chute(); + Common::drogue_chute_deployed = true; + } + + // Take telemetry + // Container Telemetry: BMP 308 @ 1Hz, GPS @ 1Hz + Common::GPS_Data gps_data; + Common::Sensor_Data sensor_data; + Hardware::read_gps(gps_data); + Hardware::read_sensors(sensor_data); + + // Build the packet with the data + String packet; + Common::build_packet(packet, "Rapid", "N", mission_start_time, sensor_data); + + // Send the container packet down to the ground station + Hardware::mtx.lock(); + Hardware::ground_packets.enqueue(packet); + Hardware::payload_packets.enqueue("0"); + Hardware::mtx.unlock(); + + // Record with camera + Hardware::update_camera() + + // If altitude drops below 400 meters, switch states + if (altitude_length >= 3) + { + for (int i = 0, i < 2, i++) + { + sum = sum + Common::altitudes[i]; + } + Common::altitudes.erase(0); + } + Common::altitudes.push_back(gps_data.altitude); + + if ((sum / 3) < 400) + { + States::EE_STATE = 4; + EEPROM.put(Common::ST_ADDR, 4); + } } } From 5da2e2d2b82fbb19e89c184ca035899cf827d834 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 10 May 2022 18:48:45 -0500 Subject: [PATCH 08/25] Add chute deployed bool --- Common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Common.h b/Common.h index 469bdf1..a8ec57f 100644 --- a/Common.h +++ b/Common.h @@ -44,7 +44,8 @@ namespace Common // List to track acceleration measurements: std::vector altitudes[3]; std::vector velocities[2]; - float acceleration = 0f; + float vertical_velocity = 0; + bool drogue_chute_deployed = false; struct GPS_Data { From 6463b397be89ff25741c5bd28e4df96b568f7102 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Thu, 12 May 2022 20:43:58 -0500 Subject: [PATCH 09/25] Update Rapid.cpp --- Rapid.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Rapid.cpp b/Rapid.cpp index bbb8083..3e70f9c 100644 --- a/Rapid.cpp +++ b/Rapid.cpp @@ -7,12 +7,6 @@ namespace States void Rapid() { float sum = 0; - // Release drogue chute - if (!Common::drogue_chute_deployed) - { - Hardware::deploy_chute(); - Common::drogue_chute_deployed = true; - } // Take telemetry // Container Telemetry: BMP 308 @ 1Hz, GPS @ 1Hz @@ -31,11 +25,14 @@ namespace States Hardware::payload_packets.enqueue("0"); Hardware::mtx.unlock(); + // Now we need to figure out how long our altitude queue is + int altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]); + // Record with camera - Hardware::update_camera() + Hardware::update_camera(); - // If altitude drops below 400 meters, switch states - if (altitude_length >= 3) + // If altitude drops below 400 meters, switch states + if (altitude_length >= 3) { for (int i = 0, i < 2, i++) { From 627e35abb3c98e949f464ebf8e561f61d506b116 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Thu, 12 May 2022 20:44:57 -0500 Subject: [PATCH 10/25] Create Slow.cpp --- Slow.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/Slow.cpp b/Slow.cpp index e3f84cc..f9b5cdb 100644 --- a/Slow.cpp +++ b/Slow.cpp @@ -3,9 +3,76 @@ #include "States.h" namespace States -{ +{ void Slow() { - // do slow + float sum = 0; + + // Release drogue chute + if (!Common::chute_deployed) + { + Hardware::deploy_chute(); + Common::chute_deployed = true; + } + + // Take telemetry + // Container Telemetry: BMP 308 @ 1Hz, GPS @ 1Hz + Common::GPS_Data gps_data; + Common::Sensor_Data sensor_data; + Hardware::read_gps(gps_data); + Hardware::read_sensors(sensor_data); + + // Build the packet with the data and check if payload is deployed + String packet; + if (Common::payload_deployed) + { + Common::build_packet(packet, "Slow", "Y", mission_start_time, sensor_data); + } + else + { + Common::build_packet(packet, "Slow", "N", mission_start_time, sensor_data); + } + + // Send the container packet down to the ground station + Hardware::mtx.lock(); + Hardware::ground_packets.enqueue(packet); + Hardware::payload_packets.enqueue("0"); + Hardware::mtx.unlock(); + + // Now we need to figure out how long our altitude queue is + int altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]); + + // Record with camera + Hardware::update_camera(); + + // If altitude drops below 400 meters, switch states + if (altitude_length >= 3) + { + for (int i = 0, i < 2, i++) + { + sum = sum + Common::altitudes[i]; + } + Common::altitudes.erase(0); + } + Common::altitudes.push_back(gps_data.altitude); + + if ((sum / 3) < 300 && !Common::payload_deployed) + { + // Deploy Payload here + Common::payload_deployed = false; + } + + if (Common::payload_deployed) + { + // Collect payload telemetry here + } + + // Finally, we check to see if the altitude stops changing + if (altitude_length == 3 && (Common::altitudes[2] - Common::altitudes[1]) >= 0) + { + States::EE_STATE = 5; + EEPROM.put(Common::ST_ADDR, 5); + } } } + From 0a8f203b6095a3a5e392974f3fbf778426ebbd0c Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Thu, 12 May 2022 20:46:34 -0500 Subject: [PATCH 11/25] Update Rapid.cpp --- Rapid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rapid.cpp b/Rapid.cpp index 3e70f9c..75918b2 100644 --- a/Rapid.cpp +++ b/Rapid.cpp @@ -29,7 +29,7 @@ namespace States int altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]); // Record with camera - Hardware::update_camera(); + Hardware::update_camera(true); // If altitude drops below 400 meters, switch states if (altitude_length >= 3) From 540e378f87c4a97db870a6cde19e7799881254c9 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Thu, 12 May 2022 20:46:52 -0500 Subject: [PATCH 12/25] Update Slow.cpp --- Slow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Slow.cpp b/Slow.cpp index f9b5cdb..203de3f 100644 --- a/Slow.cpp +++ b/Slow.cpp @@ -43,7 +43,7 @@ namespace States int altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]); // Record with camera - Hardware::update_camera(); + Hardware::update_camera(true); // If altitude drops below 400 meters, switch states if (altitude_length >= 3) From 04d9894c2afc037968a9597fefa3c7d2fc6e7aa6 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Thu, 12 May 2022 20:50:29 -0500 Subject: [PATCH 13/25] Update Landing.cpp --- Landing.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Landing.cpp b/Landing.cpp index c401f4f..7fa924f 100644 --- a/Landing.cpp +++ b/Landing.cpp @@ -3,9 +3,19 @@ #include "States.h" namespace States -{ +{ void Landing() { - // do landing + // Polling is stopped + // Poll_Payload.stop() + + // Container stops its telemetry + // Poll_Sensors.stop() + + // Sound Beacon + Hardware::buzzer_on(); + + // Container stops recording + Hardware::update_camera(false); } } From 4c57f3e89f2de7ac9c4b86236172728d931b3e17 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Thu, 12 May 2022 22:27:08 -0500 Subject: [PATCH 14/25] Change state to zero when turned off --- Landing.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Landing.cpp b/Landing.cpp index 7fa924f..4fc3c4a 100644 --- a/Landing.cpp +++ b/Landing.cpp @@ -8,6 +8,7 @@ namespace States { // Polling is stopped // Poll_Payload.stop() + EEPROM.put(Common::ST_ADDR, 0); // Container stops its telemetry // Poll_Sensors.stop() From e0e1bedf4cf3d191d5c678ab47108f303c279ec6 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 17 May 2022 15:27:31 -0500 Subject: [PATCH 15/25] Compile-Worthy common.h --- Common.h | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/Common.h b/Common.h index 6e12dca..03ece58 100644 --- a/Common.h +++ b/Common.h @@ -1,3 +1,4 @@ + #pragma once #ifndef __COMMON_H__ #define __COMMON_H__ @@ -6,11 +7,10 @@ #include #include #include -#include #define GPS_SERIAL Serial1 -#define GROUND_XBEE_SERIAL Serial4 -#define PAYLOAD_XBEE_SERIAL Serial5 +#define GROUND_XBEE_SERIAL Serial7 +#define PAYLOAD_XBEE_SERIAL Serial8 namespace Common { @@ -41,17 +41,11 @@ namespace Common static String lastCMD = "None"; - // List to track acceleration measurements: - std::vector altitudes[3]; - std::vector velocities[2]; - float vertical_velocity = 0; - bool drogue_chute_deployed = false; - struct GPS_Data { - uint8_t hours; - uint8_t minutes; - uint8_t seconds; + uint16_t hours; + uint16_t minutes; + uint16_t seconds; uint16_t milliseconds; float latitude; float longitude; @@ -73,9 +67,9 @@ namespace Common return milli; } - static void build_packet(String &packet, const String &state, const char tp_released, const GPS_Data &gps, const Sensor_Data &sensors) + static void build_packet(String& packet, const String& state, const String& tp_released, const GPS_Data &gps, const Sensor_Data &sensors) { - packet = TEAM_ID + ","; // 0 + packet = String(TEAM_ID) + ","; //0 packet += String(hour()) + ":" + String(minute()) + ":" + String(second()) + "." + String(millisecond()) + ","; packet += String(EE_PACKET_COUNT) + ","; if (SIM_ACTIVATE && SIM_ENABLE) @@ -83,16 +77,16 @@ namespace Common else packet += "F,"; packet += tp_released + ","; - packet += String(sensors.altitude) + ","; + packet += String(sensors.altitude) + ","; packet += String(sensors.temperature) + ","; packet += String(sensors.vbat) + ","; packet += String(gps.hours) + ":" + String(gps.minutes) + ":" + String(gps.seconds) + "." + String(gps.milliseconds) + ","; - packet += String(gps.latitude) + ","; - packet += String(gps.longitude) + ","; - packet += String(gps.altitude) + ","; + packet += String(gps.latitude) + ","; + packet += String(gps.longitude) + ","; + packet += String(gps.altitude) + ","; packet += String(gps.sats) + ","; packet += state + ","; - packet += lastCMD + "\n"; + packet += lastCMD; } } #endif From 8636986e5ee0d89e4095616e2b95ab7f303f6ec8 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 17 May 2022 15:28:10 -0500 Subject: [PATCH 16/25] Compile-worthy flight.cpp --- Flight.cpp | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/Flight.cpp b/Flight.cpp index 6cc3196..5f82931 100644 --- a/Flight.cpp +++ b/Flight.cpp @@ -1,6 +1,7 @@ #include "Common.h" #include "Hardware.h" #include "States.h" +#include namespace States { @@ -14,42 +15,35 @@ namespace States // Build the packet with the data String packet; - Common::build_packet(packet, "Flight", "N", mission_start_time, sensor_data); + Common::build_packet(packet, "Flight", "N", gps_data, sensor_data); // Send the container packet down to the ground station Hardware::mtx.lock(); Hardware::ground_packets.enqueue(packet); Hardware::payload_packets.enqueue("0"); Hardware::mtx.unlock(); - - // Now we're going to monitor the altitude readings and detect when altitude begins to decrease - int altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]); - - // We'll check to see if there are enough altitudes stored to calculate velocity - // NOTE: time isn't taken into account for the measurement, so technically there are no units - // The following was my logic for getting the altitude vector down to a length of two. It looks ugly but I think it works. - - if (altitude_length > 2) + + // If altitude drops we deploy the chute and change states + int item_count = Hardware::altitudes.itemCount(); + if (item_count == 3) { - do + float current_altitude = gps_data.altitude; + float previous_altitude = Hardware::altitudes.dequeue(); + Hardware::altitudes.enqueue(current_altitude); + float current_velocity = current_altitude - previous_altitude; + + // Now we'll actually switch the state + if (current_velocity < 0) { - Common::altitudes.erase(0) - altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]) - } while (altitude_length > 1) + States::EE_STATE = 3; + EEPROM.put(Common::ST_ADDR, 3); + } } - Common::altitudes.push_back(gps_data.altitude); - - if (altitude_length == 2) + else if (item_count < 3) { - Common::vertical_velocity = Common::altitudes[1] - Common::altitudes[0]; - Common::altitudes.pop_back(); + float current_altitude = gps_data.altitude; + Hardware::altitudes.enqueue(current_altitude); } - // Now we'll actually switch the state - if (Common::vertical_velocity < 0) - { - States::EE_STATE = 3; - EEPROM.put(Common::ST_ADDR, 3); - } } } From 9e20cf1fee3bae305b635ed0e2ed4bdc11078f77 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 17 May 2022 15:29:26 -0500 Subject: [PATCH 17/25] Compile-worthy hardware.cpp --- Hardware.cpp | 90 +++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 54 deletions(-) diff --git a/Hardware.cpp b/Hardware.cpp index 6f9236e..a4904dc 100644 --- a/Hardware.cpp +++ b/Hardware.cpp @@ -12,19 +12,7 @@ #include namespace Hardware -{ - bool SIM_ACTIVATE = false; - bool SIM_ENABLE = false; - int SIM_PRESSURE = 0; - float EE_BASE_ALTITUDE = 0; - uint16_t EE_PACKET_COUNT = 0; - int lastCheck = 4; - String lastCMD = "None"; - elapsedMillis cameraHold = 0; - bool cameraRecording = false; - bool firstCameraCall = true; - - +{ Adafruit_BMP3XX bmp; Adafruit_GPS GPS(&GPS_SERIAL); Servo para_servo; @@ -32,6 +20,11 @@ namespace Hardware ArduinoQueue payload_packets(20); ArduinoQueue ground_packets(20); Threads::Mutex mtx; + + // Add altitude queue + ArduinoQueue altitudes(3); + bool chute_deployed; + bool payload_deployed; void init() { @@ -40,8 +33,10 @@ namespace Hardware firstCameraCall = true; para_servo.attach(Common::PARA_SERVO_PIN); - Wire2.begin(); - bmp.begin_I2C(0x77, &Wire2); + Wire.setSCL(Common::BMP_SCL); + Wire.setSDA(Common::BMP_SDA); + Wire.begin(); + bmp.begin_I2C(); GPS.begin(9600); } @@ -113,30 +108,21 @@ namespace Hardware void read_gps(Common::GPS_Data &data) { - bool newData = false; - for (int i = 0; i < 175; i++) - { + // Loop until we have a full NMEA sentence and it parses successfully + do { GPS.read(); - if (GPS.newNMEAreceived()) - { - if (GPS.parse(GPS.lastNMEA())) - { - newData = true; - break; - } + while (!GPS.newNMEAreceived()) { + GPS.read(); } - } - - if (newData) - { - setTime(GPS.hour, GPS.minute, GPS.seconds, GPS.day, GPS.month, GPS.year); - lastCheck = GPS.milliseconds + millis(); - } + } while (!GPS.parse(GPS.lastNMEA())); + + setTime(GPS.hour, GPS.minute, GPS.seconds, GPS.day, GPS.month, GPS.year); data.hours = GPS.hour; data.minutes = GPS.minute; - data.seconds = GPS.seconds; + data.seconds = GPS.seconds + Common::LEAP_SECONDS; data.milliseconds = GPS.milliseconds; + Common::milli = GPS.milliseconds; data.latitude = GPS.latitude; data.longitude = GPS.longitude; data.altitude = GPS.altitude; @@ -165,10 +151,9 @@ namespace Hardware void read_sensors(Common::Sensor_Data &data) { - data.vbat = ((analogRead(Common::VOLTAGE_PIN) / 1023.0) * 4.2) + 0.35; - bmp.performReading(); + data.vbat = map(analogRead(Common::VOLTAGE_PIN), 0, 1023, 0, 5.5); data.altitude = bmp.readAltitude(Common::SEA_LEVEL); - data.temperature = bmp.temperature; + data.temperature = bmp.readTemperature(); } void payload_radio_loop() @@ -179,8 +164,8 @@ namespace Hardware while (!payload_packets.isEmpty()) { PAYLOAD_XBEE_SERIAL.println(payload_packets.dequeue()); - EE_PACKET_COUNT += 1; - EEPROM.put(Common::PC_ADDR, EE_PACKET_COUNT); + Common::EE_PACKET_COUNT++; + EEPROM.put(Common::PC_ADDR, Common::EE_PACKET_COUNT); } mtx.unlock(); @@ -188,15 +173,15 @@ namespace Hardware while (read_payload_radio(received)) { String header = String(Common::TEAM_ID + 5000) + ","; - header += String(hour()) + ":" + String(minute()) + ":" + String(second()) + "." + String(millisecond()) + ","; - header += String(EE_PACKET_COUNT) + ","; + header += String(hour()) + ":" + String(minute()) + ":" + String(second()) + "." + String(elapsedMillis()) + ","; + header += String(Common::EE_PACKET_COUNT) + ","; header += "T,"; mtx.lock(); ground_packets.enqueue(header + received); mtx.unlock(); } - threads.delay(250); + delay(10); } } @@ -208,8 +193,8 @@ namespace Hardware while (!ground_packets.isEmpty()) { GROUND_XBEE_SERIAL.println(ground_packets.dequeue()); - EE_PACKET_COUNT += 1; - EEPROM.put(Common::PC_ADDR, EE_PACKET_COUNT); + Common::EE_PACKET_COUNT++; + EEPROM.put(Common::PC_ADDR, Common::EE_PACKET_COUNT); } mtx.unlock(); @@ -223,7 +208,7 @@ namespace Hardware String cmd = data.substring(0, comma); String params = data.substring(data.indexOf(',')); - lastCMD = cmd; + Common::lastCMD = cmd; if (cmd.equals("CX")) { @@ -234,10 +219,7 @@ namespace Hardware } else if (params.equals("OFF")) { States::EE_STATE = 0; - //reset recovery params - //EEPROM.put(Common::BA_ADDR, 0.0f); - //EEPROM.put(Common::PC_ADDR, 0); - //EEPROM.put(Common::ST_ADDR, 0); + EEPROM.put(Common::ST_ADDR, 0); } } else if (cmd.equals("ST")) { @@ -246,22 +228,22 @@ namespace Hardware { if (params.equals("ENABLE")) { - SIM_ENABLE = true; + Common::SIM_ENABLE = true; } else if (params.equals("DISABLE")) { - SIM_ENABLE = false; - SIM_ACTIVATE = false; + Common::SIM_ENABLE = false; + Common::SIM_ACTIVATE = false; } else if (params.equals("ACTIVATE")) { - if (SIM_ENABLE) SIM_ACTIVATE = true; + if (Common::SIM_ENABLE) Common::SIM_ACTIVATE = true; } } else if (cmd.equals("SIMP")) { - SIM_PRESSURE = params.toInt(); + Common::SIM_PRESSURE = params.toInt(); } } } - threads.delay(250); + delay(10); } } } From 9f812552ea9dc47ca47681acadd7cb98aabc72fc Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 17 May 2022 15:30:04 -0500 Subject: [PATCH 18/25] Compile-worthy Hardware.h --- Hardware.h | 47 ++++++++--------------------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/Hardware.h b/Hardware.h index 22556bf..9e40687 100644 --- a/Hardware.h +++ b/Hardware.h @@ -12,14 +12,6 @@ namespace Hardware { - extern bool SIM_ACTIVATE; - extern bool SIM_ENABLE; - extern int SIM_PRESSURE; - extern float EE_BASE_ALTITUDE; - extern uint16_t EE_PACKET_COUNT; - extern int lastCheck; - extern String lastCMD; - extern Adafruit_BMP3XX bmp; extern Adafruit_GPS GPS; extern Servo para_servo; @@ -28,9 +20,14 @@ namespace Hardware extern ArduinoQueue ground_packets; extern Threads::Mutex mtx; - extern elapsedMillis cameraHold; - extern bool cameraRecording; - extern bool firstCameraCall; + // declare altitude and other state variables + extern ArduinoQueue altitudes; + extern bool chute_deployed; + extern bool payload_deployed; + + static elapsedMillis cameraHold; + static bool cameraRecording; + static bool firstCameraCall; void init(); @@ -54,33 +51,5 @@ namespace Hardware void payload_radio_loop(); void ground_radio_loop(); - - static int millisecond() - { - int elapse = millis() - lastCheck; - return abs(elapse - ((elapse / 1000) * 1000)); - } - - static void build_packet(String& packet, const String& state, const String& tp_released, const Common::GPS_Data &gps, const Common::Sensor_Data &sensors) - { - packet = String(Common::TEAM_ID) + ","; //0 - packet += String(hour()) + ":" + String(minute()) + ":" + String(second()) + "." + String(millisecond()) + ","; - packet += String(EE_PACKET_COUNT) + ","; - if (SIM_ACTIVATE && SIM_ENABLE) - packet += "S,"; - else - packet += "F,"; - packet += tp_released + ","; - packet += String(sensors.altitude) + ","; - packet += String(sensors.temperature) + ","; - packet += String(sensors.vbat) + ","; - packet += String(gps.hours) + ":" + String(gps.minutes) + ":" + String(gps.seconds) + "." + String(gps.milliseconds) + ","; - packet += String(gps.latitude) + ","; - packet += String(gps.longitude) + ","; - packet += String(gps.altitude) + ","; - packet += String(gps.sats) + ","; - packet += state + ","; - packet += lastCMD; - } } #endif From a8f8cd94b0a123578bc09b4e3f58caf8d0c14629 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 17 May 2022 15:30:37 -0500 Subject: [PATCH 19/25] Compile-worthy ContainerFSW.ino --- ContainerFSW.ino | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/ContainerFSW.ino b/ContainerFSW.ino index f9a3e5a..221c8a6 100644 --- a/ContainerFSW.ino +++ b/ContainerFSW.ino @@ -1,34 +1,34 @@ - #include "Common.h" +#include "Common.h" #include "Hardware.h" #include "States.h" -#include - #include void setup() { Hardware::init(); - Serial.begin(115200); GROUND_XBEE_SERIAL.begin(115200); //xbees must be preconfigured for this PAYLOAD_XBEE_SERIAL.begin(115200); //default baud is 9600 - - std::thread ground_thread(Hardware::ground_radio_loop); - std::thread payload_thread(Hardware::payload_radio_loop); + + std::thread ground(Hardware::ground_radio_loop); + std::thread payload(Hardware::payload_radio_loop); //load recovery params - EEPROM.get(Common::BA_ADDR, Hardware::EE_BASE_ALTITUDE); - EEPROM.get(Common::PC_ADDR, Hardware::EE_PACKET_COUNT); + EEPROM.get(Common::BA_ADDR, Common::EE_BASE_ALTITUDE); + EEPROM.get(Common::PC_ADDR, Common::EE_PACKET_COUNT); EEPROM.get(Common::ST_ADDR, States::EE_STATE); - ground_thread.detach(); - payload_thread.detach(); + ground.detach(); + + payload.detach(); } void loop() { - unsigned long start = millis(); - Hardware::mtx.lock(); switch (States::EE_STATE) { case 0: + //reset recovery params + EEPROM.put(Common::BA_ADDR, 0.0f); + EEPROM.put(Common::PC_ADDR, 0); + EEPROM.put(Common::ST_ADDR, 0); States::Initialization(); break; case 1: @@ -50,8 +50,4 @@ void loop() { States::Initialization(); break; } - Hardware::mtx.unlock(); - - if (Common::TELEMETRY_DELAY > (millis() - start)) - threads.delay(Common::TELEMETRY_DELAY - (millis() - start)); } From f63c08010cf6e2dea85f3682438109283118bf3d Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 17 May 2022 15:31:13 -0500 Subject: [PATCH 20/25] Compile-worthy Initialization.cpp --- Initialization.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Initialization.cpp b/Initialization.cpp index eea7902..516f9d3 100644 --- a/Initialization.cpp +++ b/Initialization.cpp @@ -1,26 +1,37 @@ #include "Common.h" #include "Hardware.h" #include "States.h" +#include namespace States { - uint16_t EE_STATE = 0; - void Initialization() { Common::GPS_Data gps_data; Common::Sensor_Data sensor_data; - Hardware::read_gps(gps_data); Hardware::read_sensors(sensor_data); - Hardware::start_recording(); - String packet; - Hardware::build_packet(packet, "INITIALIZATION", "N", gps_data, sensor_data); // build new packet - Serial.println(packet); + Common::build_packet(packet, "INITIALIZATION", 'N', gps_data, sensor_data); + Hardware::mtx.lock(); Hardware::ground_packets.enqueue(packet); - //Hardware::payload_packets.enqueue("0"); + Hardware::payload_packets.enqueue("0"); + Hardware::mtx.unlock(); + + int item_count = Hardware::altitudes.itemCount(); + if (item_count == 3) + { + float previous_altitude = Hardware::altitudes.dequeue(); + float current_altitude = gps_data.altitude; + Hardware::altitudes.enqueue(current_altitude); + } + + else if (item_count < 3) + { + float current_altitude = gps_data.altitude; + Hardware::altitudes.enqueue(current_altitude); + } } } From 9a867129fae423879d1dec786b6a23d7c929a499 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 17 May 2022 15:31:49 -0500 Subject: [PATCH 21/25] Compile-worthy Landing.cpp --- Landing.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Landing.cpp b/Landing.cpp index 4fc3c4a..af5c4c1 100644 --- a/Landing.cpp +++ b/Landing.cpp @@ -1,6 +1,7 @@ #include "Common.h" #include "Hardware.h" #include "States.h" +#include namespace States { @@ -8,7 +9,7 @@ namespace States { // Polling is stopped // Poll_Payload.stop() - EEPROM.put(Common::ST_ADDR, 0); + EEPROM.put(Common::ST_ADDR, 3); // Container stops its telemetry // Poll_Sensors.stop() From c2bbdb236adb790901f0a1d59d8906682fb5a809 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 17 May 2022 15:32:14 -0500 Subject: [PATCH 22/25] Compile-worthy Rapid.cpp --- Rapid.cpp | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/Rapid.cpp b/Rapid.cpp index 75918b2..91f5f23 100644 --- a/Rapid.cpp +++ b/Rapid.cpp @@ -1,6 +1,7 @@ #include "Common.h" #include "Hardware.h" #include "States.h" +#include namespace States { @@ -17,35 +18,36 @@ namespace States // Build the packet with the data String packet; - Common::build_packet(packet, "Rapid", "N", mission_start_time, sensor_data); + Common::build_packet(packet, "Rapid", "N", gps_data, sensor_data); // Send the container packet down to the ground station Hardware::mtx.lock(); Hardware::ground_packets.enqueue(packet); Hardware::payload_packets.enqueue("0"); Hardware::mtx.unlock(); - - // Now we need to figure out how long our altitude queue is - int altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]); - - // Record with camera - Hardware::update_camera(true); - - // If altitude drops below 400 meters, switch states - if (altitude_length >= 3) + + int item_count = Hardware::altitudes.itemCount(); + if (item_count == 3) { - for (int i = 0, i < 2, i++) + // If altitude drops below 400 meters, drop the payload + float previous_altitude = Hardware::altitudes.dequeue(); + float current_altitude = gps_data.altitude; + Hardware::altitudes.enqueue(current_altitude); + + // Record with camera + Hardware::update_camera(true); + + // If altitude drops below 400 meters, switch states + if (current_altitude <= 400) { - sum = sum + Common::altitudes[i]; + States::EE_STATE = 4; + EEPROM.put(Common::ST_ADDR, 4); } - Common::altitudes.erase(0); } - Common::altitudes.push_back(gps_data.altitude); - - if ((sum / 3) < 400) + else if (item_count < 3) { - States::EE_STATE = 4; - EEPROM.put(Common::ST_ADDR, 4); + float current_altitude = gps_data.altitude; + Hardware::altitudes.enqueue(current_altitude); } } } From 6ad111db7fd75d1e12ed8cf146272a0a23a537be Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 17 May 2022 15:32:45 -0500 Subject: [PATCH 23/25] Compile-worthy Slow.cpp --- Slow.cpp | 66 +++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/Slow.cpp b/Slow.cpp index 203de3f..4099bfc 100644 --- a/Slow.cpp +++ b/Slow.cpp @@ -1,18 +1,17 @@ #include "Common.h" #include "Hardware.h" #include "States.h" +#include namespace States { void Slow() { - float sum = 0; - // Release drogue chute - if (!Common::chute_deployed) + if (!Hardware::chute_deployed) { Hardware::deploy_chute(); - Common::chute_deployed = true; + Hardware::chute_deployed = true; } // Take telemetry @@ -24,13 +23,13 @@ namespace States // Build the packet with the data and check if payload is deployed String packet; - if (Common::payload_deployed) + if (Hardware::payload_deployed) { - Common::build_packet(packet, "Slow", "Y", mission_start_time, sensor_data); + Common::build_packet(packet, "Slow", "Y", gps_data, sensor_data); } else { - Common::build_packet(packet, "Slow", "N", mission_start_time, sensor_data); + Common::build_packet(packet, "Slow", "N", gps_data, sensor_data); } // Send the container packet down to the ground station @@ -39,40 +38,39 @@ namespace States Hardware::payload_packets.enqueue("0"); Hardware::mtx.unlock(); - // Now we need to figure out how long our altitude queue is - int altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]); - // Record with camera Hardware::update_camera(true); - - // If altitude drops below 400 meters, switch states - if (altitude_length >= 3) + + int item_count = Hardware::altitudes.itemCount(); + if (item_count == 3) { - for (int i = 0, i < 2, i++) + // If altitude drops below 400 meters, drop the payload + float previous_altitude = Hardware::altitudes.dequeue(); + float current_altitude = gps_data.altitude; + Hardware::altitudes.enqueue(current_altitude); + + if (current_altitude < 300 && !Hardware::payload_deployed) { - sum = sum + Common::altitudes[i]; + // Deploy Payload here + Hardware::payload_deployed = true; + } + + if (Hardware::payload_deployed) + { + // Collect payload telemetry here + } + + // Finally, we check to see if the altitude stops changing + if ((current_altitude - previous_altitude) >= 0) + { + States::EE_STATE = 5; + EEPROM.put(Common::ST_ADDR, 5); } - Common::altitudes.erase(0); - } - Common::altitudes.push_back(gps_data.altitude); - - if ((sum / 3) < 300 && !Common::payload_deployed) - { - // Deploy Payload here - Common::payload_deployed = false; - } - - if (Common::payload_deployed) - { - // Collect payload telemetry here } - - // Finally, we check to see if the altitude stops changing - if (altitude_length == 3 && (Common::altitudes[2] - Common::altitudes[1]) >= 0) + else if (item_count < 3) { - States::EE_STATE = 5; - EEPROM.put(Common::ST_ADDR, 5); + float current_altitude = gps_data.altitude; + Hardware::altitudes.enqueue(current_altitude); } } } - From 42a88d5b3579ef584690606437f7e0948f067b7b Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 17 May 2022 15:33:23 -0500 Subject: [PATCH 24/25] Compile-worthy Standby.cpp --- Standby.cpp | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/Standby.cpp b/Standby.cpp index ef4572d..dd5a83c 100644 --- a/Standby.cpp +++ b/Standby.cpp @@ -2,6 +2,7 @@ #include "Common.h" #include "Hardware.h" #include "States.h" +#include namespace States { @@ -17,7 +18,7 @@ namespace States // Build the packet with the data String packet; - Common::build_packet(packet, "Standby", "N", mission_start_time, sensor_data); + Common::build_packet(packet, "Standby", "N", gps_data, sensor_data); // Send the container packet down to the ground station Hardware::mtx.lock(); @@ -25,34 +26,27 @@ namespace States Hardware::payload_packets.enqueue("0"); Hardware::mtx.unlock(); - // Detect Acceleration - // The plan to detect acceleration is to keep a queue of maybe 20 altitude readings, - // derive it once for velocity, and derive it again for acceleration - int altitude_length = sizeof(Common::altitudes) / sizeof(Common::altitudes[0]); - float sum = 0; - - // We'll check to see if there are enough altitudes stored to calculate acceleration: - if (altitude_length >= 3) + // We make sure we always have a queue of the correct length, and if we do, we proceed to check for the next state + int item_count = Hardware::altitudes.itemCount(); + if (item_count == 3) { - for (int i = 0, i < 2, i++) + float previous_altitude = Hardware::altitudes.dequeue(); + float current_altitude = gps_data.altitude; + Hardware::altitudes.enqueue(current_altitude); + + // Now we'll actually switch the state + if (current_altitude >= 10) { - sum = sum + Common::altitudes[i]; - } - Common::altitudes.erase(0); - } - Common::altitudes.push_back(gps_data.altitude); - - // Now we'll actually switch the state - if ((sum / 3) >= 10) - { - States::EE_STATE = 2; - EEPROM.put(Common::ST_ADDR, 2); + States::EE_STATE = 2; + EEPROM.put(Common::ST_ADDR, 2); + } } - // I'm guessing that this part is to account for delay of sending??? - if (Common::TELEMETRY_DELAY > (millis() - start)) + // If the queue isn't the correct length, then it is lower than the correct length, so we will skip the dequeue + else if (item_count < 3) { - delay(Common::TELEMETRY_DELAY - (millis() - start)); + float current_altitude = gps_data.altitude; + Hardware::altitudes.enqueue(current_altitude); } } } From df2b6ecc86ba74a208d4661242d244a1763584d2 Mon Sep 17 00:00:00 2001 From: WildWesley <86993555+WildWesley@users.noreply.github.com> Date: Tue, 17 May 2022 15:33:53 -0500 Subject: [PATCH 25/25] Compile-worthy States.h --- States.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/States.h b/States.h index 8fb79a4..1aa987b 100644 --- a/States.h +++ b/States.h @@ -4,7 +4,7 @@ namespace States { - extern uint16_t EE_STATE; + static uint16_t EE_STATE = 0; void Initialization(); void Standby();