[Companion] Radio conversion improvements (#5534)

* Move MultiposPots & MultiposPotsPositions capability lookups and getAnalogInputName() to Boards class.

* Add RawSource::isAvailable() and RawSwitch::isAvailable(); Add board type param to various RawSource lookup functions.

* Add CustomFunctionData::toString(), FlightModeData::toString(), FactoryInstalledPots board capability, MAX_SWITCH_TYPE, & break out GeneralSettings source/switch defaults to own function.

* Add RadioDataConversionState class for tracking conversion actions.

* Implement RadioDataConversionState handler, add conversion process report, and improve/fix conversion issues:
    * Make sure all switches/pots/knobs have default configs for destination board type;
    * Try to move more custom control names, intelligently;
    * Convert model timers and throttle source;
    * Adjust for Horus 6P switch in place of Taranis S2 knob;
    * Adjust for extra sliders on X12 and X9E to move LS and RS to proper slots as needed;
    * Make sure ALL controls are validated, eg. to always account for extra trims/analogs/switches/etc which don't exist on destination;
    * Properly indicate invalid RawSource::toString() items with "???".

* Allow user to cancel out of file conversions & provide ample warnings if switching radio type/profile with unsaved file(s) still open;
Also: Fix bug with some orphaned MdiChild windows never being deleted; Create static bool Storage::isBoardCompatible(b1, b2).

* Add maxLibQt "stub" (will not compile).

* Add ExportableTableView for better presentation of conversion results table.

* Move getFourCC() and isBoardCompatible() to Boards class.
This commit is contained in:
Max Paperno
2017-12-18 22:56:39 +01:00
committed by Bertrand Songis
parent e63a877ed6
commit 0dbad182e8
25 changed files with 1536 additions and 420 deletions
@@ -141,7 +141,7 @@ bool OpenTxEepromInterface::saveToByteArray(const T & src, QByteArray & data, ui
// manager.Dump();
manager.Export(raw);
data.resize(8);
*((uint32_t*)&data.data()[0]) = StorageFormat::getFourCC(board);
*((uint32_t*)&data.data()[0]) = Boards::getFourCC(board);
data[4] = version;
data[5] = 'M';
*((uint16_t*)&data.data()[6]) = raw.size();
@@ -164,12 +164,12 @@ template <class T, class M>
bool OpenTxEepromInterface::loadFromByteArray(T & dest, const QByteArray & data)
{
uint32_t fourcc = *((uint32_t*)&data.data()[0]);
if (StorageFormat::getFourCC(board) != fourcc) {
if (Boards::getFourCC(board) != fourcc) {
if (IS_HORUS(board) && fourcc == 0x3178396F) {
qDebug() << QString().sprintf("%s: Deprecated fourcc used %x vs %x", getName(), fourcc, StorageFormat::getFourCC(board));
qDebug() << QString().sprintf("%s: Deprecated fourcc used %x vs %x", getName(), fourcc, Boards::getFourCC(board));
}
else {
qDebug() << QString().sprintf("%s: Wrong fourcc %x vs %x", getName(), fourcc, StorageFormat::getFourCC(board));
qDebug() << QString().sprintf("%s: Wrong fourcc %x vs %x", getName(), fourcc, Boards::getFourCC(board));
return false;
}
}
@@ -679,10 +679,6 @@ int OpenTxFirmware::getCapability(::Capability capability)
return (IS_STOCK(board) ? false : true);
case HasMahPersistent:
return (IS_ARM(board) ? true : false);
case MultiposPots:
return IS_HORUS_OR_TARANIS(board) ? 3 : 0;
case MultiposPotsPositions:
return IS_HORUS_OR_TARANIS(board) ? 6 : 0;
case SimulatorVariant:
if (board == BOARD_STOCK)
return SIMU_STOCK_VARIANTS;
@@ -714,76 +710,7 @@ int OpenTxFirmware::getCapability(::Capability capability)
QString OpenTxFirmware::getAnalogInputName(unsigned int index)
{
if ((int)index < getBoardCapability(board, Board::Sticks)) {
const QString sticks[] = {
QObject::tr("Rud"),
QObject::tr("Ele"),
QObject::tr("Thr"),
QObject::tr("Ail")
};
return sticks[index];
}
index -= getBoardCapability(board, Board::Sticks);
if (IS_9X(board) || IS_2560(board) || IS_SKY9X(board)) {
const QString pots[] = {
QObject::tr("P1"),
QObject::tr("P2"),
QObject::tr("P3")
};
return CHECK_IN_ARRAY(pots, index);
}
else if (IS_TARANIS_X9E(board)) {
const QString pots[] = {
QObject::tr("F1"),
QObject::tr("F2"),
QObject::tr("F3"),
QObject::tr("F4"),
QObject::tr("S1"),
QObject::tr("S2"),
QObject::tr("LS"),
QObject::tr("RS")
};
return CHECK_IN_ARRAY(pots, index);
}
else if (IS_TARANIS(board)) {
const QString pots[] = {
QObject::tr("S1"),
QObject::tr("S2"),
QObject::tr("S3"),
QObject::tr("LS"),
QObject::tr("RS")
};
return CHECK_IN_ARRAY(pots, index);
}
else if (IS_HORUS_X12S(board)) {
const QString pots[] = {
QObject::tr("S1"),
QObject::tr("6P"),
QObject::tr("S2"),
QObject::tr("L1"),
QObject::tr("L2"),
QObject::tr("LS"),
QObject::tr("RS"),
QObject::tr("JSx"),
QObject::tr("JSy")
};
return CHECK_IN_ARRAY(pots, index);
}
else if (IS_HORUS_X10(board)) {
const QString pots[] = {
QObject::tr("S1"),
QObject::tr("6P"),
QObject::tr("S2"),
QObject::tr("LS"),
QObject::tr("RS")
};
return CHECK_IN_ARRAY(pots, index);
}
else {
return "???";
}
return Boards::getAnalogInputName(board, index);
}
QTime OpenTxFirmware::getMaxTimerStart()