Skip to content

Commit

Permalink
Fixes #1172
Browse files Browse the repository at this point in the history
  • Loading branch information
bsongis committed Jun 4, 2014
1 parent c8e0b85 commit 61923a9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
17 changes: 17 additions & 0 deletions companion/src/eeprominterface.cpp
Expand Up @@ -1164,6 +1164,23 @@ int ModelData::getTrimValue(int phaseIdx, int trimIdx)
return 0;
}

bool ModelData::isGVarLinked(int phaseIdx, int gvarIdx)
{
return phaseData[phaseIdx].gvars[gvarIdx] > 1024;
}

int ModelData::getGVarValue(int phaseIdx, int gvarIdx)
{
int idx = phaseData[phaseIdx].gvars[gvarIdx];
for (int i=0; idx>1024 && i<C9X_MAX_FLIGHT_MODES; i++) {
int nextPhase = idx - 1025;
if (nextPhase >= phaseIdx) nextPhase += 1;
phaseIdx = nextPhase;
idx = phaseData[phaseIdx].gvars[gvarIdx];
}
return idx;
}

void ModelData::setTrimValue(int phaseIdx, int trimIdx, int value)
{
for (uint8_t i=0; i<C9X_MAX_FLIGHT_MODES; i++) {
Expand Down
4 changes: 4 additions & 0 deletions companion/src/eeprominterface.h
Expand Up @@ -1046,6 +1046,10 @@ class ModelData {

int getTrimValue(int phaseIdx, int trimIdx);
void setTrimValue(int phaseIdx, int trimIdx, int value);

bool isGVarLinked(int phaseIdx, int gvarIdx);
int getGVarValue(int phaseIdx, int gvarIdx);

ModelData removeGlobalVars();

void clearMixes();
Expand Down
12 changes: 2 additions & 10 deletions companion/src/modeledit/flightmodes.cpp
Expand Up @@ -202,17 +202,9 @@ void FlightModePanel::update()

for (int i=0; i<gvCount; i++) {
gvNames[i]->setText(model.gvars_names[i]);
gvValues[i]->setDisabled(false);
int idx = phase.gvars[i];
PhaseData *phasegvar = &phase;
while (idx > 1024) {
idx -= 1025;
phasegvar = &model.phaseData[idx];
idx = phasegvar->gvars[i];
gvValues[i]->setDisabled(true);
}
gvValues[i]->setDisabled(model.isGVarLinked(phaseIdx, i));
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
gvValues[i]->setValue(phasegvar->gvars[i]);
gvValues[i]->setValue(model.getGVarValue(phaseIdx, i));
if (phaseIdx == 0)
gvPopups[i]->setChecked(model.gvars_popups[i]);
}
Expand Down

0 comments on commit 61923a9

Please sign in to comment.