feat(cpn): only use vario sensors for vario source (#4963)
This commit is contained in:
@@ -486,7 +486,6 @@ TelemetrySourceItemModel::TelemetrySourceItemModel(const GeneralSettings * const
|
|||||||
for (int i = -count; i <= count; ++i) {
|
for (int i = -count; i <= count; ++i) {
|
||||||
QStandardItem * modelItem = new QStandardItem();
|
QStandardItem * modelItem = new QStandardItem();
|
||||||
modelItem->setData(i, IMDR_Id);
|
modelItem->setData(i, IMDR_Id);
|
||||||
modelItem->setData(i < 0 ? IMDG_Negative : i > 0 ? IMDG_Positive : IMDG_None, IMDR_Flags);
|
|
||||||
setDynamicItemData(modelItem, i);
|
setDynamicItemData(modelItem, i);
|
||||||
appendRow(modelItem);
|
appendRow(modelItem);
|
||||||
}
|
}
|
||||||
@@ -496,6 +495,10 @@ void TelemetrySourceItemModel::setDynamicItemData(QStandardItem * item, const in
|
|||||||
{
|
{
|
||||||
item->setText(SensorData::sourceToString(modelData, value));
|
item->setText(SensorData::sourceToString(modelData, value));
|
||||||
item->setData(SensorData::isSourceAvailable(modelData, value), IMDR_Available);
|
item->setData(SensorData::isSourceAvailable(modelData, value), IMDR_Available);
|
||||||
|
int flags = value < 0 ? SensorData::SensorTypeFlagNeg : value > 0 ? SensorData::SensorTypeFlagPos : SensorData::SensorTypeFlagNone;
|
||||||
|
if (value > 0 && SensorData::isSourceVario(modelData, value))
|
||||||
|
flags |= SensorData::SensorTypeFlagVario;
|
||||||
|
item->setData(flags, IMDR_Flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetrySourceItemModel::update(const int event)
|
void TelemetrySourceItemModel::update(const int event)
|
||||||
|
|||||||
@@ -425,6 +425,23 @@ bool SensorData::isSourceAvailable(const ModelData * model, const int index)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
bool SensorData::isSourceVario(const ModelData * model, const int index)
|
||||||
|
{
|
||||||
|
const int i = abs(index);
|
||||||
|
|
||||||
|
if (i > 0) {
|
||||||
|
if (model->sensorData[i - 1].isAvailable()) {
|
||||||
|
if (model->sensorData[i - 1].unit == UNIT_FEET_PER_SECOND || model->sensorData[i - 1].unit == UNIT_METERS_PER_SECOND)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#define RSSI_ID 0xF101
|
#define RSSI_ID 0xF101
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|||||||
@@ -143,6 +143,17 @@ class SensorData {
|
|||||||
UNIT_DATETIME_SEC
|
UNIT_DATETIME_SEC
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum SensorTypeMasks {
|
||||||
|
SensorTypeFlagNone = 1 << 1, // AbstractItemModel::IMDG_None
|
||||||
|
SensorTypeFlagNeg = 1 << 2, // AbstractItemModel::IMDG_Negative
|
||||||
|
SensorTypeFlagPos = 1 << 3, // AbstractItemModel::IMDG_Positive
|
||||||
|
SensorTypeFlagVario = 1 << 4,
|
||||||
|
SensorTypeContextNone = SensorTypeFlagNone,
|
||||||
|
SensorTypeContextNeg = SensorTypeFlagNeg | SensorTypeFlagNone,
|
||||||
|
SensorTypeContextPos = SensorTypeFlagPos | SensorTypeFlagNone,
|
||||||
|
SensorTypeContextVario = SensorTypeFlagVario | SensorTypeFlagNone,
|
||||||
|
};
|
||||||
|
|
||||||
SensorData() { clear(); }
|
SensorData() { clear(); }
|
||||||
unsigned int type; // custom / formula
|
unsigned int type; // custom / formula
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
@@ -200,6 +211,7 @@ class SensorData {
|
|||||||
|
|
||||||
static QString sourceToString(const ModelData * model, const int index, const bool positivesign = false);
|
static QString sourceToString(const ModelData * model, const int index, const bool positivesign = false);
|
||||||
static bool isSourceAvailable(const ModelData * model, const int index);
|
static bool isSourceAvailable(const ModelData * model, const int index);
|
||||||
|
static bool isSourceVario(const ModelData * model, const int index);
|
||||||
static QString idToString(const int value);
|
static QString idToString(const int value);
|
||||||
static QString typeToString(const int value);
|
static QString typeToString(const int value);
|
||||||
static QString formulaToString(const int value);
|
static QString formulaToString(const int value);
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ constexpr char FIM_SENSORFORMULA[] {"Sensor.Formula"};
|
|||||||
constexpr char FIM_SENSORCELLINDEX[] {"Sensor.CellIndex"};
|
constexpr char FIM_SENSORCELLINDEX[] {"Sensor.CellIndex"};
|
||||||
constexpr char FIM_SENSORUNIT[] {"Sensor.Unit"};
|
constexpr char FIM_SENSORUNIT[] {"Sensor.Unit"};
|
||||||
constexpr char FIM_SENSORPRECISION[] {"Sensor.Precision"};
|
constexpr char FIM_SENSORPRECISION[] {"Sensor.Precision"};
|
||||||
|
constexpr char FIM_TELEVARIOSRC[] {"Tele Vario Source"};
|
||||||
|
|
||||||
TelemetrySensorPanel::TelemetrySensorPanel(QWidget *parent, SensorData & sensor, int sensorIndex, int sensorCapability, ModelData & model,
|
TelemetrySensorPanel::TelemetrySensorPanel(QWidget *parent, SensorData & sensor, int sensorIndex, int sensorCapability, ModelData & model,
|
||||||
GeneralSettings & generalSettings, Firmware * firmware, const bool & parentLock,
|
GeneralSettings & generalSettings, Firmware * firmware, const bool & parentLock,
|
||||||
@@ -235,6 +236,7 @@ void TelemetrySensorPanel::on_unitDataChanged()
|
|||||||
{
|
{
|
||||||
sensor.unitChanged();
|
sensor.unitChanged();
|
||||||
update();
|
update();
|
||||||
|
emit dataModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetrySensorPanel::on_precDataChanged()
|
void TelemetrySensorPanel::on_precDataChanged()
|
||||||
@@ -403,10 +405,15 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin
|
|||||||
connectItemModelEvents(id);
|
connectItemModelEvents(id);
|
||||||
|
|
||||||
id = panelFilteredItemModels->registerItemModel(new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_TeleSource),
|
id = panelFilteredItemModels->registerItemModel(new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_TeleSource),
|
||||||
FilteredItemModel::PositiveFilter),
|
SensorData::SensorTypeContextPos),
|
||||||
FIM_TELEPOSSRC);
|
FIM_TELEPOSSRC);
|
||||||
connectItemModelEvents(id);
|
connectItemModelEvents(id);
|
||||||
|
|
||||||
|
id = panelFilteredItemModels->registerItemModel(new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_TeleSource),
|
||||||
|
SensorData::SensorTypeContextVario),
|
||||||
|
FIM_TELEVARIOSRC);
|
||||||
|
connectItemModelEvents(id);
|
||||||
|
|
||||||
id = panelItemModels->registerItemModel(SensorData::typeItemModel());
|
id = panelItemModels->registerItemModel(SensorData::typeItemModel());
|
||||||
panelFilteredItemModels->registerItemModel(new FilteredItemModel(panelItemModels->getItemModel(id)), FIM_SENSORTYPE);
|
panelFilteredItemModels->registerItemModel(new FilteredItemModel(panelItemModels->getItemModel(id)), FIM_SENSORTYPE);
|
||||||
|
|
||||||
@@ -430,7 +437,7 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin
|
|||||||
model.frsky.usrProto = 1;
|
model.frsky.usrProto = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->varioSource->setModel(panelFilteredItemModels->getItemModel(FIM_TELEPOSSRC));
|
ui->varioSource->setModel(panelFilteredItemModels->getItemModel(FIM_TELEVARIOSRC));
|
||||||
ui->varioSource->setField(model.frsky.varioSource, this);
|
ui->varioSource->setField(model.frsky.varioSource, this);
|
||||||
ui->varioCenterSilent->setField(model.frsky.varioCenterSilent, this);
|
ui->varioCenterSilent->setField(model.frsky.varioCenterSilent, this);
|
||||||
ui->A1GB->hide();
|
ui->A1GB->hide();
|
||||||
|
|||||||
Reference in New Issue
Block a user