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

S3 Configuration inside Companion

This commit is contained in:
bsongis 2014-03-20 15:40:50 +01:00
parent cdde00286a
commit dccfbb61d7
8 changed files with 189 additions and 108 deletions

View file

@ -791,115 +791,122 @@ QString FuncSwData::repeatToString()
GeneralSettings::GeneralSettings()
{
memset(this, 0, sizeof(GeneralSettings));
contrast = 25;
vBatWarn = 90;
for (int i=0; i<(NUM_STICKS+C9X_NUM_POTS ); ++i) {
for (int i=0; i<NUM_STICKS+C9X_NUM_POTS; ++i) {
calibMid[i] = 0x200;
calibSpanNeg[i] = 0x180;
calibSpanPos[i] = 0x180;
}
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
potsType[0] = 1;
potsType[1] = 1;
}
templateSetup = g.profile[g.id()].channelOrder();
stickMode = g.profile[g.id()].defaultMode();
QString t_calib=g.profile[g.id()].stickPotCalib();
int potsnum=GetEepromInterface()->getCapability(Pots);
if (t_calib.isEmpty()) {
return;
}
else {
QString t_trainercalib=g.profile[g.id()].trainerCalib();
int8_t t_vBatCalib=(int8_t)g.profile[g.id()].vBatCalib();
int8_t t_currentCalib=(int8_t)g.profile[g.id()].currentCalib();
int8_t t_PPM_Multiplier=(int8_t)g.profile[g.id()].ppmMultiplier();
uint8_t t_stickMode=(uint8_t)g.profile[g.id()].gsStickMode();
uint8_t t_vBatWarn=(uint8_t)g.profile[g.id()].vBatWarn();
QString t_DisplaySet=g.profile[g.id()].display();
QString t_BeeperSet=g.profile[g.id()].beeper();
QString t_HapticSet=g.profile[g.id()].haptic();
QString t_SpeakerSet=g.profile[g.id()].speaker();
QString t_CountrySet=g.profile[g.id()].countryCode();
QString t_calib=g.profile[g.id()].stickPotCalib();
int potsnum=GetEepromInterface()->getCapability(Pots);
if (t_calib.isEmpty()) {
return;
}
else {
QString t_trainercalib=g.profile[g.id()].trainerCalib();
int8_t t_vBatCalib=(int8_t)g.profile[g.id()].vBatCalib();
int8_t t_currentCalib=(int8_t)g.profile[g.id()].currentCalib();
int8_t t_PPM_Multiplier=(int8_t)g.profile[g.id()].ppmMultiplier();
uint8_t t_stickMode=(uint8_t)g.profile[g.id()].gsStickMode();
uint8_t t_vBatWarn=(uint8_t)g.profile[g.id()].vBatWarn();
QString t_DisplaySet=g.profile[g.id()].display();
QString t_BeeperSet=g.profile[g.id()].beeper();
QString t_HapticSet=g.profile[g.id()].haptic();
QString t_SpeakerSet=g.profile[g.id()].speaker();
QString t_CountrySet=g.profile[g.id()].countryCode();
if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) {
QString Byte;
int16_t byte16;
bool ok;
for (int i=0; i<(NUM_STICKS+potsnum); i++) {
Byte=t_calib.mid(i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibMid[i]=byte16;
Byte=t_calib.mid(4+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibSpanNeg[i]=byte16;
Byte=t_calib.mid(8+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibSpanPos[i]=byte16;
}
for (int i=0; i<4; i++) {
Byte=t_trainercalib.mid(i*4,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
trainer.calib[i]=byte16;
}
currentCalib=t_currentCalib;
vBatCalib=t_vBatCalib;
vBatWarn=t_vBatWarn;
PPM_Multiplier=t_PPM_Multiplier;
stickMode = t_stickMode;
if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) {
QString Byte;
int16_t byte16;
bool ok;
for (int i=0; i<(NUM_STICKS+potsnum); i++) {
Byte=t_calib.mid(i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibMid[i]=byte16;
Byte=t_calib.mid(4+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibSpanNeg[i]=byte16;
Byte=t_calib.mid(8+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
calibSpanPos[i]=byte16;
}
if ((t_DisplaySet.length()==6) && (t_BeeperSet.length()==4) && (t_HapticSet.length()==6) && (t_SpeakerSet.length()==6)) {
uint8_t byte8u;
int8_t byte8;
bool ok;
byte8=(int8_t)t_DisplaySet.mid(0,2).toInt(&ok,16);
for (int i=0; i<4; i++) {
Byte=t_trainercalib.mid(i*4,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
optrexDisplay=(byte8==1 ? true : false);
byte8u=(uint8_t)t_DisplaySet.mid(2,2).toUInt(&ok,16);
trainer.calib[i]=byte16;
}
currentCalib=t_currentCalib;
vBatCalib=t_vBatCalib;
vBatWarn=t_vBatWarn;
PPM_Multiplier=t_PPM_Multiplier;
stickMode = t_stickMode;
}
if ((t_DisplaySet.length()==6) && (t_BeeperSet.length()==4) && (t_HapticSet.length()==6) && (t_SpeakerSet.length()==6)) {
uint8_t byte8u;
int8_t byte8;
bool ok;
byte8=(int8_t)t_DisplaySet.mid(0,2).toInt(&ok,16);
if (ok)
optrexDisplay=(byte8==1 ? true : false);
byte8u=(uint8_t)t_DisplaySet.mid(2,2).toUInt(&ok,16);
if (ok)
contrast=byte8u;
byte8u=(uint8_t)t_DisplaySet.mid(4,2).toUInt(&ok,16);
if (ok)
backlightBright=byte8u;
byte8=(int8_t)t_BeeperSet.mid(0,2).toUInt(&ok,16);
if (ok)
beeperMode=(BeeperMode)byte8;
byte8=(int8_t)t_BeeperSet.mid(2,2).toInt(&ok,16);
if (ok)
beeperLength=byte8;
byte8=(int8_t)t_HapticSet.mid(0,2).toUInt(&ok,16);
if (ok)
hapticMode=(BeeperMode)byte8;
byte8u=(uint8_t)t_HapticSet.mid(2,2).toUInt(&ok,16);
if (ok)
hapticStrength=byte8u;
byte8=(int8_t)t_HapticSet.mid(4,2).toInt(&ok,16);
if (ok)
hapticLength=byte8;
byte8u=(uint8_t)t_SpeakerSet.mid(0,2).toUInt(&ok,16);
if (ok)
speakerMode=byte8u;
byte8u=(uint8_t)t_SpeakerSet.mid(2,2).toUInt(&ok,16);
if (ok)
speakerPitch=byte8u;
byte8u=(uint8_t)t_SpeakerSet.mid(4,2).toUInt(&ok,16);
if (ok)
speakerVolume=byte8u;
if (t_CountrySet.length()==6) {
byte8u=(uint8_t)t_CountrySet.mid(0,2).toUInt(&ok,16);
if (ok)
contrast=byte8u;
byte8u=(uint8_t)t_DisplaySet.mid(4,2).toUInt(&ok,16);
countryCode=byte8u;
byte8u=(uint8_t)t_CountrySet.mid(2,2).toUInt(&ok,16);
if (ok)
backlightBright=byte8u;
byte8=(int8_t)t_BeeperSet.mid(0,2).toUInt(&ok,16);
if (ok)
beeperMode=(BeeperMode)byte8;
byte8=(int8_t)t_BeeperSet.mid(2,2).toInt(&ok,16);
if (ok)
beeperLength=byte8;
byte8=(int8_t)t_HapticSet.mid(0,2).toUInt(&ok,16);
if (ok)
hapticMode=(BeeperMode)byte8;
byte8u=(uint8_t)t_HapticSet.mid(2,2).toUInt(&ok,16);
if (ok)
hapticStrength=byte8u;
byte8=(int8_t)t_HapticSet.mid(4,2).toInt(&ok,16);
if (ok)
hapticLength=byte8;
byte8u=(uint8_t)t_SpeakerSet.mid(0,2).toUInt(&ok,16);
if (ok)
speakerMode=byte8u;
byte8u=(uint8_t)t_SpeakerSet.mid(2,2).toUInt(&ok,16);
if (ok)
speakerPitch=byte8u;
byte8u=(uint8_t)t_SpeakerSet.mid(4,2).toUInt(&ok,16);
if (ok)
speakerVolume=byte8u;
if (t_CountrySet.length()==6) {
byte8u=(uint8_t)t_CountrySet.mid(0,2).toUInt(&ok,16);
if (ok)
countryCode=byte8u;
byte8u=(uint8_t)t_CountrySet.mid(2,2).toUInt(&ok,16);
if (ok)
imperial=byte8u;
QString chars=t_CountrySet.mid(4,2);
ttsLanguage[0]=chars[0].toAscii();
ttsLanguage[1]=chars[1].toAscii();
}
imperial=byte8u;
QString chars=t_CountrySet.mid(4,2);
ttsLanguage[0]=chars[0].toAscii();
ttsLanguage[1]=chars[1].toAscii();
}
}
}
}
RawSource GeneralSettings::getDefaultSource(unsigned int channel)

View file

@ -2595,8 +2595,8 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo
}
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]));
for (int i=0; i<4; i++) {
internalField.Append(new UnsignedField<2>(potsType[i]));
}
}
}
@ -2615,6 +2615,11 @@ void OpenTxGeneralData::beforeExport()
sum += generalData.calibSpanPos[i];
if (++count == 12) break;
}
for (int i=0; i<4; i++) {
potsType[i] = generalData.potsType[i];
if (i<2 && potsType[i] == 1)
potsType[i] = 0;
}
}
else {
for (int i=0; i<inputsCount; i++)
@ -2627,4 +2632,8 @@ void OpenTxGeneralData::beforeExport()
void OpenTxGeneralData::afterImport()
{
for (int i=0; i<4; i++) {
if (i<2 && generalData.potsType[i] == 0)
generalData.potsType[i] = 1;
}
}

View file

@ -65,6 +65,7 @@ class OpenTxGeneralData: public TransformedField {
unsigned int version;
int inputsCount;
unsigned int chkSum;
unsigned int potsType[4];
};
class ProtocolsConversionTable: public ConversionTable

View file

@ -369,6 +369,7 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
if (GetEepromInterface()->getCapability(MultiposPots)) {
ui->pot1Type->setCurrentIndex(g_eeGeneral.potsType[0]);
ui->pot2Type->setCurrentIndex(g_eeGeneral.potsType[1]);
ui->pot3Type->setCurrentIndex(g_eeGeneral.potsType[2]);
}
else {
ui->potsTypeSeparator->hide();
@ -376,6 +377,8 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
ui->pot1TypeLabel->hide();
ui->pot2Type->hide();
ui->pot2TypeLabel->hide();
ui->pot3Type->hide();
ui->pot3TypeLabel->hide();
}
}
@ -396,6 +399,12 @@ void GeneralEdit::on_pot2Type_currentIndexChanged(int index)
updateSettings();
}
void GeneralEdit::on_pot3Type_currentIndexChanged(int index)
{
g_eeGeneral.potsType[2] = index;
updateSettings();
}
void GeneralEdit::unlockSwitchEdited()
{
int i=0;

View file

@ -121,6 +121,7 @@ private slots:
void on_pot1Type_currentIndexChanged(int index);
void on_pot2Type_currentIndexChanged(int index);
void on_pot3Type_currentIndexChanged(int index);
void on_stickmodeCB_currentIndexChanged(int index);
void on_channelorderCB_currentIndexChanged(int index);

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>795</width>
<width>804</width>
<height>912</height>
</rect>
</property>
@ -1555,10 +1555,10 @@ Acceptable values are 5v..10v</string>
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<property name="topMargin">
<property name="verticalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<property name="topMargin">
<number>0</number>
</property>
<item row="0" column="2">
@ -3520,6 +3520,11 @@ p, li { white-space: pre-wrap; }
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Pot (normal)</string>
@ -3556,6 +3561,11 @@ p, li { white-space: pre-wrap; }
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Pot (normal)</string>
@ -3575,6 +3585,47 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="pot3TypeLabel">
<property name="text">
<string>S3 Type</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QComboBox" name="pot3Type">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Pot (normal)</string>
</property>
</item>
<item>
<property name="text">
<string>Multipos Switch</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</widget>

View file

@ -68,6 +68,7 @@ MdiChild::MdiChild():
fileChanged(false)
{
ui->setupUi(this);
this->setWindowIcon(CompanionIcon("open.png"));
ui->SimulateTxButton->setIcon(CompanionIcon("simulate.png"));
setAttribute(Qt::WA_DeleteOnClose);
@ -166,7 +167,8 @@ void MdiChild::OpenEditWindow(bool wizard=false)
ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) {
wizard=true;
} else {
}
else {
qSleep(500);
ret = QMessageBox::question(this, tr("Companion"), tr("Ask this question again ? "), QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::No) {
@ -496,7 +498,8 @@ void MdiChild::writeEeprom() // write to Tx
}
backupEnable=false;
}
} else {
}
else {
backupEnable=false;
}
QString stickCal=g.profile[g.id()].stickPotCalib();
@ -632,7 +635,8 @@ void MdiChild::print(int model, QString filename)
printDialog *pd = new printDialog(this, &radioData.generalSettings, &radioData.models[model], filename);
pd->show();
} else {
}
else {
if(ui->modelsList->currentRow()<1) return;
printDialog *pd = new printDialog(this, &radioData.generalSettings, &radioData.models[ui->modelsList->currentRow()-1]);
pd->show();
@ -671,9 +675,8 @@ bool MdiChild::loadBackup()
.arg(file.errorString()));
return false;
}
uint8_t *eeprom = (uint8_t *)malloc(eeprom_size);
memset(eeprom, 0, eeprom_size);
long result = file.read((char*)eeprom, eeprom_size);
QByteArray eeprom(eeprom_size, 0);
long result = file.read((char*)eeprom.data(), eeprom_size);
file.close();
if (result != eeprom_size) {
@ -685,7 +688,7 @@ bool MdiChild::loadBackup()
return false;
}
if (!LoadBackup(radioData, eeprom, eeprom_size, index)) {
if (!LoadBackup(radioData, (uint8_t *)eeprom.data(), eeprom_size, index)) {
QMessageBox::critical(this, tr("Error"),
tr("Invalid binary backup File %1")
.arg(fileName));
@ -693,6 +696,6 @@ bool MdiChild::loadBackup()
}
ui->modelsList->refreshList();
free(eeprom);
return true;
}

View file

@ -1213,10 +1213,10 @@ void menuGeneralHardware(uint8_t event)
putsMixerSource(sizeof(TR_TYPE)*FW, y, MIXSRC_FIRST_POT+idx);
uint8_t potType = (g_eeGeneral.potsType & mask) >> shift;
if (potType == POT_TYPE_NONE && i < 2)
potType = 1;
potType = POT_TYPE_POT;
potType = selectMenuItem(HW_SETTINGS_COLUMN, y, STR_TYPE, STR_POTTYPES, potType, 0, POT_TYPE_MAX, attr, event);
if (potType == POT_TYPE_POT && i < 2)
potType = 0;
potType = POT_TYPE_NONE;
g_eeGeneral.potsType &= ~mask;
g_eeGeneral.potsType |= (potType << shift);
break;