Massive clean thanks to Schwabe : unifdef -m -DCPUARM -UCPUM64 -UCPUM2560 -UPCBSTD -UPCBMEGA2560 -UPCBGRUVIN9X -UPCB9X $(find . -name "*.cpp" -or -name "*.h")
This commit is contained in:
@@ -20,10 +20,6 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
#if !defined(CPUARM)
|
||||
uint8_t frskyTxBuffer[FRSKY_TX_PACKET_SIZE];
|
||||
uint8_t frskyTxBufferCount = 0;
|
||||
#endif
|
||||
|
||||
#if defined(TELEMETREZ)
|
||||
#define PRIVATE 0x1B
|
||||
@@ -152,23 +148,3 @@ NOINLINE void processFrskyTelemetryData(uint8_t data)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(FRSKY_HUB) && !defined(CPUARM)
|
||||
void frskyUpdateCells(void)
|
||||
{
|
||||
// Voltage => Cell number + Cell voltage
|
||||
uint8_t battnumber = ((telemetryData.hub.volts & 0x00F0) >> 4);
|
||||
if (battnumber < 12) {
|
||||
if (telemetryData.hub.cellsCount < battnumber+1) {
|
||||
telemetryData.hub.cellsCount = battnumber+1;
|
||||
}
|
||||
uint8_t cellVolts = (uint8_t)(((((telemetryData.hub.volts & 0xFF00) >> 8) + ((telemetryData.hub.volts & 0x000F) << 8))) / 10);
|
||||
telemetryData.hub.cellVolts[battnumber] = cellVolts;
|
||||
if (!telemetryData.hub.minCellVolts || cellVolts<telemetryData.hub.minCellVolts || battnumber==telemetryData.hub.minCellIdx) {
|
||||
telemetryData.hub.minCellIdx = battnumber;
|
||||
telemetryData.hub.minCellVolts = cellVolts;
|
||||
if (!telemetryData.hub.minCell || telemetryData.hub.minCellVolts<telemetryData.hub.minCell)
|
||||
telemetryData.hub.minCell = telemetryData.hub.minCellVolts;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -194,116 +194,6 @@ enum FrSkyDataState {
|
||||
#define DATA_ID_SP2UH 0x45 // 5
|
||||
#define DATA_ID_SP2UR 0xC6 // 6
|
||||
|
||||
#if !defined(CPUARM)
|
||||
#if defined(FRSKY_HUB)
|
||||
PACK(struct FrskyTelemetryData {
|
||||
int16_t baroAltitudeOffset; // spare reused
|
||||
int16_t gpsAltitude_bp; // 0x01 before punct
|
||||
int16_t temperature1; // 0x02 -20 .. 250 deg. celcius
|
||||
uint16_t rpm; // 0x03 0..60,000 revs. per minute
|
||||
uint16_t fuelLevel; // 0x04 0, 25, 50, 75, 100 percent
|
||||
int16_t temperature2; // 0x05 -20 .. 250 deg. celcius
|
||||
uint16_t volts; // 0x06 1/500V increments (0..4.2V)
|
||||
uint32_t distFromEarthAxis; // 2 spares reused
|
||||
int16_t gpsAltitude_ap; // 0x01+8 after punct
|
||||
uint8_t cellVolts[12]; // 6 spares reused
|
||||
int16_t baroAltitude_bp; // 0x10 0..9,999 meters
|
||||
uint16_t gpsSpeed_bp; // 0x11 before punct
|
||||
uint16_t gpsLongitude_bp; // 0x12 before punct
|
||||
uint16_t gpsLatitude_bp; // 0x13 before punct
|
||||
uint16_t gpsCourse_bp; // 0x14 before punct (0..359.99 deg. -- seemingly 2-decimal precision)
|
||||
uint8_t day; // 0x15
|
||||
uint8_t month; // 0x15
|
||||
uint16_t year; // 0x16
|
||||
uint8_t hour; // 0x17
|
||||
uint8_t min; // 0x17
|
||||
uint16_t sec; // 0x18
|
||||
uint16_t gpsSpeed_ap; // 0x11+8
|
||||
uint16_t gpsLongitude_ap; // 0x12+8
|
||||
uint16_t gpsLatitude_ap; // 0x13+8
|
||||
uint16_t gpsCourse_ap; // 0x14+8
|
||||
uint32_t pilotLatitude; // 2 spares reused
|
||||
uint32_t pilotLongitude; // 2 spares reused
|
||||
uint16_t baroAltitude_ap; // 0x21 after punct
|
||||
uint16_t gpsLongitudeEW; // 0x1A+8 East/West
|
||||
uint16_t gpsLatitudeNS; // 0x1B+8 North/South
|
||||
int16_t accelX; // 0x24 1/256th gram (-8g ~ +8g)
|
||||
int16_t accelY; // 0x25 1/256th gram (-8g ~ +8g)
|
||||
int16_t accelZ; // 0x26 1/256th gram (-8g ~ +8g)
|
||||
uint8_t gpsDistNeeded:1; // 1bits out of 16bits spare reused
|
||||
int8_t gpsFix:2; // 2bits out of 16bits spare reused: -1=never fixed, 0=not fixed now, 1=fixed
|
||||
uint8_t openXsensor:1; // 1bits out of 16bits spare reused: we receive data from the openXsensor
|
||||
uint8_t cellsCount:4; // 4bits out of 16bits spare reused
|
||||
uint8_t minCellVolts; // 8bits out of 16bits spare reused
|
||||
uint16_t current; // 0x28 Current
|
||||
int16_t spare[5];
|
||||
int32_t varioAltitude_cm;
|
||||
int16_t varioSpeed; // 0x30 Vertical speed in cm/s
|
||||
|
||||
uint16_t gpsDistance;
|
||||
int16_t gpsAltitudeOffset;
|
||||
uint8_t varioAltitudeQueuePointer; // circular-buffer pointer
|
||||
uint8_t minCellIdx;
|
||||
int16_t cellsSum;
|
||||
uint16_t currentConsumption; // 0x35 openXsensor only! Otherwise calculated by the Tx from current
|
||||
uint16_t currentPrescale;
|
||||
uint16_t power; // 0x37 openXsensor only! Otherwise calculated by the Tx from current and voltage
|
||||
int16_t airSpeed;
|
||||
|
||||
uint16_t vfas; // 0x39 Added to FrSky protocol for home made sensors with a better precision
|
||||
uint16_t volts_bp; // 0x3A
|
||||
uint16_t volts_ap; // 0x3B
|
||||
// end of FrSky Hub data
|
||||
|
||||
/* next fields must keep this order! */
|
||||
int16_t minAltitude;
|
||||
int16_t maxAltitude;
|
||||
uint16_t maxRpm;
|
||||
int16_t maxTemperature1;
|
||||
int16_t maxTemperature2;
|
||||
uint16_t maxGpsSpeed;
|
||||
uint16_t maxGpsDistance;
|
||||
uint16_t maxAirSpeed;
|
||||
int16_t minCell;
|
||||
int16_t minCells;
|
||||
int16_t minVfas;
|
||||
uint16_t maxCurrent;
|
||||
uint16_t maxPower;
|
||||
/* end */
|
||||
|
||||
int16_t dTE;
|
||||
});
|
||||
#elif defined(WS_HOW_HIGH)
|
||||
PACK(struct FrskyTelemetryData {
|
||||
int16_t baroAltitude_bp; // 0..9,999 meters
|
||||
int16_t baroAltitudeOffset;
|
||||
int16_t minAltitude;
|
||||
int16_t maxAltitude;
|
||||
uint16_t currentConsumption;
|
||||
uint16_t currentPrescale;
|
||||
uint16_t power;
|
||||
uint16_t maxPower;
|
||||
#if defined(VARIO)
|
||||
int16_t varioSpeed; // Vertical speed in cm/s
|
||||
#endif
|
||||
});
|
||||
#elif defined(VARIO)
|
||||
PACK(struct FrskyTelemetryData {
|
||||
int16_t varioSpeed; // Vertical speed in cm/s
|
||||
uint16_t currentConsumption;
|
||||
uint16_t currentPrescale;
|
||||
uint16_t power;
|
||||
uint16_t maxPower;
|
||||
});
|
||||
#else
|
||||
PACK(struct FrskyTelemetryData {
|
||||
uint16_t currentConsumption;
|
||||
uint16_t currentPrescale;
|
||||
uint16_t power;
|
||||
uint16_t maxPower;
|
||||
});
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(NO_RAS)
|
||||
#define IS_RAS_VALUE_VALID() (false)
|
||||
@@ -327,7 +217,6 @@ enum AlarmLevel {
|
||||
#define ALARM_GREATER(channel, alarm) ((g_model.frsky.channels[channel].alarms_greater >> alarm) & 1)
|
||||
#define ALARM_LEVEL(channel, alarm) ((g_model.frsky.channels[channel].alarms_level >> (2*alarm)) & 3)
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define TELEMETRY_STREAMING() (telemetryData.rssi.value > 0)
|
||||
#define TELEMETRY_RSSI() (telemetryData.rssi.value)
|
||||
#define TELEMETRY_RSSI_MIN() (telemetryData.rssi.min)
|
||||
@@ -366,50 +255,6 @@ enum AlarmLevel {
|
||||
#define TELEMETRY_ASPEED_FORMAT "%d.%d,"
|
||||
#define TELEMETRY_ASPEED_ARGS telemetryData.hub.airSpeed / 10, telemetryData.hub.airSpeed % 10,
|
||||
#define TELEMETRY_OPENXSENSOR() (0)
|
||||
#else
|
||||
#define TELEMETRY_STREAMING() (telemetryStreaming > 0)
|
||||
#define TELEMETRY_RSSI() (telemetryData.rssi[0].value)
|
||||
#define TELEMETRY_RSSI_MIN() (telemetryData.rssi[0].min)
|
||||
|
||||
#define TELEMETRY_CELL_VOLTAGE_MUTLIPLIER 2
|
||||
|
||||
#define TELEMETRY_BARO_ALT_AVAILABLE() (telemetryData.hub.baroAltitudeOffset)
|
||||
#define TELEMETRY_BARO_ALT_UNIT (IS_IMPERIAL_ENABLE() ? LENGTH_UNIT_IMP : LENGTH_UNIT_METR)
|
||||
|
||||
#define TELEMETRY_RELATIVE_BARO_ALT_BP telemetryData.hub.baroAltitude_bp
|
||||
#define TELEMETRY_RELATIVE_BARO_ALT_AP telemetryData.hub.baroAltitude_ap
|
||||
#define TELEMETRY_RELATIVE_GPS_ALT_BP telemetryData.hub.gpsAltitude_bp
|
||||
#define TELEMETRY_GPS_SPEED_BP telemetryData.hub.gpsSpeed_bp
|
||||
#define TELEMETRY_GPS_SPEED_AP telemetryData.hub.gpsSpeed_ap
|
||||
|
||||
#define TELEMETRY_BARO_ALT_PREPARE()
|
||||
#define TELEMETRY_BARO_ALT_FORMAT "%d,"
|
||||
#define TELEMETRY_BARO_ALT_ARGS telemetryData.hub.baroAltitude_bp,
|
||||
#define TELEMETRY_GPS_ALT_FORMAT "%d,"
|
||||
#define TELEMETRY_GPS_ALT_ARGS telemetryData.hub.gpsAltitude_bp,
|
||||
#define TELEMETRY_SPEED_UNIT (IS_IMPERIAL_ENABLE() ? SPEED_UNIT_IMP : SPEED_UNIT_METR)
|
||||
#define TELEMETRY_GPS_SPEED_FORMAT "%d,"
|
||||
#define TELEMETRY_GPS_SPEED_ARGS telemetryData.hub.gpsSpeed_bp,
|
||||
|
||||
#define TELEMETRY_CELLS_ARGS telemetryData.hub.cellsSum / 10, telemetryData.hub.cellsSum % 10, telemetryData.hub.cellVolts[0]*2/100, telemetryData.hub.cellVolts[0]*2%100, telemetryData.hub.cellVolts[1]*2/100, telemetryData.hub.cellVolts[1]*2%100, telemetryData.hub.cellVolts[2]*2/100, telemetryData.hub.cellVolts[2]*2%100, telemetryData.hub.cellVolts[3]*2/100, telemetryData.hub.cellVolts[3]*2%100, telemetryData.hub.cellVolts[4]*2/100, telemetryData.hub.cellVolts[4]*2%100, telemetryData.hub.cellVolts[5]*2/100, telemetryData.hub.cellVolts[5]*2%100,
|
||||
#define TELEMETRY_CELLS_FORMAT "%d.%d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,"
|
||||
#define TELEMETRY_CELLS_LABEL "Cell volts,Cell 1,Cell 2,Cell 3,Cell 4,Cell 5,Cell 6,"
|
||||
|
||||
#define TELEMETRY_CURRENT_FORMAT "%d.%02d,"
|
||||
#define TELEMETRY_CURRENT_ARGS telemetryData.hub.current / 100, telemetryData.hub.current % 100,
|
||||
#define TELEMETRY_VFAS_FORMAT "%d.%d,"
|
||||
#define TELEMETRY_VFAS_ARGS telemetryData.hub.vfas / 10, telemetryData.hub.vfas % 10,
|
||||
#define TELEMETRY_VSPEED_FORMAT "%c%d.%02d,"
|
||||
#define TELEMETRY_VSPEED_ARGS telemetryData.hub.varioSpeed < 0 ? '-' : ' ', telemetryData.hub.varioSpeed / 100, telemetryData.hub.varioSpeed % 100,
|
||||
#define TELEMETRY_ASPEED_FORMAT "%d.%d,"
|
||||
#define TELEMETRY_ASPEED_ARGS telemetryData.hub.airSpeed / 10, telemetryData.hub.airSpeed % 10,
|
||||
|
||||
#if defined(FRSKY_HUB)
|
||||
#define TELEMETRY_OPENXSENSOR() (telemetryData.hub.openXsensor)
|
||||
#else
|
||||
#define TELEMETRY_OPENXSENSOR() (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define TELEMETRY_CELL_VOLTAGE(k) (telemetryData.hub.cellVolts[k] * TELEMETRY_CELL_VOLTAGE_MUTLIPLIER)
|
||||
#define TELEMETRY_MIN_CELL_VOLTAGE (telemetryData.hub.minCellVolts * TELEMETRY_CELL_VOLTAGE_MUTLIPLIER)
|
||||
@@ -418,20 +263,7 @@ enum AlarmLevel {
|
||||
#define BYTESTUFF 0x7d
|
||||
#define STUFF_MASK 0x20
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define frskySendAlarms()
|
||||
#else
|
||||
#define SEND_RSSI_ALARMS 6
|
||||
#define SEND_MODEL_ALARMS 4
|
||||
extern uint8_t frskyAlarmsSendState;
|
||||
#define FRSKY_TX_PACKET_SIZE 12
|
||||
extern uint8_t frskyTxBuffer[FRSKY_TX_PACKET_SIZE];
|
||||
extern uint8_t frskyTxBufferCount;
|
||||
inline void frskySendAlarms(void)
|
||||
{
|
||||
frskyAlarmsSendState = SEND_RSSI_ALARMS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FRSKY_HUB)
|
||||
typedef enum {
|
||||
@@ -454,12 +286,8 @@ void sportProcessTelemetryPacket(const uint8_t * packet);
|
||||
void telemetryWakeup();
|
||||
void telemetryReset();
|
||||
|
||||
#if defined(CPUARM)
|
||||
extern uint8_t telemetryProtocol;
|
||||
void telemetryInit(uint8_t protocol);
|
||||
#else
|
||||
void telemetryInit(void);
|
||||
#endif
|
||||
|
||||
void telemetryInterrupt10ms();
|
||||
|
||||
@@ -476,41 +304,25 @@ enum TelemetryProtocol
|
||||
enum TelemAnas {
|
||||
TELEM_ANA_A1,
|
||||
TELEM_ANA_A2,
|
||||
#if defined(CPUARM)
|
||||
TELEM_ANA_A3,
|
||||
TELEM_ANA_A4,
|
||||
#endif
|
||||
TELEM_ANA_COUNT
|
||||
};
|
||||
|
||||
#if defined(CPUARM)
|
||||
struct TelemetryData {
|
||||
TelemetryValueWithMin swr; // TODO Min not needed
|
||||
TelemetryValueWithMin rssi; // TODO Min not needed
|
||||
uint16_t xjtVersion;
|
||||
bool varioHighPrecision;
|
||||
};
|
||||
#else
|
||||
struct TelemetryData {
|
||||
TelemetryValueWithMinMax analog[TELEM_ANA_COUNT];
|
||||
TelemetryValueWithMin rssi[2];
|
||||
FrskyTelemetryData hub;
|
||||
};
|
||||
#endif
|
||||
|
||||
extern TelemetryData telemetryData;
|
||||
|
||||
#if defined(CPUARM)
|
||||
typedef uint16_t frskyCellVoltage_t;
|
||||
#elif defined(FRSKY_HUB)
|
||||
typedef uint8_t frskyCellVoltage_t;
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM) || defined(FRSKY_HUB)
|
||||
void frskySetCellsCount(uint8_t cellscount);
|
||||
void frskySetCellVoltage(uint8_t battnumber, frskyCellVoltage_t cellVolts);
|
||||
void frskyUpdateCells();
|
||||
#endif
|
||||
|
||||
void processFrskyTelemetryData(uint8_t data);
|
||||
|
||||
|
||||
@@ -114,12 +114,10 @@ void parseTelemHubByte(uint8_t byte)
|
||||
break;
|
||||
|
||||
case offsetof(FrskyTelemetryData, current):
|
||||
#if defined(FAS_OFFSET) || !defined(CPUM64)
|
||||
if ((int16_t)telemetryData.hub.current > 0 && ((int16_t)telemetryData.hub.current + g_model.frsky.fasOffset) > 0)
|
||||
telemetryData.hub.current += g_model.frsky.fasOffset;
|
||||
else
|
||||
telemetryData.hub.current = 0;
|
||||
#endif
|
||||
if (telemetryData.hub.current > telemetryData.hub.maxCurrent)
|
||||
telemetryData.hub.maxCurrent = telemetryData.hub.current;
|
||||
break;
|
||||
|
||||
@@ -140,4 +140,4 @@ enum MultiBindStatus : uint8_t {
|
||||
|
||||
extern uint8_t multiBindStatus;
|
||||
|
||||
#endif //OPENTX_MULTI_H
|
||||
#endif //OPENTX_MULTI_H
|
||||
|
||||
@@ -30,31 +30,16 @@ uint8_t wshhStreaming = 0;
|
||||
|
||||
uint8_t link_counter = 0;
|
||||
|
||||
#if defined(CPUARM)
|
||||
uint8_t telemetryState = TELEMETRY_INIT;
|
||||
#endif
|
||||
|
||||
TelemetryData telemetryData;
|
||||
|
||||
#if defined(CPUARM)
|
||||
uint8_t telemetryProtocol = 255;
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X) && defined(REVX)
|
||||
uint8_t serialInversion = 0;
|
||||
#endif
|
||||
|
||||
#if !defined(CPUARM)
|
||||
uint16_t getChannelRatio(source_t channel)
|
||||
{
|
||||
return (uint16_t)g_model.frsky.channels[channel].ratio << g_model.frsky.channels[channel].multiplier;
|
||||
}
|
||||
|
||||
lcdint_t applyChannelRatio(source_t channel, lcdint_t val)
|
||||
{
|
||||
return ((int32_t)val+g_model.frsky.channels[channel].offset) * getChannelRatio(channel) * 2 / 51;
|
||||
}
|
||||
#endif
|
||||
|
||||
void processTelemetryData(uint8_t data)
|
||||
{
|
||||
@@ -83,7 +68,6 @@ void processTelemetryData(uint8_t data)
|
||||
|
||||
void telemetryWakeup()
|
||||
{
|
||||
#if defined(CPUARM)
|
||||
uint8_t requiredTelemetryProtocol = modelTelemetryProtocol();
|
||||
#if defined(REVX)
|
||||
uint8_t requiredSerialInversion = g_model.moduleData[EXTERNAL_MODULE].invertedSerial;
|
||||
@@ -94,7 +78,6 @@ void telemetryWakeup()
|
||||
#endif
|
||||
telemetryInit(requiredTelemetryProtocol);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(STM32)
|
||||
uint8_t data;
|
||||
@@ -118,27 +101,13 @@ void telemetryWakeup()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(CPUARM)
|
||||
if (IS_FRSKY_D_PROTOCOL()) {
|
||||
// Attempt to transmit any waiting Fr-Sky alarm set packets every 50ms (subject to packet buffer availability)
|
||||
static uint8_t frskyTxDelay = 5;
|
||||
if (frskyAlarmsSendState && (--frskyTxDelay == 0)) {
|
||||
frskyTxDelay = 5; // 50ms
|
||||
#if !defined(SIMU)
|
||||
frskyDSendNextAlarm();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
for (int i=0; i<MAX_TELEMETRY_SENSORS; i++) {
|
||||
const TelemetrySensor & sensor = g_model.telemetrySensors[i];
|
||||
if (sensor.type == TELEM_TYPE_CALCULATED) {
|
||||
telemetryItems[i].eval(sensor);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(VARIO)
|
||||
if (TELEMETRY_STREAMING() && !IS_FAI_ENABLED()) {
|
||||
@@ -148,7 +117,6 @@ void telemetryWakeup()
|
||||
|
||||
#define FRSKY_BAD_ANTENNA() (IS_RAS_VALUE_VALID() && telemetryData.swr.value > 0x33)
|
||||
|
||||
#if defined(CPUARM)
|
||||
static tmr10ms_t alarmsCheckTime = 0;
|
||||
#define SCHEDULE_NEXT_ALARMS_CHECK(seconds) alarmsCheckTime = get_tmr10ms() + (100*(seconds))
|
||||
if (int32_t(get_tmr10ms() - alarmsCheckTime) > 0) {
|
||||
@@ -206,70 +174,21 @@ void telemetryWakeup()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void telemetryInterrupt10ms()
|
||||
{
|
||||
#if defined(FRSKY_HUB) && !defined(CPUARM)
|
||||
uint16_t voltage = 0; /* unit: 1/10 volts */
|
||||
for (uint8_t i=0; i<telemetryData.hub.cellsCount; i++)
|
||||
voltage += telemetryData.hub.cellVolts[i];
|
||||
voltage /= (10 / TELEMETRY_CELL_VOLTAGE_MUTLIPLIER);
|
||||
telemetryData.hub.cellsSum = voltage;
|
||||
if (telemetryData.hub.cellsSum < telemetryData.hub.minCells) {
|
||||
telemetryData.hub.minCells = telemetryData.hub.cellsSum;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (TELEMETRY_STREAMING()) {
|
||||
if (!TELEMETRY_OPENXSENSOR()) {
|
||||
#if defined(CPUARM)
|
||||
for (int i=0; i<MAX_TELEMETRY_SENSORS; i++) {
|
||||
const TelemetrySensor & sensor = g_model.telemetrySensors[i];
|
||||
if (sensor.type == TELEM_TYPE_CALCULATED) {
|
||||
telemetryItems[i].per10ms(sensor);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// power calculation
|
||||
uint8_t channel = g_model.frsky.voltsSource;
|
||||
if (channel <= FRSKY_VOLTS_SOURCE_A2) {
|
||||
voltage = applyChannelRatio(channel, telemetryData.analog[channel].value) / 10;
|
||||
}
|
||||
|
||||
#if defined(FRSKY_HUB)
|
||||
else if (channel == FRSKY_VOLTS_SOURCE_FAS) {
|
||||
voltage = telemetryData.hub.vfas;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FRSKY_HUB)
|
||||
uint16_t current = telemetryData.hub.current; /* unit: 1/10 amps */
|
||||
#else
|
||||
uint16_t current = 0;
|
||||
#endif
|
||||
|
||||
channel = g_model.frsky.currentSource - FRSKY_CURRENT_SOURCE_A1;
|
||||
if (channel < MAX_FRSKY_A_CHANNELS) {
|
||||
current = applyChannelRatio(channel, telemetryData.analog[channel].value) / 10;
|
||||
}
|
||||
|
||||
telemetryData.hub.power = ((current>>1) * (voltage>>1)) / 25;
|
||||
|
||||
telemetryData.hub.currentPrescale += current;
|
||||
if (telemetryData.hub.currentPrescale >= 3600) {
|
||||
telemetryData.hub.currentConsumption += 1;
|
||||
telemetryData.hub.currentPrescale -= 3600;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(CPUARM)
|
||||
if (telemetryData.hub.power > telemetryData.hub.maxPower) {
|
||||
telemetryData.hub.maxPower = telemetryData.hub.power;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(WS_HOW_HIGH)
|
||||
@@ -283,12 +202,7 @@ void telemetryInterrupt10ms()
|
||||
}
|
||||
else {
|
||||
#if !defined(SIMU)
|
||||
#if defined(CPUARM)
|
||||
telemetryData.rssi.reset();
|
||||
#else
|
||||
telemetryData.rssi[0].set(0);
|
||||
telemetryData.rssi[1].set(0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -297,82 +211,18 @@ void telemetryReset()
|
||||
{
|
||||
memclear(&telemetryData, sizeof(telemetryData));
|
||||
|
||||
#if defined(CPUARM)
|
||||
for (int index=0; index<MAX_TELEMETRY_SENSORS; index++) {
|
||||
telemetryItems[index].clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
telemetryStreaming = 0; // reset counter only if valid frsky packets are being detected
|
||||
link_counter = 0;
|
||||
|
||||
#if defined(CPUARM)
|
||||
telemetryState = TELEMETRY_INIT;
|
||||
#endif
|
||||
|
||||
#if defined(FRSKY_HUB) && !defined(CPUARM)
|
||||
telemetryData.hub.gpsLatitude_bp = 2;
|
||||
telemetryData.hub.gpsLongitude_bp = 2;
|
||||
telemetryData.hub.gpsFix = -1;
|
||||
#endif
|
||||
|
||||
#if defined(SIMU) && !defined(CPUARM)
|
||||
telemetryData.rssi[0].value = 75;
|
||||
telemetryData.rssi[1].value = 75;
|
||||
telemetryData.analog[TELEM_ANA_A1].set(120, UNIT_VOLTS);
|
||||
telemetryData.analog[TELEM_ANA_A2].set(240, UNIT_VOLTS);
|
||||
|
||||
telemetryData.hub.fuelLevel = 75;
|
||||
telemetryData.hub.rpm = 12000;
|
||||
telemetryData.hub.vfas = 100;
|
||||
telemetryData.hub.minVfas = 90;
|
||||
|
||||
#if defined(GPS)
|
||||
telemetryData.hub.gpsFix = 1;
|
||||
telemetryData.hub.gpsLatitude_bp = 4401;
|
||||
telemetryData.hub.gpsLatitude_ap = 7710;
|
||||
telemetryData.hub.gpsLongitude_bp = 1006;
|
||||
telemetryData.hub.gpsLongitude_ap = 8872;
|
||||
telemetryData.hub.gpsSpeed_bp = 200; //in knots
|
||||
telemetryData.hub.gpsSpeed_ap = 0;
|
||||
getGpsPilotPosition();
|
||||
|
||||
telemetryData.hub.gpsLatitude_bp = 4401;
|
||||
telemetryData.hub.gpsLatitude_ap = 7455;
|
||||
telemetryData.hub.gpsLongitude_bp = 1006;
|
||||
telemetryData.hub.gpsLongitude_ap = 9533;
|
||||
getGpsDistance();
|
||||
#endif
|
||||
|
||||
telemetryData.hub.airSpeed = 1000; // 185.1 km/h
|
||||
|
||||
telemetryData.hub.cellsCount = 6;
|
||||
telemetryData.hub.cellVolts[0] = 410/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
telemetryData.hub.cellVolts[1] = 420/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
telemetryData.hub.cellVolts[2] = 430/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
telemetryData.hub.cellVolts[3] = 440/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
telemetryData.hub.cellVolts[4] = 450/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
telemetryData.hub.cellVolts[5] = 460/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
telemetryData.hub.minCellVolts = 250/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
telemetryData.hub.minCell = 300; //unit 10mV
|
||||
telemetryData.hub.minCells = 220; //unit 100mV
|
||||
//telemetryData.hub.cellsSum = 261; //calculated from cellVolts[]
|
||||
|
||||
telemetryData.hub.gpsAltitude_bp = 50;
|
||||
telemetryData.hub.baroAltitude_bp = 50;
|
||||
telemetryData.hub.minAltitude = 10;
|
||||
telemetryData.hub.maxAltitude = 500;
|
||||
|
||||
telemetryData.hub.accelY = 100;
|
||||
telemetryData.hub.temperature1 = -30;
|
||||
telemetryData.hub.maxTemperature1 = 100;
|
||||
|
||||
telemetryData.hub.current = 55;
|
||||
telemetryData.hub.maxCurrent = 65;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(CPUARM)
|
||||
// we don't reset the telemetry here as we would also reset the consumption after model load
|
||||
void telemetryInit(uint8_t protocol)
|
||||
{
|
||||
@@ -432,19 +282,7 @@ void telemetryInit(uint8_t protocol)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
void telemetryInit()
|
||||
{
|
||||
telemetryPortInit();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(CPUARM)
|
||||
NOINLINE uint8_t getRssiAlarmValue(uint8_t alarm)
|
||||
{
|
||||
return (45 - 3*alarm + g_model.frsky.rssiAlarms[alarm].value);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LOG_TELEMETRY) && !defined(SIMU)
|
||||
extern FIL g_telemetryFile;
|
||||
|
||||
@@ -55,14 +55,12 @@ extern uint8_t wshhStreaming;
|
||||
|
||||
extern uint8_t link_counter;
|
||||
|
||||
#if defined(CPUARM)
|
||||
enum TelemetryStates {
|
||||
TELEMETRY_INIT,
|
||||
TELEMETRY_OK,
|
||||
TELEMETRY_KO
|
||||
};
|
||||
extern uint8_t telemetryState;
|
||||
#endif
|
||||
|
||||
#define TELEMETRY_TIMEOUT10ms 100 // 1 second
|
||||
|
||||
@@ -80,7 +78,6 @@ extern uint8_t telemetryState;
|
||||
extern uint8_t telemetryRxBuffer[TELEMETRY_RX_PACKET_SIZE];
|
||||
extern uint8_t telemetryRxBufferCount;
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define TELEMETRY_AVERAGE_COUNT 3
|
||||
|
||||
enum {
|
||||
@@ -119,12 +116,10 @@ int32_t convertTelemetryValue(int32_t value, uint8_t unit, uint8_t prec, uint8_t
|
||||
|
||||
void frskySportSetDefault(int index, uint16_t id, uint8_t subId, uint8_t instance);
|
||||
void frskyDSetDefault(int index, uint16_t id);
|
||||
#endif
|
||||
|
||||
#define IS_DISTANCE_UNIT(unit) ((unit) == UNIT_METERS || (unit) == UNIT_FEET)
|
||||
#define IS_SPEED_UNIT(unit) ((unit) >= UNIT_KTS && (unit) <= UNIT_MPH)
|
||||
|
||||
#if defined(CPUARM)
|
||||
extern uint8_t telemetryProtocol;
|
||||
#define IS_FRSKY_D_PROTOCOL() (telemetryProtocol == PROTOCOL_FRSKY_D)
|
||||
#if defined (MULTIMODULE)
|
||||
@@ -134,12 +129,7 @@ extern uint8_t telemetryProtocol;
|
||||
#define IS_FRSKY_SPORT_PROTOCOL() (telemetryProtocol == PROTOCOL_FRSKY_SPORT)
|
||||
#endif
|
||||
#define IS_SPEKTRUM_PROTOCOL() (telemetryProtocol == PROTOCOL_SPEKTRUM)
|
||||
#else
|
||||
#define IS_FRSKY_D_PROTOCOL() (true)
|
||||
#define IS_FRSKY_SPORT_PROTOCOL() (false)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
inline uint8_t modelTelemetryProtocol()
|
||||
{
|
||||
#if defined(CROSSFIRE)
|
||||
@@ -161,11 +151,8 @@ inline uint8_t modelTelemetryProtocol()
|
||||
// default choice
|
||||
return PROTOCOL_FRSKY_SPORT;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#include "telemetry_sensors.h"
|
||||
#endif
|
||||
|
||||
#if defined(LOG_TELEMETRY) && !defined(SIMU)
|
||||
void logTelemetryWriteStart();
|
||||
@@ -204,3 +191,4 @@ extern Fifo<uint8_t, LUA_TELEMETRY_INPUT_FIFO_SIZE> * luaInputTelemetryFifo;
|
||||
#endif
|
||||
|
||||
#endif // _TELEMETRY_H_
|
||||
|
||||
|
||||
@@ -20,16 +20,13 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
#if defined(CPUARM)
|
||||
void TelemetryValueWithMin::reset()
|
||||
{
|
||||
memclear(this, sizeof(*this));
|
||||
}
|
||||
#endif
|
||||
|
||||
void TelemetryValueWithMin::set(uint8_t value)
|
||||
{
|
||||
#if defined(CPUARM)
|
||||
if (this->value == 0) {
|
||||
memset(values, value, TELEMETRY_AVERAGE_COUNT);
|
||||
this->value = value;
|
||||
@@ -47,18 +44,6 @@ void TelemetryValueWithMin::set(uint8_t value)
|
||||
sum += value;
|
||||
this->value = sum/(TELEMETRY_AVERAGE_COUNT+1);
|
||||
}
|
||||
#else
|
||||
if (this->value == 0) {
|
||||
this->value = value;
|
||||
}
|
||||
else {
|
||||
sum += value;
|
||||
if (link_counter == 0) {
|
||||
this->value = sum / (IS_FRSKY_D_PROTOCOL() ? FRSKY_D_AVERAGING : FRSKY_SPORT_AVERAGING);
|
||||
sum = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!min || value < min) {
|
||||
min = value;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define TELEMETRY_AVERAGE_COUNT 3 // we actually average one more reading!
|
||||
#define RAW_FRSKY_MINMAX(v) v.values[TELEMETRY_AVERAGE_COUNT-1]
|
||||
class TelemetryValueWithMin {
|
||||
@@ -34,16 +33,6 @@ class TelemetryValueWithMin {
|
||||
void set(uint8_t value);
|
||||
void reset();
|
||||
};
|
||||
#else
|
||||
#define RAW_FRSKY_MINMAX(v) v.value
|
||||
class TelemetryValueWithMin {
|
||||
public:
|
||||
uint8_t value;
|
||||
uint8_t min;
|
||||
uint16_t sum;
|
||||
void set(uint8_t value);
|
||||
};
|
||||
#endif
|
||||
|
||||
class TelemetryValueWithMinMax: public TelemetryValueWithMin {
|
||||
public:
|
||||
@@ -51,4 +40,4 @@ class TelemetryValueWithMinMax: public TelemetryValueWithMin {
|
||||
void set(uint8_t value, uint8_t unit);
|
||||
};
|
||||
|
||||
#endif // _TELEMETRY_HOLDERS_H_
|
||||
#endif // _TELEMETRY_HOLDERS_H_
|
||||
|
||||
Reference in New Issue
Block a user