diff --git a/src/main/config/config.c b/src/main/config/config.c index 1871a778b9..3c3a5f3de8 100755 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -270,6 +270,7 @@ void resetTelemetryConfig(telemetryConfig_t *telemetryConfig) telemetryConfig->frsky_vfas_precision = 0; telemetryConfig->frsky_vfas_cell_voltage = 0; telemetryConfig->hottAlarmSoundInterval = 5; + telemetryConfig->pidValuesAsTelemetry = 0; } #endif diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index 8e65658e4d..010fa34d2d 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -747,6 +747,7 @@ const clivalue_t valueTable[] = { { "frsky_vfas_precision", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.frsky_vfas_precision, .config.minmax = { FRSKY_VFAS_PRECISION_LOW, FRSKY_VFAS_PRECISION_HIGH } }, { "frsky_vfas_cell_voltage", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.telemetryConfig.frsky_vfas_cell_voltage, .config.lookup = { TABLE_OFF_ON } }, { "hott_alarm_sound_interval", VAR_UINT8 | MASTER_VALUE, &masterConfig.telemetryConfig.hottAlarmSoundInterval, .config.minmax = { 0, 120 } }, + { "pid_values_as_telemetry", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, &masterConfig.telemetryConfig.pidValuesAsTelemetry, .config.lookup = {TABLE_OFF_ON } }, #endif { "battery_capacity", VAR_UINT16 | MASTER_VALUE, &masterConfig.batteryConfig.batteryCapacity, .config.minmax = { 0, 20000 } }, diff --git a/src/main/telemetry/smartport.c b/src/main/telemetry/smartport.c index 4396b0c0a6..fcf26b010f 100644 --- a/src/main/telemetry/smartport.c +++ b/src/main/telemetry/smartport.c @@ -61,6 +61,9 @@ #include "fc/runtime_config.h" #include "config/config.h" +#include "config/config_profile.h" +extern profile_t *currentProfile; +extern controlRateConfig_t *currentControlRateProfile; enum { @@ -314,7 +317,9 @@ void handleSmartPortTelemetry(void) smartPortIdCnt++; int32_t tmpi; + uint32_t tmp2; static uint8_t t1Cnt = 0; + static uint8_t t2Cnt = 0; switch(id) { #ifdef GPS @@ -464,6 +469,38 @@ void handleSmartPortTelemetry(void) smartPortSendPackage(id, 0); smartPortHasRequest = 0; } + + else if (telemetryConfig->pidValuesAsTelemetry){ + switch (t2Cnt) { + case 0: + tmp2 = currentProfile->pidProfile.P8[ROLL]; + tmp2 += (currentProfile->pidProfile.P8[PITCH]<<8); + tmp2 += (currentProfile->pidProfile.P8[YAW]<<16); + break; + case 1: + tmp2 = currentProfile->pidProfile.I8[ROLL]; + tmp2 += (currentProfile->pidProfile.I8[PITCH]<<8); + tmp2 += (currentProfile->pidProfile.I8[YAW]<<16); + break; + case 2: + tmp2 = currentProfile->pidProfile.D8[ROLL]; + tmp2 += (currentProfile->pidProfile.D8[PITCH]<<8); + tmp2 += (currentProfile->pidProfile.D8[YAW]<<16); + break; + case 3: + tmp2 = currentControlRateProfile->rates[FD_ROLL]; + tmp2 += (currentControlRateProfile->rates[FD_PITCH]<<8); + tmp2 += (currentControlRateProfile->rates[FD_YAW]<<16); + break; + } + tmp2 += t2Cnt<<24; + t2Cnt++; + if (t2Cnt == 4) { + t2Cnt = 0; + } + smartPortSendPackage(id, tmp2); + smartPortHasRequest = 0; + } break; #ifdef GPS case FSSP_DATAID_GPS_ALT : diff --git a/src/main/telemetry/telemetry.h b/src/main/telemetry/telemetry.h index b61aa68bd4..1d45ed5b9e 100644 --- a/src/main/telemetry/telemetry.h +++ b/src/main/telemetry/telemetry.h @@ -44,6 +44,7 @@ typedef struct telemetryConfig_s { uint8_t frsky_vfas_precision; uint8_t frsky_vfas_cell_voltage; uint8_t hottAlarmSoundInterval; + uint8_t pidValuesAsTelemetry; } telemetryConfig_t; void telemetryInit(void);