X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fao_telemetry.c;h=15ba4302b3fb28b1eb707c68b707d2ba5ba37758;hb=41e5be32819d305c8268e6f992be91411ea13435;hp=dcd0ff625926a376fd62ab2f96f6d5e9200e8d28;hpb=359baab005c274a0841268c615c23b3ffef813cf;p=fw%2Faltos diff --git a/src/ao_telemetry.c b/src/ao_telemetry.c index dcd0ff62..15ba4302 100644 --- a/src/ao_telemetry.c +++ b/src/ao_telemetry.c @@ -25,6 +25,10 @@ static __pdata int8_t ao_telemetry_config_cur; static __pdata int8_t ao_telemetry_loc_cur; static __pdata int8_t ao_telemetry_sat_cur; #endif +#if HAS_COMPANION +static __pdata int8_t ao_telemetry_companion_max; +static __pdata int8_t ao_telemetry_companion_cur; +#endif static __pdata uint8_t ao_rdf = 0; static __pdata uint16_t ao_rdf_time; @@ -35,7 +39,7 @@ static __pdata uint16_t ao_rdf_time; #define AO_TELEMETRY_SENSOR AO_TELEMETRY_SENSOR_TELEMETRUM #endif -#if defined(TELEMINI_V_0_1) +#if defined(TELEMINI_V_1_0) #define AO_TELEMETRY_SENSOR AO_TELEMETRY_SENSOR_TELEMINI #endif @@ -77,9 +81,15 @@ ao_send_sensor(void) telemetry.sensor.height = ao_height; telemetry.sensor.ground_pres = ao_ground_pres; +#if HAS_ACCEL telemetry.sensor.ground_accel = ao_ground_accel; telemetry.sensor.accel_plus_g = ao_config.accel_plus_g; telemetry.sensor.accel_minus_g = ao_config.accel_minus_g; +#else + telemetry.sensor.ground_accel = 0; + telemetry.sensor.accel_plus_g = 0; + telemetry.sensor.accel_minus_g = 0; +#endif ao_radio_send(&telemetry, sizeof (telemetry)); } @@ -143,6 +153,26 @@ ao_send_satellite(void) } #endif +#if HAS_COMPANION +static void +ao_send_companion(void) +{ + if (--ao_telemetry_companion_cur <= 0) { + telemetry.generic.type = AO_TELEMETRY_COMPANION; + telemetry.companion.board_id = ao_companion_setup.board_id; + telemetry.companion.update_period = ao_companion_setup.update_period; + telemetry.companion.channels = ao_companion_setup.channels; + ao_mutex_get(&ao_companion_mutex); + memcpy(&telemetry.companion.companion_data, + ao_companion_data, + ao_companion_setup.channels * 2); + ao_mutex_put(&ao_companion_mutex); + ao_radio_send(&telemetry, sizeof (telemetry)); + ao_telemetry_companion_cur = ao_telemetry_companion_max; + } +} +#endif + void ao_telemetry(void) { @@ -162,6 +192,10 @@ ao_telemetry(void) ao_send_sensor(); +#if HAS_COMPANION + if (ao_companion_running) + ao_send_companion(); +#endif ao_send_configuration(); #if HAS_GPS ao_send_location(); @@ -187,14 +221,29 @@ void ao_telemetry_set_interval(uint16_t interval) { ao_telemetry_interval = interval; + +#if HAS_COMPANION + if (!ao_companion_setup.update_period) + ao_companion_setup.update_period = AO_SEC_TO_TICKS(1); + ao_telemetry_companion_max = ao_companion_setup.update_period / interval; + ao_telemetry_companion_cur = 1; +#endif + ao_telemetry_config_max = AO_SEC_TO_TICKS(1) / interval; - ao_telemetry_config_cur = 0; +#if HAS_COMPANION + ao_telemetry_config_cur = ao_telemetry_companion_cur; + if (ao_telemetry_config_max > ao_telemetry_config_cur) + ao_telemetry_config_cur++; +#else + ao_telemetry_config_cur = 1; +#endif + #if HAS_GPS - ao_telemetry_loc_cur = 0; - if (ao_telemetry_config_max - 1 > ao_telemetry_loc_cur) + ao_telemetry_loc_cur = ao_telemetry_config_cur; + if (ao_telemetry_config_max > ao_telemetry_loc_cur) ao_telemetry_loc_cur++; ao_telemetry_sat_cur = ao_telemetry_loc_cur; - if (ao_telemetry_config_max - 1 > ao_telemetry_sat_cur) + if (ao_telemetry_config_max > ao_telemetry_sat_cur) ao_telemetry_sat_cur++; #endif ao_wakeup(&telemetry);