mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 04:15:26 +03:00
Issue #469 fixed (Telemetry tab in Companion rewritten - 20% code
removed). More tests needed!
This commit is contained in:
parent
59d8653b61
commit
ce2b033ccb
10 changed files with 479 additions and 1709 deletions
|
@ -1260,6 +1260,7 @@ void compareDialog::printFrSky()
|
||||||
color=getColor1(fd1->rssiAlarms[1].value,fd2->rssiAlarms[1].value);
|
color=getColor1(fd1->rssiAlarms[1].value,fd2->rssiAlarms[1].value);
|
||||||
str.append("<td align=\"center\"><font color="+color+">"+QString::number(fd1->rssiAlarms[1].value,10)+"</td>");
|
str.append("<td align=\"center\"><font color="+color+">"+QString::number(fd1->rssiAlarms[1].value,10)+"</td>");
|
||||||
str.append("</table>");
|
str.append("</table>");
|
||||||
|
#if 0
|
||||||
if (GetEepromInterface()->getCapability(TelemetryBars) || GetEepromInterface()->getCapability(TelemetryCSFields)) {
|
if (GetEepromInterface()->getCapability(TelemetryBars) || GetEepromInterface()->getCapability(TelemetryCSFields)) {
|
||||||
int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields);
|
int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields);
|
||||||
if (cols==0) cols=2;
|
if (cols==0) cols=2;
|
||||||
|
@ -1315,6 +1316,7 @@ void compareDialog::printFrSky()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
str.append("</td><td width=\"50%\">");
|
str.append("</td><td width=\"50%\">");
|
||||||
str.append("<table border=1 cellspacing=0 cellpadding=1 width=\"100%\">");
|
str.append("<table border=1 cellspacing=0 cellpadding=1 width=\"100%\">");
|
||||||
|
@ -1377,7 +1379,7 @@ void compareDialog::printFrSky()
|
||||||
color=getColor2(fd1->rssiAlarms[1].value,fd2->rssiAlarms[1].value);
|
color=getColor2(fd1->rssiAlarms[1].value,fd2->rssiAlarms[1].value);
|
||||||
str.append("<td align=\"center\"><font color="+color+">"+QString::number(fd2->rssiAlarms[1].value,10)+"</td>");
|
str.append("<td align=\"center\"><font color="+color+">"+QString::number(fd2->rssiAlarms[1].value,10)+"</td>");
|
||||||
str.append("</table></br>");
|
str.append("</table></br>");
|
||||||
|
#if 0
|
||||||
if (GetEepromInterface()->getCapability(TelemetryBars) || GetEepromInterface()->getCapability(TelemetryCSFields)) {
|
if (GetEepromInterface()->getCapability(TelemetryBars) || GetEepromInterface()->getCapability(TelemetryCSFields)) {
|
||||||
int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields);
|
int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields);
|
||||||
if (cols==0) cols=2;
|
if (cols==0) cols=2;
|
||||||
|
@ -1433,6 +1435,7 @@ void compareDialog::printFrSky()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
str.append("</td></tr></table>");
|
str.append("</td></tr></table>");
|
||||||
te->append(str);
|
te->append(str);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,18 +67,15 @@ RawSourceRange RawSource::getRange(bool singleprec)
|
||||||
case TELEMETRY_SOURCE_A1:
|
case TELEMETRY_SOURCE_A1:
|
||||||
case TELEMETRY_SOURCE_A2:
|
case TELEMETRY_SOURCE_A2:
|
||||||
if (model) {
|
if (model) {
|
||||||
if (model->frsky.channels[index-TELEMETRY_SOURCE_A1].type==0) {
|
FrSkyChannelData channel = model->frsky.channels[index-TELEMETRY_SOURCE_A1]; // TODO const &
|
||||||
result.step = (model->frsky.channels[index-TELEMETRY_SOURCE_A1].ratio / 2550.0);
|
float ratio = channel.getRatio();
|
||||||
result.min = (model->frsky.channels[index-TELEMETRY_SOURCE_A1].offset * model->frsky.channels[index-TELEMETRY_SOURCE_A1].ratio) / 2550.0;
|
if (channel.type==0 || channel.type==1 || channel.type==2)
|
||||||
result.max = model->frsky.channels[index-TELEMETRY_SOURCE_A1].ratio - (model->frsky.channels[index-TELEMETRY_SOURCE_A1].offset * model->frsky.channels[index-TELEMETRY_SOURCE_A1].ratio) / 2550.0;
|
|
||||||
result.decimals = 2;
|
result.decimals = 2;
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
result.step = (model->frsky.channels[index-TELEMETRY_SOURCE_A1].ratio / 255.0);
|
|
||||||
result.min = (model->frsky.channels[index-TELEMETRY_SOURCE_A1].offset * model->frsky.channels[index-TELEMETRY_SOURCE_A1].ratio) / 255.0;
|
|
||||||
result.max = model->frsky.channels[index-TELEMETRY_SOURCE_A1].ratio - (model->frsky.channels[index-TELEMETRY_SOURCE_A1].offset * model->frsky.channels[index-TELEMETRY_SOURCE_A1].ratio) / 255.0;
|
|
||||||
result.decimals = 0;
|
result.decimals = 0;
|
||||||
}
|
result.step = ratio / 255;
|
||||||
|
result.min = channel.offset * result.step;
|
||||||
|
result.max = ratio + result.min;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TELEMETRY_SOURCE_ALT:
|
case TELEMETRY_SOURCE_ALT:
|
||||||
|
|
|
@ -296,7 +296,7 @@ class RawSourceRange
|
||||||
}
|
}
|
||||||
|
|
||||||
float getValue(int value) {
|
float getValue(int value) {
|
||||||
return round(float(value) * step);
|
return min + float(value) * step;
|
||||||
}
|
}
|
||||||
|
|
||||||
int decimals;
|
int decimals;
|
||||||
|
@ -737,6 +737,14 @@ class FrSkyChannelData {
|
||||||
unsigned int multiplier;
|
unsigned int multiplier;
|
||||||
FrSkyAlarmData alarms[2];
|
FrSkyAlarmData alarms[2];
|
||||||
|
|
||||||
|
float getRatio()
|
||||||
|
{
|
||||||
|
if (type==0 || type==1 || type==2)
|
||||||
|
return float(ratio << multiplier) / 10.0;
|
||||||
|
else
|
||||||
|
return ratio << multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
void clear() { memset(this, 0, sizeof(FrSkyChannelData)); }
|
void clear() { memset(this, 0, sizeof(FrSkyChannelData)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1007,8 +1015,8 @@ enum Capability {
|
||||||
GvarsHaveSources,
|
GvarsHaveSources,
|
||||||
GvarsName,
|
GvarsName,
|
||||||
NoTelemetryProtocol,
|
NoTelemetryProtocol,
|
||||||
TelemetryCSFields,
|
TelemetryCustomScreens,
|
||||||
TelemetryColsCSFields,
|
TelemetryCustomScreensFieldsPerLine,
|
||||||
TelemetryRSSIModel,
|
TelemetryRSSIModel,
|
||||||
TelemetryAlarm,
|
TelemetryAlarm,
|
||||||
TelemetryInternalAlarm,
|
TelemetryInternalAlarm,
|
||||||
|
|
|
@ -610,24 +610,12 @@ int Open9xInterface::getCapability(const Capability capability)
|
||||||
return TM_HASTELEMETRY|TM_HASOFFSET|TM_HASWSHH;
|
return TM_HASTELEMETRY|TM_HASOFFSET|TM_HASWSHH;
|
||||||
case TelemetryBars:
|
case TelemetryBars:
|
||||||
return 1;
|
return 1;
|
||||||
case TelemetryCSFields:
|
case TelemetryCustomScreens:
|
||||||
if (IS_TARANIS(board)) {
|
return IS_TARANIS(board) ? 3 : 2;
|
||||||
return 36;
|
case TelemetryCustomScreensFieldsPerLine:
|
||||||
} else {
|
return IS_TARANIS(board) ? 3 : 2;
|
||||||
return IS_ARM(board) ? 24 : 16;
|
|
||||||
}
|
|
||||||
case TelemetryColsCSFields:
|
|
||||||
if (IS_TARANIS(board)) {
|
|
||||||
return 3;
|
|
||||||
} else {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
case NoTelemetryProtocol:
|
case NoTelemetryProtocol:
|
||||||
if (IS_TARANIS(board)) {
|
return IS_TARANIS(board) ? 1 : 0;
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
case TelemetryUnits:
|
case TelemetryUnits:
|
||||||
return 0;
|
return 0;
|
||||||
case TelemetryBlades:
|
case TelemetryBlades:
|
||||||
|
|
|
@ -42,6 +42,7 @@ set(modeledit_UIS
|
||||||
setup_module.ui
|
setup_module.ui
|
||||||
flightmode.ui
|
flightmode.ui
|
||||||
telemetry_analog.ui
|
telemetry_analog.ui
|
||||||
|
telemetry_customscreen.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(name ${modeledit_NAMES})
|
foreach(name ${modeledit_NAMES})
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "telemetry.h"
|
#include "telemetry.h"
|
||||||
#include "ui_telemetry.h"
|
#include "ui_telemetry.h"
|
||||||
#include "ui_telemetry_analog.h"
|
#include "ui_telemetry_analog.h"
|
||||||
|
#include "ui_telemetry_customscreen.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
TelemetryAnalog::TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog):
|
TelemetryAnalog::TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog):
|
||||||
|
@ -11,15 +12,13 @@ TelemetryAnalog::TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog):
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
float ratio;
|
float ratio = analog.getRatio();
|
||||||
|
|
||||||
if (analog.type==0 || analog.type==1 || analog.type==2) {
|
if (analog.type==0 || analog.type==1 || analog.type==2) {
|
||||||
ratio = (analog.ratio<<analog.multiplier)/10.0;
|
|
||||||
ui->RatioSB->setDecimals(1);
|
ui->RatioSB->setDecimals(1);
|
||||||
ui->RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
|
ui->RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ratio = analog.ratio<<analog.multiplier;
|
|
||||||
ui->RatioSB->setDecimals(0);
|
ui->RatioSB->setDecimals(0);
|
||||||
ui->RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
|
ui->RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
|
||||||
}
|
}
|
||||||
|
@ -44,69 +43,44 @@ TelemetryAnalog::TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog):
|
||||||
|
|
||||||
void TelemetryAnalog::update()
|
void TelemetryAnalog::update()
|
||||||
{
|
{
|
||||||
float ratio, alarm1value, alarm2value;
|
float ratio = analog.getRatio();
|
||||||
if (analog.ratio==0) {
|
float step = ratio / 255;
|
||||||
ui->alarm1ValueSB->setMinimum(0);
|
float mini = (ratio * analog.offset) / 255;
|
||||||
ui->alarm1ValueSB->setMaximum(0);
|
float maxi = mini + ratio;
|
||||||
ui->alarm2ValueSB->setMinimum(0);
|
|
||||||
ui->alarm2ValueSB->setMaximum(0);
|
|
||||||
ui->CalibSB->setMinimum(0);
|
|
||||||
ui->CalibSB->setMaximum(0);
|
|
||||||
ui->CalibSB->setValue(0);
|
|
||||||
ui->alarm1ValueSB->setValue(0);
|
|
||||||
ui->alarm2ValueSB->setValue(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (analog.type==0 || analog.type==1 || analog.type==2) {
|
ui->alarm1ValueSB->setDecimals(2);
|
||||||
ratio=(analog.ratio<<analog.multiplier)/10.0;
|
ui->alarm1ValueSB->setSingleStep(step);
|
||||||
ui->alarm1ValueSB->setDecimals(2);
|
ui->alarm1ValueSB->setMinimum(mini);
|
||||||
ui->alarm1ValueSB->setSingleStep(ratio/255.0);
|
ui->alarm1ValueSB->setMaximum(maxi);
|
||||||
ui->alarm2ValueSB->setDecimals(2);
|
ui->alarm1ValueSB->setValue(mini + step*analog.alarms[0].value);
|
||||||
ui->alarm2ValueSB->setSingleStep(ratio/255.0);
|
|
||||||
ui->alarm1ValueSB->setMinimum((analog.ratio*1.0*analog.offset)/2550.0);
|
ui->alarm2ValueSB->setDecimals(2);
|
||||||
ui->alarm1ValueSB->setMaximum(ratio+(analog.ratio*1.0*analog.offset)/2550.0);
|
ui->alarm2ValueSB->setSingleStep(step);
|
||||||
ui->alarm2ValueSB->setMinimum((analog.offset*1.0*analog.ratio)/2550.0);
|
ui->alarm2ValueSB->setMinimum(mini);
|
||||||
ui->alarm2ValueSB->setMaximum(ratio+(analog.offset*1.0*analog.ratio)/2550.0);
|
ui->alarm2ValueSB->setMaximum(maxi);
|
||||||
}
|
ui->alarm2ValueSB->setValue(mini + step*analog.alarms[1].value);
|
||||||
else {
|
|
||||||
ratio=analog.ratio<<analog.multiplier;
|
ui->CalibSB->setDecimals(2);
|
||||||
ui->alarm1ValueSB->setDecimals(2);
|
ui->CalibSB->setMaximum(step*127);
|
||||||
ui->alarm1ValueSB->setSingleStep(ratio/255.0);
|
ui->CalibSB->setMinimum(-step*128);
|
||||||
ui->alarm2ValueSB->setDecimals(2);
|
ui->CalibSB->setSingleStep(step);
|
||||||
ui->alarm2ValueSB->setSingleStep(ratio/255.0);
|
ui->CalibSB->setValue(mini);
|
||||||
ui->alarm1ValueSB->setMinimum((analog.offset*1.0*analog.ratio)/255.0);
|
|
||||||
ui->alarm1ValueSB->setMaximum(ratio+(analog.offset*1.0*analog.ratio)/255.0);
|
|
||||||
ui->alarm2ValueSB->setMinimum((analog.offset*1.0*analog.ratio)/255.0);
|
|
||||||
ui->alarm2ValueSB->setMaximum(ratio+(analog.offset*1.0*analog.ratio)/255.0);
|
|
||||||
}
|
|
||||||
ui->CalibSB->setDecimals(2);
|
|
||||||
ui->CalibSB->setMaximum((ratio*127)/255.0);
|
|
||||||
ui->CalibSB->setMinimum((-ratio*128)/255.0);
|
|
||||||
ui->CalibSB->setSingleStep(ratio/255.0);
|
|
||||||
ui->CalibSB->setValue((analog.offset*ratio)/255);
|
|
||||||
alarm1value=ratio*(analog.alarms[0].value/255.0+analog.offset/255.0);
|
|
||||||
alarm2value=ratio*(analog.alarms[1].value/255.0+analog.offset/255.0);;
|
|
||||||
ui->alarm1ValueSB->setValue(alarm1value);
|
|
||||||
ui->alarm2ValueSB->setValue(alarm2value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryAnalog::on_UnitCB_currentIndexChanged(int index)
|
void TelemetryAnalog::on_UnitCB_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
float ratio;
|
float ratio = analog.getRatio();
|
||||||
analog.type=index;
|
analog.type = index;
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
ui->RatioSB->setDecimals(1);
|
ui->RatioSB->setDecimals(1);
|
||||||
ui->RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
|
ui->RatioSB->setMaximum(25.5*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
|
||||||
ratio=(analog.ratio<<analog.multiplier)/10.0;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ui->RatioSB->setDecimals(0);
|
ui->RatioSB->setDecimals(0);
|
||||||
ui->RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
|
ui->RatioSB->setMaximum(255*GetEepromInterface()->getCapability(TelemetryMaxMultiplier));
|
||||||
ratio=(analog.ratio<<analog.multiplier);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ui->RatioSB->setValue(ratio);
|
ui->RatioSB->setValue(ratio);
|
||||||
|
@ -127,7 +101,7 @@ void TelemetryAnalog::on_RatioSB_valueChanged()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
analog.multiplier = findmult(ui->RatioSB->value(), 255);
|
analog.multiplier = findmult(ui->RatioSB->value(), 255);
|
||||||
float singlestep =(1<<analog.multiplier);
|
float singlestep = (1<<analog.multiplier);
|
||||||
lock = true;
|
lock = true;
|
||||||
ui->RatioSB->setSingleStep(singlestep);
|
ui->RatioSB->setSingleStep(singlestep);
|
||||||
ui->RatioSB->setValue(round(ui->RatioSB->value()/singlestep)*singlestep);
|
ui->RatioSB->setValue(round(ui->RatioSB->value()/singlestep)*singlestep);
|
||||||
|
@ -139,15 +113,17 @@ void TelemetryAnalog::on_RatioSB_valueChanged()
|
||||||
|
|
||||||
void TelemetryAnalog::on_RatioSB_editingFinished()
|
void TelemetryAnalog::on_RatioSB_editingFinished()
|
||||||
{
|
{
|
||||||
|
if (!lock) {
|
||||||
float ratio, calib, alarm1value,alarm2value;
|
float ratio, calib, alarm1value,alarm2value;
|
||||||
if (lock) return;
|
|
||||||
if (analog.type==0 || analog.type==1 || analog.type==2) {
|
if (analog.type==0 || analog.type==1 || analog.type==2) {
|
||||||
analog.multiplier = findmult(ui->RatioSB->value(), 25.5);
|
analog.multiplier = findmult(ui->RatioSB->value(), 25.5);
|
||||||
ui->CalibSB->setSingleStep((1<<analog.multiplier)/10.0);
|
ui->CalibSB->setSingleStep((1<<analog.multiplier)/10.0);
|
||||||
ui->alarm1ValueSB->setSingleStep((1<<analog.multiplier)/10.0);
|
ui->alarm1ValueSB->setSingleStep((1<<analog.multiplier)/10.0);
|
||||||
ui->alarm2ValueSB->setSingleStep((1<<analog.multiplier)/10.0);
|
ui->alarm2ValueSB->setSingleStep((1<<analog.multiplier)/10.0);
|
||||||
analog.ratio = ((int)(round(ui->RatioSB->value()*10))/(1 <<analog.multiplier));
|
analog.ratio = ((int)(round(ui->RatioSB->value()*10))/(1 <<analog.multiplier));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
analog.multiplier = findmult(ui->RatioSB->value(), 255);
|
analog.multiplier = findmult(ui->RatioSB->value(), 255);
|
||||||
ui->CalibSB->setSingleStep(1<<analog.multiplier);
|
ui->CalibSB->setSingleStep(1<<analog.multiplier);
|
||||||
ui->alarm1ValueSB->setSingleStep(1<<analog.multiplier);
|
ui->alarm1ValueSB->setSingleStep(1<<analog.multiplier);
|
||||||
|
@ -171,7 +147,8 @@ void TelemetryAnalog::on_RatioSB_editingFinished()
|
||||||
if (calib>0) {
|
if (calib>0) {
|
||||||
if (calib>((ratio*127)/255)) {
|
if (calib>((ratio*127)/255)) {
|
||||||
analog.offset=127;
|
analog.offset=127;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
analog.offset=round(calib*255/ratio);
|
analog.offset=round(calib*255/ratio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,18 +162,15 @@ void TelemetryAnalog::on_RatioSB_editingFinished()
|
||||||
analog.alarms[0].value=round((alarm1value*255-analog.offset*(analog.ratio<<analog.multiplier))/(analog.ratio<<analog.multiplier));
|
analog.alarms[0].value=round((alarm1value*255-analog.offset*(analog.ratio<<analog.multiplier))/(analog.ratio<<analog.multiplier));
|
||||||
analog.alarms[1].value=round((alarm2value*255-analog.offset*(analog.ratio<<analog.multiplier))/(analog.ratio<<analog.multiplier));
|
analog.alarms[1].value=round((alarm2value*255-analog.offset*(analog.ratio<<analog.multiplier))/(analog.ratio<<analog.multiplier));
|
||||||
update();
|
update();
|
||||||
// TODO ? telBarUpdate();
|
|
||||||
emit modified();
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryAnalog::on_CalibSB_editingFinished()
|
void TelemetryAnalog::on_CalibSB_editingFinished()
|
||||||
{
|
{
|
||||||
float ratio,calib,alarm1value,alarm2value;
|
float ratio = analog.getRatio();
|
||||||
if (analog.type==0 || analog.type==1 || analog.type==2) {
|
float calib,alarm1value,alarm2value;
|
||||||
ratio=(analog.ratio<<analog.multiplier)/10.0;
|
|
||||||
} else {
|
|
||||||
ratio=analog.ratio<<analog.multiplier;
|
|
||||||
}
|
|
||||||
if (ratio!=0) {
|
if (ratio!=0) {
|
||||||
analog.offset = round((255*ui->CalibSB->value()/ratio));
|
analog.offset = round((255*ui->CalibSB->value()/ratio));
|
||||||
calib=ratio*analog.offset/255.0;
|
calib=ratio*analog.offset/255.0;
|
||||||
|
@ -204,7 +178,8 @@ void TelemetryAnalog::on_CalibSB_editingFinished()
|
||||||
alarm2value=ui->alarm2ValueSB->value();
|
alarm2value=ui->alarm2ValueSB->value();
|
||||||
if (alarm1value<calib) {
|
if (alarm1value<calib) {
|
||||||
alarm1value=calib;
|
alarm1value=calib;
|
||||||
} else if (alarm1value>(ratio+calib)) {
|
}
|
||||||
|
else if (alarm1value>(ratio+calib)) {
|
||||||
alarm1value=ratio+calib;
|
alarm1value=ratio+calib;
|
||||||
}
|
}
|
||||||
if (alarm2value<calib) {
|
if (alarm2value<calib) {
|
||||||
|
@ -220,37 +195,37 @@ void TelemetryAnalog::on_CalibSB_editingFinished()
|
||||||
analog.alarms[1].value=0;
|
analog.alarms[1].value=0;
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
// TODO ? telBarUpdate();
|
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryAnalog::on_alarm1LevelCB_currentIndexChanged(int index)
|
void TelemetryAnalog::on_alarm1LevelCB_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
analog.alarms[0].level = index;
|
analog.alarms[0].level = index;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TelemetryAnalog::on_alarm1GreaterCB_currentIndexChanged(int index)
|
void TelemetryAnalog::on_alarm1GreaterCB_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
analog.alarms[0].greater = index;
|
analog.alarms[0].greater = index;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryAnalog::on_alarm1ValueSB_editingFinished()
|
void TelemetryAnalog::on_alarm1ValueSB_editingFinished()
|
||||||
{
|
{
|
||||||
float ratio, calib, alarm1value;
|
float ratio = analog.getRatio();
|
||||||
ratio=analog.ratio<<analog.multiplier;
|
float calib, alarm1value;
|
||||||
|
|
||||||
calib=analog.offset;
|
calib=analog.offset;
|
||||||
alarm1value=ui->alarm1ValueSB->value();
|
alarm1value=ui->alarm1ValueSB->value();
|
||||||
if (analog.type==0) {
|
|
||||||
ratio/=10;
|
|
||||||
}
|
|
||||||
if (alarm1value<((calib*ratio)/255)) {
|
if (alarm1value<((calib*ratio)/255)) {
|
||||||
analog.alarms[0].value=0;
|
analog.alarms[0].value=0;
|
||||||
} else if (alarm1value>(ratio+(calib*ratio)/255)) {
|
}
|
||||||
|
else if (alarm1value>(ratio+(calib*ratio)/255)) {
|
||||||
analog.alarms[0].value=255;
|
analog.alarms[0].value=255;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
analog.alarms[0].value = round((alarm1value-((calib*ratio)/255))/ratio*255);
|
analog.alarms[0].value = round((alarm1value-((calib*ratio)/255))/ratio*255);
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
|
@ -259,28 +234,26 @@ void TelemetryAnalog::on_alarm1ValueSB_editingFinished()
|
||||||
|
|
||||||
void TelemetryAnalog::on_alarm2LevelCB_currentIndexChanged(int index)
|
void TelemetryAnalog::on_alarm2LevelCB_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
analog.alarms[1].level = index;
|
analog.alarms[1].level = index;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryAnalog::on_alarm2GreaterCB_currentIndexChanged(int index)
|
void TelemetryAnalog::on_alarm2GreaterCB_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
analog.alarms[1].greater = index;
|
analog.alarms[1].greater = index;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryAnalog::on_alarm2ValueSB_editingFinished()
|
void TelemetryAnalog::on_alarm2ValueSB_editingFinished()
|
||||||
{
|
{
|
||||||
float ratio, calib, alarm2value;
|
float calib, alarm2value;
|
||||||
ratio = analog.ratio<<analog.multiplier;
|
float ratio = analog.getRatio();
|
||||||
calib = analog.offset;
|
calib = analog.offset;
|
||||||
alarm2value = ui->alarm2ValueSB->value();
|
alarm2value = ui->alarm2ValueSB->value();
|
||||||
if (analog.type==0) {
|
|
||||||
ratio/=10;
|
|
||||||
}
|
|
||||||
if (alarm2value<((calib*ratio)/255)) {
|
if (alarm2value<((calib*ratio)/255)) {
|
||||||
analog.alarms[1].value=0;
|
analog.alarms[1].value=0;
|
||||||
} else if (alarm2value>(ratio+(calib*ratio)/255)) {
|
}
|
||||||
|
else if (alarm2value>(ratio+(calib*ratio)/255)) {
|
||||||
analog.alarms[1].value=255;
|
analog.alarms[1].value=255;
|
||||||
} else {
|
} else {
|
||||||
analog.alarms[1].value = round((alarm2value-((calib*ratio)/255))/ratio*255);
|
analog.alarms[1].value = round((alarm2value-((calib*ratio)/255))/ratio*255);
|
||||||
|
@ -296,41 +269,182 @@ TelemetryAnalog::~TelemetryAnalog()
|
||||||
|
|
||||||
/******************************************************/
|
/******************************************************/
|
||||||
|
|
||||||
|
TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen):
|
||||||
|
ModelPanel(parent, model),
|
||||||
|
ui(new Ui::TelemetryCustomScreen),
|
||||||
|
screen(screen)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
for (int l=0; l<4; l++) {
|
||||||
|
for (int c=0; c<GetEepromInterface()->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
|
||||||
|
fieldsCB[l][c] = new QComboBox(this);
|
||||||
|
fieldsCB[l][c]->setProperty("index", c + (l<<8));
|
||||||
|
populateCustomScreenFieldCB(fieldsCB[l][c], screen.body.lines[l].source[c], (l<4), model.frsky.usrProto);
|
||||||
|
ui->screenNumsLayout->addWidget(fieldsCB[l][c], l, c, 1, 1);
|
||||||
|
connect(fieldsCB[l][c], SIGNAL(currentIndexChanged(int)), this, SLOT(customFieldChanged(int)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int l=0; l<4; l++) {
|
||||||
|
barsCB[l] = new QComboBox(this);
|
||||||
|
barsCB[l]->setProperty("index", l);
|
||||||
|
populateCustomScreenFieldCB(barsCB[l], screen.body.bars[l].source, false, model.frsky.usrProto);
|
||||||
|
connect(barsCB[l], SIGNAL(currentIndexChanged(int)), this, SLOT(barSourceChanged(int)));
|
||||||
|
ui->screenBarsLayout->addWidget(barsCB[l], l, 0, 1, 1);
|
||||||
|
|
||||||
|
minSB[l] = new QDoubleSpinBox(this);
|
||||||
|
minSB[l]->setProperty("index", l);
|
||||||
|
connect(minSB[l], SIGNAL(valueChanged(double)), this, SLOT(barMinChanged(double)));
|
||||||
|
ui->screenBarsLayout->addWidget(minSB[l], l, 1, 1, 1);
|
||||||
|
|
||||||
|
QLabel * label = new QLabel(this);
|
||||||
|
label->setAutoFillBackground(false);
|
||||||
|
label->setStyleSheet(QString::fromUtf8("Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),)\n"""));
|
||||||
|
label->setFrameShape(QFrame::Panel);
|
||||||
|
label->setFrameShadow(QFrame::Raised);
|
||||||
|
label->setAlignment(Qt::AlignCenter);
|
||||||
|
ui->screenBarsLayout->addWidget(label, l, 2, 1, 1);
|
||||||
|
|
||||||
|
maxSB[l] = new QDoubleSpinBox(this);
|
||||||
|
maxSB[l]->setProperty("index", l);
|
||||||
|
connect(maxSB[l], SIGNAL(valueChanged(double)), this, SLOT(barMaxChanged(double)));
|
||||||
|
ui->screenBarsLayout->addWidget(maxSB[l], l, 3, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
TelemetryCustomScreen::~TelemetryCustomScreen()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetryCustomScreen::update()
|
||||||
|
{
|
||||||
|
lock = true;
|
||||||
|
|
||||||
|
ui->screenType->setCurrentIndex(screen.type);
|
||||||
|
ui->screenNums->setVisible(screen.type == 0);
|
||||||
|
ui->screenBars->setVisible(screen.type != 0);
|
||||||
|
|
||||||
|
if (screen.type == 0) {
|
||||||
|
for (int l=0; l<4; l++) {
|
||||||
|
for (int c=0; c<GetEepromInterface()->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
|
||||||
|
fieldsCB[l][c]->setCurrentIndex(screen.body.lines[l].source[c]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
updateBar(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lock = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetryCustomScreen::updateBar(int line)
|
||||||
|
{
|
||||||
|
int index = screen.body.bars[line].source;
|
||||||
|
barsCB[line]->setCurrentIndex(index);
|
||||||
|
if (index) {
|
||||||
|
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model);
|
||||||
|
RawSourceRange range = source.getRange(true);
|
||||||
|
int max = round((range.max - range.min) / range.step);
|
||||||
|
if (255-screen.body.bars[line].barMax > max)
|
||||||
|
screen.body.bars[line].barMax = 255 - max;
|
||||||
|
minSB[line]->setEnabled(true);
|
||||||
|
minSB[line]->setDecimals(range.decimals);
|
||||||
|
minSB[line]->setMinimum(range.min);
|
||||||
|
minSB[line]->setMaximum(range.max);
|
||||||
|
minSB[line]->setSingleStep(range.step);
|
||||||
|
minSB[line]->setValue(range.getValue(screen.body.bars[line].barMin));
|
||||||
|
maxSB[line]->setEnabled(true);
|
||||||
|
maxSB[line]->setDecimals(range.decimals);
|
||||||
|
maxSB[line]->setMinimum(range.min);
|
||||||
|
maxSB[line]->setMaximum(range.max);
|
||||||
|
maxSB[line]->setSingleStep(range.step);
|
||||||
|
maxSB[line]->setValue(range.getValue(255 - screen.body.bars[line].barMax));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
minSB[line]->setDisabled(true);
|
||||||
|
maxSB[line]->setDisabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetryCustomScreen::on_screenType_currentIndexChanged(int index)
|
||||||
|
{
|
||||||
|
if (!lock) {
|
||||||
|
memset(&screen.body, 0, sizeof(screen.body));
|
||||||
|
screen.type = index;
|
||||||
|
update();
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetryCustomScreen::customFieldChanged(int value)
|
||||||
|
{
|
||||||
|
int index = sender()->property("index").toInt();
|
||||||
|
screen.body.lines[index/256].source[index%256] = value;
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetryCustomScreen::barSourceChanged(int index)
|
||||||
|
{
|
||||||
|
QComboBox * cb = qobject_cast<QComboBox*>(sender());
|
||||||
|
int line = cb->property("index").toInt();
|
||||||
|
screen.body.bars[line].source = index;
|
||||||
|
screen.body.bars[line].barMin = 0;
|
||||||
|
screen.body.bars[line].barMax = 0;
|
||||||
|
updateBar(line);
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetryCustomScreen::barMinChanged(double value)
|
||||||
|
{
|
||||||
|
if (!lock) {
|
||||||
|
int line = sender()->property("index").toInt();
|
||||||
|
screen.body.bars[line].barMin = round((value-minSB[line]->minimum()) / minSB[line]->singleStep());
|
||||||
|
// TODO set min (maxSB)
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TelemetryCustomScreen::barMaxChanged(double value)
|
||||||
|
{
|
||||||
|
if (!lock) {
|
||||||
|
int line = sender()->property("index").toInt();
|
||||||
|
screen.body.bars[line].barMax = 255 - round((value-minSB[line]->minimum()) / maxSB[line]->singleStep());
|
||||||
|
// TODO set max (minSB)
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************/
|
||||||
|
|
||||||
TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model):
|
TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model):
|
||||||
ModelPanel(parent, model),
|
ModelPanel(parent, model),
|
||||||
ui(new Ui::Telemetry)
|
ui(new Ui::Telemetry)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
if (GetEepromInterface()->getCapability(NoTelemetryProtocol)) {
|
||||||
|
model.frsky.usrProto = 1;
|
||||||
|
}
|
||||||
|
|
||||||
analogs[0] = new TelemetryAnalog(this, model.frsky.channels[0]);
|
analogs[0] = new TelemetryAnalog(this, model.frsky.channels[0]);
|
||||||
ui->A1Layout->addWidget(analogs[0]);
|
ui->A1Layout->addWidget(analogs[0]);
|
||||||
connect(analogs[0], SIGNAL(modified()), this, SLOT(onAnalogModified()));
|
connect(analogs[0], SIGNAL(modified()), this, SLOT(onAnalogModified()));
|
||||||
|
|
||||||
analogs[1] = new TelemetryAnalog(this, model.frsky.channels[1]);
|
analogs[1] = new TelemetryAnalog(this, model.frsky.channels[1]);
|
||||||
ui->A2Layout->addWidget(analogs[1]);
|
ui->A2Layout->addWidget(analogs[1]);
|
||||||
connect(analogs[1], SIGNAL(modified()), this, SLOT(onAnalogModified()));
|
connect(analogs[1], SIGNAL(modified()), this, SLOT(onAnalogModified()));
|
||||||
|
|
||||||
QGroupBox* barsgb[3] = { ui->CS1Bars, ui->CS2Bars, ui->CS3Bars };
|
for (int i=0; i<GetEepromInterface()->getCapability(TelemetryCustomScreens); i++) {
|
||||||
QGroupBox* numsgb[3] = { ui->CS1Nums, ui->CS2Nums, ui->CS3Nums };
|
TelemetryCustomScreen * tab = new TelemetryCustomScreen(this, model, model.frsky.screens[i]);
|
||||||
|
ui->customScreens->addTab(tab, tr("Telemetry screen %1").arg(i+1));
|
||||||
QComboBox* barscb[12] = { ui->telBarCS1B1_CB, ui->telBarCS1B2_CB, ui->telBarCS1B3_CB, ui->telBarCS1B4_CB,
|
}
|
||||||
ui->telBarCS2B1_CB, ui->telBarCS2B2_CB, ui->telBarCS2B3_CB, ui->telBarCS2B4_CB,
|
|
||||||
ui->telBarCS3B1_CB, ui->telBarCS3B2_CB, ui->telBarCS3B3_CB, ui->telBarCS3B4_CB};
|
|
||||||
QDoubleSpinBox* minSB[12] = { ui->telMinCS1SB1, ui->telMinCS1SB2, ui->telMinCS1SB3, ui->telMinCS1SB4,
|
|
||||||
ui->telMinCS2SB1, ui->telMinCS2SB2, ui->telMinCS2SB3, ui->telMinCS2SB4,
|
|
||||||
ui->telMinCS3SB1, ui->telMinCS3SB2, ui->telMinCS3SB3, ui->telMinCS3SB4};
|
|
||||||
QDoubleSpinBox* maxSB[12] = { ui->telMaxCS1SB1, ui->telMaxCS1SB2, ui->telMaxCS1SB3, ui->telMaxCS1SB4,
|
|
||||||
ui->telMaxCS2SB1, ui->telMaxCS2SB2, ui->telMaxCS2SB3, ui->telMaxCS2SB4,
|
|
||||||
ui->telMaxCS3SB1, ui->telMaxCS3SB2, ui->telMaxCS3SB3, ui->telMaxCS3SB4};
|
|
||||||
QComboBox* tmp[36] = { ui->telemetryCS1F1_CB, ui->telemetryCS1F2_CB, ui->telemetryCS1F3_CB, ui->telemetryCS1F4_CB, ui->telemetryCS1F5_CB, ui->telemetryCS1F6_CB, ui->telemetryCS1F7_CB, ui->telemetryCS1F8_CB, ui->telemetryCS1F9_CB, ui->telemetryCS1F10_CB, ui->telemetryCS1F11_CB, ui->telemetryCS1F12_CB,
|
|
||||||
ui->telemetryCS2F1_CB, ui->telemetryCS2F2_CB, ui->telemetryCS2F3_CB, ui->telemetryCS2F4_CB, ui->telemetryCS2F5_CB, ui->telemetryCS2F6_CB, ui->telemetryCS2F7_CB, ui->telemetryCS2F8_CB, ui->telemetryCS2F9_CB, ui->telemetryCS2F10_CB, ui->telemetryCS2F11_CB, ui->telemetryCS2F12_CB,
|
|
||||||
ui->telemetryCS3F1_CB, ui->telemetryCS3F2_CB, ui->telemetryCS3F3_CB, ui->telemetryCS3F4_CB, ui->telemetryCS3F5_CB, ui->telemetryCS3F6_CB, ui->telemetryCS3F7_CB, ui->telemetryCS3F8_CB, ui->telemetryCS3F9_CB, ui->telemetryCS3F10_CB, ui->telemetryCS3F11_CB, ui->telemetryCS3F12_CB};
|
|
||||||
|
|
||||||
memcpy(barsGB, barsgb, sizeof(barsGB));
|
|
||||||
memcpy(numsGB, numsgb, sizeof(numsGB));
|
|
||||||
memcpy(barsCB, barscb, sizeof(barsCB));
|
|
||||||
memcpy(this->maxSB, maxSB, sizeof(this->maxSB));
|
|
||||||
memcpy(this->minSB, minSB, sizeof(this->minSB));
|
|
||||||
memcpy(csf, tmp, sizeof(csf));
|
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
@ -346,19 +460,6 @@ void TelemetryPanel::setup()
|
||||||
QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString();
|
QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString();
|
||||||
|
|
||||||
lock=true;
|
lock=true;
|
||||||
ui->telemetryCSType1->setCurrentIndex(model.frsky.screens[0].type);
|
|
||||||
ui->telemetryCSType2->setCurrentIndex(model.frsky.screens[1].type);
|
|
||||||
ui->telemetryCSType3->setCurrentIndex(model.frsky.screens[2].type);
|
|
||||||
|
|
||||||
for (int i=0; i<3; i++) {
|
|
||||||
bool isNum = (model.frsky.screens[i].type==0);
|
|
||||||
barsGB[i]->setVisible(!isNum);
|
|
||||||
numsGB[i]->setVisible(isNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(ui->telemetryCSType1,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int)));
|
|
||||||
connect(ui->telemetryCSType2,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int)));
|
|
||||||
connect(ui->telemetryCSType3,SIGNAL(currentIndexChanged(int)),this,SLOT(ScreenTypeCBcurrentIndexChanged(int)));
|
|
||||||
|
|
||||||
//frsky Settings
|
//frsky Settings
|
||||||
if (!GetEepromInterface()->getCapability(TelemetryRSSIModel) ) {
|
if (!GetEepromInterface()->getCapability(TelemetryRSSIModel) ) {
|
||||||
|
@ -397,7 +498,8 @@ void TelemetryPanel::setup()
|
||||||
ui->VarioLabel_4->hide();
|
ui->VarioLabel_4->hide();
|
||||||
ui->varioSourceCB->hide();
|
ui->varioSourceCB->hide();
|
||||||
ui->varioSource_label->hide();
|
ui->varioSource_label->hide();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (!GetEepromInterface()->getCapability(HasVarioSink)) {
|
if (!GetEepromInterface()->getCapability(HasVarioSink)) {
|
||||||
ui->varioLimitMinOff_ChkB->hide();
|
ui->varioLimitMinOff_ChkB->hide();
|
||||||
ui->varioLimitMin_DSB->hide();
|
ui->varioLimitMin_DSB->hide();
|
||||||
|
@ -431,44 +533,12 @@ void TelemetryPanel::setup()
|
||||||
if (!(GetEepromInterface()->getCapability(HasAltitudeSel)||GetEepromInterface()->getCapability(HasVario))) {
|
if (!(GetEepromInterface()->getCapability(HasAltitudeSel)||GetEepromInterface()->getCapability(HasVario))) {
|
||||||
ui->altimetryGB->hide();
|
ui->altimetryGB->hide();
|
||||||
}
|
}
|
||||||
if (GetEepromInterface()->getCapability(NoTelemetryProtocol)) {
|
|
||||||
model.frsky.usrProto=1;
|
|
||||||
ui->frskyProtoCB->setDisabled(true);
|
|
||||||
} else {
|
|
||||||
ui->frskyProtoCB->setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetEepromInterface()->getCapability(TelemetryCSFields)==0) {
|
if (GetEepromInterface()->getCapability(NoTelemetryProtocol)) {
|
||||||
ui->groupBox_5->hide();
|
ui->frskyProtoCB->setDisabled(true);
|
||||||
} else {
|
}
|
||||||
if (GetEepromInterface()->getCapability(TelemetryCSFields)==8) {
|
else {
|
||||||
ui->tabCsView->removeTab(1);
|
ui->frskyProtoCB->setEnabled(true);
|
||||||
ui->tabCsView->removeTab(2);
|
|
||||||
}
|
|
||||||
if (GetEepromInterface()->getCapability(TelemetryCSFields)==16) {
|
|
||||||
ui->tabCsView->removeTab(2);
|
|
||||||
}
|
|
||||||
int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields);
|
|
||||||
if (cols==0) cols=2;
|
|
||||||
for (int screen=0; screen<(GetEepromInterface()->getCapability(TelemetryCSFields)/(4*cols)); screen++) {
|
|
||||||
for (int c=0; c<cols; c++) {
|
|
||||||
for (int r=0; r<4; r++) {
|
|
||||||
int index=screen*12+c*4+r;
|
|
||||||
if (model.frsky.screens[screen].type==0) {
|
|
||||||
populateCustomScreenFieldCB(csf[index], model.frsky.screens[screen].body.lines[r].source[c], (r<4), model.frsky.usrProto);
|
|
||||||
} else {
|
|
||||||
populateCustomScreenFieldCB(csf[index], 0, (r<4), model.frsky.usrProto);
|
|
||||||
}
|
|
||||||
connect(csf[index], SIGNAL(currentIndexChanged(int)), this, SLOT(customFieldEdited()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int c=cols; c<3; c++) {
|
|
||||||
for (int r=0; r<4; r++) {
|
|
||||||
int index=screen*12+c*4+r;
|
|
||||||
csf[index]->hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GetEepromInterface()->getCapability(TelemetryUnits)) {
|
if (!GetEepromInterface()->getCapability(TelemetryUnits)) {
|
||||||
|
@ -479,9 +549,11 @@ void TelemetryPanel::setup()
|
||||||
}
|
}
|
||||||
ui->frskyUnitsCB->setCurrentIndex(index);
|
ui->frskyUnitsCB->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((GetEepromInterface()->getCapability(Telemetry)&TM_HASWSHH)) {
|
if ((GetEepromInterface()->getCapability(Telemetry)&TM_HASWSHH)) {
|
||||||
ui->frskyProtoCB->addItem(tr("Winged Shadow How High"));
|
ui->frskyProtoCB->addItem(tr("Winged Shadow How High"));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ui->frskyProtoCB->addItem(tr("Winged Shadow How High (not supported)"));
|
ui->frskyProtoCB->addItem(tr("Winged Shadow How High (not supported)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,40 +589,6 @@ void TelemetryPanel::setup()
|
||||||
ui->frskyCurrentCB->setCurrentIndex(model.frsky.currentSource);
|
ui->frskyCurrentCB->setCurrentIndex(model.frsky.currentSource);
|
||||||
ui->frskyVoltCB->setCurrentIndex(model.frsky.voltsSource);
|
ui->frskyVoltCB->setCurrentIndex(model.frsky.voltsSource);
|
||||||
|
|
||||||
for (int screen=0; screen<2;screen++) {
|
|
||||||
for (int rows=0; rows<4; rows++) {
|
|
||||||
for (int cols=0; cols<3; cols++) {
|
|
||||||
int index=screen*12+cols*4+rows;
|
|
||||||
populateCustomScreenFieldCB(csf[index], model.frsky.screens[screen].body.lines[rows].source[cols], (rows<4), model.frsky.usrProto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j=0; j<12; j++) {
|
|
||||||
int screen = j/4;
|
|
||||||
int field = j%4;
|
|
||||||
populateCustomScreenFieldCB(barsCB[j], model.frsky.screens[screen].body.bars[field].source, false, model.frsky.usrProto);
|
|
||||||
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, model.frsky.screens[screen].body.bars[field].source, &model);
|
|
||||||
RawSourceRange range = source.getRange(true);
|
|
||||||
minSB[j]->setDecimals(range.decimals);
|
|
||||||
minSB[j]->setMinimum(range.min);
|
|
||||||
minSB[j]->setMaximum(range.max);
|
|
||||||
minSB[j]->setSingleStep(range.step);
|
|
||||||
minSB[j]->setValue(range.getValue(model.frsky.screens[screen].body.bars[field].barMin));
|
|
||||||
maxSB[j]->setDecimals(range.decimals);
|
|
||||||
maxSB[j]->setMinimum(range.min);
|
|
||||||
maxSB[j]->setMaximum(range.max);
|
|
||||||
maxSB[j]->setSingleStep(range.step);
|
|
||||||
maxSB[j]->setValue(range.getValue(255 - model.frsky.screens[screen].body.bars[field].barMax));
|
|
||||||
if (model.frsky.screens[screen].body.bars[field].source==0 || model.frsky.screens[screen].type==0) {
|
|
||||||
minSB[j]->setDisabled(true);
|
|
||||||
maxSB[j]->setDisabled(true);
|
|
||||||
}
|
|
||||||
connect(barsCB[j], SIGNAL(currentIndexChanged(int)), this, SLOT(telBarCBcurrentIndexChanged(int)));
|
|
||||||
connect(maxSB[j], SIGNAL(editingFinished()), this, SLOT(telMaxSBeditingFinished()));
|
|
||||||
connect(minSB[j], SIGNAL(editingFinished()), this, SLOT(telMinSBeditingFinished()));
|
|
||||||
}
|
|
||||||
|
|
||||||
lock=false;
|
lock=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,316 +623,119 @@ void TelemetryPanel::on_frskyVoltCB_currentIndexChanged(int index)
|
||||||
|
|
||||||
void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index)
|
void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (lock) return;
|
model.frsky.usrProto = index;
|
||||||
int bindex[12];
|
emit modified();
|
||||||
lock=true;
|
|
||||||
for (int i=0; i<12; i++) {
|
|
||||||
bindex[i]=barsCB[i]->currentIndex();
|
|
||||||
model.frsky.usrProto=index;
|
|
||||||
populateCustomScreenFieldCB(barsCB[i], bindex[i], false, model.frsky.usrProto);
|
|
||||||
}
|
|
||||||
if (!GetEepromInterface()->getCapability(TelemetryCSFields)) {
|
|
||||||
ui->groupBox_5->hide();
|
|
||||||
} else {
|
|
||||||
for (int screen=0; screen<2;screen++) {
|
|
||||||
for (int rows=0; rows<4; rows++) {
|
|
||||||
for (int cols=0; cols<3; cols++) {
|
|
||||||
int index=screen*12+cols*4+rows;
|
|
||||||
populateCustomScreenFieldCB(csf[index], model.frsky.screens[screen].body.lines[rows].source[cols], (rows<4), model.frsky.usrProto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lock=false;
|
|
||||||
if (index==0) {
|
|
||||||
for (int i=0; i<12; i++) {
|
|
||||||
if (bindex[i]>2) {
|
|
||||||
barsCB[i]->setCurrentIndex(0);
|
|
||||||
} else {
|
|
||||||
barsCB[i]->setCurrentIndex(bindex[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (index==2) {
|
|
||||||
for (int i=0; i<12; i++) {
|
|
||||||
if (bindex[i]>3) {
|
|
||||||
barsCB[i]->setCurrentIndex(0);
|
|
||||||
} else {
|
|
||||||
barsCB[i]->setCurrentIndex(bindex[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int i=0; i<12; i++) {
|
|
||||||
barsCB[i]->setCurrentIndex(bindex[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit modified();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_rssiAlarm1CB_currentIndexChanged(int index) {
|
void TelemetryPanel::on_rssiAlarm1CB_currentIndexChanged(int index)
|
||||||
if (lock) return;
|
{
|
||||||
model.frsky.rssiAlarms[0].level=index;
|
model.frsky.rssiAlarms[0].level = index;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_rssiAlarm2CB_currentIndexChanged(int index) {
|
void TelemetryPanel::on_rssiAlarm2CB_currentIndexChanged(int index)
|
||||||
if (lock) return;
|
{
|
||||||
model.frsky.rssiAlarms[1].level=index;
|
model.frsky.rssiAlarms[1].level = index;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_rssiAlarm1SB_editingFinished()
|
void TelemetryPanel::on_rssiAlarm1SB_editingFinished()
|
||||||
{
|
{
|
||||||
if (lock) return;
|
model.frsky.rssiAlarms[0].value = ui->rssiAlarm1SB->value();
|
||||||
model.frsky.rssiAlarms[0].value=(ui->rssiAlarm1SB->value());
|
emit modified();
|
||||||
emit modified();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_rssiAlarm2SB_editingFinished()
|
void TelemetryPanel::on_rssiAlarm2SB_editingFinished()
|
||||||
{
|
{
|
||||||
if (lock) return;
|
model.frsky.rssiAlarms[1].value = ui->rssiAlarm2SB->value();
|
||||||
model.frsky.rssiAlarms[1].value=(ui->rssiAlarm2SB->value());
|
emit modified();
|
||||||
emit modified();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_AltitudeGPS_ChkB_toggled(bool checked)
|
void TelemetryPanel::on_AltitudeGPS_ChkB_toggled(bool checked)
|
||||||
{
|
{
|
||||||
if (lock) return;
|
model.frsky.FrSkyGpsAlt = checked;
|
||||||
model.frsky.FrSkyGpsAlt = checked;
|
emit modified();
|
||||||
emit modified();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_AltitudeToolbar_ChkB_toggled(bool checked)
|
void TelemetryPanel::on_AltitudeToolbar_ChkB_toggled(bool checked)
|
||||||
{
|
{
|
||||||
model.frsky.altitudeDisplayed = checked;
|
model.frsky.altitudeDisplayed = checked;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_varioSourceCB_currentIndexChanged(int index)
|
void TelemetryPanel::on_varioSourceCB_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (lock) return;
|
model.frsky.varioSource = index;
|
||||||
model.frsky.varioSource = index;
|
emit modified();
|
||||||
emit modified();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_varioLimitMin_DSB_editingFinished()
|
void TelemetryPanel::on_varioLimitMin_DSB_editingFinished()
|
||||||
{
|
{
|
||||||
if (lock) return;
|
model.frsky.varioMin = round(ui->varioLimitMin_DSB->value()+10);
|
||||||
model.frsky.varioMin= round(ui->varioLimitMin_DSB->value()+10);
|
emit modified();
|
||||||
emit modified();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_varioLimitMax_DSB_editingFinished()
|
void TelemetryPanel::on_varioLimitMax_DSB_editingFinished()
|
||||||
{
|
{
|
||||||
if (lock) return;
|
model.frsky.varioMax = round(ui->varioLimitMax_DSB->value()-10);
|
||||||
model.frsky.varioMax= round(ui->varioLimitMax_DSB->value()-10);
|
emit modified();
|
||||||
emit modified();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_varioLimitCenterMin_DSB_editingFinished()
|
void TelemetryPanel::on_varioLimitCenterMin_DSB_editingFinished()
|
||||||
{
|
{
|
||||||
if (lock) return;
|
if (!lock) {
|
||||||
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
|
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
|
||||||
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
|
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
|
||||||
}
|
}
|
||||||
model.frsky.varioCenterMin= round((ui->varioLimitCenterMin_DSB->value()+0.5)*10);
|
model.frsky.varioCenterMin = round((ui->varioLimitCenterMin_DSB->value()+0.5)*10);
|
||||||
emit modified();
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_varioLimitMinOff_ChkB_toggled(bool checked)
|
void TelemetryPanel::on_varioLimitMinOff_ChkB_toggled(bool checked)
|
||||||
{
|
{
|
||||||
if (lock) return;
|
if (!lock) {
|
||||||
model.frsky.varioCenterMin = -16;
|
model.frsky.varioCenterMin = -16;
|
||||||
if (!checked) {
|
if (!checked) {
|
||||||
lock=true;
|
lock=true;
|
||||||
ui->varioLimitCenterMin_DSB->setValue(-2.0);
|
ui->varioLimitCenterMin_DSB->setValue(-2.0);
|
||||||
ui->varioLimitCenterMin_DSB->setEnabled(true);
|
ui->varioLimitCenterMin_DSB->setEnabled(true);
|
||||||
lock=false;
|
lock=false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
ui->varioLimitCenterMin_DSB->setValue(-2.0);
|
ui->varioLimitCenterMin_DSB->setValue(-2.0);
|
||||||
ui->varioLimitCenterMin_DSB->setDisabled(true);
|
ui->varioLimitCenterMin_DSB->setDisabled(true);
|
||||||
}
|
}
|
||||||
emit modified();
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_varioLimitCenterMax_DSB_editingFinished()
|
void TelemetryPanel::on_varioLimitCenterMax_DSB_editingFinished()
|
||||||
{
|
{
|
||||||
if (lock) return;
|
if (!lock) {
|
||||||
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
|
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
|
||||||
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
|
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
|
||||||
}
|
}
|
||||||
model.frsky.varioCenterMax= round((ui->varioLimitCenterMax_DSB->value()-0.5)*10);
|
model.frsky.varioCenterMax = round((ui->varioLimitCenterMax_DSB->value()-0.5)*10);
|
||||||
emit modified();
|
emit modified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_fasOffset_DSB_editingFinished()
|
void TelemetryPanel::on_fasOffset_DSB_editingFinished()
|
||||||
{
|
{
|
||||||
model.frsky.fasOffset = ui->fasOffset_DSB->value()*10;
|
model.frsky.fasOffset = ui->fasOffset_DSB->value() * 10;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_mahCount_SB_editingFinished()
|
void TelemetryPanel::on_mahCount_SB_editingFinished()
|
||||||
{
|
{
|
||||||
model.frsky.storedMah = ui->mahCount_SB->value();
|
model.frsky.storedMah = ui->mahCount_SB->value();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_mahCount_ChkB_toggled(bool checked)
|
void TelemetryPanel::on_mahCount_ChkB_toggled(bool checked)
|
||||||
{
|
{
|
||||||
model.frsky.mAhPersistent = checked;
|
model.frsky.mAhPersistent = checked;
|
||||||
ui->mahCount_SB->setDisabled(!checked);
|
ui->mahCount_SB->setDisabled(!checked);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::telBarUpdate()
|
|
||||||
{
|
|
||||||
int index;
|
|
||||||
lock=true;
|
|
||||||
for (int i=0; i<12; i++) {
|
|
||||||
int screen=i/4;
|
|
||||||
index=barsCB[i]->currentIndex();
|
|
||||||
if (index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1 || index==TELEMETRY_SOURCE_A1_MIN || index==TELEMETRY_SOURCE_A2_MIN) {
|
|
||||||
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index, &model);
|
|
||||||
RawSourceRange range = source.getRange(true);
|
|
||||||
minSB[i]->setMinimum(range.min);
|
|
||||||
minSB[i]->setMaximum(range.max);
|
|
||||||
minSB[i]->setSingleStep(range.step);
|
|
||||||
maxSB[i]->setMinimum(range.min);
|
|
||||||
maxSB[i]->setMaximum(range.max);
|
|
||||||
maxSB[i]->setSingleStep(range.step);
|
|
||||||
minSB[i]->setValue(range.getValue(model.frsky.screens[screen].body.bars[i%4].barMin));
|
|
||||||
maxSB[i]->setValue(range.getValue(255 - model.frsky.screens[screen].body.bars[i%4].barMax));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lock=false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TelemetryPanel::ScreenTypeCBcurrentIndexChanged(int index)
|
|
||||||
{
|
|
||||||
if (!lock) {
|
|
||||||
lock = true;
|
|
||||||
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
|
|
||||||
int screen = comboBox->objectName().right(1).toInt() -1;
|
|
||||||
model.frsky.screens[screen].type = index;
|
|
||||||
for (int i=0; i<3; i++) {
|
|
||||||
bool isNum = (model.frsky.screens[i].type==0);
|
|
||||||
barsGB[i]->setVisible(!isNum);
|
|
||||||
numsGB[i]->setVisible(isNum);
|
|
||||||
}
|
|
||||||
lock = false;
|
|
||||||
emit modified();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TelemetryPanel::telBarCBcurrentIndexChanged(int index)
|
|
||||||
{
|
|
||||||
if (!lock) {
|
|
||||||
lock = true;
|
|
||||||
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
|
|
||||||
int screenId = comboBox->objectName().mid(8,1).toInt() - 1;
|
|
||||||
int barId = comboBox->objectName().mid(10,1).toInt() - 1;
|
|
||||||
int bar=barId+screenId*4;
|
|
||||||
model.frsky.screens[screenId].body.bars[barId].source=index;
|
|
||||||
if (index==0) {
|
|
||||||
model.frsky.screens[screenId].body.bars[barId].barMin=0;
|
|
||||||
model.frsky.screens[screenId].body.bars[barId].barMax=0;
|
|
||||||
minSB[bar]->setDisabled(true);
|
|
||||||
maxSB[bar]->setDisabled(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
minSB[bar]->setEnabled(true);
|
|
||||||
maxSB[bar]->setEnabled(true);
|
|
||||||
}
|
|
||||||
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model);
|
|
||||||
RawSourceRange range = source.getRange(true);
|
|
||||||
minSB[bar]->setDecimals(range.decimals);
|
|
||||||
minSB[bar]->setMinimum(range.min);
|
|
||||||
minSB[bar]->setMaximum(range.max);
|
|
||||||
minSB[bar]->setSingleStep(range.step);
|
|
||||||
maxSB[bar]->setDecimals(range.decimals);
|
|
||||||
maxSB[bar]->setMinimum(range.min);
|
|
||||||
maxSB[bar]->setMaximum(range.max);
|
|
||||||
maxSB[bar]->setSingleStep(range.step);
|
|
||||||
minSB[bar]->setValue(range.getValue(model.frsky.screens[screenId].body.bars[barId].barMin));
|
|
||||||
maxSB[bar]->setValue(range.getValue(255 - model.frsky.screens[screenId].body.bars[barId].barMax));
|
|
||||||
lock = false;
|
|
||||||
emit modified();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TelemetryPanel::telMinSBeditingFinished()
|
|
||||||
{
|
|
||||||
if (!lock) {
|
|
||||||
lock = true;
|
|
||||||
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());
|
|
||||||
int screenId = spinBox->objectName().mid(8,1).toInt() - 1;
|
|
||||||
int barId = spinBox->objectName().right(1).toInt() - 1;
|
|
||||||
int minId = barId+screenId*4;
|
|
||||||
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, model.frsky.screens[screenId].body.bars[barId].source, &model);
|
|
||||||
RawSourceRange range = source.getRange(true);
|
|
||||||
if (model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1 || model.frsky.screens[screenId].body.bars[barId].source==TELEMETRY_SOURCE_A1_MIN) {
|
|
||||||
model.frsky.screens[screenId].body.bars[barId].barMin = round((minSB[minId]->value()-analogs[0]->ui->CalibSB->value())/range.step);
|
|
||||||
}
|
|
||||||
else if (model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2 || model.frsky.screens[screenId].body.bars[minId].source==TELEMETRY_SOURCE_A2_MIN) {
|
|
||||||
model.frsky.screens[screenId].body.bars[barId].barMin = round((minSB[minId]->value()-analogs[1]->ui->CalibSB->value())/range.step);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
model.frsky.screens[screenId].body.bars[barId].barMin = round((minSB[minId]->value()-range.getValue(0))/range.step);
|
|
||||||
}
|
|
||||||
spinBox->setValue(range.getValue(model.frsky.screens[screenId].body.bars[barId].barMin));
|
|
||||||
if (maxSB[minId]->value()<minSB[minId]->value()) {
|
|
||||||
model.frsky.screens[screenId].body.bars[minId].barMax = (255-model.frsky.screens[screenId].body.bars[barId].barMin+1);
|
|
||||||
maxSB[minId]->setValue(range.getValue(255 - model.frsky.screens[screenId].body.bars[barId].barMax));
|
|
||||||
}
|
|
||||||
maxSB[minId]->setMinimum(range.getValue((model.frsky.screens[screenId].body.bars[barId].barMin+1)));
|
|
||||||
|
|
||||||
lock = false;
|
|
||||||
emit modified();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TelemetryPanel::telMaxSBeditingFinished()
|
|
||||||
{
|
|
||||||
if (!lock) {
|
|
||||||
QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());
|
|
||||||
int screenId = spinBox->objectName().mid(8,1).toInt() - 1;
|
|
||||||
int barId = spinBox->objectName().right(1).toInt() - 1;
|
|
||||||
lock = true;
|
|
||||||
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, model.frsky.screens[screenId].body.bars[barId].source, &model);
|
|
||||||
RawSourceRange range = source.getRange(true);
|
|
||||||
if (model.frsky.screens[screenId].body.bars[barId].source==5) {
|
|
||||||
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-analogs[0]->ui->CalibSB->value())/range.step));
|
|
||||||
}
|
|
||||||
else if (model.frsky.screens[screenId].body.bars[barId].source==6) {
|
|
||||||
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-analogs[1]->ui->CalibSB->value())/range.step));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
model.frsky.screens[screenId].body.bars[barId].barMax = (255-round((spinBox->value()-range.getValue(0))/range.step));
|
|
||||||
}
|
|
||||||
spinBox->setValue(range.getValue(255-model.frsky.screens[screenId].body.bars[barId].barMax));
|
|
||||||
lock = false;
|
|
||||||
emit modified();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TelemetryPanel::customFieldEdited()
|
|
||||||
{
|
|
||||||
if (!lock) {
|
|
||||||
lock = true;
|
|
||||||
|
|
||||||
int cols = GetEepromInterface()->getCapability(TelemetryColsCSFields);
|
|
||||||
if (cols==0) cols=2;
|
|
||||||
|
|
||||||
for (int i=0; i<GetEepromInterface()->getCapability(TelemetryCSFields); i++) {
|
|
||||||
int screen=i/(4*cols);
|
|
||||||
int r=((i%(4*cols))%4);
|
|
||||||
int c=((i%(4*cols))/4);
|
|
||||||
if (model.frsky.screens[screen].type==0) {
|
|
||||||
model.frsky.screens[screen].body.lines[r].source[c]=csf[i]->currentIndex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lock = false;
|
|
||||||
emit modified();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class TelemetryAnalog;
|
class TelemetryAnalog;
|
||||||
|
class TelemetryCustomScreen;
|
||||||
class Telemetry;
|
class Telemetry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +45,32 @@ class TelemetryAnalog : public QWidget
|
||||||
void update();
|
void update();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TelemetryCustomScreen : public ModelPanel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen);
|
||||||
|
~TelemetryCustomScreen();
|
||||||
|
void update();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_screenType_currentIndexChanged(int index);
|
||||||
|
void customFieldChanged(int index);
|
||||||
|
void barSourceChanged(int index);
|
||||||
|
void barMinChanged(double value);
|
||||||
|
void barMaxChanged(double value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateBar(int line);
|
||||||
|
Ui::TelemetryCustomScreen * ui;
|
||||||
|
FrSkyScreenData & screen;
|
||||||
|
QComboBox * fieldsCB[4][3];
|
||||||
|
QComboBox * barsCB[4];
|
||||||
|
QDoubleSpinBox * minSB[4];
|
||||||
|
QDoubleSpinBox * maxSB[4];
|
||||||
|
};
|
||||||
|
|
||||||
class TelemetryPanel : public ModelPanel
|
class TelemetryPanel : public ModelPanel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -77,21 +104,10 @@ class TelemetryPanel : public ModelPanel
|
||||||
void on_fasOffset_DSB_editingFinished();
|
void on_fasOffset_DSB_editingFinished();
|
||||||
void on_mahCount_SB_editingFinished();
|
void on_mahCount_SB_editingFinished();
|
||||||
void on_mahCount_ChkB_toggled(bool checked);
|
void on_mahCount_ChkB_toggled(bool checked);
|
||||||
void telBarCBcurrentIndexChanged(int index);
|
|
||||||
void ScreenTypeCBcurrentIndexChanged(int index);
|
|
||||||
void telMaxSBeditingFinished();
|
|
||||||
void telMinSBeditingFinished();
|
|
||||||
void customFieldEdited();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Telemetry *ui;
|
Ui::Telemetry *ui;
|
||||||
TelemetryAnalog * analogs[2];
|
TelemetryAnalog * analogs[2];
|
||||||
QGroupBox* barsGB[3];
|
|
||||||
QGroupBox* numsGB[3];
|
|
||||||
QComboBox* barsCB[12];
|
|
||||||
QDoubleSpinBox* minSB[12];
|
|
||||||
QDoubleSpinBox* maxSB[12];
|
|
||||||
QComboBox* csf[36];
|
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
void telBarUpdate();
|
void telBarUpdate();
|
||||||
|
|
File diff suppressed because it is too large
Load diff
138
companion/src/modeledit/telemetry_customscreen.ui
Normal file
138
companion/src/modeledit/telemetry_customscreen.ui
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>TelemetryCustomScreen</class>
|
||||||
|
<widget class="QWidget" name="TelemetryCustomScreen">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>650</width>
|
||||||
|
<height>393</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,0,1">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="screenTypeLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Custom Screen Type</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="screenType">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>90</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Nums</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Bars</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_16">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="screenNums">
|
||||||
|
<layout class="QGridLayout" name="screenNumsLayout"/>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="screenBars">
|
||||||
|
<layout class="QGridLayout" name="screenBarsLayout" columnstretch="1,0,1,0">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="label_266">
|
||||||
|
<property name="text">
|
||||||
|
<string>Min</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_265">
|
||||||
|
<property name="text">
|
||||||
|
<string>Source</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="label_267">
|
||||||
|
<property name="text">
|
||||||
|
<string>Gauge</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QLabel" name="label_268">
|
||||||
|
<property name="text">
|
||||||
|
<string>Max</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -796,7 +796,7 @@ void printDialog::printFrSky()
|
||||||
str.append("<tr><td colspan=2 align=\"Left\"><b>"+tr("System of units")+"</b></td><td colspan=8 align=\"left\">"+getFrSkyMeasure(fd->imperial)+"</td></tr>");
|
str.append("<tr><td colspan=2 align=\"Left\"><b>"+tr("System of units")+"</b></td><td colspan=8 align=\"left\">"+getFrSkyMeasure(fd->imperial)+"</td></tr>");
|
||||||
str.append("<tr><td colspan=2 align=\"Left\"><b>"+tr("Propeller blades")+"</b></td><td colspan=8 align=\"left\">"+getFrSkyBlades(fd->blades)+"</td></tr>");
|
str.append("<tr><td colspan=2 align=\"Left\"><b>"+tr("Propeller blades")+"</b></td><td colspan=8 align=\"left\">"+getFrSkyBlades(fd->blades)+"</td></tr>");
|
||||||
str.append("<tr><td colspan=10 align=\"Left\" height=\"4px\"></td></tr></table>");
|
str.append("<tr><td colspan=10 align=\"Left\" height=\"4px\"></td></tr></table>");
|
||||||
|
#if 0
|
||||||
if (GetEepromInterface()->getCapability(TelemetryBars) || (GetEepromInterface()->getCapability(TelemetryCSFields))) {
|
if (GetEepromInterface()->getCapability(TelemetryBars) || (GetEepromInterface()->getCapability(TelemetryCSFields))) {
|
||||||
int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields);
|
int cols=GetEepromInterface()->getCapability(TelemetryColsCSFields);
|
||||||
if (cols==0) cols=2;
|
if (cols==0) cols=2;
|
||||||
|
@ -840,6 +840,7 @@ void printDialog::printFrSky()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (tc>0)
|
if (tc>0)
|
||||||
te->append(str);
|
te->append(str);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue