Merge pull request #2173 from mpaperno/telemetrysimu_add_fields_next

Companion/Sim: [next] Add more fields to telemetry simulator UI
This commit is contained in:
Andre Bernet
2015-03-28 18:25:38 +04:00
2 changed files with 408 additions and 23 deletions
+115 -5
View File
@@ -61,11 +61,14 @@ void generateSportPacket(uint8_t * packet, uint8_t dataId, uint8_t prim, uint16_
void TelemetrySimulator::generateTelemetryFrame()
{
static int item = 0;
bool ok = true;
uint8_t buffer[FRSKY_SPORT_PACKET_SIZE];
memset(buffer, 0, sizeof(buffer));
switch(item++) {
case 0:
generateSportPacket(buffer, 1, DATA_FRAME, RSSI_ID, LIMIT<uint32_t>(0, ui->Rssi->text().toInt(), 0xFF));
if (ui->Rssi->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, RSSI_ID, LIMIT<uint32_t>(0, ui->Rssi->text().toInt(&ok, 0), 0xFF));
break;
case 1:
@@ -75,20 +78,127 @@ void TelemetrySimulator::generateTelemetryFrame()
break;
case 2:
generateSportPacket(buffer, 1, DATA_FRAME, SWR_ID, LIMIT<uint32_t>(0, ui->Swr->text().toInt(), 0xFF));
if (ui->Swr->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, SWR_ID, LIMIT<uint32_t>(0, ui->Swr->text().toInt(&ok, 0), 0xFFFF));
break;
case 3:
generateSportPacket(buffer, 1, DATA_FRAME, ADC1_ID, LIMIT<uint32_t>(0, ui->A1->text().toInt(), 0xFF));
if (ui->A1->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, ADC1_ID, LIMIT<uint32_t>(0, ui->A1->text().toInt(&ok, 0), 0xFF));
break;
case 4:
generateSportPacket(buffer, 1, DATA_FRAME, ADC2_ID, LIMIT<uint32_t>(0, ui->A2->text().toInt(), 0xFF));
if (ui->A2->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, ADC2_ID, LIMIT<uint32_t>(0, ui->A2->text().toInt(&ok, 0), 0xFF));
break;
case 5:
if (ui->A3->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, A3_FIRST_ID, LIMIT<uint32_t>(0, ui->A3->text().toInt(&ok, 0), 0xFFFFFFFF));
break;
case 6:
if (ui->A4->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, A4_FIRST_ID, LIMIT<uint32_t>(0, ui->A4->text().toInt(&ok, 0), 0xFFFFFFFF));
break;
case 7:
if (ui->T1->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, T1_FIRST_ID, LIMIT<int32_t>(-0x7FFFFFFF, ui->T1->text().toInt(&ok, 0), 0x7FFFFFFF));
break;
case 8:
if (ui->T2->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, T2_FIRST_ID, LIMIT<int32_t>(-0x7FFFFFFF, ui->T2->text().toInt(&ok, 0), 0x7FFFFFFF));
break;
case 9:
if (ui->rpm->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, RPM_FIRST_ID, LIMIT<uint32_t>(0, ui->rpm->text().toInt(&ok, 0), 0xFFFF));
break;
case 10:
if (ui->fuel->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, FUEL_FIRST_ID, LIMIT<uint32_t>(0, ui->fuel->text().toInt(&ok, 0), 0xFFFF));
break;
case 11:
if (ui->aspeed->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, AIR_SPEED_FIRST_ID, LIMIT<uint32_t>(0, ui->aspeed->text().toInt(&ok, 0), 0xFFFFFFFF));
break;
case 12:
if (ui->vspeed->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, VARIO_FIRST_ID, LIMIT<int32_t>(-0x7FFFFFFF, ui->vspeed->text().toInt(&ok, 0), 0x7FFFFFFF));
break;
case 13:
if (ui->valt->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, ALT_FIRST_ID, LIMIT<int32_t>(-0x7FFFFFFF, ui->valt->text().toInt(&ok, 0), 0x7FFFFFFF));
break;
case 14:
if (ui->accx->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, ACCX_FIRST_ID, LIMIT<int32_t>(-0x7FFFFFFF, ui->accx->text().toInt(&ok, 0), 0x7FFFFFFF));
break;
case 15:
if (ui->accy->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, ACCY_FIRST_ID, LIMIT<int32_t>(-0x7FFFFFFF, ui->accy->text().toInt(&ok, 0), 0x7FFFFFFF));
break;
case 16:
if (ui->accz->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, ACCZ_FIRST_ID, LIMIT<int32_t>(-0x7FFFFFFF, ui->accz->text().toInt(&ok, 0), 0x7FFFFFFF));
break;
case 17:
if (ui->vfas->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, VFAS_FIRST_ID, LIMIT<uint32_t>(0, ui->vfas->text().toInt(&ok, 0), 0xFFFFFFFF));
break;
case 18:
if (ui->curr->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, CURR_FIRST_ID, LIMIT<uint32_t>(0, ui->curr->text().toInt(&ok, 0), 0xFFFFFFFF));
break;
case 19:
if (ui->cells->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, CELLS_FIRST_ID, LIMIT<uint32_t>(0, ui->cells->text().toInt(&ok, 0), 0xFFFFFFFF));
break;
case 20:
if (ui->gps_alt->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, GPS_ALT_FIRST_ID, LIMIT<int32_t>(-0x7FFFFFFF, ui->gps_alt->text().toInt(&ok, 0), 0x7FFFFFFF));
break;
case 21:
if (ui->gps_speed->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, GPS_SPEED_FIRST_ID, LIMIT<uint32_t>(0, ui->gps_speed->text().toInt(&ok, 0), 0xFFFFFFFF));
break;
case 22:
if (ui->gps_course->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, GPS_COURS_FIRST_ID, LIMIT<uint32_t>(0, ui->gps_course->text().toInt(&ok, 0), 0xFFFFFFFF));
break;
case 23:
if (ui->gps_time->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, GPS_TIME_DATE_FIRST_ID, LIMIT<uint32_t>(0, ui->gps_time->text().toInt(&ok, 0), 0xFFFFFFFF));
break;
case 24:
if (ui->gps_latlon->text().length())
generateSportPacket(buffer, 1, DATA_FRAME, GPS_LONG_LATI_FIRST_ID, LIMIT<uint32_t>(0, ui->gps_latlon->text().toInt(&ok, 0), 0xFFFFFFFF));
break;
default:
item = 0;
return;
}
simulator->sendTelemetry(buffer, 9);
if (ok && buffer[0])
simulator->sendTelemetry(buffer, FRSKY_SPORT_PACKET_SIZE);
else
onTimerEvent();
}
+293 -18
View File
@@ -6,67 +6,342 @@
<rect>
<x>0</x>
<y>0</y>
<width>184</width>
<height>165</height>
<width>278</width>
<height>384</height>
</rect>
</property>
<property name="windowTitle">
<string>Telemetry Simulator</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="bottomMargin">
<number>6</number>
</property>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="12" column="0">
<widget class="QLabel" name="label_12">
<property name="toolTip">
<string>Vario Altitude</string>
</property>
<property name="text">
<string>V-ALT</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_11">
<property name="toolTip">
<string>Vario Vertical Speed</string>
</property>
<property name="text">
<string>V-VSPD</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QLineEdit" name="valt"/>
</item>
<item row="11" column="1">
<widget class="QLineEdit" name="vspeed"/>
</item>
<item row="5" column="3">
<widget class="QLineEdit" name="gps_alt"/>
</item>
<item row="12" column="2">
<widget class="QLabel" name="label_15">
<property name="text">
<string>ACCZ</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLabel" name="label_23">
<property name="toolTip">
<string>GPS Time</string>
</property>
<property name="text">
<string>GPS-T</string>
</property>
</widget>
</item>
<item row="8" column="3">
<widget class="QLineEdit" name="gps_time"/>
</item>
<item row="10" column="2">
<widget class="QLabel" name="label_13">
<property name="text">
<string>ACCX</string>
</property>
</widget>
</item>
<item row="10" column="3">
<widget class="QLineEdit" name="accx"/>
</item>
<item row="3" column="3">
<widget class="QLineEdit" name="Swr"/>
<widget class="QLineEdit" name="cells"/>
</item>
<item row="4" column="3">
<widget class="QLineEdit" name="A1"/>
<item row="2" column="3">
<widget class="QLineEdit" name="curr"/>
</item>
<item row="1" column="1">
<item row="6" column="3">
<widget class="QLineEdit" name="gps_speed"/>
</item>
<item row="9" column="2">
<widget class="QLabel" name="label_24">
<property name="toolTip">
<string>GPS Lat/Lon</string>
</property>
<property name="text">
<string>GPS-LL</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_17">
<property name="toolTip">
<string>VFAS</string>
</property>
<property name="text">
<string>FAS-V</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="label_21">
<property name="toolTip">
<string>GPS Speed</string>
</property>
<property name="text">
<string>GPS-S</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_19">
<property name="text">
<string>CELLS</string>
</property>
</widget>
</item>
<item row="11" column="3">
<widget class="QLineEdit" name="accy"/>
</item>
<item row="7" column="3">
<widget class="QLineEdit" name="gps_course"/>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="vfas"/>
</item>
<item row="11" column="2">
<widget class="QLabel" name="label_14">
<property name="text">
<string>ACCY</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="label_22">
<property name="toolTip">
<string>GPS Course</string>
</property>
<property name="text">
<string>GPS-C</string>
</property>
</widget>
</item>
<item row="9" column="3">
<widget class="QLineEdit" name="gps_latlon"/>
</item>
<item row="12" column="3">
<widget class="QLineEdit" name="accz"/>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_20">
<property name="toolTip">
<string>GPS Altitude</string>
</property>
<property name="text">
<string>GPS-A</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_18">
<property name="toolTip">
<string>CURRENT</string>
</property>
<property name="text">
<string>FAS-C</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="Swr">
<property name="text">
<string>30</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>RSSI</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="Rssi"/>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_3">
<item row="1" column="1">
<widget class="QLineEdit" name="Rssi">
<property name="text">
<string>A1</string>
<string>75</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>SWR</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="Simulate">
<item row="4" column="2">
<widget class="QLabel" name="label_16">
<property name="toolTip">
<string>FR_ID_AIR_SPEED</string>
</property>
<property name="text">
<string>simulate</string>
<string>ASPD</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLineEdit" name="aspeed"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="A1"/>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="A2"/>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="A3"/>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="A4"/>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="T1"/>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="T2"/>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="rpm"/>
</item>
<item row="10" column="1">
<widget class="QLineEdit" name="fuel"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>A1</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>A2</string>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QLineEdit" name="A2"/>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>A3</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>A4</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_8">
<property name="toolTip">
<string>Temperature 1</string>
</property>
<property name="text">
<string>T1</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_9">
<property name="toolTip">
<string>Temperature 2</string>
</property>
<property name="text">
<string>T2</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>RPM</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>FUEL</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="Simulate">
<property name="toolTip">
<string>When enabled, sends any non-blank values as simulated telemetry data.</string>
</property>
<property name="text">
<string>simulate</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Start with &lt;span style=&quot; font-style:italic;&quot;&gt;0x&lt;/span&gt; for hex, &lt;span style=&quot; font-style:italic;&quot;&gt;0&lt;/span&gt; for octal, otherwise decimal.&lt;br/&gt;Numeric entry only. Blank values are not sent.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>Simulate</tabstop>
<tabstop>Rssi</tabstop>
<tabstop>Swr</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>