mirror of
https://github.com/opentx/opentx.git
synced 2025-07-22 15:55:26 +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_A2:
|
||||
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();
|
||||
if (channel.type==0 || channel.type==1 || channel.type==2)
|
||||
result.decimals = 2;
|
||||
|
@ -239,12 +239,14 @@ QString SwitchDn(const char sw)
|
|||
|
||||
QString RawSwitch::toString()
|
||||
{
|
||||
static const QString switches9X[] = { QObject::tr("THR"), QObject::tr("RUD"), QObject::tr("ELE"),
|
||||
QObject::tr("ID0"), QObject::tr("ID1"), QObject::tr("ID2"),
|
||||
QObject::tr("AIL"), QObject::tr("GEA"), QObject::tr("TRN")
|
||||
static const QString switches9X[] = {
|
||||
QString("THR"), QString("RUD"), QString("ELE"),
|
||||
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('A'), QString::fromUtf8("SA-"), SwitchDn('A'),
|
||||
SwitchUp('B'), QString::fromUtf8("SB-"), SwitchDn('B'),
|
||||
SwitchUp('C'), QString::fromUtf8("SC-"), SwitchDn('C'),
|
||||
SwitchUp('D'), QString::fromUtf8("SD-"), SwitchDn('D'),
|
||||
|
@ -254,12 +256,18 @@ QString RawSwitch::toString()
|
|||
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("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("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("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) {
|
||||
case SWITCH_TYPE_SWITCH:
|
||||
if (IS_TARANIS(GetEepromInterface()->getBoard()))
|
||||
|
@ -268,6 +276,8 @@ QString RawSwitch::toString()
|
|||
return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1) : QString("!") + CHECK_IN_ARRAY(switches9X, -index-1);
|
||||
case SWITCH_TYPE_VIRTUAL:
|
||||
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:
|
||||
return QObject::tr("ON");
|
||||
case SWITCH_TYPE_ONM:
|
||||
|
|
|
@ -356,6 +356,7 @@ enum RawSwitchType {
|
|||
SWITCH_TYPE_NONE,
|
||||
SWITCH_TYPE_SWITCH,
|
||||
SWITCH_TYPE_VIRTUAL,
|
||||
SWITCH_TYPE_MULTIPOS_POT,
|
||||
SWITCH_TYPE_MOMENT_SWITCH,
|
||||
SWITCH_TYPE_MOMENT_VIRTUAL,
|
||||
SWITCH_TYPE_ON,
|
||||
|
@ -503,6 +504,7 @@ class GeneralSettings {
|
|||
unsigned int mavbaud;
|
||||
unsigned int switchUnlockStates;
|
||||
unsigned int hw_uartMode;
|
||||
unsigned int potsType[8];
|
||||
};
|
||||
|
||||
class CurveReference {
|
||||
|
@ -737,7 +739,7 @@ class FrSkyChannelData {
|
|||
unsigned int multiplier;
|
||||
FrSkyAlarmData alarms[2];
|
||||
|
||||
float getRatio()
|
||||
float getRatio() const
|
||||
{
|
||||
if (type==0 || type==1 || type==2)
|
||||
return float(ratio << multiplier) / 10.0;
|
||||
|
@ -1052,7 +1054,9 @@ enum Capability {
|
|||
EnhancedCurves,
|
||||
TelemetryInternalAlarms,
|
||||
HasFasOffset,
|
||||
HasMahPersistent
|
||||
HasMahPersistent,
|
||||
MultiposPots,
|
||||
MultiposPotsPositions
|
||||
};
|
||||
|
||||
enum UseContext {
|
||||
|
|
|
@ -56,21 +56,29 @@ class SwitchesConversionTable: public ConversionTable {
|
|||
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_ON), val++);
|
||||
|
||||
for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) {
|
||||
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++);
|
||||
}
|
||||
|
||||
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_ONM, 1 ), -val);
|
||||
// addConversion(RawSwitch(SWITCH_TYPE_ONM, 1 ), -val);
|
||||
addConversion(RawSwitch(SWITCH_TYPE_ONM, 0 ), val++);
|
||||
addConversion(RawSwitch(SWITCH_TYPE_TRN, 0), 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))
|
||||
internalField.Append(new UnsignedField<16>(generalData.variant));
|
||||
|
||||
if (version >= 216) {
|
||||
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.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<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.backgroundVolume));
|
||||
}
|
||||
if (version >= 216) {
|
||||
if (IS_TARANIS(board) && version >= 216) {
|
||||
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);
|
||||
case HasMahPersistent:
|
||||
return (IS_ARM(board) ? true : false);
|
||||
case MultiposPots:
|
||||
return IS_TARANIS(board) ? 2 : 0;
|
||||
case MultiposPotsPositions:
|
||||
return IS_TARANIS(board) ? 6 : 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -842,6 +842,8 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
|
|||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// TODO check ... I removed negative toggle switches in the FW, no?
|
||||
if (attr & POPULATE_MSWITCHES) {
|
||||
if (attr & POPULATE_ONOFF) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (attr & POPULATE_ONOFF) {
|
||||
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 (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) {
|
||||
item = RawSwitch(SWITCH_TYPE_ON);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
|
|
|
@ -245,8 +245,8 @@ enum BeeperMode {
|
|||
#if defined(PCBTARANIS)
|
||||
#define EXTRA_GENERAL_FIELDS \
|
||||
EXTRA_GENERAL_FIELDS_ARM \
|
||||
uint8_t potsType; \
|
||||
uint8_t hw_uartMode;
|
||||
uint8_t hw_uartMode; \
|
||||
uint8_t potsType;
|
||||
#elif defined(CPUARM)
|
||||
#define EXTRA_GENERAL_FIELDS EXTRA_GENERAL_FIELDS_ARM
|
||||
#elif defined(PXX)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue