* - Concentrated Multi protocol definitions into a consistent single source. Actually two .h files, one for the protocol list and names, the other for subtypes and capababilites, see comments in .h files as to why - updated available protocols reflecting 1.3.3.20 (15+ protocols) - fixed Companion always showing f/s and channel map options in model setup disregarding the protocol capability * Following @pfeerick's review: changed heaeders and typos fixed Ubuntu runtime error on assert fixed change of Multi protocol not triggering writing yaml file * corrected copy/paste error * fixed FrSky index juggling * Updated Multiprotocol database to current MPM project status (ref. MPM Multiprotos.ino) - changed protocol name FX816 to FX - added Flysky AFHDS2A options PPM and PPWM SBUS 16ch subtypes "PWM,SB16" and "PPM,SB16 - added V761 option to select TOPRC - added FX options "816" and "620" - added FRSKYR9 option "-- 8ch" * MPM protocol scan excludes some protocols which are not meant to be selected. For Companion and Simualtor (and for radios if there is no MPM connected) this was handled in different places with outdated information. Harmonized and centralized the handling of non-selectabale protocols into the single source for all companion, Simulator and all gui types. * More cleanup: - changed some MPM protocol names to the ones the MPM delivers with MPM protocol scan to harmonize names between CPN/Simulator/radio - added XN2927DUMP and MOULDKG to the list of excluded MPM protocols just like the MPM does with MPM protocol scan - added new option value limits and moved definitions to single source - adapted CPN and radio to use common definitions of option values for all GUI types - moved distributed MPM (as far as possible) to one coherent place under a single #if defined (MULTIMODULE) - fixed option value not reset at change of protocol - some editorial stuff Note: There is still some work to be done on CPN GUI option values. DSM2 servo rates are hard coded, BAYANG telemetry options are only shown by index and not by text as in radio code, AFHDS2A servo update rate is shown as index too which is to no use for users. I'll try to fix all this in the next session, but request to get rid of BAYANG telemetry options translations. It is much easier to define a common string list by using untranslated.h * rebase due to fr.h * resolve merge conflict with main fr.h * more cleanup: - deleted multiple definition of MM_RF_CUSTOM_SELECTED in favor of single source define - bw radios: change to only allow defined protocols rather than a fixed 127 protocols * Changes: - magic sentinel number 0xfe as define - add 10 NN protocol entries for future use of new MPM protocols not yet defined in ETX (still recommend timely ETX maintenance update if MPM releases new firmware) * Changes by @elecpower: - align field labels to radio - change servo update frequency from combo box to spin box with edit only via up/down arrows to stop invalid values being entered via keyboard. Remove frequency list used to populate combo box as only used by Companion. - add validation to module yaml decode checking for unsupported multi protocols and/or multi protocol sub types and if unsupported set module to OFF just to be safe. * Changes: - radio: added validation to module yaml decode checking for unsupported multi protocols and/or multi protocol sub types and if unsupported set module to OFF just to be safe. * CPN: use sentinel define * cpn: Sort multi protocols list (courtesy @elecpower) * fixes #3480 changes: - moved FrSky subtype defines to MultiProtoDefs.h - updated bind_button_driver.cpp * missed replacing one instance of setMultiProtocol() * changes: - editorial change - added multi option to OMP protocol (ref #2713) * rather go for STR_MULTI_RFTUNE because MPM manual talks about RF tune * made XN297_DUMP selectable (available with MPM debug fw only) * corrected merge mistakes
246 lines
7.8 KiB
C++
246 lines
7.8 KiB
C++
/*
|
|
* Copyright (C) OpenTX
|
|
*
|
|
* Based on code named
|
|
* th9x - http://code.google.com/p/th9x
|
|
* er9x - http://code.google.com/p/er9x
|
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
|
*
|
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "modeledit.h"
|
|
#include "eeprominterface.h"
|
|
#include "compounditemmodels.h"
|
|
#include "filtereditemmodels.h"
|
|
|
|
constexpr char MIMETYPE_TIMER[] = "application/x-companion-timer";
|
|
|
|
namespace Ui {
|
|
class Setup;
|
|
class Timer;
|
|
class Module;
|
|
class FunctionSwitches;
|
|
}
|
|
|
|
class AutoLineEdit;
|
|
|
|
class TimerPanel : public ModelPanel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware,
|
|
QWidget * prevFocus, FilteredItemModelFactory * panelFilteredModels, CompoundItemModelFactory * panelItemModels);
|
|
virtual ~TimerPanel();
|
|
|
|
virtual void update();
|
|
QWidget * getLastFocus();
|
|
|
|
private slots:
|
|
void onNameChanged();
|
|
void onItemModelAboutToBeUpdated();
|
|
void onItemModelUpdateComplete();
|
|
void onCountdownBeepChanged(int index);
|
|
void onModeChanged(int index);
|
|
|
|
signals:
|
|
void nameChanged();
|
|
|
|
private:
|
|
TimerData & timer;
|
|
Ui::Timer * ui;
|
|
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
|
int modelsUpdateCnt;
|
|
};
|
|
|
|
class ModulePanel : public ModelPanel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
ModulePanel(QWidget * parent, ModelData & model, ModuleData & module, GeneralSettings & generalSettings, Firmware * firmware, int moduleIdx,
|
|
FilteredItemModelFactory * panelFilteredItemModels = nullptr);
|
|
virtual ~ModulePanel();
|
|
virtual void update();
|
|
|
|
public slots:
|
|
void onExtendedLimitsToggled();
|
|
void onFailsafeModified(unsigned index);
|
|
|
|
signals:
|
|
void channelsRangeChanged();
|
|
void failsafeModified(unsigned index);
|
|
void updateItemModels();
|
|
|
|
private slots:
|
|
void setupFailsafes();
|
|
void onProtocolChanged(int index);
|
|
void on_ppmDelay_editingFinished();
|
|
void on_channelsCount_editingFinished();
|
|
void on_channelsStart_editingFinished();
|
|
void on_ppmPolarity_currentIndexChanged(int index);
|
|
void on_ppmOutputType_currentIndexChanged(int index);
|
|
void on_ppmFrameLength_editingFinished();
|
|
void on_rxNumber_editingFinished();
|
|
void on_failsafeMode_currentIndexChanged(int value);
|
|
void onMultiProtocolChanged(int index);
|
|
void onSubTypeChanged();
|
|
void on_autoBind_stateChanged(int state);
|
|
void on_disableChMap_stateChanged(int state);
|
|
void on_raw12bits_stateChanged(int state);
|
|
void on_racingMode_stateChanged(int state);
|
|
void on_disableTelem_stateChanged(int state);
|
|
void on_lowPower_stateChanged(int state);
|
|
void on_r9mPower_currentIndexChanged(int index);
|
|
void setChannelFailsafeValue(const int channel, const int value, quint8 updtSb = 0);
|
|
void onFailsafeComboIndexChanged(int index);
|
|
void onFailsafeUsecChanged(int value);
|
|
void onFailsafePercentChanged(double value);
|
|
void onFailsafesDisplayValueTypeChanged(int type);
|
|
void onRfFreqChanged(int freq);
|
|
void updateFailsafe(unsigned channel);
|
|
void on_optionValue_valueChanged(int value);
|
|
void onClearAccessRxClicked();
|
|
void on_chkOption_stateChanged(int state);
|
|
void on_cboOption_currentIndexChanged(int value);
|
|
|
|
private:
|
|
enum FailsafeValueDisplayTypes { FAILSAFE_DISPLAY_PERCENT = 1, FAILSAFE_DISPLAY_USEC = 2 };
|
|
|
|
struct ChannelFailsafeWidgetsGroup {
|
|
QLabel * label;
|
|
QComboBox * combo;
|
|
QSpinBox * sbUsec;
|
|
QDoubleSpinBox * sbPercent;
|
|
};
|
|
|
|
ModuleData & module;
|
|
int moduleIdx;
|
|
Ui::Module *ui;
|
|
QMap<int, ChannelFailsafeWidgetsGroup> failsafeGroupsMap;
|
|
static quint8 failsafesValueDisplayType; // FailsafeValueDisplayTypes
|
|
void updateFailsafeUI(unsigned channel, quint8 updtSb);
|
|
};
|
|
|
|
class FunctionSwitchesPanel : public ModelPanel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
FunctionSwitchesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
|
virtual ~FunctionSwitchesPanel();
|
|
|
|
virtual void update();
|
|
void update(int index);
|
|
|
|
signals:
|
|
void updateDataModels();
|
|
|
|
private slots:
|
|
void on_nameEditingFinished();
|
|
void on_configCurrentIndexChanged(int index);
|
|
void on_startPosnCurrentIndexChanged(int index);
|
|
void on_groupChanged(int value);
|
|
void on_alwaysOnGroupChanged(int value);
|
|
|
|
private:
|
|
Ui::FunctionSwitches * ui;
|
|
QVector<AutoLineEdit *> aleNames;
|
|
QVector<QComboBox *> cboConfigs;
|
|
QVector<QComboBox *> cboStartupPosns;
|
|
QVector<QSpinBox *> sbGroups;
|
|
QVector<QCheckBox *> cbAlwaysOnGroups;
|
|
int switchcnt;
|
|
};
|
|
|
|
class SetupPanel : public ModelPanel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CompoundItemModelFactory * sharedItemModels);
|
|
virtual ~SetupPanel();
|
|
|
|
virtual void update();
|
|
|
|
signals:
|
|
void extendedLimitsToggled();
|
|
void updated();
|
|
|
|
private slots:
|
|
void on_name_editingFinished();
|
|
void on_throttleTrimSwitch_currentIndexChanged(int index);
|
|
void on_throttleTrim_toggled(bool checked);
|
|
void on_extendedLimits_toggled(bool checked);
|
|
void on_extendedTrims_toggled(bool checked);
|
|
void on_throttleWarning_toggled(bool checked);
|
|
void on_enableCustomThrottleWarning_toggled(bool checked);
|
|
void on_customThrottleWarningPosition_valueChanged(int value);
|
|
void on_throttleReverse_toggled(bool checked);
|
|
void on_displayText_toggled(bool checked);
|
|
void on_gfEnabled_toggled(bool checked);
|
|
void on_image_currentIndexChanged(int index);
|
|
void on_trimIncrement_currentIndexChanged(int index);
|
|
void onBeepCenterToggled(bool checked);
|
|
void startupSwitchEdited(int value);
|
|
void startupSwitchToggled(bool checked);
|
|
void potWarningToggled(bool checked);
|
|
void on_potWarningMode_currentIndexChanged(int index);
|
|
void on_editText_clicked();
|
|
void onTimerCustomContextMenuRequested(QPoint pos);
|
|
void cmTimerClear(bool prompt = true);
|
|
void cmTimerClearAll();
|
|
void cmTimerCopy();
|
|
void cmTimerCut();
|
|
void cmTimerDelete();
|
|
void cmTimerInsert();
|
|
void cmTimerPaste();
|
|
void cmTimerMoveDown();
|
|
void cmTimerMoveUp();
|
|
void onTimerNameChanged();
|
|
void onItemModelAboutToBeUpdated();
|
|
void onItemModelUpdateComplete();
|
|
void onModuleUpdateItemModels();
|
|
void onFunctionSwitchesUpdateItemModels();
|
|
void on_jitterFilter_currentIndexChanged(int index);
|
|
|
|
private:
|
|
Ui::Setup *ui;
|
|
QVector<QSlider *> startupSwitchesSliders;
|
|
QVector<QCheckBox *> startupSwitchesCheckboxes;
|
|
QVector<QCheckBox *> potWarningCheckboxes;
|
|
QVector<QCheckBox *> centerBeepCheckboxes;
|
|
ModulePanel * modules[CPN_MAX_MODULES + 1];
|
|
TimerPanel * timers[CPN_MAX_TIMERS];
|
|
FunctionSwitchesPanel * funcswitches;
|
|
|
|
void updateStartupSwitches();
|
|
void updatePotWarnings();
|
|
void updateBeepCenter();
|
|
void populateThrottleTrimSwitchCB();
|
|
int timersCount;
|
|
int selectedTimerIndex;
|
|
bool hasTimerClipboardData(QByteArray * data = nullptr) const;
|
|
bool insertTimerAllowed() const;
|
|
bool moveTimerDownAllowed() const;
|
|
bool moveTimerUpAllowed() const;
|
|
void swapTimerData(int idx1, int idx2);
|
|
CompoundItemModelFactory * sharedItemModels;
|
|
void updateItemModels();
|
|
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
|
CompoundItemModelFactory * panelItemModels;
|
|
FilteredItemModelFactory * panelFilteredModels;
|
|
};
|