mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
New parameter added in TELEMETRY screen to choose S.PORT or D protocol.
This commit is contained in:
parent
54447a45a0
commit
5385a01b2e
8 changed files with 88 additions and 41 deletions
|
@ -1028,6 +1028,7 @@ class ModelData {
|
|||
uint8_t bt_telemetry;
|
||||
uint8_t numVoice;
|
||||
MavlinkData mavlink;
|
||||
unsigned int telemetryProtocol;
|
||||
FrSkyData frsky;
|
||||
|
||||
char bitmap[10+1];
|
||||
|
|
|
@ -2412,8 +2412,8 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne
|
|||
}
|
||||
}
|
||||
|
||||
if (IS_TARANIS(board))
|
||||
internalField.Append(new SpareBitsField<3>());
|
||||
if (IS_ARM(board))
|
||||
internalField.Append(new UnsignedField<3>(modelData.telemetryProtocol));
|
||||
else
|
||||
internalField.Append(new ConversionField< SignedField<3> >(modelData.moduleData[0].protocol, &protocolsConversionTable, "Protocol", ::QObject::tr("OpenTX doesn't accept this protocol")));
|
||||
|
||||
|
|
|
@ -476,6 +476,14 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin
|
|||
model.frsky.usrProto = 1;
|
||||
}
|
||||
|
||||
if (IS_ARM(firmware->getBoard())) {
|
||||
ui->telemetryProtocol->setCurrentIndex(model.telemetryProtocol);
|
||||
}
|
||||
else {
|
||||
ui->telemetryProtocolLabel->hide();
|
||||
ui->telemetryProtocol->hide();
|
||||
}
|
||||
|
||||
analogs[0] = new TelemetryAnalog(this, model.frsky.channels[0], model, generalSettings, firmware);
|
||||
ui->A1Layout->addWidget(analogs[0]);
|
||||
connect(analogs[0], SIGNAL(modified()), this, SLOT(onAnalogModified()));
|
||||
|
@ -711,6 +719,12 @@ void TelemetryPanel::populateCurrentSource()
|
|||
cb->addItem(tr("FAS"), TELEMETRY_CURRENT_SOURCE_FAS);
|
||||
}
|
||||
|
||||
void TelemetryPanel::on_telemetryProtocol_currentIndexChanged(int index)
|
||||
{
|
||||
model.telemetryProtocol = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryPanel::onAnalogModified()
|
||||
{
|
||||
emit modified();
|
||||
|
|
|
@ -83,6 +83,7 @@ class TelemetryPanel : public ModelPanel
|
|||
virtual ~TelemetryPanel();
|
||||
|
||||
private slots:
|
||||
void on_telemetryProtocol_currentIndexChanged(int index);
|
||||
void onAnalogModified();
|
||||
void on_frskyProtoCB_currentIndexChanged(int index);
|
||||
void on_frskyUnitsCB_currentIndexChanged(int index);
|
||||
|
|
|
@ -13,10 +13,53 @@
|
|||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="telemetryProtocolLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Protocol</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="telemetryProtocol">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>FrSky S.PORT</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>FrSky D</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
|
|
|
@ -5360,6 +5360,7 @@ void menuModelCustomScripts(uint8_t event)
|
|||
#endif
|
||||
|
||||
enum menuModelTelemetryItems {
|
||||
CASE_CPUARM(ITEM_TELEMETRY_PROTOCOL_TYPE)
|
||||
#if defined(CPUARM)
|
||||
ITEM_TELEMETRY_RXBATT_LABEL,
|
||||
ITEM_TELEMETRY_RXBATT_ALARM1,
|
||||
|
@ -5496,7 +5497,7 @@ enum menuModelTelemetryItems {
|
|||
|
||||
void menuModelTelemetry(uint8_t event)
|
||||
{
|
||||
MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, RXBATT_ROWS CHANNEL_ROWS, CHANNEL_ROWS, CASE_CPUARM(CHANNEL_ROWS) CASE_CPUARM(CHANNEL_ROWS) RSSI_ROWS, USRDATA_LINES 0, 0, IF_FAS_OFFSET(0) CASE_CPUARM(0) CASE_VARIO(LABEL(Vario)) CASE_VARIO(0) CASE_VARIO(VARIO_RANGE_ROWS) CASE_PCBTARANIS(LABEL(TopBar)) CASE_PCBTARANIS(0) SCREEN_TYPE_ROWS, 2, 2, 2, 2, SCREEN_TYPE_ROWS, 2, 2, 2, 2, CASE_CPUARM(SCREEN_TYPE_ROWS) CASE_CPUARM(2) CASE_CPUARM(2) CASE_CPUARM(2) CASE_CPUARM(2) });
|
||||
MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, CASE_CPUARM(0) RXBATT_ROWS CHANNEL_ROWS, CHANNEL_ROWS, CASE_CPUARM(CHANNEL_ROWS) CASE_CPUARM(CHANNEL_ROWS) RSSI_ROWS, USRDATA_LINES 0, 0, IF_FAS_OFFSET(0) CASE_CPUARM(0) CASE_VARIO(LABEL(Vario)) CASE_VARIO(0) CASE_VARIO(VARIO_RANGE_ROWS) CASE_PCBTARANIS(LABEL(TopBar)) CASE_PCBTARANIS(0) SCREEN_TYPE_ROWS, 2, 2, 2, 2, SCREEN_TYPE_ROWS, 2, 2, 2, 2, CASE_CPUARM(SCREEN_TYPE_ROWS) CASE_CPUARM(2) CASE_CPUARM(2) CASE_CPUARM(2) CASE_CPUARM(2)});
|
||||
|
||||
uint8_t sub = m_posVert - 1;
|
||||
|
||||
|
@ -5530,7 +5531,15 @@ void menuModelTelemetry(uint8_t event)
|
|||
#endif
|
||||
FrSkyChannelData & channel = g_model.frsky.channels[ch];
|
||||
uint8_t dest = TELEM_A1-1+ch;
|
||||
|
||||
switch (k) {
|
||||
|
||||
#if defined(CPUARM)
|
||||
case ITEM_TELEMETRY_PROTOCOL_TYPE:
|
||||
g_model.telemetryProtocol = selectMenuItem(TELEM_COL2, y, "Telemetry Type", "\006S.PORTD\0 ", g_model.telemetryProtocol, PROTOCOL_FRSKY_SPORT, PROTOCOL_FRSKY_D, attr, event);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
case ITEM_TELEMETRY_RXBATT_LABEL:
|
||||
lcd_putsLeft(y, "RxBatt");
|
||||
|
|
|
@ -1693,11 +1693,17 @@ enum ThrottleSources {
|
|||
THROTTLE_SOURCE_CH1,
|
||||
};
|
||||
|
||||
enum TelemetryProtocol
|
||||
{
|
||||
PROTOCOL_FRSKY_SPORT,
|
||||
PROTOCOL_FRSKY_D,
|
||||
};
|
||||
|
||||
PACK(typedef struct t_ModelData {
|
||||
ModelHeader header;
|
||||
TimerData timers[MAX_TIMERS];
|
||||
AVR_FIELD(uint8_t protocol:3);
|
||||
ARM_FIELD(uint8_t spare:3);
|
||||
ARM_FIELD(uint8_t telemetryProtocol:3);
|
||||
uint8_t thrTrim:1; // Enable Throttle Trim
|
||||
AVR_FIELD(int8_t ppmNCH:4)
|
||||
ARM_FIELD(int8_t spare2:4)
|
||||
|
|
|
@ -68,30 +68,9 @@ uint8_t frskyRxBufferCount = 0;
|
|||
FrskyData frskyData;
|
||||
|
||||
#if defined(CPUARM)
|
||||
enum TelemetryProtocol
|
||||
{
|
||||
PROTOCOL_NONE,
|
||||
PROTOCOL_FRSKY_D,
|
||||
PROTOCOL_FRSKY_SPORT,
|
||||
};
|
||||
|
||||
uint8_t telemetryProtocol = 255;
|
||||
#define IS_FRSKY_D_PROTOCOL() (telemetryProtocol == PROTOCOL_FRSKY_D)
|
||||
#define IS_FRSKY_SPORT_PROTOCOL() (telemetryProtocol == PROTOCOL_FRSKY_SPORT)
|
||||
|
||||
TelemetryProtocol telemetryProtocol = PROTOCOL_NONE;
|
||||
|
||||
TelemetryProtocol getTelemetryProtocol()
|
||||
{
|
||||
if (IS_MODULE_XJT(EXTERNAL_MODULE))
|
||||
return PROTOCOL_FRSKY_SPORT;
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
if (IS_MODULE_XJT(INTERNAL_MODULE))
|
||||
return PROTOCOL_FRSKY_SPORT;
|
||||
#endif
|
||||
|
||||
return PROTOCOL_FRSKY_D;
|
||||
}
|
||||
#else
|
||||
#define IS_FRSKY_D_PROTOCOL() (true)
|
||||
#define IS_FRSKY_SPORT_PROTOCOL() (false)
|
||||
|
@ -301,9 +280,8 @@ enum AlarmsCheckSteps {
|
|||
void telemetryWakeup()
|
||||
{
|
||||
#if defined(CPUARM)
|
||||
TelemetryProtocol currentProtocol = getTelemetryProtocol();
|
||||
if (telemetryProtocol != currentProtocol) {
|
||||
telemetryProtocol = currentProtocol;
|
||||
if (telemetryProtocol != g_model.telemetryProtocol) {
|
||||
telemetryProtocol = g_model.telemetryProtocol;
|
||||
telemetryInit();
|
||||
}
|
||||
#endif
|
||||
|
@ -600,13 +578,8 @@ void telemetryReset()
|
|||
|
||||
void telemetryInit(void)
|
||||
{
|
||||
#if defined(PCBTARANIS)
|
||||
if (IS_MODULE_XJT(INTERNAL_MODULE) || IS_MODULE_XJT(EXTERNAL_MODULE))
|
||||
telemetryPortInit(FRSKY_SPORT_BAUDRATE);
|
||||
else
|
||||
telemetryPortInit(FRSKY_D_BAUDRATE);
|
||||
#elif defined(PCBSKY9X)
|
||||
if (IS_MODULE_XJT(EXTERNAL_MODULE))
|
||||
#if defined(CPUARM)
|
||||
if (telemetryProtocol == PROTOCOL_FRSKY_SPORT)
|
||||
telemetryPortInit(FRSKY_SPORT_BAUDRATE);
|
||||
else
|
||||
telemetryPortInit(FRSKY_D_BAUDRATE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue