X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fkernel%2Fao_telemetry.c;h=e0f4d8c22aea4f6399cf03c4b46ad3915b63b335;hb=c1708f3fa4ff412da8817ba0fa58d05fe7ef44f5;hp=d567f9c2a3604c0a3a073432b869bd7204d8f92e;hpb=c49bd3cb0c31a51fae79ddc92237cc309be9a242;p=fw%2Faltos diff --git a/src/kernel/ao_telemetry.c b/src/kernel/ao_telemetry.c index d567f9c2..e0f4d8c2 100644 --- a/src/kernel/ao_telemetry.c +++ b/src/kernel/ao_telemetry.c @@ -58,7 +58,7 @@ static AO_TICK_TYPE ao_aprs_time; #define AO_SEND_MEGA 1 #endif -#if defined (TELEMETRUM_V_2_0) || defined (TELEMETRUM_V_3_0) +#if defined (TELEMETRUM_V_2_0) || defined (TELEMETRUM_V_3_0) || defined (TELEMETRUM_V_4_0) #define AO_SEND_METRUM 1 #endif @@ -490,7 +490,10 @@ ao_set_aprs_time(void) } else { delta = second - ao_gps_data.second; } - ao_aprs_time = ao_gps_tick + AO_SEC_TO_TICKS(delta); + if (delta < (interval >> 1)) + delta += interval; + + ao_aprs_time = ao_gps_utc_tick + AO_SEC_TO_TICKS(delta); } else { ao_aprs_time += AO_SEC_TO_TICKS(ao_config.aprs_interval); } @@ -636,45 +639,47 @@ ao_telemetry_set_interval(uint16_t interval) interval = min_interval[ao_config.radio_rate]; #endif ao_telemetry_interval = interval; + if (interval) { #if AO_SEND_MEGA - if (interval > 1) - ao_telemetry_mega_data_max = 1; - else - ao_telemetry_mega_data_max = 2; - if (ao_telemetry_mega_data_max > cur) - cur++; - ao_telemetry_mega_data_cur = cur; + if (interval > 1) + ao_telemetry_mega_data_max = 1; + else + ao_telemetry_mega_data_max = 2; + if (ao_telemetry_mega_data_max > cur) + cur++; + ao_telemetry_mega_data_cur = cur; #endif #if AO_SEND_METRUM - ao_telemetry_metrum_data_max = (int16_t) (AO_SEC_TO_TICKS(1) / interval); - if (ao_telemetry_metrum_data_max > cur) - cur++; - ao_telemetry_metrum_data_cur = cur; + ao_telemetry_metrum_data_max = (int16_t) (AO_SEC_TO_TICKS(1) / interval); + if (ao_telemetry_metrum_data_max > cur) + cur++; + ao_telemetry_metrum_data_cur = cur; #endif #if HAS_COMPANION - if (!ao_companion_setup.update_period) - ao_companion_setup.update_period = AO_SEC_TO_TICKS(1); - ao_telemetry_companion_max = (int16_t) (ao_companion_setup.update_period / interval); - if (ao_telemetry_companion_max > cur) - cur++; - ao_telemetry_companion_cur = cur; + if (!ao_companion_setup.update_period) + ao_companion_setup.update_period = AO_SEC_TO_TICKS(1); + ao_telemetry_companion_max = (int16_t) (ao_companion_setup.update_period / interval); + if (ao_telemetry_companion_max > cur) + cur++; + ao_telemetry_companion_cur = cur; #endif #if HAS_GPS - ao_telemetry_gps_max = (int16_t) (AO_SEC_TO_TICKS(1) / interval); - if (ao_telemetry_gps_max > cur) - cur++; - ao_telemetry_loc_cur = cur; - if (ao_telemetry_gps_max > cur) - cur++; - ao_telemetry_sat_cur = cur; -#endif - - ao_telemetry_config_max = (int16_t) (AO_SEC_TO_TICKS(5) / interval); - if (ao_telemetry_config_max > cur) - cur++; - ao_telemetry_config_cur = cur; + ao_telemetry_gps_max = (int16_t) (AO_SEC_TO_TICKS(1) / interval); + if (ao_telemetry_gps_max > cur) + cur++; + ao_telemetry_loc_cur = cur; + if (ao_telemetry_gps_max > cur) + cur++; + ao_telemetry_sat_cur = cur; +#endif + + ao_telemetry_config_max = (int16_t) (AO_SEC_TO_TICKS(5) / interval); + if (ao_telemetry_config_max > cur) + cur++; + ao_telemetry_config_cur = cur; + } #ifndef SIMPLIFY ao_telemetry_time =