From 13d312acb4c13716dcbeb37155317a3c371ebc03 Mon Sep 17 00:00:00 2001 From: Mathis et Yohan Date: Wed, 24 Nov 2021 17:45:07 +0100 Subject: [PATCH] fix reboot options --- .../R2Home_OBC_V1.01/R2Home_OBC_V1.01.ino | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/RLS_V1.0/R2Home_SOFTWARE_V1.01/R2Home_OBC_V1.01/R2Home_OBC_V1.01.ino b/RLS_V1.0/R2Home_SOFTWARE_V1.01/R2Home_OBC_V1.01/R2Home_OBC_V1.01.ino index b9328ea..79de053 100644 --- a/RLS_V1.0/R2Home_SOFTWARE_V1.01/R2Home_OBC_V1.01/R2Home_OBC_V1.01.ino +++ b/RLS_V1.0/R2Home_SOFTWARE_V1.01/R2Home_OBC_V1.01/R2Home_OBC_V1.01.ino @@ -12,6 +12,7 @@ // ----------------------------------- SETUP PANEL ----------------------------------- // #define i_want_to_fly false +#define no_init false #define autopilot_mode 1 #define drop true #define record_home false @@ -19,10 +20,12 @@ #define vup 1.5 #define vdown 2 +#define time_out 300 + #define gps_port Serial7 -#define bcritical 3.7 -#define blow 3.8 +#define bcritical 3.4 +#define blow 3.5 #define no_batt 4.0 #define servo_man_min 1100 @@ -459,6 +462,11 @@ void datacmpt() { if (abs(prev_gps-gps.altitude.meters())<1 and (gps.altitude.meters() != 0)) { gps_count = (gps_count + 1); } else { gps_count = 0; } + + if (gps_count >= 10) { gps_stab = true; } + else if(millis()<(time_out*1000)) { gps_stab = false; } + else { gps_stab = true; } + if (vspeed_count >= 10) { baro_stab = true; } else { baro_stab = false; } @@ -789,9 +797,9 @@ void flight_state() { void flight_init() { - if (reboot_state == 0) { + if (reboot_state !=1) { - if ((gps.satellites.value() >= 6) and (gps_ok == true) and (gps_stab == true) and (millis()>5000)) { + if (((gps.satellites.value() >= 6) and (gps_ok == true) and (gps_stab == true) and (millis()>5000)) or (no_init == true)) { EasyBuzzer.beep(3000,100,50,10,500,1); lat_B = gps.location.lat(); @@ -855,7 +863,7 @@ void flight_init() { sprintf(namebuff, "%s.txt", sdnamebuff); reboot_state = 0; - EEPROM.write(0, 0); + EEPROM.put(0, 0); } } @@ -875,7 +883,7 @@ void ready_steady() { if (vspeed>vup) { flight_mode = 2; EasyBuzzer.beep(1000,100,50,2,500,1); strip.setBrightness(75); } if (vspeed