added receiver display to sensors

This commit is contained in:
Raphael Coeffic
2019-08-20 00:50:28 +02:00
parent 645fb219f8
commit 5fa820f98d
6 changed files with 112 additions and 5 deletions
+14
View File
@@ -30,6 +30,20 @@ void ModuleData::convert(RadioDataConversionState & cstate)
}
}
bool ModuleData::isPxx2Module() const
{
switch(protocol){
case PULSES_ACCESS_ISRM:
case PULSES_ACCESS_R9M:
case PULSES_ACCESS_R9M_LITE:
case PULSES_ACCESS_R9M_LITE_PRO:
case PULSES_XJT_LITE_X16:
return true;
default:
return false;
}
}
QString ModuleData::rfProtocolToString() const
{
switch (protocol) {
+2 -1
View File
@@ -175,11 +175,12 @@ class ModuleData {
struct Access {
unsigned int receivers;
char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME];
char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME+1];
} access;
void clear() { memset(this, 0, sizeof(ModuleData)); }
void convert(RadioDataConversionState & cstate);
bool isPxx2Module() const;
QString polarityToString() const { return ppm.pulsePol ? tr("Positive") : tr("Negative"); }
QString rfProtocolToString() const;
QString subTypeToString(int type = -1) const;
@@ -1868,7 +1868,8 @@ class SensorField: public TransformedField {
if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) {
_id = sensor.id;
_subid = sensor.subid;
_instance = sensor.instance;
// keep highest 3 bits from instance (rxIdx & moduleIdx are read-only)
_instance = (sensor.instance & 0x1F) | (_instance & 0xE0);
_ratio = sensor.ratio;
_offset = sensor.offset;
}
@@ -1891,7 +1892,9 @@ class SensorField: public TransformedField {
if (sensor.type == SensorData::TELEM_TYPE_CUSTOM) {
sensor.id = _id;
sensor.subid = _subid;
sensor.instance = _instance;
sensor.instance = _instance & 0x1F; // 5 bits instance
sensor.rxIdx = (_instance >> 5) & 0x03; // 2 bits Rx idx
sensor.moduleIdx = (_instance >> 7) & 0x1; // 1 bit module idx
sensor.ratio = _ratio;
sensor.offset = _offset;
}
@@ -2056,7 +2059,7 @@ class ModuleUnionField: public UnionField<unsigned int> {
internalField.Append(new SpareBitsField<5>(this));
for (int i=0; i<PXX2_MAX_RECEIVERS_PER_MODULE; i++)
internalField.Append(new CharField<8>(this, module.access.receiverName[i]));
internalField.Append(new CharField<8>(this, receiverName[i]));
}
bool select(const unsigned int& attr) const {
@@ -2076,11 +2079,24 @@ class ModuleUnionField: public UnionField<unsigned int> {
if (module.protocol == PULSES_ACCESS_ISRM) {
module.protocol += module.subType;
}
for (int i=0; i<PXX2_MAX_RECEIVERS_PER_MODULE; i++) {
for (int pos=0; pos<PXX2_LEN_RX_NAME+1; pos++) {
if (pos == PXX2_LEN_RX_NAME || receiverName[i][pos] == ' '
|| receiverName[i][pos] == '\0') {
module.access.receiverName[i][pos] = '\0';
break;
}
module.access.receiverName[i][pos] = receiverName[i][pos];
}
}
}
private:
StructField internalField;
ModuleData& module;
char receiverName[PXX2_MAX_RECEIVERS_PER_MODULE][PXX2_LEN_RX_NAME+1];
};
public:
+2
View File
@@ -111,6 +111,8 @@ class SensorData {
unsigned int id;
unsigned int subid;
unsigned int instance;
unsigned int rxIdx;
unsigned int moduleIdx;
unsigned int persistentValue;
unsigned int formula;
char label[4+1];
+26
View File
@@ -653,6 +653,9 @@ void TelemetrySensorPanel::update()
ui->id->hide();
ui->instanceLabel->hide();
ui->instance->hide();
ui->rxLabel->hide();
ui->moduleLabel->hide();
ui->rxOrMod->hide();
ui->formula->show();
ui->formula->setCurrentIndex(sensor.formula);
isConfigurable = (sensor.formula < SensorData::TELEM_FORMULA_CELL);
@@ -676,6 +679,29 @@ void TelemetrySensorPanel::update()
ui->id->show();
ui->instanceLabel->show();
ui->instance->show();
const ModuleData& module = model->moduleData[sensor.moduleIdx];
if (module.isPxx2Module()) {
ui->rxLabel->show();
ui->moduleLabel->hide();
if (module.access.receivers & (1 << sensor.rxIdx)) {
ui->rxOrMod->setText(module.access.receiverName[sensor.rxIdx]);
}
else {
// receiver does not seem to be active
ui->rxOrMod->clear();
}
}
else {
ui->rxLabel->hide();
ui->moduleLabel->show();
if (sensor.moduleIdx)
ui->rxOrMod->setText(tr("Internal Module"));
else
ui->rxOrMod->setText(tr("External Module"));
}
ui->rxOrMod->show();
ui->formula->hide();
isConfigurable = sensor.unit < SensorData::UNIT_FIRST_VIRTUAL;
ratioFieldsDisplayed = (sensor.unit < SensorData::UNIT_FIRST_VIRTUAL);
+49 -1
View File
@@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,1,1,1,1,0,0,1,0,1,0,1,1,1,1,1,1,0,1,0,0,1,0,0,1,0,0,0,0,0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,1,0,0,0,1,1,1,0,0,1,0,1,0,1,1,1,1,1,1,0,1,0,0,1,0,0,1,0,0,0,0,0">
<property name="leftMargin">
<number>0</number>
</property>
@@ -28,6 +28,12 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="maxLength">
<number>4</number>
</property>
@@ -114,6 +120,48 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rxLabel">
<property name="text">
<string>Rx</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="moduleLabel">
<property name="text">
<string>Mod.</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="rxOrMod">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="maxLength">
<number>10</number>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="formula">
<property name="sizePolicy">