Merge with latest 2.3

This commit is contained in:
Bertrand Songis
2020-05-30 11:57:03 +02:00
240 changed files with 16050 additions and 14404 deletions
+5
View File
@@ -201,6 +201,11 @@ void processCrossfireTelemetryData(uint8_t data)
auxSerialPutc(data);
}
#endif
#if defined(AUX2_SERIAL)
if (g_eeGeneral.aux2SerialMode == UART_MODE_TELEMETRY_MIRROR) {
aux2SerialPutc(data);
}
#endif
if (telemetryRxBufferCount == 0 && data != RADIO_ADDRESS) {
TRACE("[XF] address 0x%02X error", data);
+5
View File
@@ -32,6 +32,11 @@ void processFrskyTelemetryData(uint8_t data)
auxSerialPutc(data);
}
#endif
#if defined(AUX2_SERIAL)
if (g_eeGeneral.aux2SerialMode == UART_MODE_TELEMETRY_MIRROR) {
aux2SerialPutc(data);
}
#endif
if (pushFrskyTelemetryData(data)) {
if (IS_FRSKY_SPORT_PROTOCOL()) {
+8 -3
View File
@@ -33,7 +33,12 @@ enum FrSkyDataState {
STATE_DATA_XOR,
};
#define FRSKY_SPORT_BAUDRATE 57600
#define FRSKY_SPORT_BAUDRATE 57600
#if defined(RADIO_TX16S)
#define FRSKY_TELEM_MIRROR_BAUDRATE 115200
#else
#define FRSKY_TELEM_MIRROR_BAUDRATE FRSKY_SPORT_BAUDRATE
#endif
#define FRSKY_D_BAUDRATE 9600
@@ -293,10 +298,10 @@ inline bool isRasValueValid()
{
return true;
}
#elif defined(PCBX9DP) || defined(PCBX9E)
#elif defined(PCBTARANIS)
inline bool isRasValueValid()
{
return telemetryData.xjtVersion != 0x0000 && telemetryData.xjtVersion != 0x00FF;
return telemetryData.xjtVersion != 0x00FF;
}
#elif defined(PCBHORUS)
inline bool isRasValueValid()
+2 -2
View File
@@ -125,8 +125,8 @@ void processRegisterFrame(uint8_t module, const uint8_t * frame)
case 0x01:
if (reusableBuffer.moduleSetup.pxx2.registerStep == REGISTER_RX_NAME_SELECTED) {
// RX_NAME + PASSWORD follow, we check they are good
if (cmpStrWithZchar((char *)&frame[4], reusableBuffer.moduleSetup.pxx2.registerRxName, PXX2_LEN_RX_NAME) &&
cmpStrWithZchar((char *)&frame[12], g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID)) {
if (memcmp(&frame[4], reusableBuffer.moduleSetup.pxx2.registerRxName, PXX2_LEN_RX_NAME) == 0 &&
memcmp(&frame[12], g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID) == 0) {
reusableBuffer.moduleSetup.pxx2.registerStep = REGISTER_OK;
moduleState[module].mode = MODULE_MODE_NORMAL;
#if !defined(COLORLCD)
+7 -4
View File
@@ -130,7 +130,7 @@ uint16_t rboxState;
void sportProcessTelemetryPacket(uint16_t id, uint8_t subId, uint8_t instance, uint32_t data, TelemetryUnit unit=UNIT_RAW)
{
const FrSkySportSensor * sensor = getFrSkySportSensor(id, subId);
uint8_t precision = 0;
uint8_t precision = 255;
if (sensor) {
if (unit == UNIT_RAW)
unit = sensor->unit;
@@ -177,17 +177,20 @@ void sportProcessTelemetryPacketWithoutCrc(uint8_t origin, const uint8_t * packe
if (primId == DATA_FRAME) {
uint8_t originMask;
uint8_t moduleIndex;
if (origin == TELEMETRY_ENDPOINT_SPORT) {
#if defined(SIMU) && defined(INTERNAL_MODULE_PXX2)
// When running simu on ACCESS radio, we set the origin as internal module
moduleIndex = 0;
origin = 0;
originMask = 0x01;
#else
moduleIndex = isSportLineUsedByInternalModule() ? 0 : 1;
originMask = 0x04;
#endif
}
else {
uint8_t moduleIndex = (origin >> 2);
moduleIndex = (origin >> 2);
originMask = 0x01 << moduleIndex;
}
uint8_t instance = physicalId + (origin << 5);
@@ -226,12 +229,12 @@ void sportProcessTelemetryPacketWithoutCrc(uint8_t origin, const uint8_t * packe
else if (dataId == XJT_VERSION_ID) {
telemetryData.xjtVersion = HUB_DATA_U16(packet);
if (!isRasValueValid()) {
telemetryData.setSwr(origin >> 2, 0);
telemetryData.setSwr(moduleIndex, 0);
}
}
else if (dataId == RAS_ID) {
if (isRasValueValid()) {
telemetryData.setSwr(origin >> 2, SPORT_DATA_U8(packet));
telemetryData.setSwr(moduleIndex, SPORT_DATA_U8(packet));
}
}
+7 -1
View File
@@ -322,6 +322,12 @@ static void processMultiTelemetryPaket(const uint8_t * packet, uint8_t module)
auxSerialPutc(packet[c]);
}
#endif
#if defined(AUX2_SERIAL)
if (g_eeGeneral.aux2SerialMode == UART_MODE_TELEMETRY_MIRROR) {
for (uint8_t c=0; c < len; c++)
aux2SerialPutc(packet[c]);
}
#endif
// Switch type
switch (type) {
@@ -555,7 +561,7 @@ void MultiModuleStatus::getStatusString(char * statusText) const
return;
}
if (major <= 1 && minor <= 3 && revision <= 0 && patch <= 47 && SLOW_BLINK_ON_PHASE) {
if (major <= 1 && minor <= 3 && revision <= 0 && patch < 91 && SLOW_BLINK_ON_PHASE) {
strcpy(statusText, STR_MODULE_UPGRADE);
}
else {
+116 -1
View File
@@ -24,6 +24,7 @@
/*
* Documentation of the Spektrum protocol is available under
* https://www.spektrumrc.com/ProdInfo/Files/SPM_Telemetry_Developers_Specs.pdf
* https://github.com/SpektrumRC/SpektrumDocumentation/blob/master/Telemetry/spektrumTelemetrySensors.h
*
* Multi module adds two byte header of 0xAA [RSSI of telemetry packet] [16 byte message]
*/
@@ -49,7 +50,18 @@
#define I2C_TEXTGEN 0x0c
#define I2C_GPS 0x17
#define I2C_GPS2 0x17
#define I2C_ESC 0x20
#define I2C_CELLS 0x3a
// SMART_BAT is using fake I2C adresses compared to official Spektrum address because of subtype used only for this I2C address
#define I2C_SMART_BAT_BASE_ADDRESS 0x42
#define I2C_SMART_BAT_REALTIME 0x42
#define I2C_SMART_BAT_CELLS_1_6 0x43
#define I2C_SMART_BAT_CELLS_7_12 0x44
#define I2C_SMART_BAT_CELLS_13_18 0x45
#define I2C_SMART_BAT_ID 0x4A
#define I2C_SMART_BAT_LIMITS 0x4B
#define I2C_QOS 0x7f
enum SpektrumDataType : uint8_t {
@@ -62,6 +74,8 @@ enum SpektrumDataType : uint8_t {
uint8bcd,
uint16bcd,
uint32bcd,
uint16le,
uint32le,
custom
};
@@ -151,7 +165,16 @@ const SpektrumSensor spektrumSensors[] = {
{0x1b, 2, int16, STR_SENSOR_PITCH, UNIT_DEGREE, 1},
{0x1b, 4, int16, STR_SENSOR_YAW, UNIT_DEGREE, 1},
// {0x20, esc}, does not exist in the wild?
// {0x20, esc}, Smart ESC telemetry
{I2C_ESC, 0, uint16, ZSTR_ESC_RPM, UNIT_RPMS, 0},
{I2C_ESC, 2, uint16, ZSTR_ESC_VIN, UNIT_VOLTS, 2},
{I2C_ESC, 4, uint16, ZSTR_ESC_TFET, UNIT_CELSIUS, 1},
{I2C_ESC, 6, uint16, ZSTR_ESC_CUR, UNIT_MAH, 1},
{I2C_ESC, 8, uint16, ZSTR_ESC_TBEC, UNIT_CELSIUS, 1},
{I2C_ESC, 10, uint8, ZSTR_ESC_BCUR, UNIT_AMPS, 1},
{I2C_ESC, 11, uint8, ZSTR_ESC_VBEC, UNIT_VOLTS, 2},
{I2C_ESC, 12, uint8, ZSTR_ESC_THR, UNIT_PERCENT, 1},
{I2C_ESC, 13, uint8, ZSTR_ESC_POUT, UNIT_PERCENT, 1},
// Dual Cell monitor (0x34)
{0x34, 0, int16, STR_SENSOR_BATT1_CURRENT, UNIT_AMPS, 1},
@@ -178,6 +201,53 @@ const SpektrumSensor spektrumSensors[] = {
{0x40, 0, int16, STR_SENSOR_ALT, UNIT_METERS, 1},
{0x40, 2, int16, STR_SENSOR_VSPD, UNIT_METERS_PER_SECOND, 1},
// Smartbat
//{I2C_SMART_BAT_REALTIME, 1, int8, ZSTR_SMART_BAT_BTMP, UNIT_CELSIUS, 0}, // disabled because sensor is a duplicate of cells sensors ones
{I2C_SMART_BAT_REALTIME, 2, uint32le, ZSTR_SMART_BAT_BCUR, UNIT_MAH, 0},
{I2C_SMART_BAT_REALTIME, 6, uint16le, ZSTR_SMART_BAT_BCAP, UNIT_MAH, 0},
{I2C_SMART_BAT_REALTIME, 8, uint16le, ZSTR_SMART_BAT_MIN_CEL, UNIT_VOLTS, 2},
{I2C_SMART_BAT_REALTIME, 10, uint16le, ZSTR_SMART_BAT_MAX_CEL, UNIT_VOLTS, 2},
//{I2C_SMART_BAT_REALTIME, 12, uint16le, "RFU[2]", UNIT_RAW, 0}, // disabled to save sensors slots
{I2C_SMART_BAT_CELLS_1_6, 1, int8, ZSTR_SMART_BAT_BTMP, UNIT_CELSIUS, 0},
{I2C_SMART_BAT_CELLS_1_6, 2, uint16le, ZSTR_CL01, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_1_6, 4, uint16le, ZSTR_CL02, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_1_6, 6, uint16le, ZSTR_CL03, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_1_6, 8, uint16le, ZSTR_CL04, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_1_6, 10, uint16le, ZSTR_CL05, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_1_6, 12, uint16le, ZSTR_CL06, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_7_12, 1, int8, ZSTR_SMART_BAT_BTMP, UNIT_CELSIUS, 0},
{I2C_SMART_BAT_CELLS_7_12, 2, uint16le, ZSTR_CL07, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_7_12, 4, uint16le, ZSTR_CL08, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_7_12, 6, uint16le, ZSTR_CL09, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_7_12, 8, uint16le, ZSTR_CL10, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_7_12, 10, uint16le, ZSTR_CL11, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_7_12, 12, uint16le, ZSTR_CL12, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_13_18, 1, int8, ZSTR_SMART_BAT_BTMP, UNIT_CELSIUS, 0},
{I2C_SMART_BAT_CELLS_13_18, 2, uint16le, ZSTR_CL13, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_13_18, 4, uint16le, ZSTR_CL14, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_13_18, 6, uint16le, ZSTR_CL15, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_13_18, 8, uint16le, ZSTR_CL16, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_13_18, 10, uint16le, ZSTR_CL17, UNIT_VOLTS, 2},
{I2C_SMART_BAT_CELLS_13_18, 12, uint16le, ZSTR_CL18, UNIT_VOLTS, 2},
//{I2C_SMART_BAT_ID, 1, uint8, "chemistery", UNIT_RAW, 0}, // disabled to save sensors slots
//{I2C_SMART_BAT_ID, 2, uint8, "number of cells", UNIT_RAW, 0}, // disabled to save sensors slots
//{I2C_SMART_BAT_ID, 3, uint8, "manufacturer code", UNIT_RAW, 0}, // disabled to save sensors slots
{I2C_SMART_BAT_ID, 4, uint16le, ZSTR_SMART_BAT_CYCLES, UNIT_RAW, 0},
//{I2C_SMART_BAT_ID, 6, uint8, "uniqueID[8]", UNIT_RAW, 0}, // disabled to save sensors slots
//{I2C_SMART_BAT_LIMITS, 1, uint8, "rfu", UNIT_RAW, 0}, // disabled to save sensors slots
{I2C_SMART_BAT_LIMITS, 2, uint16le, ZSTR_SMART_BAT_CAPACITY,UNIT_MAH, 0},
//{I2C_SMART_BAT_LIMITS, 4, uint16le, "dischargeCurrentRating", UNIT_RAW, 0}, // disabled to save sensors slots
//{I2C_SMART_BAT_LIMITS, 6, uint16le, "overDischarge_mV", UNIT_RAW, 0}, // disabled to save sensors slots
//{I2C_SMART_BAT_LIMITS, 8, uint16le, "zeroCapacity_mV", UNIT_RAW, 0}, // disabled to save sensors slots
//{I2C_SMART_BAT_LIMITS, 10, uint16le, "fullyCharged_mV", UNIT_RAW, 0}, // disabled to save sensors slots
//{I2C_SMART_BAT_LIMITS, 12, uint8, "minWorkingTemp", UNIT_RAW, 0}, // disabled to save sensors slots
//{I2C_SMART_BAT_LIMITS, 13, uint8, "maxWorkingTemp", UNIT_RAW, 0}, // disabled to save sensors slots
// 0x50-0x56 custom 3rd party sensors
//{0x50, 0, int16, STR_SENSOR_}
@@ -248,6 +318,10 @@ static int32_t spektrumGetValue(const uint8_t *packet, int startByte, SpektrumDa
return bcdToInt8(*(uint8_t *)data);
case uint32bcd:
return bcdToInt32(*(uint32_t *)data);
case uint16le:
return (int16_t) ((uint16_t) (data[0] + (data[1] << 8)));
case uint32le:
return ((uint32_t) (data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24)));
default:
return -1;
}
@@ -274,6 +348,12 @@ void processSpektrumPacket(const uint8_t *packet)
setTelemetryValue(PROTOCOL_TELEMETRY_SPEKTRUM, (I2C_PSEUDO_TX << 8) + 0, 0, 0, packet[1], UNIT_RAW, 0);
// highest bit indicates that TM1100 is in use, ignore it
uint8_t i2cAddress = (packet[2] & 0x7f);
//SmartBat Hack
if (i2cAddress == I2C_SMART_BAT_BASE_ADDRESS) {
i2cAddress = i2cAddress + (packet[4] >> 4); // use type to create virtual I2CAddresses
}
uint8_t instance = packet[3];
if (i2cAddress == I2C_TEXTGEN) {
@@ -303,6 +383,41 @@ void processSpektrumPacket(const uint8_t *packet)
if (!isSpektrumValidValue(value, sensor->dataType))
continue;
// mV to VOLT PREC2 for Smart Batteries
if ((i2cAddress >= I2C_SMART_BAT_REALTIME && i2cAddress <= I2C_SMART_BAT_LIMITS) && sensor->unit == UNIT_VOLTS) {
if (value == -1) {
continue; // discard unavailable sensors
}
else {
value = value / 10;
}
}
// RPM, 10RPM (0-655340 RPM)
if (i2cAddress == I2C_ESC && sensor->unit == UNIT_RPMS) {
value = value / 10;
}
// Current, 10mA (0-655.34A)
if (i2cAddress == I2C_ESC && sensor->startByte == 6) {
value = value / 10;
}
// BEC Current, 100mA (0-25.4A)
if (i2cAddress == I2C_ESC && sensor->startByte == 10) {
value = value / 10;
}
// Throttle 0.5% (0-127%)
if (i2cAddress == I2C_ESC && sensor->startByte == 12) {
value = value / 2;
}
// Power 0.5% (0-127%)
if (i2cAddress == I2C_ESC && sensor->startByte == 13) {
value = value / 2;
}
if (i2cAddress == I2C_CELLS && sensor->unit == UNIT_VOLTS) {
// Map to FrSky style cell values
int cellIndex = (sensor->startByte / 2) << 16;
+5 -1
View File
@@ -110,8 +110,11 @@ void frskyDSetDefault(int index, uint16_t id);
extern uint8_t telemetryProtocol;
#if defined (MULTIMODULE)
#define IS_D16_MULTI(module) ((g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FRSKY) && (g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16 || g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16_8CH || g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16_LBT || g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16_LBT_8CH))
#define IS_D16_MULTI(module) (((g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FRSKY) && (g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16 || g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16_8CH || g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16_LBT || g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16_LBT_8CH || g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16_CLONED)) \
|| (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FRSKYX2))
#define IS_HOTT_MULTI(module) (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_HOTT)
#define IS_RX_MULTI(module) ((g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_AFHDS2A_RX) || (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FRSKYX_RX) \
|| (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_BAYANG_RX) || (g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_DSM_RX))
#if defined(HARDWARE_INTERNAL_MODULE)
#define IS_FRSKY_SPORT_PROTOCOL() (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT || (telemetryProtocol == PROTOCOL_TELEMETRY_MULTIMODULE && (IS_D16_MULTI(INTERNAL_MODULE)||IS_D16_MULTI(EXTERNAL_MODULE))))
#else
@@ -121,6 +124,7 @@ extern uint8_t telemetryProtocol;
#define IS_D16_MULTI(module) false
#define IS_HOTT_MULTI(module) false
#define IS_FRSKY_SPORT_PROTOCOL() (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT)
#define IS_RX_MULTI(module) false
#endif
#define IS_SPEKTRUM_PROTOCOL() (telemetryProtocol == PROTOCOL_TELEMETRY_SPEKTRUM)
@@ -82,6 +82,10 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t val, uint32
{
int32_t newVal = val;
if(prec == 255) {
prec = sensor.prec;
}
if (unit == UNIT_CELLS) {
uint32_t data = uint32_t(newVal);
uint8_t cellsCount = (data >> 24);