[X9E] Switch warning export issue
This commit is contained in:
@@ -113,19 +113,19 @@ class BaseUnsignedField: public DataField {
|
|||||||
DataField("Unsigned"),
|
DataField("Unsigned"),
|
||||||
field(field),
|
field(field),
|
||||||
min(0),
|
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),
|
DataField(name),
|
||||||
field(field),
|
field(field),
|
||||||
min(0),
|
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),
|
DataField(name),
|
||||||
field(field),
|
field(field),
|
||||||
min(min),
|
min(min),
|
||||||
@@ -141,8 +141,9 @@ class BaseUnsignedField: public DataField {
|
|||||||
|
|
||||||
output.resize(N);
|
output.resize(N);
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
if (value & (1<<i))
|
if (value & ((container)1<<i)) {
|
||||||
output.setBit(i);
|
output.setBit(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +152,7 @@ class BaseUnsignedField: public DataField {
|
|||||||
field = 0;
|
field = 0;
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
if (input[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);
|
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()
|
virtual void beforeExport()
|
||||||
{
|
{
|
||||||
_sw = sw;
|
_sw = sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void afterImport()
|
virtual void afterImport()
|
||||||
@@ -2092,7 +2092,7 @@ class SwitchesWarningField: public TransformedField {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseUnsignedField<uint64_t, N> internalField;
|
BaseUnsignedField<uint64_t, N> internalField;
|
||||||
uint64_t &sw;
|
uint64_t & sw;
|
||||||
uint64_t _sw;
|
uint64_t _sw;
|
||||||
BoardEnum board;
|
BoardEnum board;
|
||||||
unsigned int version;
|
unsigned int version;
|
||||||
|
|||||||
@@ -910,18 +910,19 @@ void SetupPanel::updateStartupSwitches()
|
|||||||
{
|
{
|
||||||
lock = true;
|
lock = true;
|
||||||
|
|
||||||
unsigned int switchStates = model->switchWarningStates;
|
uint64_t switchStates = model->switchWarningStates;
|
||||||
unsigned int value;
|
uint64_t value;
|
||||||
|
|
||||||
for (int i=0; i<startupSwitchesSliders.size(); i++) {
|
for (int i=0; i<startupSwitchesSliders.size(); i++) {
|
||||||
QSlider *slider = startupSwitchesSliders[i];
|
QSlider * slider = startupSwitchesSliders[i];
|
||||||
QCheckBox * cb = startupSwitchesCheckboxes[i];
|
QCheckBox * cb = startupSwitchesCheckboxes[i];
|
||||||
int index = slider->property("index").toInt();
|
int index = slider->property("index").toInt();
|
||||||
bool enabled = !(model->switchWarningEnable & (1 << index));
|
bool enabled = !(model->switchWarningEnable & (1 << index));
|
||||||
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||||
value = (switchStates >> 2*index) & 0x03;
|
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;
|
value = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
value = (i==0 ? switchStates & 0x3 : switchStates & 0x1);
|
value = (i==0 ? switchStates & 0x3 : switchStates & 0x1);
|
||||||
@@ -939,12 +940,12 @@ void SetupPanel::startupSwitchEdited(int value)
|
|||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
unsigned int mask;
|
uint64_t mask;
|
||||||
int index = sender()->property("index").toInt();
|
int index = sender()->property("index").toInt();
|
||||||
|
|
||||||
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||||
shift = index * 2;
|
shift = index * 2;
|
||||||
mask = 0x03 << shift;
|
mask = 0x03ul << shift;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
@@ -952,18 +953,20 @@ void SetupPanel::startupSwitchEdited(int value)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
shift = index+1;
|
shift = index+1;
|
||||||
mask = 0x01 << shift;
|
mask = 0x01ul << shift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model->switchWarningStates &= ~mask;
|
model->switchWarningStates &= ~mask;
|
||||||
|
|
||||||
if (IS_TARANIS(GetEepromInterface()->getBoard()) && generalSettings.switchConfig[index] != Firmware::SWITCH_3POS) {
|
if (IS_TARANIS(GetEepromInterface()->getBoard()) && generalSettings.switchConfig[index] != Firmware::SWITCH_3POS) {
|
||||||
if (value == 1) value = 2;
|
if (value == 1) {
|
||||||
|
value = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
model->switchWarningStates |= (value << shift);
|
model->switchWarningStates |= ((uint64_t)value << shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStartupSwitches();
|
updateStartupSwitches();
|
||||||
|
|||||||
Reference in New Issue
Block a user