mirror of
https://github.com/opentx/opentx.git
synced 2025-07-22 07:45:14 +03:00
EEPROM support in Companion for the 6pos pots on Taranis
This commit is contained in:
parent
1cef62df48
commit
8ef1456fe9
6 changed files with 82 additions and 33 deletions
|
@ -67,7 +67,7 @@ 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) {
|
||||||
FrSkyChannelData channel = model->frsky.channels[index-TELEMETRY_SOURCE_A1]; // TODO const &
|
const FrSkyChannelData & channel = model->frsky.channels[index-TELEMETRY_SOURCE_A1];
|
||||||
float ratio = channel.getRatio();
|
float ratio = channel.getRatio();
|
||||||
if (channel.type==0 || channel.type==1 || channel.type==2)
|
if (channel.type==0 || channel.type==1 || channel.type==2)
|
||||||
result.decimals = 2;
|
result.decimals = 2;
|
||||||
|
@ -239,26 +239,34 @@ QString SwitchDn(const char sw)
|
||||||
|
|
||||||
QString RawSwitch::toString()
|
QString RawSwitch::toString()
|
||||||
{
|
{
|
||||||
static const QString switches9X[] = { QObject::tr("THR"), QObject::tr("RUD"), QObject::tr("ELE"),
|
static const QString switches9X[] = {
|
||||||
QObject::tr("ID0"), QObject::tr("ID1"), QObject::tr("ID2"),
|
QString("THR"), QString("RUD"), QString("ELE"),
|
||||||
QObject::tr("AIL"), QObject::tr("GEA"), QObject::tr("TRN")
|
QString("ID0"), QString("ID1"), QString("ID2"),
|
||||||
};
|
QString("AIL"), QString("GEA"), QString("TRN")
|
||||||
|
};
|
||||||
|
|
||||||
static const QString switchesX9D[] = { SwitchUp('A'), QString::fromUtf8("SA-"), SwitchDn('A'),
|
static const QString switchesX9D[] = {
|
||||||
SwitchUp('B'), QString::fromUtf8("SB-"), SwitchDn('B'),
|
SwitchUp('A'), QString::fromUtf8("SA-"), SwitchDn('A'),
|
||||||
SwitchUp('C'), QString::fromUtf8("SC-"), SwitchDn('C'),
|
SwitchUp('B'), QString::fromUtf8("SB-"), SwitchDn('B'),
|
||||||
SwitchUp('D'), QString::fromUtf8("SD-"), SwitchDn('D'),
|
SwitchUp('C'), QString::fromUtf8("SC-"), SwitchDn('C'),
|
||||||
SwitchUp('E'), QString::fromUtf8("SE-"), SwitchDn('E'),
|
SwitchUp('D'), QString::fromUtf8("SD-"), SwitchDn('D'),
|
||||||
SwitchUp('F'), SwitchDn('F'),
|
SwitchUp('E'), QString::fromUtf8("SE-"), SwitchDn('E'),
|
||||||
SwitchUp('G'), QString::fromUtf8("SG-"), SwitchDn('G'),
|
SwitchUp('F'), SwitchDn('F'),
|
||||||
SwitchUp('H'), SwitchDn('H'),
|
SwitchUp('G'), QString::fromUtf8("SG-"), SwitchDn('G'),
|
||||||
};
|
SwitchUp('H'), SwitchDn('H'),
|
||||||
|
};
|
||||||
|
|
||||||
static const QString virtualSwitches[] = { QObject::tr("LS1"), QObject::tr("LS2"), QObject::tr("LS3"), QObject::tr("LS4"), QObject::tr("LS5"), QObject::tr("LS6"), QObject::tr("LS7"), QObject::tr("LS8"), QObject::tr("LS9"), QObject::tr("LSA"),
|
static const QString virtualSwitches[] = {
|
||||||
QObject::tr("LSB"), QObject::tr("LSC"), QObject::tr("LSD"), QObject::tr("LSE"), QObject::tr("LSF"), QObject::tr("LSG"), QObject::tr("LSH"), QObject::tr("LSI"), QObject::tr("LSJ"), QObject::tr("LSK"),
|
QObject::tr("LS1"), QObject::tr("LS2"), QObject::tr("LS3"), QObject::tr("LS4"), QObject::tr("LS5"), QObject::tr("LS6"), QObject::tr("LS7"), QObject::tr("LS8"), QObject::tr("LS9"), QObject::tr("LSA"),
|
||||||
QObject::tr("LSL"), QObject::tr("LSM"), QObject::tr("LSN"), QObject::tr("LSO"), QObject::tr("LSP"), QObject::tr("LSQ"), QObject::tr("LSR"), QObject::tr("LSS"), QObject::tr("LST"), QObject::tr("LSU"),
|
QObject::tr("LSB"), QObject::tr("LSC"), QObject::tr("LSD"), QObject::tr("LSE"), QObject::tr("LSF"), QObject::tr("LSG"), QObject::tr("LSH"), QObject::tr("LSI"), QObject::tr("LSJ"), QObject::tr("LSK"),
|
||||||
QObject::tr("LSV"), QObject::tr("LSW")
|
QObject::tr("LSL"), QObject::tr("LSM"), QObject::tr("LSN"), QObject::tr("LSO"), QObject::tr("LSP"), QObject::tr("LSQ"), QObject::tr("LSR"), QObject::tr("LSS"), QObject::tr("LST"), QObject::tr("LSU"),
|
||||||
};
|
QObject::tr("LSV"), QObject::tr("LSW")
|
||||||
|
};
|
||||||
|
|
||||||
|
static const QString multiposPots[] = {
|
||||||
|
QObject::tr("S11"), QObject::tr("S12"), QObject::tr("S13"), QObject::tr("S14"), QObject::tr("S15"), QObject::tr("S16"),
|
||||||
|
QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26")
|
||||||
|
};
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SWITCH_TYPE_SWITCH:
|
case SWITCH_TYPE_SWITCH:
|
||||||
|
@ -268,6 +276,8 @@ QString RawSwitch::toString()
|
||||||
return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1) : QString("!") + CHECK_IN_ARRAY(switches9X, -index-1);
|
return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1) : QString("!") + CHECK_IN_ARRAY(switches9X, -index-1);
|
||||||
case SWITCH_TYPE_VIRTUAL:
|
case SWITCH_TYPE_VIRTUAL:
|
||||||
return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1) : QString("!") + CHECK_IN_ARRAY(virtualSwitches, -index-1);
|
return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1) : QString("!") + CHECK_IN_ARRAY(virtualSwitches, -index-1);
|
||||||
|
case SWITCH_TYPE_MULTIPOS_POT:
|
||||||
|
return CHECK_IN_ARRAY(multiposPots, index);
|
||||||
case SWITCH_TYPE_ON:
|
case SWITCH_TYPE_ON:
|
||||||
return QObject::tr("ON");
|
return QObject::tr("ON");
|
||||||
case SWITCH_TYPE_ONM:
|
case SWITCH_TYPE_ONM:
|
||||||
|
|
|
@ -356,6 +356,7 @@ enum RawSwitchType {
|
||||||
SWITCH_TYPE_NONE,
|
SWITCH_TYPE_NONE,
|
||||||
SWITCH_TYPE_SWITCH,
|
SWITCH_TYPE_SWITCH,
|
||||||
SWITCH_TYPE_VIRTUAL,
|
SWITCH_TYPE_VIRTUAL,
|
||||||
|
SWITCH_TYPE_MULTIPOS_POT,
|
||||||
SWITCH_TYPE_MOMENT_SWITCH,
|
SWITCH_TYPE_MOMENT_SWITCH,
|
||||||
SWITCH_TYPE_MOMENT_VIRTUAL,
|
SWITCH_TYPE_MOMENT_VIRTUAL,
|
||||||
SWITCH_TYPE_ON,
|
SWITCH_TYPE_ON,
|
||||||
|
@ -503,6 +504,7 @@ class GeneralSettings {
|
||||||
unsigned int mavbaud;
|
unsigned int mavbaud;
|
||||||
unsigned int switchUnlockStates;
|
unsigned int switchUnlockStates;
|
||||||
unsigned int hw_uartMode;
|
unsigned int hw_uartMode;
|
||||||
|
unsigned int potsType[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
class CurveReference {
|
class CurveReference {
|
||||||
|
@ -737,7 +739,7 @@ class FrSkyChannelData {
|
||||||
unsigned int multiplier;
|
unsigned int multiplier;
|
||||||
FrSkyAlarmData alarms[2];
|
FrSkyAlarmData alarms[2];
|
||||||
|
|
||||||
float getRatio()
|
float getRatio() const
|
||||||
{
|
{
|
||||||
if (type==0 || type==1 || type==2)
|
if (type==0 || type==1 || type==2)
|
||||||
return float(ratio << multiplier) / 10.0;
|
return float(ratio << multiplier) / 10.0;
|
||||||
|
@ -1052,7 +1054,9 @@ enum Capability {
|
||||||
EnhancedCurves,
|
EnhancedCurves,
|
||||||
TelemetryInternalAlarms,
|
TelemetryInternalAlarms,
|
||||||
HasFasOffset,
|
HasFasOffset,
|
||||||
HasMahPersistent
|
HasMahPersistent,
|
||||||
|
MultiposPots,
|
||||||
|
MultiposPotsPositions
|
||||||
};
|
};
|
||||||
|
|
||||||
enum UseContext {
|
enum UseContext {
|
||||||
|
|
|
@ -56,21 +56,29 @@ class SwitchesConversionTable: public ConversionTable {
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, i), val++);
|
addConversion(RawSwitch(SWITCH_TYPE_VIRTUAL, i), val++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_TARANIS(board) && version >= 216) {
|
||||||
|
for (int i=0; i<2; i++) {
|
||||||
|
for (int j=0; j<6; j++) {
|
||||||
|
addConversion(RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i*6+j), val++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_OFF), -val);
|
addConversion(RawSwitch(SWITCH_TYPE_OFF), -val);
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_ON), val++);
|
addConversion(RawSwitch(SWITCH_TYPE_ON), val++);
|
||||||
|
|
||||||
for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) {
|
for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) {
|
||||||
int s = switchIndex(i, board, version);
|
int s = switchIndex(i, board, version);
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, -s), -val);
|
// addConversion(RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, -s), -val);
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, s), val++);
|
addConversion(RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, s), val++);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=1; i<=MAX_CUSTOM_SWITCHES(board, version); i++) {
|
for (int i=1; i<=MAX_CUSTOM_SWITCHES(board, version); i++) {
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, -i), -val);
|
// addConversion(RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, -i), -val);
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, i), val++);
|
addConversion(RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, i), val++);
|
||||||
}
|
}
|
||||||
|
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_ONM, 1 ), -val);
|
// addConversion(RawSwitch(SWITCH_TYPE_ONM, 1 ), -val);
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_ONM, 0 ), val++);
|
addConversion(RawSwitch(SWITCH_TYPE_ONM, 0 ), val++);
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_TRN, 0), val++);
|
addConversion(RawSwitch(SWITCH_TYPE_TRN, 0), val++);
|
||||||
addConversion(RawSwitch(SWITCH_TYPE_TRN, 1), val++);
|
addConversion(RawSwitch(SWITCH_TYPE_TRN, 1), val++);
|
||||||
|
@ -2011,12 +2019,21 @@ Open9xGeneralDataNew::Open9xGeneralDataNew(GeneralSettings & generalData, BoardE
|
||||||
if (version >= 213 || (!IS_ARM(board) && version >= 212))
|
if (version >= 213 || (!IS_ARM(board) && version >= 212))
|
||||||
internalField.Append(new UnsignedField<16>(generalData.variant));
|
internalField.Append(new UnsignedField<16>(generalData.variant));
|
||||||
|
|
||||||
for (int i=0; i<inputsCount; i++)
|
if (version >= 216) {
|
||||||
internalField.Append(new SignedField<16>(generalData.calibMid[i]));
|
for (int i=0; i<inputsCount; i++) {
|
||||||
for (int i=0; i<inputsCount; i++)
|
internalField.Append(new SignedField<16>(generalData.calibMid[i]));
|
||||||
internalField.Append(new SignedField<16>(generalData.calibSpanNeg[i]));
|
internalField.Append(new SignedField<16>(generalData.calibSpanNeg[i]));
|
||||||
for (int i=0; i<inputsCount; i++)
|
internalField.Append(new SignedField<16>(generalData.calibSpanPos[i]));
|
||||||
internalField.Append(new SignedField<16>(generalData.calibSpanPos[i]));
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (int i=0; i<inputsCount; i++)
|
||||||
|
internalField.Append(new SignedField<16>(generalData.calibMid[i]));
|
||||||
|
for (int i=0; i<inputsCount; i++)
|
||||||
|
internalField.Append(new SignedField<16>(generalData.calibSpanNeg[i]));
|
||||||
|
for (int i=0; i<inputsCount; i++)
|
||||||
|
internalField.Append(new SignedField<16>(generalData.calibSpanPos[i]));
|
||||||
|
}
|
||||||
|
|
||||||
internalField.Append(new UnsignedField<16>(chkSum));
|
internalField.Append(new UnsignedField<16>(chkSum));
|
||||||
internalField.Append(new UnsignedField<8>(generalData.currModel));
|
internalField.Append(new UnsignedField<8>(generalData.currModel));
|
||||||
|
@ -2110,8 +2127,11 @@ Open9xGeneralDataNew::Open9xGeneralDataNew(GeneralSettings & generalData, BoardE
|
||||||
internalField.Append(new SignedField<8>(generalData.varioVolume));
|
internalField.Append(new SignedField<8>(generalData.varioVolume));
|
||||||
internalField.Append(new SignedField<8>(generalData.backgroundVolume));
|
internalField.Append(new SignedField<8>(generalData.backgroundVolume));
|
||||||
}
|
}
|
||||||
if (version >= 216) {
|
if (IS_TARANIS(board) && version >= 216) {
|
||||||
internalField.Append(new UnsignedField<8>(generalData.hw_uartMode));
|
internalField.Append(new UnsignedField<8>(generalData.hw_uartMode));
|
||||||
|
for (int i=0; i<8; i++) {
|
||||||
|
internalField.Append(new UnsignedField<1>(generalData.potsType[i]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -682,6 +682,10 @@ int Open9xInterface::getCapability(const Capability capability)
|
||||||
return (IS_STOCK(board) ? false : true);
|
return (IS_STOCK(board) ? false : true);
|
||||||
case HasMahPersistent:
|
case HasMahPersistent:
|
||||||
return (IS_ARM(board) ? true : false);
|
return (IS_ARM(board) ? true : false);
|
||||||
|
case MultiposPots:
|
||||||
|
return IS_TARANIS(board) ? 2 : 0;
|
||||||
|
case MultiposPotsPositions:
|
||||||
|
return IS_TARANIS(board) ? 6 : 0;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -842,6 +842,8 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// TODO check ... I removed negative toggle switches in the FW, no?
|
||||||
if (attr & POPULATE_MSWITCHES) {
|
if (attr & POPULATE_MSWITCHES) {
|
||||||
if (attr & POPULATE_ONOFF) {
|
if (attr & POPULATE_ONOFF) {
|
||||||
item = RawSwitch(SWITCH_TYPE_ONM, 1);
|
item = RawSwitch(SWITCH_TYPE_ONM, 1);
|
||||||
|
@ -860,6 +862,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (attr & POPULATE_ONOFF) {
|
if (attr & POPULATE_ONOFF) {
|
||||||
item = RawSwitch(SWITCH_TYPE_OFF);
|
item = RawSwitch(SWITCH_TYPE_OFF);
|
||||||
|
@ -905,6 +908,14 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
|
||||||
if (item == value) b->setCurrentIndex(b->count()-1);
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||||
|
for (int i=0; i<GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) {
|
||||||
|
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i);
|
||||||
|
b->addItem(item.toString(), item.toValue());
|
||||||
|
if (item == value) b->setCurrentIndex(b->count()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (attr & POPULATE_ONOFF) {
|
if (attr & POPULATE_ONOFF) {
|
||||||
item = RawSwitch(SWITCH_TYPE_ON);
|
item = RawSwitch(SWITCH_TYPE_ON);
|
||||||
b->addItem(item.toString(), item.toValue());
|
b->addItem(item.toString(), item.toValue());
|
||||||
|
|
|
@ -245,8 +245,8 @@ enum BeeperMode {
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
#define EXTRA_GENERAL_FIELDS \
|
#define EXTRA_GENERAL_FIELDS \
|
||||||
EXTRA_GENERAL_FIELDS_ARM \
|
EXTRA_GENERAL_FIELDS_ARM \
|
||||||
uint8_t potsType; \
|
uint8_t hw_uartMode; \
|
||||||
uint8_t hw_uartMode;
|
uint8_t potsType;
|
||||||
#elif defined(CPUARM)
|
#elif defined(CPUARM)
|
||||||
#define EXTRA_GENERAL_FIELDS EXTRA_GENERAL_FIELDS_ARM
|
#define EXTRA_GENERAL_FIELDS EXTRA_GENERAL_FIELDS_ARM
|
||||||
#elif defined(PXX)
|
#elif defined(PXX)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue