void TelemetryCustomScreen::updateBar(int line) { lock = true; int index = screen.body.bars[line].source; barsCB[line]->setCurrentIndex(index); if (index) { RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1); RawSourceRange range = source.getRange(model, generalSettings, RANGE_SINGLE_PRECISION); 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; 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); } lock = false; }
void ExpoDialog::valuesChanged() { QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; RawSource srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt()); if (ed->srcRaw != srcRaw) { ed->srcRaw = srcRaw; updateScale(); } RawSourceRange range = srcRaw.getRange(&model, generalSettings); ed->scale = round(float(ui->scale->value()) / range.step); ed->carryTrim = 1 - ui->trimCB->currentIndex(); ed->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt()); ed->mode = ui->sideCB->currentIndex() + 1; strcpy(ed->name, ui->lineName->text().toAscii().data()); if (firmware->getCapability(VirtualInputs)) { inputName = ui->inputName->text(); } ed->flightModes = 0; for (int i=8; i>=0 ; i--) { if (!cb_fp[i]->checkState()) { ed->flightModes++; } ed->flightModes <<= 1; } ed->flightModes >>= 1; if (firmware->getCapability(FlightModes)) { int zeros = 0; int ones = 0; int phtemp = ed->flightModes; for (int i=0; i<firmware->getCapability(FlightModes); i++) { if (phtemp & 1) { ones++; } else { zeros++; } phtemp >>= 1; } if (zeros == 1) { phtemp=ed->flightModes; for (int i=0; i<firmware->getCapability(FlightModes); i++) { if ((phtemp & 1) == 0) { break; } phtemp >>= 1; } }
QString ModelPrinter::printLogicalSwitchLine(int idx) { QString result = ""; const LogicalSwitchData & ls = model.logicalSw[idx]; if (!ls.func) return result; if (ls.andsw!=0) { result +="( "; } switch (ls.getFunctionFamily()) { case LS_FAMILY_EDGE: result += tr("Edge(%1, [%2:%3])").arg(RawSwitch(ls.val1).toString()).arg(ValToTim(ls.val2)).arg(ls.val3<0 ? tr("instant") : QString("%1").arg(ValToTim(ls.val2+ls.val3))); break; case LS_FAMILY_STICKY: result += tr("Sticky(%1, %2)").arg(RawSwitch(ls.val1).toString()).arg(RawSwitch(ls.val2).toString()); break; case LS_FAMILY_TIMER: result += tr("Timer(%1, %2)").arg(ValToTim(ls.val1)).arg(ValToTim(ls.val2)); break; case LS_FAMILY_VOFS: { RawSource source = RawSource(ls.val1); RawSourceRange range = source.getRange(&model, generalSettings); QString res; if (ls.val1) res += source.toString(&model); else res += "0"; res.remove(" "); if (ls.func == LS_FN_APOS || ls.func == LS_FN_ANEG) res = "|" + res + "|"; else if (ls.func == LS_FN_DAPOS) res = "|d(" + res + ")|"; else if (ls.func == LS_FN_DPOS) result = "d(" + res + ")"; result += res; if (ls.func == LS_FN_VEQUAL) result += " = "; else if (ls.func == LS_FN_APOS || ls.func == LS_FN_VPOS || ls.func == LS_FN_DPOS || ls.func == LS_FN_DAPOS) result += " > "; else if (ls.func == LS_FN_ANEG || ls.func == LS_FN_VNEG) result += " < "; else if (ls.func == LS_FN_VALMOSTEQUAL) result += " ~ "; else result += " missing"; result += QString::number(range.step * (ls.val2 /*TODO+ source.getRawOffset(model)*/) + range.offset); break; } case LS_FAMILY_VBOOL: result += RawSwitch(ls.val1).toString(); switch (ls.func) { case LS_FN_AND: result += " AND "; break; case LS_FN_OR: result += " OR "; break; case LS_FN_XOR: result += " XOR "; break; default: result += " bar "; break; } result += RawSwitch(ls.val2).toString(); break; case LS_FAMILY_VCOMP: if (ls.val1) result += RawSource(ls.val1).toString(&model); else result += "0"; switch (ls.func) { case LS_FN_EQUAL: case LS_FN_VEQUAL: result += " = "; break; case LS_FN_NEQUAL: result += " != "; break; case LS_FN_GREATER: result += " > "; break; case LS_FN_LESS: result += " < "; break; case LS_FN_EGREATER: result += " >= "; break; case LS_FN_ELESS: result += " <= "; break; default: result += " foo "; break; } if (ls.val2) result += RawSource(ls.val2).toString(&model); else result += "0"; break; } if (ls.andsw != 0) { result +=" ) AND "; result += RawSwitch(ls.andsw).toString(); } if (firmware->getCapability(LogicalSwitchesExt)) { if (ls.duration) result += " " + tr("Duration(%1s)").arg(ls.duration/10.0); if (ls.delay) result += " " + tr("Delay(%1s)").arg(ls.delay/10.0); } return result; }
QString LogicalSwitchData::toString(const ModelData & model, const GeneralSettings & settings) { QString result = ""; if (!func) return result; if (andsw!=0) { result +="( "; } switch (getFunctionFamily()) { case LS_FAMILY_STAY: result += QObject::tr("Edge(%1, [%2:%3])").arg(RawSwitch(val1).toString()).arg(ValToTim(val2)).arg(ValToTim(val2+val3)); break; case LS_FAMILY_STICKY: result += QObject::tr("Sticky(%1, %2)").arg(RawSwitch(val1).toString()).arg(RawSwitch(val2).toString()); break; case LS_FAMILY_TIMER: result += QObject::tr("Timer(%1, %2)").arg(ValToTim(val1)).arg(ValToTim(val2)); break; case LS_FAMILY_VOFS: { RawSource source = RawSource(val1); RawSourceRange range = source.getRange(model, settings); QString res; if (val1) res += source.toString(model); else res += "0"; res.remove(" "); if (func == LS_FN_APOS || func == LS_FN_ANEG) res = "|" + res + "|"; else if (func == LS_FN_DAPOS) res = "|d(" + res + ")|"; else if (func == LS_FN_DPOS) result = "d(" + res + ")"; result += res; if (func == LS_FN_APOS || func == LS_FN_VPOS || func == LS_FN_DPOS || func == LS_FN_DAPOS) result += " > "; else if (func == LS_FN_ANEG || func == LS_FN_VNEG) result += " < "; else if (func == LS_FN_VALMOSTEQUAL) result += " ~ "; else result += " missing"; result += QString::number(range.step * (val2 /*TODO+ source.getRawOffset(model)*/) + range.offset); break; } case LS_FAMILY_VBOOL: result += RawSwitch(val1).toString(); switch (func) { case LS_FN_AND: result += " AND "; break; case LS_FN_OR: result += " OR "; break; case LS_FN_XOR: result += " XOR "; break; default: result += " bar "; break; } result += RawSwitch(val2).toString(); break; case LS_FAMILY_VCOMP: if (val1) result += RawSource(val1).toString(model); else result += "0"; switch (func) { case LS_FN_EQUAL: case LS_FN_VEQUAL: result += " = "; break; case LS_FN_NEQUAL: result += " != "; break; case LS_FN_GREATER: result += " > "; break; case LS_FN_LESS: result += " < "; break; case LS_FN_EGREATER: result += " >= "; break; case LS_FN_ELESS: result += " <= "; break; default: result += " foo "; break; } if (val2) result += RawSource(val2).toString(model); else result += "0"; break; } if (andsw!=0) { result +=" ) AND "; result += RawSwitch(andsw).toString(); } if (GetCurrentFirmware()->getCapability(LogicalSwitchesExt)) { if (duration) result += QObject::tr(" Duration (%1s)").arg(duration/10.0); if (delay) result += QObject::tr(" Delay (%1s)").arg(delay/10.0); } return result; }