Implement R9M Companion support (#5157)
[opentx.git] / companion / src / modeledit / setup.h
blobe59f7a2ba0d54ece96a4bc70a6eb02a86a8220c1
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _SETUP_H_
22 #define _SETUP_H_
24 #include "modeledit.h"
25 #include "eeprominterface.h"
27 class RawSwitchFilterItemModel;
29 namespace Ui {
30 class Setup;
31 class Timer;
32 class Module;
35 class TimerPanel : public ModelPanel
37 Q_OBJECT
39 public:
40 TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget *prevFocus);
41 virtual ~TimerPanel();
43 virtual void update();
44 QWidget * getLastFocus();
46 private slots:
47 void on_mode_currentIndexChanged(int index);
48 void on_value_editingFinished();
49 void on_minuteBeep_toggled(bool checked);
50 void on_name_editingFinished();
52 private:
53 TimerData & timer;
54 Ui::Timer * ui;
55 RawSwitchFilterItemModel * rawSwitchItemModel;
58 class ModulePanel : public ModelPanel
60 Q_OBJECT
62 public:
63 ModulePanel(QWidget *parent, ModelData & model, ModuleData & module, GeneralSettings & generalSettings, Firmware * firmware, int moduleIdx);
64 virtual ~ModulePanel();
65 virtual void update();
66 bool moduleHasFailsafes();
68 public slots:
69 void onExtendedLimitsToggled();
71 signals:
72 void channelsRangeChanged();
74 private slots:
75 void setupFailsafes();
76 void on_trainerMode_currentIndexChanged(int index);
77 void onProtocolChanged(int index);
78 void on_ppmDelay_editingFinished();
79 void on_channelsCount_editingFinished();
80 void on_channelsStart_editingFinished();
81 void on_ppmPolarity_currentIndexChanged(int index);
82 void on_ppmOutputType_currentIndexChanged(int index);
83 void on_ppmFrameLength_editingFinished();
84 void on_antennaMode_currentIndexChanged(int index);
85 void on_rxNumber_editingFinished();
86 void on_failsafeMode_currentIndexChanged(int value);
87 void onMultiProtocolChanged(int index);
88 void on_multiSubType_currentIndexChanged(int index);
89 void on_autoBind_stateChanged(int state);
90 void on_lowPower_stateChanged(int state);
91 void on_sportOut_currentIndexChanged(int index);
92 void on_r9mPower_currentIndexChanged(int index);
93 void setChannelFailsafeValue(const int channel, const int value, quint8 updtSb = 0);
94 void onFailsafeComboIndexChanged(int index);
95 void onFailsafeUsecChanged(int value);
96 void onFailsafePercentChanged(double value);
97 void onFailsafesDisplayValueTypeChanged(int type);
98 void updateFailsafe(int channel);
99 void on_optionValue_editingFinished();
101 private:
102 enum FailsafeValueDisplayTypes { FAILSAFE_DISPLAY_PERCENT = 1, FAILSAFE_DISPLAY_USEC = 2 };
104 struct ChannelFailsafeWidgetsGroup {
105 QLabel * label;
106 QComboBox * combo;
107 QSpinBox * sbUsec;
108 QDoubleSpinBox * sbPercent;
111 ModuleData & module;
112 int moduleIdx;
113 Ui::Module *ui;
114 QMap<int, ChannelFailsafeWidgetsGroup> failsafeGroupsMap;
115 static quint8 failsafesValueDisplayType; // FailsafeValueDisplayTypes
118 class SetupPanel : public ModelPanel
120 Q_OBJECT
122 public:
123 SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
124 virtual ~SetupPanel();
126 virtual void update();
128 signals:
129 void extendedLimitsToggled();
131 private slots:
132 void on_name_editingFinished();
133 void on_throttleSource_currentIndexChanged(int index);
134 void on_throttleTrim_toggled(bool checked);
135 void on_extendedLimits_toggled(bool checked);
136 void on_extendedTrims_toggled(bool checked);
137 void on_throttleWarning_toggled(bool checked);
138 void on_throttleReverse_toggled(bool checked);
139 void on_displayText_toggled(bool checked);
140 void on_gfEnabled_toggled(bool checked);
141 void on_image_currentIndexChanged(int index);
142 void on_trimIncrement_currentIndexChanged(int index);
143 void onBeepCenterToggled(bool checked);
144 void startupSwitchEdited(int value);
145 void startupSwitchToggled(bool checked);
146 void potWarningToggled(bool checked);
147 void on_potWarningMode_currentIndexChanged(int index);
148 void on_editText_clicked();
150 private:
151 Ui::Setup *ui;
152 QVector<QSlider *> startupSwitchesSliders;
153 QVector<QCheckBox *> startupSwitchesCheckboxes;
154 QVector<QCheckBox *> potWarningCheckboxes;
155 QVector<QCheckBox *> centerBeepCheckboxes;
156 ModulePanel * modules[CPN_MAX_MODULES+1];
157 TimerPanel * timers[CPN_MAX_TIMERS];
158 void updateStartupSwitches();
159 void updatePotWarnings();
160 void updateBeepCenter();
161 void populateThrottleSourceCB();
164 #endif // _SETUP_H_