mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
Made FrSky SPI telemetry and external telemetry values configurable.
This commit is contained in:
parent
83a9af8571
commit
d88bec63a8
5 changed files with 30 additions and 9 deletions
|
@ -948,6 +948,7 @@ const clivalue_t valueTable[] = {
|
|||
{ "frsky_spi_offset", VAR_INT8 | MASTER_VALUE, .config.minmax = { -127, 127 }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, bindOffset) },
|
||||
{ "frsky_spi_bind_hop_data", VAR_UINT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = 50, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, bindHopData) },
|
||||
{ "frsky_x_rx_num", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 255 }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, rxNum) },
|
||||
{ "frsky_spi_use_external_adc", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_RX_FRSKY_SPI_CONFIG, offsetof(rxFrSkySpiConfig_t, useExternalAdc) },
|
||||
#endif
|
||||
{ "led_inversion", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, ((1 << STATUS_LED_NUMBER) - 1) }, PG_STATUS_LED_CONFIG, offsetof(statusLedConfig_t, inversion) },
|
||||
#ifdef USE_DASHBOARD
|
||||
|
|
|
@ -27,6 +27,7 @@ typedef struct rxFrSkySpiConfig_s {
|
|||
int8_t bindOffset;
|
||||
uint8_t bindHopData[50];
|
||||
uint8_t rxNum;
|
||||
bool useExternalAdc;
|
||||
} rxFrSkySpiConfig_t;
|
||||
|
||||
PG_DECLARE(rxFrSkySpiConfig_t, rxFrSkySpiConfig);
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "common/maths.h"
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "drivers/adc.h"
|
||||
#include "drivers/rx/rx_cc2500.h"
|
||||
#include "drivers/io.h"
|
||||
|
@ -102,14 +104,19 @@ static void frSkyDTelemetryWriteByte(const char data)
|
|||
|
||||
static void buildTelemetryFrame(uint8_t *packet)
|
||||
{
|
||||
const uint16_t adcExternal1Sample = adcGetChannel(ADC_EXTERNAL1);
|
||||
const uint16_t adcRssiSample = adcGetChannel(ADC_RSSI);
|
||||
uint8_t a1Value;
|
||||
if (rxFrSkySpiConfig()->useExternalAdc) {
|
||||
a1Value = (adcGetChannel(ADC_EXTERNAL1) & 0xff0) >> 4;
|
||||
} else {
|
||||
a1Value = (2 * getBatteryVoltage()) & 0xff;
|
||||
}
|
||||
const uint8_t a2Value = (adcGetChannel(ADC_RSSI)) >> 4;
|
||||
telemetryId = packet[4];
|
||||
frame[0] = 0x11; // length
|
||||
frame[1] = rxFrSkySpiConfig()->bindTxId[0];
|
||||
frame[2] = rxFrSkySpiConfig()->bindTxId[1];
|
||||
frame[3] = (uint8_t)((adcExternal1Sample & 0xff0) >> 4); // A1
|
||||
frame[4] = (uint8_t)((adcRssiSample & 0xff0) >> 4); // A2
|
||||
frame[3] = a1Value;
|
||||
frame[4] = a2Value;
|
||||
frame[5] = (uint8_t)rssiDbm;
|
||||
uint8_t bytesUsed = 0;
|
||||
#if defined(USE_TELEMETRY_FRSKY_HUB)
|
||||
|
@ -292,7 +299,9 @@ rx_spi_received_e frSkyDHandlePacket(uint8_t * const packet, uint8_t * const pro
|
|||
void frSkyDInit(void)
|
||||
{
|
||||
#if defined(USE_RX_FRSKY_SPI_TELEMETRY) && defined(USE_TELEMETRY_FRSKY_HUB)
|
||||
telemetryEnabled = initFrSkyHubTelemetryExternal(frSkyDTelemetryWriteByte);
|
||||
if (feature(FEATURE_TELEMETRY)) {
|
||||
telemetryEnabled = initFrSkyHubTelemetryExternal(frSkyDTelemetryWriteByte);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -89,6 +89,7 @@ PG_RESET_TEMPLATE(rxFrSkySpiConfig_t, rxFrSkySpiConfig,
|
|||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
.rxNum = 0,
|
||||
.useExternalAdc = false,
|
||||
);
|
||||
|
||||
#if defined(USE_RX_FRSKY_SPI_TELEMETRY)
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "common/maths.h"
|
||||
#include "common/utils.h"
|
||||
|
||||
#include "config/feature.h"
|
||||
|
||||
#include "drivers/adc.h"
|
||||
#include "drivers/rx/rx_cc2500.h"
|
||||
#include "drivers/io.h"
|
||||
|
@ -181,10 +183,15 @@ static void buildTelemetryFrame(uint8_t *packet)
|
|||
frame[3] = packet[3];
|
||||
|
||||
if (evenRun) {
|
||||
frame[4]=(uint8_t)rssiDbm|0x80;
|
||||
frame[4] = (uint8_t)rssiDbm | 0x80;
|
||||
} else {
|
||||
const uint16_t adcExternal1Sample = adcGetChannel(ADC_EXTERNAL1);
|
||||
frame[4] = (uint8_t)((adcExternal1Sample & 0xfe0) >> 5); // A1;
|
||||
uint8_t a1Value;
|
||||
if (rxFrSkySpiConfig()->useExternalAdc) {
|
||||
a1Value = (uint8_t)((adcGetChannel(ADC_EXTERNAL1) & 0xfe0) >> 5);
|
||||
} else {
|
||||
a1Value = getBatteryVoltage() & 0x7f;
|
||||
}
|
||||
frame[4] = a1Value;
|
||||
}
|
||||
evenRun = !evenRun;
|
||||
|
||||
|
@ -526,7 +533,9 @@ rx_spi_received_e frSkyXHandlePacket(uint8_t * const packet, uint8_t * const pro
|
|||
void frSkyXInit(void)
|
||||
{
|
||||
#if defined(USE_TELEMETRY_SMARTPORT)
|
||||
telemetryEnabled = initSmartPortTelemetryExternal(frSkyXTelemetryWriteFrame);
|
||||
if (feature(FEATURE_TELEMETRY)) {
|
||||
telemetryEnabled = initSmartPortTelemetryExternal(frSkyXTelemetryWriteFrame);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue