Ebeo / eepe

Automatically exported from code.google.com/p/eepe
0 stars 1 forks source link

Trainer Tab, issue with weight fields #107

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Open EEPROM file (or new file) and go to general settings then trainer tab. Go 
to RUD weight and set at 100% using arrows. Then click on THR and set to 100% 
using arrows. RUD value will change to 91%. This is occurring for all the 
weight settings in this screen. Weight seem to influence the field above it if 
that makes sense. Also could not enter the weight value directly from keyboard, 
had to use mouse and up/down arrow 

What is the expected output? What do you see instead?
Changing weight value should only alter value in active field. Changing weight 
in active field alters weight field above it. 

What version of the product are you using? On what operating system?
version 267 on both Ubuntu and Win XP

Please provide any additional information below.

Original issue reported on code.google.com by mjfl.lam...@gmail.com on 24 Aug 2011 at 11:15

GoogleCodeExporter commented 9 years ago
yep, confirm. it doesn't happen only with 100.. try to set other values. it 
gets crazy too

Original comment by joaoalve...@googlemail.com on 24 Aug 2011 at 2:32

GoogleCodeExporter commented 9 years ago
from generaledit.cpp remove lines 115-118:
connect(ui->weightSB_1, SIGNAL(valueChanged(int)), this, 
SLOT(validateWeightSB())); connect(ui->weightSB_2, SIGNAL(valueChanged(int)), 
this, SLOT(validateWeightSB())); connect(ui->weightSB_3, 
SIGNAL(valueChanged(int)), this, SLOT(validateWeightSB())); 
connect(ui->weightSB_4, SIGNAL(valueChanged(int)), this, 
SLOT(validateWeightSB())); 

and:

line 156 need to be changed from:
ui->modeCB_4->setCurrentIndex(g_eeGeneral.trainer.mix[0].mode);
to:
ui->modeCB_4->setCurrentIndex(g_eeGeneral.trainer.mix[3].mode);

Original comment by gbir...@gmail.com on 6 Nov 2011 at 11:19

GoogleCodeExporter commented 9 years ago
On the right track but if you change the weights, exit General Edit and then 
reopen General Settings the weight variables have changed again. Try entering 
100 for all the weights as per above. Exit and then reopen as above and the 
weights will have changed to 97. These variables are being changed elsewhere in 
the code.

Original comment by mjfl.lam...@gmail.com on 7 Nov 2011 at 8:08

GoogleCodeExporter commented 9 years ago
It makes some sense.... to have variable changed due to te fact that in er9x 
trainer weights are represented as 6 bit signed values and scaled each time to 
+/- 100. (value*13/4) considering. 
If you insert 100 in the weight when saving in the eeprom it becomes 30 as 
100*4/13=30,7 and trunking to integer becomes 30
When you reload from eeprom 30 convert to 97.5 and again trunking to integer 
becomes 97
If you save the value back 97*4/13 it convert as 29.
And so on... Probably some rounding is missed around...

Original comment by romolo.m...@gmail.com on 7 Nov 2011 at 11:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Romolo thanks for nice demonstration.
then it need to be changed for (value*10/3)+1 and value*3/10
with this formula, there is always only one conversion to nearest value
and stepping by 3 looks beter replace all <number>4</number> with 
<number>3</number> in genetaledit.ui

generaledit.cpp:
void GeneralEdit::updateTrianerTab()
{
    on_tabWidget_selected(""); // updates channel name labels

    ui->modeCB_1->setCurrentIndex(g_eeGeneral.trainer.mix[0].mode);
    ui->weightSB_1->setValue((g_eeGeneral.trainer.mix[0].studWeight*10/3)+1);
    ui->sourceCB_1->setCurrentIndex(g_eeGeneral.trainer.mix[0].srcChn);
    populateSwitchCB(ui->swtchCB_1,g_eeGeneral.trainer.mix[0].swtch);

    ui->modeCB_2->setCurrentIndex(g_eeGeneral.trainer.mix[1].mode);
    ui->weightSB_2->setValue((g_eeGeneral.trainer.mix[1].studWeight*10/3)+1);
    ui->sourceCB_2->setCurrentIndex(g_eeGeneral.trainer.mix[1].srcChn);
    populateSwitchCB(ui->swtchCB_2,g_eeGeneral.trainer.mix[1].swtch);

    ui->modeCB_3->setCurrentIndex(g_eeGeneral.trainer.mix[2].mode);
    ui->weightSB_3->setValue((g_eeGeneral.trainer.mix[2].studWeight*10/3)+1);
    ui->sourceCB_3->setCurrentIndex(g_eeGeneral.trainer.mix[2].srcChn);
    populateSwitchCB(ui->swtchCB_3,g_eeGeneral.trainer.mix[2].swtch);

    ui->modeCB_4->setCurrentIndex(g_eeGeneral.trainer.mix[3].mode);
    ui->weightSB_4->setValue((g_eeGeneral.trainer.mix[3].studWeight*10/3)+1);
    ui->sourceCB_4->setCurrentIndex(g_eeGeneral.trainer.mix[3].srcChn);
    populateSwitchCB(ui->swtchCB_4,g_eeGeneral.trainer.mix[3].swtch);

    ui->trainerCalib_1->setValue(g_eeGeneral.trainer.calib[0]);
    ui->trainerCalib_2->setValue(g_eeGeneral.trainer.calib[1]);
    ui->trainerCalib_3->setValue(g_eeGeneral.trainer.calib[2]);
    ui->trainerCalib_4->setValue(g_eeGeneral.trainer.calib[3]);

    ui->PPM_MultiplierDSB->setValue(double(g_eeGeneral.PPM_Multiplier+10)/10);
}

void GeneralEdit::trainerTabValueChanged()
{
    g_eeGeneral.trainer.mix[0].mode       = ui->modeCB_1->currentIndex();
    g_eeGeneral.trainer.mix[0].studWeight = ui->weightSB_1->value()*3/10;
    g_eeGeneral.trainer.mix[0].srcChn     = ui->sourceCB_1->currentIndex();
    g_eeGeneral.trainer.mix[0].swtch      = ui->swtchCB_1->currentIndex()-MAX_DRSWITCH;

    g_eeGeneral.trainer.mix[1].mode       = ui->modeCB_2->currentIndex();
    g_eeGeneral.trainer.mix[1].studWeight = ui->weightSB_2->value()*3/10;
    g_eeGeneral.trainer.mix[1].srcChn     = ui->sourceCB_2->currentIndex();
    g_eeGeneral.trainer.mix[1].swtch      = ui->swtchCB_2->currentIndex()-MAX_DRSWITCH;

    g_eeGeneral.trainer.mix[2].mode       = ui->modeCB_3->currentIndex();
    g_eeGeneral.trainer.mix[2].studWeight = ui->weightSB_3->value()*3/10;
    g_eeGeneral.trainer.mix[2].srcChn     = ui->sourceCB_3->currentIndex();
    g_eeGeneral.trainer.mix[2].swtch      = ui->swtchCB_3->currentIndex()-MAX_DRSWITCH;

    g_eeGeneral.trainer.mix[3].mode       = ui->modeCB_4->currentIndex();
    g_eeGeneral.trainer.mix[3].studWeight = ui->weightSB_4->value()*3/10;
    g_eeGeneral.trainer.mix[3].srcChn     = ui->sourceCB_4->currentIndex();
    g_eeGeneral.trainer.mix[3].swtch      = ui->swtchCB_4->currentIndex()-MAX_DRSWITCH;

    g_eeGeneral.trainer.calib[0] = ui->trainerCalib_1->value();
    g_eeGeneral.trainer.calib[1] = ui->trainerCalib_2->value();
    g_eeGeneral.trainer.calib[2] = ui->trainerCalib_3->value();
    g_eeGeneral.trainer.calib[3] = ui->trainerCalib_4->value();

    g_eeGeneral.PPM_Multiplier = ((quint16)(ui->PPM_MultiplierDSB->value()*10))-10;

    updateSettings();
}

void GeneralEdit::validateWeightSB()
{
    int i;

    ui->weightSB_1->blockSignals(true);
    ui->weightSB_2->blockSignals(true);
    ui->weightSB_3->blockSignals(true);
    ui->weightSB_4->blockSignals(true);

    i = ui->weightSB_1->value()*3/10;
    ui->weightSB_1->setValue((i*10/3)+1);

    i = ui->weightSB_2->value()*3/10;
    ui->weightSB_2->setValue((i*10/3)+1);

    i = ui->weightSB_3->value()*3/10;
    ui->weightSB_3->setValue((i*10/3)+1);

    i = ui->weightSB_4->value()*3/10;
    ui->weightSB_4->setValue((i*10/3)+1);

    ui->weightSB_1->blockSignals(false);
    ui->weightSB_2->blockSignals(false);
    ui->weightSB_3->blockSignals(false);
    ui->weightSB_4->blockSignals(false);
}

Original comment by gbir...@gmail.com on 7 Nov 2011 at 5:18

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Fixed in R288, please close.

Original comment by romolo.m...@gmail.com on 13 Nov 2011 at 2:03