1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-23 16:25:12 +03:00

[Companion] Fixes

This commit is contained in:
Bertrand Songis 2017-01-18 15:25:27 +01:00
parent 38c7f1c7d3
commit 1924d28be3
34 changed files with 297 additions and 325 deletions

View file

@ -115,7 +115,7 @@ void getFileComboBoxValue(QComboBox * b, char * dest, int length)
void populatePhasesCB(QComboBox *b, int value)
{
for (int i=-GetCurrentFirmware()->getCapability(FlightModes); i<=GetCurrentFirmware()->getCapability(FlightModes); i++) {
for (int i=-getCurrentFirmware()->getCapability(FlightModes); i<=getCurrentFirmware()->getCapability(FlightModes); i++) {
if (i < 0)
b->addItem(QObject::tr("!Flight mode %1").arg(-i-1), i);
else if (i > 0)
@ -123,7 +123,7 @@ void populatePhasesCB(QComboBox *b, int value)
else
b->addItem(QObject::tr("----"), 0);
}
b->setCurrentIndex(value + GetCurrentFirmware()->getCapability(FlightModes));
b->setCurrentIndex(value + getCurrentFirmware()->getCapability(FlightModes));
}
GVarGroup::GVarGroup(QCheckBox * weightGV, QAbstractSpinBox * weightSB, QComboBox * weightCB, int & weight, const ModelData & model, const int deflt, const int mini, const int maxi, const double step, bool allowGvars, ModelPanel * panel):
@ -138,7 +138,7 @@ GVarGroup::GVarGroup(QCheckBox * weightGV, QAbstractSpinBox * weightSB, QComboBo
lock(true),
panel(panel)
{
if (allowGvars && GetCurrentFirmware()->getCapability(Gvars)) {
if (allowGvars && getCurrentFirmware()->getCapability(Gvars)) {
populateGVCB(*weightCB, weight, model);
connect(weightGV, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int)));
connect(weightCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
@ -242,7 +242,7 @@ void CurveGroup::update()
curveTypeCB->setCurrentIndex(found);
if (curve.type == CurveReference::CURVE_REF_DIFF || curve.type == CurveReference::CURVE_REF_EXPO) {
curveGVarCB->setVisible(GetCurrentFirmware()->getCapability(Gvars));
curveGVarCB->setVisible(getCurrentFirmware()->getCapability(Gvars));
if (curve.value > 100 || curve.value < -100) {
curveGVarCB->setChecked(true);
if (lastType != CurveReference::CURVE_REF_DIFF && lastType != CurveReference::CURVE_REF_EXPO) {
@ -278,7 +278,7 @@ void CurveGroup::update()
break;
case CurveReference::CURVE_REF_CUSTOM:
{
int numcurves = GetCurrentFirmware()->getCapability(NumCurves);
int numcurves = getCurrentFirmware()->getCapability(NumCurves);
if (lastType != curve.type) {
lastType = curve.type;
curveValueCB->clear();
@ -367,7 +367,7 @@ void CurveGroup::valuesChanged()
void populateGvarUseCB(QComboBox *b, unsigned int phase)
{
b->addItem(QObject::tr("Own value"));
for (int i=0; i<GetCurrentFirmware()->getCapability(FlightModes); i++) {
for (int i=0; i<getCurrentFirmware()->getCapability(FlightModes); i++) {
if (i != (int)phase) {
b->addItem(QObject::tr("Flight mode %1 value").arg(i));
}
@ -376,7 +376,7 @@ void populateGvarUseCB(QComboBox *b, unsigned int phase)
void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettings & generalSettings, SwitchContext context)
{
BoardEnum board = GetCurrentFirmware()->getBoard();
BoardEnum board = getCurrentBoard();
RawSwitch item;
b->clear();
@ -384,7 +384,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
if (context != MixesContext && context != GlobalFunctionsContext) {
// !FMx
if (IS_ARM(board)) {
for (int i=-GetCurrentFirmware()->getCapability(FlightModes); i<0; i++) {
for (int i=-getCurrentFirmware()->getCapability(FlightModes); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
@ -393,14 +393,14 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
}
if (context != GlobalFunctionsContext) {
for (int i=-GetCurrentFirmware()->getCapability(LogicalSwitches); i<0; i++) {
for (int i=-getCurrentFirmware()->getCapability(LogicalSwitches); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
for (int i=-GetCurrentFirmware()->getCapability(RotaryEncoders); i<0; i++) {
for (int i=-getCurrentFirmware()->getCapability(RotaryEncoders); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
@ -412,17 +412,17 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=GetCurrentFirmware()->getCapability(MultiposPots)-1; i>=0; i--) {
for (int i=getCurrentFirmware()->getCapability(MultiposPots)-1; i>=0; i--) {
if (generalSettings.potConfig[i] == GeneralSettings::POT_MULTIPOS_SWITCH) {
for (int j=-GetCurrentFirmware()->getCapability(MultiposPotsPositions); j<0; j++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, -i*GetCurrentFirmware()->getCapability(MultiposPotsPositions)+j);
for (int j=-getCurrentFirmware()->getCapability(MultiposPotsPositions); j<0; j++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, -i*getCurrentFirmware()->getCapability(MultiposPotsPositions)+j);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
}
for (int i=-GetCurrentFirmware()->getCapability(SwitchesPositions); i<0; i++) {
for (int i=-getCurrentFirmware()->getCapability(SwitchesPositions); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (IS_HORUS_OR_TARANIS(board) && !generalSettings.switchPositionAllowedTaranis(i)) {
continue;
@ -444,7 +444,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetCurrentFirmware()->getCapability(SwitchesPositions); i++) {
for (int i=1; i<=getCurrentFirmware()->getCapability(SwitchesPositions); i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (IS_HORUS_OR_TARANIS(board) && !generalSettings.switchPositionAllowedTaranis(i)) {
continue;
@ -453,10 +453,10 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=0; i<GetCurrentFirmware()->getCapability(MultiposPots); i++) {
for (int i=0; i<getCurrentFirmware()->getCapability(MultiposPots); i++) {
if (generalSettings.potConfig[i] == GeneralSettings::POT_MULTIPOS_SWITCH) {
for (int j=1; j<=GetCurrentFirmware()->getCapability(MultiposPotsPositions); j++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i*GetCurrentFirmware()->getCapability(MultiposPotsPositions)+j);
for (int j=1; j<=getCurrentFirmware()->getCapability(MultiposPotsPositions); j++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i*getCurrentFirmware()->getCapability(MultiposPotsPositions)+j);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
@ -469,14 +469,14 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetCurrentFirmware()->getCapability(RotaryEncoders); i++) {
for (int i=1; i<=getCurrentFirmware()->getCapability(RotaryEncoders); i++) {
item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
if (context != GlobalFunctionsContext) {
for (int i=1; i<=GetCurrentFirmware()->getCapability(LogicalSwitches); i++) {
for (int i=1; i<=getCurrentFirmware()->getCapability(LogicalSwitches); i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
@ -497,7 +497,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
// FMx
if (context != MixesContext && context != GlobalFunctionsContext) {
if (IS_ARM(board)) {
for (int i=1; i<=GetCurrentFirmware()->getCapability(FlightModes); i++) {
for (int i=1; i<=getCurrentFirmware()->getCapability(FlightModes); i++) {
item = RawSwitch(SWITCH_TYPE_FLIGHT_MODE, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
@ -514,7 +514,7 @@ void populateGVCB(QComboBox & b, int value, const ModelData & model)
b.clear();
int count = GetCurrentFirmware()->getCapability(Gvars);
int count = getCurrentFirmware()->getCapability(Gvars);
for (int i=-count; i<=-1; i++) {
int16_t gval = (int16_t)(-10000+i);
if (strlen(model.gvars_names[-i-1]) > 0)
@ -546,7 +546,7 @@ void populateGVCB(QComboBox & b, int value, const ModelData & model)
void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSettings generalSettings, const ModelData * model, unsigned int flags)
{
BoardEnum board = GetCurrentFirmware()->getBoard();
BoardEnum board = getCurrentBoard();
RawSource item;
b->clear();
@ -558,8 +558,8 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
}
if (flags & POPULATE_SCRIPT_OUTPUTS) {
for (int i=0; i<GetCurrentFirmware()->getCapability(LuaScripts); i++) {
for (int j=0; j<GetCurrentFirmware()->getCapability(LuaOutputsPerScript); j++) {
for (int i=0; i<getCurrentFirmware()->getCapability(LuaScripts); i++) {
for (int j=0; j<getCurrentFirmware()->getCapability(LuaOutputsPerScript); j++) {
item = RawSource(SOURCE_TYPE_LUA_OUTPUT, i*16+j);
b->addItem(item.toString(model), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
@ -568,7 +568,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
}
if (model && (flags & POPULATE_VIRTUAL_INPUTS)) {
int virtualInputs = GetCurrentFirmware()->getCapability(VirtualInputs);
int virtualInputs = getCurrentFirmware()->getCapability(VirtualInputs);
for (int i=0; i<virtualInputs; i++) {
if (model->isInputValid(i)) {
item = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i);
@ -579,15 +579,15 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
}
if (flags & POPULATE_SOURCES) {
for (int i=0; i<CPN_MAX_STICKS+GetCurrentFirmware()->getCapability(Pots)+GetCurrentFirmware()->getCapability(Sliders); i++) {
for (int i=0; i<CPN_MAX_STICKS+getCurrentFirmware()->getCapability(Pots)+getCurrentFirmware()->getCapability(Sliders); i++) {
item = RawSource(SOURCE_TYPE_STICK, i);
// skip unavailable pots and sliders
if (item.isPot() && !generalSettings.isPotAvailable(i-CPN_MAX_STICKS)) continue;
if (item.isSlider() && !generalSettings.isSliderAvailable(i-CPN_MAX_STICKS-GetCurrentFirmware()->getCapability(Pots))) continue;
if (item.isSlider() && !generalSettings.isSliderAvailable(i-CPN_MAX_STICKS-getCurrentFirmware()->getCapability(Pots))) continue;
b->addItem(item.toString(model), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
}
for (int i=0; i<GetCurrentFirmware()->getCapability(RotaryEncoders); i++) {
for (int i=0; i<getCurrentFirmware()->getCapability(RotaryEncoders); i++) {
item = RawSource(SOURCE_TYPE_ROTARY_ENCODER, i);
b->addItem(item.toString(model), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
@ -609,7 +609,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
}
if (flags & POPULATE_SWITCHES) {
for (int i=0; i<GetCurrentFirmware()->getCapability(Switches); i++) {
for (int i=0; i<getCurrentFirmware()->getCapability(Switches); i++) {
item = RawSource(SOURCE_TYPE_SWITCH, i);
b->addItem(item.toString(model), item.toValue());
if (IS_HORUS_OR_TARANIS(board) && !generalSettings.switchSourceAllowedTaranis(i)) {
@ -620,7 +620,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
if (item == source) b->setCurrentIndex(b->count()-1);
}
for (int i=0; i<GetCurrentFirmware()->getCapability(LogicalSwitches); i++) {
for (int i=0; i<getCurrentFirmware()->getCapability(LogicalSwitches); i++) {
item = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, i);
b->addItem(item.toString(model), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
@ -634,13 +634,13 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
if (item == source) b->setCurrentIndex(b->count()-1);
}
for (int i=0; i<GetCurrentFirmware()->getCapability(TrainerInputs); i++) {
for (int i=0; i<getCurrentFirmware()->getCapability(TrainerInputs); i++) {
item = RawSource(SOURCE_TYPE_PPM, i);
b->addItem(item.toString(model), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
}
for (int i=0; i<GetCurrentFirmware()->getCapability(Outputs); i++) {
for (int i=0; i<getCurrentFirmware()->getCapability(Outputs); i++) {
item = RawSource(SOURCE_TYPE_CH, i);
b->addItem(item.toString(model), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
@ -648,7 +648,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
}
if (flags & POPULATE_TELEMETRY) {
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
if (IS_ARM(getCurrentBoard())) {
for (int i=0; i<5; ++i) {
item = RawSource(SOURCE_TYPE_SPECIAL, i);
b->addItem(item.toString(model), item.toValue());
@ -667,9 +667,9 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
}
else {
for (int i=0; i<(flags & POPULATE_TELEMETRYEXT ? TELEMETRY_SOURCES_STATUS_COUNT : TELEMETRY_SOURCES_COUNT); i++) {
if (i==TELEMETRY_SOURCE_TX_TIME && !GetCurrentFirmware()->getCapability(RtcTime))
if (i==TELEMETRY_SOURCE_TX_TIME && !getCurrentFirmware()->getCapability(RtcTime))
continue;
if (i==TELEMETRY_SOURCE_SWR && !GetCurrentFirmware()->getCapability(SportTelemetry))
if (i==TELEMETRY_SOURCE_SWR && !getCurrentFirmware()->getCapability(SportTelemetry))
continue;
if (i==TELEMETRY_SOURCE_TIMER3 && !IS_ARM(board))
continue;
@ -681,7 +681,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const GeneralSetti
}
if (flags & POPULATE_GVARS) {
for (int i=0; i<GetCurrentFirmware()->getCapability(Gvars); i++) {
for (int i=0; i<getCurrentFirmware()->getCapability(Gvars); i++) {
item = RawSource(SOURCE_TYPE_GVAR, i);
b->addItem(item.toString(model), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
@ -752,7 +752,7 @@ QString getFrSkyProtocol(int protocol)
{
switch(protocol) {
case 2:
if ((GetCurrentFirmware()->getCapability(Telemetry) & TM_HASWSHH))
if ((getCurrentFirmware()->getCapability(Telemetry) & TM_HASWSHH))
return QObject::tr("Winged Shadow How High");
else
return QObject::tr("Winged Shadow How High (not supported)");
@ -814,8 +814,8 @@ CompanionIcon::CompanionIcon(const QString &baseimage)
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
{
QString settingsPath;
Firmware * firmware = GetCurrentFirmware();
SimulatorInterface * simulator = GetCurrentFirmwareSimulator();
Firmware * firmware = getCurrentFirmware();
SimulatorInterface * simulator = getCurrentSimulator();
if (simulator) {
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
AllocConsole();
@ -833,7 +833,7 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
if (radioData.generalSettings.stickMode & 1) {
flags |= SIMULATOR_FLAGS_STICK_MODE_LEFT;
}
BoardEnum board = GetCurrentFirmware()->getBoard();
BoardEnum board = getCurrentBoard();
SimulatorDialog * dialog;
if (board == BOARD_HORUS) {
@ -850,12 +850,12 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
else if (board == BOARD_FLAMENCO) {
dialog = new SimulatorDialogFlamenco(parent, simulator, flags);
QByteArray eeprom(getEEpromSize(board), 0);
firmware->saveEEPROM((uint8_t *)eeprom.data(), *simuData);
firmware->getEEpromInterface()->save((uint8_t *)eeprom.data(), *simuData);
simulator->setSdPath(g.profile[g.id()].sdPath(), "");
dialog->start(eeprom);
}
else if (board == BOARD_TARANIS_X9D || board == BOARD_TARANIS_X9DP || board == BOARD_TARANIS_X9E) {
for (int i=0; i<GetCurrentFirmware()->getCapability(Pots); i++) {
for (int i=0; i<getCurrentFirmware()->getCapability(Pots); i++) {
if (radioData.generalSettings.isPotAvailable(i)) {
flags |= (SIMULATOR_FLAGS_S1 << i);
if (radioData.generalSettings.potConfig[1] == GeneralSettings::POT_MULTIPOS_SWITCH ) {
@ -865,7 +865,7 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
}
dialog = new SimulatorDialogTaranis(parent, simulator, flags);
QByteArray eeprom(getEEpromSize(board), 0);
firmware->saveEEPROM((uint8_t *)eeprom.data(), *simuData);
firmware->getEEpromInterface()->save((uint8_t *)eeprom.data(), *simuData);
qDebug() << "Starting Taranis simulation with SD path" << g.profile[g.id()].sdPath();
simulator->setSdPath(g.profile[g.id()].sdPath(), "");
dialog->start(eeprom);
@ -873,7 +873,7 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
else {
dialog = new SimulatorDialog9X(parent, simulator, flags);
QByteArray eeprom(getEEpromSize(board), 0);
firmware->saveEEPROM((uint8_t *)eeprom.data(), *simuData, 0, firmware->getCapability(SimulatorVariant));
firmware->getEEpromInterface()->save((uint8_t *)eeprom.data(), *simuData, 0, firmware->getCapability(SimulatorVariant));
simulator->setSdPath(g.profile[g.id()].sdPath(), ""); // does 9X need SD card path? I think not.
dialog->start(eeprom);
}
@ -900,7 +900,7 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
QPixmap makePixMap(const QImage & image)
{
Firmware * firmware = GetCurrentFirmware();
Firmware * firmware = getCurrentFirmware();
QImage result = image.scaled(firmware->getCapability(LcdWidth), firmware->getCapability(LcdHeight));
if (firmware->getCapability(LcdDepth) == 4) {
result = result.convertToFormat(QImage::Format_RGB32);