1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

Merge pull request #1081 from KiteAnton/pid_values_smartport

Added PID values over smartport telemetry
This commit is contained in:
borisbstyle 2016-08-31 22:21:36 +02:00 committed by GitHub
commit a303509920
4 changed files with 40 additions and 0 deletions

View file

@ -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

View file

@ -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 } },

View file

@ -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 :

View file

@ -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);