@@ -42,7 +42,6 @@ set(modeledit_UIS
|
||||
setup_timer.ui
|
||||
setup_module.ui
|
||||
flightmode.ui
|
||||
telemetry_analog.ui
|
||||
telemetry_customscreen.ui
|
||||
telemetry_sensor.ui
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ LimitsGroup::LimitsGroup(Firmware * firmware, TableLayout * tableLayout, int row
|
||||
spinbox->setSuffix("%");
|
||||
}
|
||||
|
||||
if (IS_ARM(board) || deflt == 0 /*it's the offset*/) {
|
||||
if (deflt == 0 /*it's the offset*/) {
|
||||
spinbox->setDecimals(1);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -29,7 +29,7 @@ RepeatComboBox::RepeatComboBox(QWidget *parent, int & repeatParam):
|
||||
QComboBox(parent),
|
||||
repeatParam(repeatParam)
|
||||
{
|
||||
unsigned int step = IS_ARM(getCurrentBoard()) ? 1 : 10;
|
||||
unsigned int step = 1;
|
||||
int value = repeatParam/step;
|
||||
|
||||
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
|
||||
@@ -58,7 +58,7 @@ void RepeatComboBox::onIndexChanged(int index)
|
||||
|
||||
void RepeatComboBox::update()
|
||||
{
|
||||
unsigned int step = IS_ARM(getCurrentBoard()) ? 1 : 10;
|
||||
unsigned int step = 1;
|
||||
int value = repeatParam/step;
|
||||
if (step == 1) {
|
||||
value++;
|
||||
@@ -422,29 +422,20 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||
if (cfn.adjustMode == FUNC_ADJUST_GVAR_CONSTANT || cfn.adjustMode == FUNC_ADJUST_GVAR_INCDEC) {
|
||||
if (modified)
|
||||
cfn.param = fswtchParam[i]->value() * model->gvarData[gvidx].multiplierSet();
|
||||
if (IS_ARM(getCurrentBoard())) {
|
||||
fswtchParam[i]->setDecimals(model->gvarData[gvidx].prec);
|
||||
fswtchParam[i]->setSingleStep(model->gvarData[gvidx].multiplierGet());
|
||||
fswtchParam[i]->setSuffix(model->gvarData[gvidx].unitToString());
|
||||
if (cfn.adjustMode==FUNC_ADJUST_GVAR_INCDEC) {
|
||||
double rng = abs(model->gvarData[gvidx].getMax() - model->gvarData[gvidx].getMin());
|
||||
rng *= model->gvarData[gvidx].multiplierGet();
|
||||
fswtchParam[i]->setMinimum(-rng);
|
||||
fswtchParam[i]->setMaximum(rng);
|
||||
}
|
||||
else {
|
||||
fswtchParam[i]->setMinimum(model->gvarData[gvidx].getMinPrec());
|
||||
fswtchParam[i]->setMaximum(model->gvarData[gvidx].getMaxPrec());
|
||||
}
|
||||
fswtchParam[i]->setValue(cfn.param * model->gvarData[gvidx].multiplierGet());
|
||||
fswtchParam[i]->setDecimals(model->gvarData[gvidx].prec);
|
||||
fswtchParam[i]->setSingleStep(model->gvarData[gvidx].multiplierGet());
|
||||
fswtchParam[i]->setSuffix(model->gvarData[gvidx].unitToString());
|
||||
if (cfn.adjustMode==FUNC_ADJUST_GVAR_INCDEC) {
|
||||
double rng = abs(model->gvarData[gvidx].getMax() - model->gvarData[gvidx].getMin());
|
||||
rng *= model->gvarData[gvidx].multiplierGet();
|
||||
fswtchParam[i]->setMinimum(-rng);
|
||||
fswtchParam[i]->setMaximum(rng);
|
||||
}
|
||||
else {
|
||||
fswtchParam[i]->setDecimals(0);
|
||||
fswtchParam[i]->setSingleStep(1);
|
||||
fswtchParam[i]->setMinimum(-125);
|
||||
fswtchParam[i]->setMaximum(125);
|
||||
fswtchParam[i]->setValue(cfn.param);
|
||||
fswtchParam[i]->setMinimum(model->gvarData[gvidx].getMinPrec());
|
||||
fswtchParam[i]->setMaximum(model->gvarData[gvidx].getMaxPrec());
|
||||
}
|
||||
fswtchParam[i]->setValue(cfn.param * model->gvarData[gvidx].multiplierGet());
|
||||
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
|
||||
}
|
||||
else {
|
||||
@@ -679,7 +670,6 @@ void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
|
||||
((i==FuncPlayHaptic) && !firmware->getCapability(Haptic)) ||
|
||||
((i==FuncPlayBoth) && !firmware->getCapability(HasBeeper)) ||
|
||||
((i==FuncLogs) && !firmware->getCapability(HasSDLogs)) ||
|
||||
((i==FuncSetTimer1 || i==FuncSetTimer2) && !IS_ARM(firmware->getBoard())) ||
|
||||
((i==FuncSetTimer3) && firmware->getCapability(Timers) < 3) ||
|
||||
((i==FuncScreenshot) && !IS_HORUS_OR_TARANIS(firmware->getBoard())) ||
|
||||
((i>=FuncRangeCheckInternalModule && i<=FuncBindExternalModule) && (!model || !firmware->getCapability(DangerousFunctions))) ||
|
||||
|
||||
@@ -46,18 +46,8 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||
setWindowTitle(tr("Edit %1").arg(RawSource(srcType, ed->chn).toString(&model, &generalSettings)));
|
||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||
|
||||
if (IS_ARM(getCurrentBoard())) {
|
||||
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, model, 100, -100, 100);
|
||||
gvOffsetGroup = new GVarGroup(ui->offsetGV, ui->offsetSB, ui->offsetCB, ed->offset, model, 0, -100, 100);
|
||||
}
|
||||
else {
|
||||
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, model, 100, 0, 100);
|
||||
gvOffsetGroup = NULL;
|
||||
ui->offsetLabel->hide();
|
||||
ui->offsetGV->hide();
|
||||
ui->offsetSB->hide();
|
||||
ui->offsetCB->hide();
|
||||
}
|
||||
gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, model, 100, -100, 100);
|
||||
gvOffsetGroup = new GVarGroup(ui->offsetGV, ui->offsetSB, ui->offsetCB, ed->offset, model, 0, -100, 100);
|
||||
|
||||
curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve, model,
|
||||
firmware->getCapability(HasInputDiff) ? 0 : (HIDE_DIFF | HIDE_NEGATIVE_CURVES));
|
||||
|
||||
@@ -479,10 +479,6 @@ void LogicalSwitchesPanel::populateFunctionCB(QComboBox *b)
|
||||
int func = order[i];
|
||||
if (func == LS_FN_NEQUAL || func == LS_FN_EGREATER || func == LS_FN_ELESS)
|
||||
continue;
|
||||
if (!IS_ARM(firmware->getBoard())) {
|
||||
if (func == LS_FN_VEQUAL || func == LS_FN_EDGE)
|
||||
continue;
|
||||
}
|
||||
b->addItem(LogicalSwitchData(func).funcToString(), func);
|
||||
}
|
||||
b->setMaxVisibleItems(10);
|
||||
@@ -490,27 +486,7 @@ void LogicalSwitchesPanel::populateFunctionCB(QComboBox *b)
|
||||
|
||||
void LogicalSwitchesPanel::populateAndSwitchCB(QComboBox *b)
|
||||
{
|
||||
if (IS_ARM(firmware->getBoard())) {
|
||||
b->setModel(rawSwitchItemModel);
|
||||
}
|
||||
else {
|
||||
RawSwitch item;
|
||||
|
||||
b->clear();
|
||||
|
||||
item = RawSwitch(SWITCH_TYPE_NONE);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
|
||||
for (int i=1; i <= Boards::getCapability(firmware->getBoard(), Board::SwitchPositions); i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
}
|
||||
|
||||
for (int i=1; i<=6; i++) {
|
||||
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
}
|
||||
}
|
||||
b->setModel(rawSwitchItemModel);
|
||||
b->setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
|
||||
s1.report("LS");
|
||||
addTab(new CustomFunctionsPanel(this, &radioData.models[modelId], radioData.generalSettings, firmware), tr("Special Functions"));
|
||||
s1.report("CF");
|
||||
if (firmware->getCapability(Telemetry) & TM_HASTELEMETRY)
|
||||
if (firmware->getCapability(Telemetry))
|
||||
addTab(new TelemetryPanel(this, radioData.models[modelId], radioData.generalSettings, firmware), tr("Telemetry"));
|
||||
|
||||
onTabIndexChanged(ui->tabWidget->currentIndex()); // make sure to trigger update on default tab panel
|
||||
|
||||
@@ -36,7 +36,6 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge
|
||||
timer(timer),
|
||||
ui(new Ui::Timer)
|
||||
{
|
||||
Board::Type board = firmware->getBoard();
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -65,10 +64,8 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, Ge
|
||||
ui->countdownBeep->setField(timer.countdownBeep, this);
|
||||
ui->countdownBeep->addItem(tr("Silent"), TimerData::COUNTDOWN_SILENT);
|
||||
ui->countdownBeep->addItem(tr("Beeps"), TimerData::COUNTDOWN_BEEPS);
|
||||
if (IS_ARM(board) || IS_2560(board)) {
|
||||
ui->countdownBeep->addItem(tr("Voice"), TimerData::COUNTDOWN_VOICE);
|
||||
ui->countdownBeep->addItem(tr("Haptic"), TimerData::COUNTDOWN_HAPTIC);
|
||||
}
|
||||
ui->countdownBeep->addItem(tr("Voice"), TimerData::COUNTDOWN_VOICE);
|
||||
ui->countdownBeep->addItem(tr("Haptic"), TimerData::COUNTDOWN_HAPTIC);
|
||||
|
||||
ui->value->setMaximumTime(firmware->getMaxTimerStart());
|
||||
|
||||
@@ -1205,13 +1202,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
ui->potWarningMode->hide();
|
||||
}
|
||||
|
||||
if (IS_ARM(board)) {
|
||||
ui->trimsDisplay->setField(model.trimsDisplay, this);
|
||||
}
|
||||
else {
|
||||
ui->labelTrimsDisplay->hide();
|
||||
ui->trimsDisplay->hide();
|
||||
}
|
||||
ui->trimsDisplay->setField(model.trimsDisplay, this);
|
||||
|
||||
for (int i = firmware->getCapability(NumFirstUsableModule); i < firmware->getCapability(NumModules); i++) {
|
||||
modules[i] = new ModulePanel(this, model, model.moduleData[i], generalSettings, firmware, i);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "telemetry.h"
|
||||
#include "ui_telemetry.h"
|
||||
#include "ui_telemetry_analog.h"
|
||||
#include "ui_telemetry_customscreen.h"
|
||||
#include "ui_telemetry_sensor.h"
|
||||
#include "helpers.h"
|
||||
@@ -29,291 +28,6 @@
|
||||
|
||||
#include <TimerEdit>
|
||||
|
||||
TelemetryAnalog::TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
ui(new Ui::TelemetryAnalog),
|
||||
analog(analog),
|
||||
lock(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
float ratio = analog.getRatio();
|
||||
|
||||
if (analog.type==0 || analog.type==1 || analog.type==2) {
|
||||
ui->RatioSB->setDecimals(1);
|
||||
ui->RatioSB->setMaximum(25.5*firmware->getCapability(TelemetryMaxMultiplier));
|
||||
}
|
||||
else {
|
||||
ui->RatioSB->setDecimals(0);
|
||||
ui->RatioSB->setMaximum(255*firmware->getCapability(TelemetryMaxMultiplier));
|
||||
}
|
||||
ui->RatioSB->setValue(ratio);
|
||||
|
||||
update();
|
||||
|
||||
ui->UnitCB->setCurrentIndex(analog.type);
|
||||
ui->alarm1LevelCB->setCurrentIndex(analog.alarms[0].level);
|
||||
ui->alarm1GreaterCB->setCurrentIndex(analog.alarms[0].greater);
|
||||
ui->alarm2LevelCB->setCurrentIndex(analog.alarms[1].level);
|
||||
ui->alarm2GreaterCB->setCurrentIndex(analog.alarms[1].greater);
|
||||
|
||||
if (!(firmware->getCapability(Telemetry) & TM_HASOFFSET)) {
|
||||
ui->CalibSB->hide();
|
||||
ui->CalibLabel->hide();
|
||||
}
|
||||
else {
|
||||
ui->label_Max->setText(tr("Range"));
|
||||
}
|
||||
|
||||
disableMouseScrolling();
|
||||
}
|
||||
|
||||
void TelemetryAnalog::update()
|
||||
{
|
||||
float ratio = analog.getRatio();
|
||||
float step = ratio / 255;
|
||||
float mini = (ratio * analog.offset) / 255;
|
||||
float maxi = mini + ratio;
|
||||
|
||||
ui->alarm1ValueSB->setDecimals(2);
|
||||
ui->alarm1ValueSB->setSingleStep(step);
|
||||
ui->alarm1ValueSB->setMinimum(mini);
|
||||
ui->alarm1ValueSB->setMaximum(maxi);
|
||||
ui->alarm1ValueSB->setValue(mini + step*analog.alarms[0].value);
|
||||
|
||||
ui->alarm2ValueSB->setDecimals(2);
|
||||
ui->alarm2ValueSB->setSingleStep(step);
|
||||
ui->alarm2ValueSB->setMinimum(mini);
|
||||
ui->alarm2ValueSB->setMaximum(maxi);
|
||||
ui->alarm2ValueSB->setValue(mini + step*analog.alarms[1].value);
|
||||
|
||||
ui->CalibSB->setDecimals(2);
|
||||
ui->CalibSB->setMaximum(step*127);
|
||||
ui->CalibSB->setMinimum(-step*128);
|
||||
ui->CalibSB->setSingleStep(step);
|
||||
ui->CalibSB->setValue(mini);
|
||||
}
|
||||
|
||||
static int findmult(float value, float base)
|
||||
{
|
||||
int vvalue = value*10;
|
||||
int vbase = base*10;
|
||||
vvalue--;
|
||||
|
||||
int mult = 0;
|
||||
for (int i=8; i>=0; i--) {
|
||||
if (vvalue/vbase >= (1<<i)) {
|
||||
mult = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return mult;
|
||||
}
|
||||
|
||||
void TelemetryAnalog::on_UnitCB_currentIndexChanged(int index)
|
||||
{
|
||||
float ratio = analog.getRatio();
|
||||
analog.type = index;
|
||||
switch (index) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
ui->RatioSB->setDecimals(1);
|
||||
ui->RatioSB->setMaximum(25.5*firmware->getCapability(TelemetryMaxMultiplier));
|
||||
break;
|
||||
default:
|
||||
ui->RatioSB->setDecimals(0);
|
||||
ui->RatioSB->setMaximum(255*firmware->getCapability(TelemetryMaxMultiplier));
|
||||
break;
|
||||
}
|
||||
ui->RatioSB->setValue(ratio);
|
||||
update();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryAnalog::on_RatioSB_valueChanged()
|
||||
{
|
||||
if (!lock) {
|
||||
if (analog.type==0 || analog.type==1 || analog.type==2) {
|
||||
analog.multiplier = findmult(ui->RatioSB->value(), 25.5);
|
||||
float singlestep =(1<<analog.multiplier)/10.0;
|
||||
lock=true;
|
||||
ui->RatioSB->setSingleStep(singlestep);
|
||||
ui->RatioSB->setValue(round(ui->RatioSB->value()/singlestep)*singlestep);
|
||||
lock=false;
|
||||
}
|
||||
else {
|
||||
analog.multiplier = findmult(ui->RatioSB->value(), 255);
|
||||
float singlestep = (1<<analog.multiplier);
|
||||
lock = true;
|
||||
ui->RatioSB->setSingleStep(singlestep);
|
||||
ui->RatioSB->setValue(round(ui->RatioSB->value()/singlestep)*singlestep);
|
||||
lock = false;
|
||||
}
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryAnalog::on_RatioSB_editingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
float ratio, calib, alarm1value,alarm2value;
|
||||
|
||||
if (analog.type==0 || analog.type==1 || analog.type==2) {
|
||||
analog.multiplier = findmult(ui->RatioSB->value(), 25.5);
|
||||
ui->CalibSB->setSingleStep((1<<analog.multiplier)/10.0);
|
||||
ui->alarm1ValueSB->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));
|
||||
}
|
||||
else {
|
||||
analog.multiplier = findmult(ui->RatioSB->value(), 255);
|
||||
ui->CalibSB->setSingleStep(1<<analog.multiplier);
|
||||
ui->alarm1ValueSB->setSingleStep(1<<analog.multiplier);
|
||||
ui->alarm2ValueSB->setSingleStep(1<<analog.multiplier);
|
||||
analog.ratio = (ui->RatioSB->value()/(1 << analog.multiplier));
|
||||
}
|
||||
ui->CalibSB->setMaximum((ui->RatioSB->value()*127)/255);
|
||||
ui->CalibSB->setMinimum((ui->RatioSB->value()*-128)/255);
|
||||
ui->alarm1ValueSB->setMaximum(ui->RatioSB->value());
|
||||
ui->alarm2ValueSB->setMaximum(ui->RatioSB->value());
|
||||
repaint();
|
||||
ratio=analog.ratio * (1 << analog.multiplier);
|
||||
calib=ui->CalibSB->value();
|
||||
alarm1value=ui->alarm1ValueSB->value();
|
||||
alarm2value=ui->alarm2ValueSB->value();
|
||||
if (analog.type==0) {
|
||||
calib*=10;
|
||||
alarm1value*=10;
|
||||
alarm2value*=10;
|
||||
}
|
||||
if (calib>0) {
|
||||
if (calib>((ratio*127)/255)) {
|
||||
analog.offset=127;
|
||||
}
|
||||
else {
|
||||
analog.offset=round(calib*255/ratio);
|
||||
}
|
||||
}
|
||||
if (calib<0) {
|
||||
if (calib<((ratio*-128)/255)) {
|
||||
analog.offset=-128;
|
||||
}
|
||||
else {
|
||||
analog.offset=round(calib*255/ratio);
|
||||
}
|
||||
}
|
||||
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));
|
||||
update();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryAnalog::on_CalibSB_editingFinished()
|
||||
{
|
||||
float ratio = analog.getRatio();
|
||||
float calib,alarm1value,alarm2value;
|
||||
|
||||
if (ratio!=0) {
|
||||
analog.offset = round((255*ui->CalibSB->value()/ratio));
|
||||
calib=ratio*analog.offset/255.0;
|
||||
alarm1value=ui->alarm1ValueSB->value();
|
||||
alarm2value=ui->alarm2ValueSB->value();
|
||||
if (alarm1value<calib) {
|
||||
alarm1value=calib;
|
||||
}
|
||||
else if (alarm1value>(ratio+calib)) {
|
||||
alarm1value=ratio+calib;
|
||||
}
|
||||
if (alarm2value<calib) {
|
||||
alarm2value=calib;
|
||||
}
|
||||
else if (alarm2value>(ratio+calib)) {
|
||||
alarm2value=ratio+calib;
|
||||
}
|
||||
analog.alarms[0].value=round(((alarm1value-calib)*255)/ratio);
|
||||
analog.alarms[1].value=round(((alarm2value-calib)*255)/ratio);
|
||||
}
|
||||
else {
|
||||
analog.offset=0;
|
||||
analog.alarms[0].value=0;
|
||||
analog.alarms[1].value=0;
|
||||
}
|
||||
update();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryAnalog::on_alarm1LevelCB_currentIndexChanged(int index)
|
||||
{
|
||||
analog.alarms[0].level = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
|
||||
void TelemetryAnalog::on_alarm1GreaterCB_currentIndexChanged(int index)
|
||||
{
|
||||
analog.alarms[0].greater = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryAnalog::on_alarm1ValueSB_editingFinished()
|
||||
{
|
||||
float ratio = analog.getRatio();
|
||||
float calib, alarm1value;
|
||||
|
||||
calib=analog.offset;
|
||||
alarm1value=ui->alarm1ValueSB->value();
|
||||
|
||||
if (alarm1value<((calib*ratio)/255)) {
|
||||
analog.alarms[0].value=0;
|
||||
}
|
||||
else if (alarm1value>(ratio+(calib*ratio)/255)) {
|
||||
analog.alarms[0].value=255;
|
||||
}
|
||||
else {
|
||||
analog.alarms[0].value = round((alarm1value-((calib*ratio)/255))/ratio*255);
|
||||
}
|
||||
update();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryAnalog::on_alarm2LevelCB_currentIndexChanged(int index)
|
||||
{
|
||||
analog.alarms[1].level = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryAnalog::on_alarm2GreaterCB_currentIndexChanged(int index)
|
||||
{
|
||||
analog.alarms[1].greater = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryAnalog::on_alarm2ValueSB_editingFinished()
|
||||
{
|
||||
float calib, alarm2value;
|
||||
float ratio = analog.getRatio();
|
||||
calib = analog.offset;
|
||||
alarm2value = ui->alarm2ValueSB->value();
|
||||
if (alarm2value<((calib*ratio)/255)) {
|
||||
analog.alarms[1].value=0;
|
||||
}
|
||||
else if (alarm2value>(ratio+(calib*ratio)/255)) {
|
||||
analog.alarms[1].value=255;
|
||||
}
|
||||
else {
|
||||
analog.alarms[1].value = round((alarm2value-((calib*ratio)/255))/ratio*255);
|
||||
}
|
||||
update();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
TelemetryAnalog::~TelemetryAnalog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
/******************************************************/
|
||||
|
||||
@@ -377,8 +91,7 @@ TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model,
|
||||
disableMouseScrolling();
|
||||
|
||||
lock = true;
|
||||
if (IS_ARM(firmware->getBoard()))
|
||||
ui->screenType->addItem(tr("None"), TELEMETRY_SCREEN_NONE);
|
||||
ui->screenType->addItem(tr("None"), TELEMETRY_SCREEN_NONE);
|
||||
ui->screenType->addItem(tr("Numbers"), TELEMETRY_SCREEN_NUMBERS);
|
||||
ui->screenType->addItem(tr("Bars"), TELEMETRY_SCREEN_BARS);
|
||||
if (IS_TARANIS(firmware->getBoard()))
|
||||
@@ -439,14 +152,8 @@ void TelemetryCustomScreen::updateBar(int line)
|
||||
|
||||
if (source.type != SOURCE_TYPE_NONE) {
|
||||
RawSourceRange range = source.getRange(model, generalSettings);
|
||||
if (!IS_ARM(getCurrentBoard())) {
|
||||
int max = round((range.max - range.min) / range.step);
|
||||
if (int(255-screen.body.bars[line].barMax) > max) {
|
||||
screen.body.bars[line].barMax = 255 - max;
|
||||
}
|
||||
}
|
||||
float minVal = range.getValue(screen.body.bars[line].barMin);
|
||||
float maxVal = IS_ARM(getCurrentBoard()) ? screen.body.bars[line].barMax : 255 - screen.body.bars[line].barMax;
|
||||
float maxVal = screen.body.bars[line].barMax;
|
||||
maxVal = range.getValue(maxVal);
|
||||
|
||||
if (source.isTimeBased()) {
|
||||
@@ -552,10 +259,7 @@ void TelemetryCustomScreen::barMinChanged(double value)
|
||||
{
|
||||
if (!lock) {
|
||||
int line = sender()->property("index").toInt();
|
||||
if (IS_ARM(getCurrentBoard()))
|
||||
screen.body.bars[line].barMin = round(value / minSB[line]->singleStep());
|
||||
else
|
||||
screen.body.bars[line].barMin = round((value-minSB[line]->minimum()) / minSB[line]->singleStep());
|
||||
screen.body.bars[line].barMin = round(value / minSB[line]->singleStep());
|
||||
// TODO set min (maxSB)
|
||||
emit modified();
|
||||
}
|
||||
@@ -565,10 +269,7 @@ void TelemetryCustomScreen::barMaxChanged(double value)
|
||||
{
|
||||
if (!lock) {
|
||||
int line = sender()->property("index").toInt();
|
||||
if (IS_ARM(getCurrentBoard()))
|
||||
screen.body.bars[line].barMax = round((value) / maxSB[line]->singleStep());
|
||||
else
|
||||
screen.body.bars[line].barMax = 255 - round((value-minSB[line]->minimum()) / maxSB[line]->singleStep());
|
||||
screen.body.bars[line].barMax = round((value) / maxSB[line]->singleStep());
|
||||
// TODO set max (minSB)
|
||||
emit modified();
|
||||
}
|
||||
@@ -583,10 +284,7 @@ void TelemetryCustomScreen::barTimeChanged()
|
||||
if (!te)
|
||||
return;
|
||||
|
||||
if (IS_ARM(getCurrentBoard()))
|
||||
valRef = round(te->timeInSeconds() / te->singleStep());
|
||||
else
|
||||
valRef = round((te->timeInSeconds() - te->minimumTime()) / te->singleStep());
|
||||
valRef = round(te->timeInSeconds() / te->singleStep());
|
||||
|
||||
emit modified();
|
||||
}
|
||||
@@ -946,29 +644,17 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin
|
||||
model.frsky.usrProto = 1;
|
||||
}
|
||||
|
||||
if (IS_ARM(firmware->getBoard())) {
|
||||
ui->varioSource->setField(model.frsky.varioSource, this);
|
||||
ui->varioCenterSilent->setField(model.frsky.varioCenterSilent, this);
|
||||
ui->A1GB->hide();
|
||||
ui->A2GB->hide();
|
||||
for (unsigned i= 0; i < CPN_MAX_SENSORS; ++i) {
|
||||
TelemetrySensorPanel * panel = new TelemetrySensorPanel(this, model.sensorData[i], i, model, generalSettings, firmware);
|
||||
ui->sensorsLayout->addWidget(panel);
|
||||
sensorPanels[i] = panel;
|
||||
connect(panel, SIGNAL(dataModified()), this, SLOT(update()));
|
||||
connect(panel, SIGNAL(modified()), this, SLOT(onModified()));
|
||||
connect(panel, SIGNAL(clearAllSensors()), this, SLOT(on_clearAllSensors()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ui->sensorsGB->hide();
|
||||
ui->altimetryGB->hide();
|
||||
analogs[0] = new TelemetryAnalog(this, model.frsky.channels[0], model, generalSettings, firmware);
|
||||
ui->A1Layout->addWidget(analogs[0]);
|
||||
connect(analogs[0], SIGNAL(modified()), this, SLOT(onAnalogModified()));
|
||||
analogs[1] = new TelemetryAnalog(this, model.frsky.channels[1], model, generalSettings, firmware);
|
||||
ui->A2Layout->addWidget(analogs[1]);
|
||||
connect(analogs[1], SIGNAL(modified()), this, SLOT(onModified()));
|
||||
ui->varioSource->setField(model.frsky.varioSource, this);
|
||||
ui->varioCenterSilent->setField(model.frsky.varioCenterSilent, this);
|
||||
ui->A1GB->hide();
|
||||
ui->A2GB->hide();
|
||||
for (unsigned i= 0; i < CPN_MAX_SENSORS; ++i) {
|
||||
TelemetrySensorPanel * panel = new TelemetrySensorPanel(this, model.sensorData[i], i, model, generalSettings, firmware);
|
||||
ui->sensorsLayout->addWidget(panel);
|
||||
sensorPanels[i] = panel;
|
||||
connect(panel, SIGNAL(dataModified()), this, SLOT(update()));
|
||||
connect(panel, SIGNAL(modified()), this, SLOT(onModified()));
|
||||
connect(panel, SIGNAL(clearAllSensors()), this, SLOT(on_clearAllSensors()));
|
||||
}
|
||||
|
||||
if (IS_TARANIS_X9(firmware->getBoard())) {
|
||||
@@ -1017,10 +703,8 @@ void TelemetryPanel::update()
|
||||
populateTelemetrySourcesComboBox(ui->varioSource, model, false);
|
||||
}
|
||||
|
||||
if (IS_ARM(firmware->getBoard())) {
|
||||
for (unsigned i=0; i<CPN_MAX_SENSORS; ++i) {
|
||||
sensorPanels[i]->update();
|
||||
}
|
||||
for (unsigned i=0; i<CPN_MAX_SENSORS; ++i) {
|
||||
sensorPanels[i]->update();
|
||||
}
|
||||
|
||||
emit updated();
|
||||
@@ -1032,52 +716,29 @@ void TelemetryPanel::setup()
|
||||
|
||||
lock = true;
|
||||
|
||||
if (IS_ARM(firmware->getBoard())) {
|
||||
ui->telemetryProtocol->addItem(tr("FrSky S.PORT"), 0);
|
||||
ui->telemetryProtocol->addItem(tr("FrSky D"), 1);
|
||||
if (IS_9XRPRO(firmware->getBoard()) ||
|
||||
(IS_TARANIS(firmware->getBoard()) && generalSettings.auxSerialMode == 2)) {
|
||||
ui->telemetryProtocol->addItem(tr("FrSky D (cable)"), 2);
|
||||
}
|
||||
ui->telemetryProtocol->setCurrentIndex(model->telemetryProtocol);
|
||||
ui->ignoreSensorIds->setField(model->frsky.ignoreSensorIds, this);
|
||||
ui->disableTelemetryAlarms->setField(model->rssiAlarms.disabled);
|
||||
}
|
||||
else {
|
||||
ui->telemetryProtocolLabel->hide();
|
||||
ui->telemetryProtocol->hide();
|
||||
ui->ignoreSensorIds->hide();
|
||||
ui->disableTelemetryAlarms->hide();
|
||||
ui->telemetryProtocol->addItem(tr("FrSky S.PORT"), 0);
|
||||
ui->telemetryProtocol->addItem(tr("FrSky D"), 1);
|
||||
if (IS_9XRPRO(firmware->getBoard()) ||
|
||||
(IS_TARANIS(firmware->getBoard()) && generalSettings.auxSerialMode == 2)) {
|
||||
ui->telemetryProtocol->addItem(tr("FrSky D (cable)"), 2);
|
||||
}
|
||||
ui->telemetryProtocol->setCurrentIndex(model->telemetryProtocol);
|
||||
ui->ignoreSensorIds->setField(model->frsky.ignoreSensorIds, this);
|
||||
ui->disableTelemetryAlarms->setField(model->rssiAlarms.disabled);
|
||||
|
||||
ui->rssiAlarmWarningSB->setValue(model->rssiAlarms.warning);
|
||||
ui->rssiAlarmCriticalSB->setValue(model->rssiAlarms.critical);
|
||||
if (!IS_ARM(firmware->getBoard())) {
|
||||
ui->rssiSourceLabel->hide();
|
||||
ui->rssiSourceCB->hide();
|
||||
ui->rssiAlarmWarningCB->setCurrentIndex(model->rssiAlarms.level[0]);
|
||||
ui->rssiAlarmCriticalCB->setCurrentIndex(model->rssiAlarms.level[1]);
|
||||
}
|
||||
else {
|
||||
ui->rssiSourceLabel->show();
|
||||
ui->rssiSourceLabel->setText(tr("Source"));
|
||||
ui->rssiSourceCB->setField(model->rssiSource, this);
|
||||
ui->rssiSourceCB->show();
|
||||
populateTelemetrySourcesComboBox(ui->rssiSourceCB, model, false);
|
||||
|
||||
ui->rssiAlarmWarningCB->hide();
|
||||
ui->rssiAlarmCriticalCB->hide();
|
||||
ui->rssiAlarmWarningLabel->setText(tr("Low Alarm"));
|
||||
ui->rssiAlarmCriticalLabel->setText(tr("Critical Alarm"));
|
||||
}
|
||||
ui->rssiSourceLabel->show();
|
||||
ui->rssiSourceLabel->setText(tr("Source"));
|
||||
ui->rssiSourceCB->setField(model->rssiSource, this);
|
||||
ui->rssiSourceCB->show();
|
||||
populateTelemetrySourcesComboBox(ui->rssiSourceCB, model, false);
|
||||
|
||||
/*if (IS_ARM(firmware->getBoard())) {
|
||||
for (int i=0; i<CPN_MAX_SENSORS; ++i) {
|
||||
TelemetrySensorPanel * panel = new TelemetrySensorPanel(this, model->, model, generalSettings, firmware);
|
||||
ui->sensorsLayout->addWidget(panel);
|
||||
sensorPanels[i] = panel;
|
||||
}
|
||||
}*/
|
||||
ui->rssiAlarmWarningCB->hide();
|
||||
ui->rssiAlarmCriticalCB->hide();
|
||||
ui->rssiAlarmWarningLabel->setText(tr("Low Alarm"));
|
||||
ui->rssiAlarmCriticalLabel->setText(tr("Critical Alarm"));
|
||||
|
||||
int varioCap = firmware->getCapability(HasVario);
|
||||
if (!varioCap) {
|
||||
@@ -1109,7 +770,7 @@ void TelemetryPanel::setup()
|
||||
ui->altimetryGB->setVisible(firmware->getCapability(HasVario)),
|
||||
ui->frskyProtoCB->setDisabled(firmware->getCapability(NoTelemetryProtocol));
|
||||
|
||||
if (firmware->getCapability(Telemetry) & TM_HASWSHH) {
|
||||
if (firmware->getCapability(Telemetry)) {
|
||||
ui->frskyProtoCB->addItem(tr("Winged Shadow How High"));
|
||||
}
|
||||
else {
|
||||
@@ -1117,38 +778,6 @@ void TelemetryPanel::setup()
|
||||
}
|
||||
|
||||
ui->variousGB->hide();
|
||||
if (!IS_ARM(firmware->getBoard())) {
|
||||
if (!(firmware->getCapability(HasFasOffset)) && !(firmware_id.contains("fasoffset"))) {
|
||||
ui->fasOffset_label->hide();
|
||||
ui->fasOffset_DSB->hide();
|
||||
}
|
||||
else {
|
||||
ui->fasOffset_DSB->setValue(model->frsky.fasOffset/10.0);
|
||||
ui->variousGB->show();
|
||||
}
|
||||
|
||||
if (!(firmware->getCapability(HasMahPersistent))) {
|
||||
ui->mahCount_label->hide();
|
||||
ui->mahCount_SB->hide();
|
||||
ui->mahCount_ChkB->hide();
|
||||
}
|
||||
else {
|
||||
if (model->frsky.mAhPersistent) {
|
||||
ui->mahCount_ChkB->setChecked(true);
|
||||
ui->mahCount_SB->setValue(model->frsky.storedMah);
|
||||
}
|
||||
else {
|
||||
ui->mahCount_SB->setDisabled(true);
|
||||
}
|
||||
ui->variousGB->show();
|
||||
}
|
||||
|
||||
ui->frskyProtoCB->setCurrentIndex(model->frsky.usrProto);
|
||||
ui->bladesCount->setValue(model->frsky.blades);
|
||||
populateVarioSource();
|
||||
populateVoltsSource();
|
||||
populateCurrentSource();
|
||||
}
|
||||
|
||||
lock = false;
|
||||
}
|
||||
@@ -1170,10 +799,8 @@ void TelemetryPanel::populateVoltsSource()
|
||||
cb->setField(model->frsky.voltsSource, this);
|
||||
cb->addItem(tr("A1"), TELEMETRY_VOLTS_SOURCE_A1);
|
||||
cb->addItem(tr("A2"), TELEMETRY_VOLTS_SOURCE_A2);
|
||||
if (IS_ARM(firmware->getBoard())) {
|
||||
cb->addItem(tr("A3"), TELEMETRY_VOLTS_SOURCE_A3);
|
||||
cb->addItem(tr("A4"), TELEMETRY_VOLTS_SOURCE_A4);
|
||||
}
|
||||
cb->addItem(tr("A3"), TELEMETRY_VOLTS_SOURCE_A3);
|
||||
cb->addItem(tr("A4"), TELEMETRY_VOLTS_SOURCE_A4);
|
||||
cb->addItem(tr("FAS"), TELEMETRY_VOLTS_SOURCE_FAS);
|
||||
cb->addItem(tr("Cells"), TELEMETRY_VOLTS_SOURCE_CELLS);
|
||||
}
|
||||
@@ -1185,10 +812,8 @@ void TelemetryPanel::populateCurrentSource()
|
||||
cb->addItem(tr("---"), TELEMETRY_CURRENT_SOURCE_NONE);
|
||||
cb->addItem(tr("A1"), TELEMETRY_CURRENT_SOURCE_A1);
|
||||
cb->addItem(tr("A2"), TELEMETRY_CURRENT_SOURCE_A2);
|
||||
if (IS_ARM(firmware->getBoard())) {
|
||||
cb->addItem(tr("A3"), TELEMETRY_CURRENT_SOURCE_A3);
|
||||
cb->addItem(tr("A4"), TELEMETRY_CURRENT_SOURCE_A4);
|
||||
}
|
||||
cb->addItem(tr("A3"), TELEMETRY_CURRENT_SOURCE_A3);
|
||||
cb->addItem(tr("A4"), TELEMETRY_CURRENT_SOURCE_A4);
|
||||
cb->addItem(tr("FAS"), TELEMETRY_CURRENT_SOURCE_FAS);
|
||||
}
|
||||
|
||||
@@ -1223,18 +848,6 @@ void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index)
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryPanel::on_rssiAlarmWarningCB_currentIndexChanged(int index)
|
||||
{
|
||||
model->rssiAlarms.level[0] = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryPanel::on_rssiAlarmCriticalCB_currentIndexChanged(int index)
|
||||
{
|
||||
model->rssiAlarms.level[1] = index;
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryPanel::on_rssiAlarmWarningSB_editingFinished()
|
||||
{
|
||||
model->rssiAlarms.warning= ui->rssiAlarmWarningSB->value();
|
||||
|
||||
@@ -31,45 +31,11 @@ class RawSourceFilterItemModel;
|
||||
class TimerEdit;
|
||||
|
||||
namespace Ui {
|
||||
class TelemetryAnalog;
|
||||
class TelemetryCustomScreen;
|
||||
class TelemetrySensor;
|
||||
class Telemetry;
|
||||
}
|
||||
|
||||
class TelemetryAnalog: public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class TelemetryPanel;
|
||||
|
||||
public:
|
||||
TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~TelemetryAnalog();
|
||||
|
||||
signals:
|
||||
void modified();
|
||||
|
||||
private slots:
|
||||
void on_UnitCB_currentIndexChanged(int index);
|
||||
void on_RatioSB_editingFinished();
|
||||
void on_RatioSB_valueChanged();
|
||||
void on_CalibSB_editingFinished();
|
||||
void on_alarm1LevelCB_currentIndexChanged(int index);
|
||||
void on_alarm1GreaterCB_currentIndexChanged(int index);
|
||||
void on_alarm1ValueSB_editingFinished();
|
||||
void on_alarm2LevelCB_currentIndexChanged(int index);
|
||||
void on_alarm2GreaterCB_currentIndexChanged(int index);
|
||||
void on_alarm2ValueSB_editingFinished();
|
||||
|
||||
private:
|
||||
Ui::TelemetryAnalog *ui;
|
||||
FrSkyChannelData & analog;
|
||||
bool lock;
|
||||
|
||||
void update();
|
||||
};
|
||||
|
||||
class TelemetryCustomScreen: public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -155,8 +121,6 @@ class TelemetryPanel : public ModelPanel
|
||||
void onModified();
|
||||
void on_frskyProtoCB_currentIndexChanged(int index);
|
||||
void on_bladesCount_editingFinished();
|
||||
void on_rssiAlarmWarningCB_currentIndexChanged(int index);
|
||||
void on_rssiAlarmCriticalCB_currentIndexChanged(int index);
|
||||
void on_rssiAlarmWarningSB_editingFinished();
|
||||
void on_rssiAlarmCriticalSB_editingFinished();
|
||||
void on_varioLimitMin_DSB_editingFinished();
|
||||
@@ -170,7 +134,6 @@ class TelemetryPanel : public ModelPanel
|
||||
|
||||
private:
|
||||
Ui::Telemetry *ui;
|
||||
TelemetryAnalog * analogs[4];
|
||||
TelemetryCustomScreen * telemetryCustomScreens[4];
|
||||
TelemetrySensorPanel * sensorPanels[CPN_MAX_SENSORS];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user