Limit sensors available as possible RSSI source
This commit is contained in:
@@ -488,7 +488,7 @@ TelemetrySourceItemModel::TelemetrySourceItemModel(const GeneralSettings * const
|
|||||||
if (!modelData)
|
if (!modelData)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setUpdateMask(IMUE_TeleSensors);
|
setUpdateMask(IMUE_TeleSensors | IMUE_Modules);
|
||||||
const int count = firmware->getCapability(Sensors);
|
const int count = firmware->getCapability(Sensors);
|
||||||
|
|
||||||
for (int i = -count; i <= count; ++i) {
|
for (int i = -count; i <= count; ++i) {
|
||||||
@@ -519,6 +519,49 @@ void TelemetrySourceItemModel::update(const int event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// RssiSourceItemModel
|
||||||
|
//
|
||||||
|
|
||||||
|
RssiSourceItemModel::RssiSourceItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData,
|
||||||
|
Firmware * firmware, const Boards * const board, const Board::Type boardType) :
|
||||||
|
AbstractDynamicItemModel(generalSettings, modelData, firmware, board, boardType)
|
||||||
|
{
|
||||||
|
setId(IMID_RssiSource);
|
||||||
|
|
||||||
|
if (!modelData)
|
||||||
|
return;
|
||||||
|
|
||||||
|
setUpdateMask(IMUE_TeleSensors | IMUE_Modules);
|
||||||
|
|
||||||
|
for (int i = 0; i <= firmware->getCapability(Sensors); ++i) {
|
||||||
|
QStandardItem * modelItem = new QStandardItem();
|
||||||
|
modelItem->setData(i, IMDR_Id);
|
||||||
|
modelItem->setData(i < 0 ? IMDG_Negative : i > 0 ? IMDG_Positive : IMDG_None, IMDR_Flags);
|
||||||
|
setDynamicItemData(modelItem, i);
|
||||||
|
appendRow(modelItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RssiSourceItemModel::setDynamicItemData(QStandardItem * item, const int value) const
|
||||||
|
{
|
||||||
|
item->setText(SensorData::rssiSensorToString(modelData, value));
|
||||||
|
item->setData(SensorData::isRssiSensorAvailable(modelData, value), IMDR_Available);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RssiSourceItemModel::update(const int event)
|
||||||
|
{
|
||||||
|
if (doUpdate(event)) {
|
||||||
|
emit aboutToBeUpdated();
|
||||||
|
|
||||||
|
for (int i = 0; i < rowCount(); ++i) {
|
||||||
|
setDynamicItemData(item(i), item(i)->data(IMDR_Id).toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
emit updateComplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// CurveRefTypeItemModel
|
// CurveRefTypeItemModel
|
||||||
//
|
//
|
||||||
@@ -624,6 +667,9 @@ void CompoundItemModelFactory::addItemModel(const int id)
|
|||||||
case AbstractItemModel::IMID_TeleSource:
|
case AbstractItemModel::IMID_TeleSource:
|
||||||
registerItemModel(new TelemetrySourceItemModel(generalSettings, modelData, firmware, board, boardType));
|
registerItemModel(new TelemetrySourceItemModel(generalSettings, modelData, firmware, board, boardType));
|
||||||
break;
|
break;
|
||||||
|
case AbstractItemModel::IMID_RssiSource:
|
||||||
|
registerItemModel(new RssiSourceItemModel(generalSettings, modelData, firmware, board, boardType));
|
||||||
|
break;
|
||||||
case AbstractItemModel::IMID_CurveRefType:
|
case AbstractItemModel::IMID_CurveRefType:
|
||||||
registerItemModel(new CurveRefTypeItemModel(generalSettings, modelData, firmware, board, boardType));
|
registerItemModel(new CurveRefTypeItemModel(generalSettings, modelData, firmware, board, boardType));
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COMPOUNDITEMMODELS_H
|
#pragma once
|
||||||
#define COMPOUNDITEMMODELS_H
|
|
||||||
|
|
||||||
#include "rawsource.h"
|
#include "rawsource.h"
|
||||||
#include "rawswitch.h"
|
#include "rawswitch.h"
|
||||||
@@ -44,6 +43,7 @@ class AbstractItemModel: public QStandardItemModel
|
|||||||
IMID_CustomFuncAction,
|
IMID_CustomFuncAction,
|
||||||
IMID_CustomFuncResetParam,
|
IMID_CustomFuncResetParam,
|
||||||
IMID_TeleSource,
|
IMID_TeleSource,
|
||||||
|
IMID_RssiSource,
|
||||||
IMID_CurveRefType,
|
IMID_CurveRefType,
|
||||||
IMID_CurveRefFunc,
|
IMID_CurveRefFunc,
|
||||||
IMID_ReservedCount,
|
IMID_ReservedCount,
|
||||||
@@ -78,8 +78,9 @@ class AbstractItemModel: public QStandardItemModel
|
|||||||
IMUE_Scripts = 1 << 7,
|
IMUE_Scripts = 1 << 7,
|
||||||
IMUE_TeleSensors = 1 << 8,
|
IMUE_TeleSensors = 1 << 8,
|
||||||
IMUE_Timers = 1 << 9,
|
IMUE_Timers = 1 << 9,
|
||||||
|
IMUE_Modules = 1 << 10,
|
||||||
IMUE_All = IMUE_SystemRefresh | IMUE_Channels | IMUE_Curves | IMUE_FlightModes | IMUE_GVars | IMUE_Inputs |
|
IMUE_All = IMUE_SystemRefresh | IMUE_Channels | IMUE_Curves | IMUE_FlightModes | IMUE_GVars | IMUE_Inputs |
|
||||||
IMUE_LogicalSwitches | IMUE_Scripts | IMUE_TeleSensors | IMUE_Timers
|
IMUE_LogicalSwitches | IMUE_Scripts | IMUE_TeleSensors | IMUE_Timers | IMUE_Modules
|
||||||
};
|
};
|
||||||
Q_ENUM(ItemModelUpdateEvent)
|
Q_ENUM(ItemModelUpdateEvent)
|
||||||
|
|
||||||
@@ -305,6 +306,21 @@ class TelemetrySourceItemModel: public AbstractDynamicItemModel
|
|||||||
virtual void setDynamicItemData(QStandardItem * item, const int value) const;
|
virtual void setDynamicItemData(QStandardItem * item, const int value) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RssiSourceItemModel: public AbstractDynamicItemModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit RssiSourceItemModel(const GeneralSettings * const generalSettings, const ModelData * const modelData,
|
||||||
|
Firmware * firmware, const Boards * const board, const Board::Type boardType);
|
||||||
|
virtual ~RssiSourceItemModel() {};
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void update(const int event = IMUE_SystemRefresh) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void setDynamicItemData(QStandardItem * item, const int value) const;
|
||||||
|
};
|
||||||
|
|
||||||
class CurveRefTypeItemModel : public AbstractStaticItemModel
|
class CurveRefTypeItemModel : public AbstractStaticItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -361,5 +377,3 @@ class CompoundItemModelFactory
|
|||||||
private:
|
private:
|
||||||
void setSourceId(AbstractItemModel * itemModel);
|
void setSourceId(AbstractItemModel * itemModel);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COMPOUNDITEMMODELS_H
|
|
||||||
|
|||||||
@@ -427,6 +427,28 @@ bool SensorData::isSourceAvailable(const ModelData * model, const int index)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define RSSI_ID 0xF101
|
||||||
|
|
||||||
|
// static
|
||||||
|
bool SensorData::isRssiSensorAvailable(const ModelData * model, const int value)
|
||||||
|
{
|
||||||
|
if (value == 0)
|
||||||
|
return true;
|
||||||
|
else {
|
||||||
|
const SensorData &sensor = model->sensorData[abs(value) - 1];
|
||||||
|
return (sensor.isAvailable() && sensor.id == RSSI_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
QString SensorData::rssiSensorToString(const ModelData * model, const int value)
|
||||||
|
{
|
||||||
|
if (value == 0)
|
||||||
|
return tr("(default)");
|
||||||
|
else
|
||||||
|
return sourceToString(model, value);
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
AbstractStaticItemModel * SensorData::typeItemModel()
|
AbstractStaticItemModel * SensorData::typeItemModel()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -206,6 +206,8 @@ class SensorData {
|
|||||||
static QString unitToString(const int value);
|
static QString unitToString(const int value);
|
||||||
static QString precToString(const int value);
|
static QString precToString(const int value);
|
||||||
static QString boolToString(const bool value) { return value ? tr("Y") : tr("N"); }
|
static QString boolToString(const bool value) { return value ? tr("Y") : tr("N"); }
|
||||||
|
static bool isRssiSensorAvailable(const ModelData * model, const int value);
|
||||||
|
static QString rssiSensorToString(const ModelData * model, const int value);
|
||||||
|
|
||||||
static AbstractStaticItemModel * typeItemModel();
|
static AbstractStaticItemModel * typeItemModel();
|
||||||
static AbstractStaticItemModel * formulaItemModel();
|
static AbstractStaticItemModel * formulaItemModel();
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
|
|||||||
sharedItemModels->addItemModel(AbstractItemModel::IMID_CustomFuncAction);
|
sharedItemModels->addItemModel(AbstractItemModel::IMID_CustomFuncAction);
|
||||||
sharedItemModels->addItemModel(AbstractItemModel::IMID_CustomFuncResetParam);
|
sharedItemModels->addItemModel(AbstractItemModel::IMID_CustomFuncResetParam);
|
||||||
sharedItemModels->addItemModel(AbstractItemModel::IMID_TeleSource);
|
sharedItemModels->addItemModel(AbstractItemModel::IMID_TeleSource);
|
||||||
|
sharedItemModels->addItemModel(AbstractItemModel::IMID_RssiSource);
|
||||||
sharedItemModels->addItemModel(AbstractItemModel::IMID_CurveRefType);
|
sharedItemModels->addItemModel(AbstractItemModel::IMID_CurveRefType);
|
||||||
sharedItemModels->addItemModel(AbstractItemModel::IMID_CurveRefFunc);
|
sharedItemModels->addItemModel(AbstractItemModel::IMID_CurveRefFunc);
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge
|
|||||||
ui->persistent->addItem(tr("Not persistent"), 0);
|
ui->persistent->addItem(tr("Not persistent"), 0);
|
||||||
ui->persistent->addItem(tr("Persistent (flight)"), 1);
|
ui->persistent->addItem(tr("Persistent (flight)"), 1);
|
||||||
ui->persistent->addItem(tr("Persistent (manual reset)"), 2);
|
ui->persistent->addItem(tr("Persistent (manual reset)"), 2);
|
||||||
|
|
||||||
ui->countdownStart->setField(timer.countdownStart, this);
|
ui->countdownStart->setField(timer.countdownStart, this);
|
||||||
ui->countdownStart->addItem("5s", 1);
|
ui->countdownStart->addItem("5s", 1);
|
||||||
ui->countdownStart->addItem("10s", 0);
|
ui->countdownStart->addItem("10s", 0);
|
||||||
@@ -701,6 +701,7 @@ void ModulePanel::onProtocolChanged(int index)
|
|||||||
module.protocol = ui->protocol->itemData(index).toInt();
|
module.protocol = ui->protocol->itemData(index).toInt();
|
||||||
module.channelsCount = module.getMaxChannelCount();
|
module.channelsCount = module.getMaxChannelCount();
|
||||||
update();
|
update();
|
||||||
|
emit updateItemModels();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -801,6 +802,7 @@ void ModulePanel::onMultiProtocolChanged(int index)
|
|||||||
module.subType = std::min(module.subType, maxSubTypes - 1);
|
module.subType = std::min(module.subType, maxSubTypes - 1);
|
||||||
module.channelsCount = module.getMaxChannelCount();
|
module.channelsCount = module.getMaxChannelCount();
|
||||||
update();
|
update();
|
||||||
|
emit updateItemModels();
|
||||||
emit modified();
|
emit modified();
|
||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
@@ -1251,6 +1253,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
|||||||
modules[i] = new ModulePanel(this, model, model.moduleData[i], generalSettings, firmware, i);
|
modules[i] = new ModulePanel(this, model, model.moduleData[i], generalSettings, firmware, i);
|
||||||
ui->modulesLayout->addWidget(modules[i]);
|
ui->modulesLayout->addWidget(modules[i]);
|
||||||
connect(modules[i], &ModulePanel::modified, this, &SetupPanel::modified);
|
connect(modules[i], &ModulePanel::modified, this, &SetupPanel::modified);
|
||||||
|
connect(modules[i], &ModulePanel::updateItemModels, this, &SetupPanel::onModuleUpdateItemModels);
|
||||||
connect(this, &SetupPanel::extendedLimitsToggled, modules[i], &ModulePanel::onExtendedLimitsToggled);
|
connect(this, &SetupPanel::extendedLimitsToggled, modules[i], &ModulePanel::onExtendedLimitsToggled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1798,3 +1801,8 @@ void SetupPanel::updateItemModels()
|
|||||||
{
|
{
|
||||||
sharedItemModels->update(AbstractItemModel::IMUE_Timers);
|
sharedItemModels->update(AbstractItemModel::IMUE_Timers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetupPanel::onModuleUpdateItemModels()
|
||||||
|
{
|
||||||
|
sharedItemModels->update(AbstractItemModel::IMUE_Modules);
|
||||||
|
}
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ class ModulePanel : public ModelPanel
|
|||||||
signals:
|
signals:
|
||||||
void channelsRangeChanged();
|
void channelsRangeChanged();
|
||||||
void failsafeModified(unsigned index);
|
void failsafeModified(unsigned index);
|
||||||
|
void updateItemModels();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setupFailsafes();
|
void setupFailsafes();
|
||||||
@@ -175,6 +176,7 @@ class SetupPanel : public ModelPanel
|
|||||||
void onTimerNameChanged();
|
void onTimerNameChanged();
|
||||||
void onItemModelAboutToBeUpdated();
|
void onItemModelAboutToBeUpdated();
|
||||||
void onItemModelUpdateComplete();
|
void onItemModelUpdateComplete();
|
||||||
|
void onModuleUpdateItemModels();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Setup *ui;
|
Ui::Setup *ui;
|
||||||
|
|||||||
@@ -35,6 +35,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_RSSISOURCE[] {"Rssi Source"};
|
||||||
|
|
||||||
TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings,
|
TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings,
|
||||||
Firmware * firmware, const bool & parentLock, FilteredItemModelFactory * panelFilteredItemModels):
|
Firmware * firmware, const bool & parentLock, FilteredItemModelFactory * panelFilteredItemModels):
|
||||||
@@ -696,6 +697,11 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin
|
|||||||
FIM_TELEPOSSRC);
|
FIM_TELEPOSSRC);
|
||||||
connectItemModelEvents(id);
|
connectItemModelEvents(id);
|
||||||
|
|
||||||
|
|
||||||
|
id = panelFilteredItemModels->registerItemModel(new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_RssiSource)),
|
||||||
|
FIM_RSSISOURCE);
|
||||||
|
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);
|
||||||
|
|
||||||
@@ -818,7 +824,7 @@ void TelemetryPanel::setup()
|
|||||||
|
|
||||||
ui->rssiSourceLabel->show();
|
ui->rssiSourceLabel->show();
|
||||||
ui->rssiSourceLabel->setText(tr("Source"));
|
ui->rssiSourceLabel->setText(tr("Source"));
|
||||||
ui->rssiSourceCB->setModel(panelFilteredItemModels->getItemModel(FIM_TELEPOSSRC));
|
ui->rssiSourceCB->setModel(panelFilteredItemModels->getItemModel(FIM_RSSISOURCE));
|
||||||
ui->rssiSourceCB->setField(model->rssiSource, this);
|
ui->rssiSourceCB->setField(model->rssiSource, this);
|
||||||
ui->rssiSourceCB->show();
|
ui->rssiSourceCB->show();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user