[X9E] Switch warning export issue

This commit is contained in:
Bertrand Songis
2016-11-18 22:52:31 +01:00
parent 32581568d3
commit 796f0b75ff
3 changed files with 21 additions and 17 deletions
+7 -6
View File
@@ -113,19 +113,19 @@ class BaseUnsignedField: public DataField {
DataField("Unsigned"),
field(field),
min(0),
max(UINT_MAX)
max(std::numeric_limits<container>::max())
{
}
BaseUnsignedField(container & field, const char *name):
BaseUnsignedField(container & field, const char * name):
DataField(name),
field(field),
min(0),
max(UINT_MAX)
max(std::numeric_limits<container>::max())
{
}
BaseUnsignedField(container & field, unsigned int min, unsigned int max, const char *name="Unsigned"):
BaseUnsignedField(container & field, container min, container max, const char * name="Unsigned"):
DataField(name),
field(field),
min(min),
@@ -141,8 +141,9 @@ class BaseUnsignedField: public DataField {
output.resize(N);
for (int i=0; i<N; i++) {
if (value & (1<<i))
if (value & ((container)1<<i)) {
output.setBit(i);
}
}
}
@@ -151,7 +152,7 @@ class BaseUnsignedField: public DataField {
field = 0;
for (int i=0; i<N; i++) {
if (input[i])
field |= (1<<i);
field |= ((container)1<<i);
}
eepromImportDebug() << QString("\timported %1<%2>: 0x%3(%4)").arg(name).arg(N).arg(field, 0, 16).arg(field);
}
@@ -2072,7 +2072,7 @@ class SwitchesWarningField: public TransformedField {
virtual void beforeExport()
{
_sw = sw;
_sw = sw;
}
virtual void afterImport()
@@ -2092,7 +2092,7 @@ class SwitchesWarningField: public TransformedField {
protected:
BaseUnsignedField<uint64_t, N> internalField;
uint64_t &sw;
uint64_t & sw;
uint64_t _sw;
BoardEnum board;
unsigned int version;
+12 -9
View File
@@ -910,18 +910,19 @@ void SetupPanel::updateStartupSwitches()
{
lock = true;
unsigned int switchStates = model->switchWarningStates;
unsigned int value;
uint64_t switchStates = model->switchWarningStates;
uint64_t value;
for (int i=0; i<startupSwitchesSliders.size(); i++) {
QSlider *slider = startupSwitchesSliders[i];
QSlider * slider = startupSwitchesSliders[i];
QCheckBox * cb = startupSwitchesCheckboxes[i];
int index = slider->property("index").toInt();
bool enabled = !(model->switchWarningEnable & (1 << index));
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
value = (switchStates >> 2*index) & 0x03;
if (generalSettings.switchConfig[index] != Firmware::SWITCH_3POS && value == 2)
if (generalSettings.switchConfig[index] != Firmware::SWITCH_3POS && value == 2) {
value = 1;
}
}
else {
value = (i==0 ? switchStates & 0x3 : switchStates & 0x1);
@@ -939,12 +940,12 @@ void SetupPanel::startupSwitchEdited(int value)
{
if (!lock) {
int shift = 0;
unsigned int mask;
uint64_t mask;
int index = sender()->property("index").toInt();
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
shift = index * 2;
mask = 0x03 << shift;
mask = 0x03ul << shift;
}
else {
if (index == 0) {
@@ -952,18 +953,20 @@ void SetupPanel::startupSwitchEdited(int value)
}
else {
shift = index+1;
mask = 0x01 << shift;
mask = 0x01ul << shift;
}
}
model->switchWarningStates &= ~mask;
if (IS_TARANIS(GetEepromInterface()->getBoard()) && generalSettings.switchConfig[index] != Firmware::SWITCH_3POS) {
if (value == 1) value = 2;
if (value == 1) {
value = 2;
}
}
if (value) {
model->switchWarningStates |= (value << shift);
model->switchWarningStates |= ((uint64_t)value << shift);
}
updateStartupSwitches();