Fixes #1092 - Chronos names

This commit is contained in:
bsongis
2014-08-18 14:17:59 +02:00
parent 2d43ecdd05
commit 1454eff428
23 changed files with 281 additions and 190 deletions
+4
View File
@@ -914,10 +914,13 @@ class MavlinkData {
void clear() { memset(this, 0, sizeof(MavlinkData)); }
};
#define TIMER_NAME_LEN 8
class TimerData {
public:
TimerData() { clear(); }
RawSwitch mode;
char name[TIMER_NAME_LEN+1];
bool minuteBeep;
unsigned int countdownBeep;
unsigned int val;
@@ -1063,6 +1066,7 @@ enum Capability {
Imperial,
Mixes,
Timers,
TimersName,
TimeDivisions,
CustomFunctions,
SafetyChannelCustomFunction,
@@ -2452,6 +2452,10 @@ OpenTxModelData::OpenTxModelData(ModelData & modelData, BoardEnum board, unsigne
internalField.Append(new SpareBitsField<3>());
internalField.Append(new UnsignedField<24>(modelData.timers[i].val));
internalField.Append(new SignedField<24>(modelData.timers[i].pvalue));
if (IS_TARANIS(board))
internalField.Append(new ZCharField<8>(modelData.timers[i].name));
else
internalField.Append(new ZCharField<3>(modelData.timers[i].name));
}
else if ((IS_ARM(board) || IS_2560(board)) && version >= 216) {
internalField.Append(new UnsignedField<16>(modelData.timers[i].val));
@@ -561,6 +561,8 @@ int OpenTxFirmware::getCapability(const Capability capability)
return (IS_ARM(board) ? 500 : 245);
case Timers:
return (IS_ARM(board) ? 3 : 2);
case TimersName:
return (IS_TARANIS(board) ? 8 : (IS_ARM(board) ? 3 : 0));
case PermTimers:
if (board == BOARD_GRUVIN9X || IS_ARM(board))
return 1;
+27 -6
View File
@@ -10,10 +10,22 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge
timer(timer),
ui(new Ui::Timer)
{
BoardEnum board = firmware->getBoard();
ui->setupUi(this);
lock = true;
// Name
int length = firmware->getCapability(TimersName);
if (length == 0) {
ui->name->hide();
}
else {
ui->name->setMaxLength(length);
ui->name->setText(timer.name);
}
// Mode
populateSwitchCB(ui->mode, timer.mode, generalSettings, TimersContext);
@@ -25,7 +37,7 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge
ui->countdownBeep->setField(&timer.countdownBeep, this);
ui->countdownBeep->addItem(tr("Silent"), 0);
ui->countdownBeep->addItem(tr("Beeps"), 1);
if (IS_ARM(GetEepromInterface()->getBoard()) || IS_2560(GetEepromInterface()->getBoard())) {
if (IS_ARM(board) || IS_2560(board)) {
ui->countdownBeep->addItem(tr("Voice"), 2);
}
@@ -87,6 +99,13 @@ void TimerPanel::on_minuteBeep_toggled(bool checked)
emit modified();
}
void TimerPanel::on_name_editingFinished()
{
int length = ui->name->maxLength();
strncpy(timer.name, ui->name->text().toAscii(), length);
emit modified();
}
/******************************************************************************/
ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module, GeneralSettings & generalSettings, FirmwareInterface * firmware, int moduleIdx):
@@ -336,13 +355,15 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
ModelPanel(parent, model, generalSettings, firmware),
ui(new Ui::Setup)
{
BoardEnum board = firmware->getBoard();
lock = true;
memset(modules, 0, sizeof(modules));
ui->setupUi(this);
ui->name->setMaxLength(IS_TARANIS(firmware->getBoard()) ? 12 : 10);
ui->name->setMaxLength(IS_TARANIS(board) ? 12 : 10);
for (int i=0; i<C9X_MAX_TIMERS; i++) {
if (i<firmware->getCapability(Timers)) {
@@ -428,7 +449,7 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
ui->centerBeepLayout->addWidget(checkbox, 0, i+1);
connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
centerBeepCheckboxes << checkbox;
if (!IS_TARANIS_PLUS(firmware->getBoard()) && i==6) {
if (!IS_TARANIS_PLUS(board) && i==6) {
checkbox->hide();
}
}
@@ -448,7 +469,7 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
slider->setTickInterval(1);
slider->setMinimumSize(QSize(30, 50));
slider->setMaximumSize(QSize(50, 50));
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
if (IS_TARANIS(board)) {
label->setText(switchesX9D[i]);
slider->setMaximum(i==5 ? 1 : 2);
}
@@ -471,7 +492,7 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, firmware->getCapability(Switches));
// Pot warnings
if (IS_TARANIS(firmware->getBoard())) {
if (IS_TARANIS(board)) {
for (int i=0; i<firmware->getCapability(Pots); i++) {
QCheckBox * cb = new QCheckBox(this);
cb->setProperty("index", i+1);
@@ -479,7 +500,7 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen
ui->potWarningLayout->addWidget(cb, 0, i+1);
connect(cb, SIGNAL(toggled(bool)), this, SLOT(potWarningToggled(bool)));
potWarningCheckboxes << cb;
if (!IS_TARANIS_PLUS(firmware->getBoard()) && i==2) {
if (!IS_TARANIS_PLUS(board) && i==2) {
cb->hide();
}
}
+1
View File
@@ -29,6 +29,7 @@ class TimerPanel : public ModelPanel
void on_mode_currentIndexChanged(int index);
void on_value_editingFinished();
void on_minuteBeep_toggled(bool checked);
void on_name_editingFinished();
private:
TimerData & timer;
+18 -2
View File
@@ -2,21 +2,37 @@
<ui version="4.0">
<class>Timer</class>
<widget class="QWidget" name="Timer">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>586</width>
<height>38</height>
<width>626</width>
<height>33</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>-1</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="name">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="value">
<property name="accelerated">