Skip to content

Commit

Permalink
added support for min/max contrast to eeprom interface and use it (op…
Browse files Browse the repository at this point in the history
…entx#5473)

Added support for min/max contrast to eeprom interface and use it. Fixes opentx#5468
  • Loading branch information
raphaelcoeffic authored and mr-pokryshkin committed Dec 19, 2017
1 parent f8c0e18 commit 8d47a29
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions companion/src/eeprominterface.h
Expand Up @@ -69,6 +69,8 @@ enum Capability {
SoundMod,
SoundPitch,
MaxVolume,
MaxContrast,
MinContrast,
Haptic,
HasBeeper,
ModelTrainerEnable,
Expand Down
10 changes: 10 additions & 0 deletions companion/src/firmwares/opentx/opentxinterface.cpp
Expand Up @@ -543,6 +543,16 @@ int OpenTxFirmware::getCapability(::Capability capability)
return 0;
case MaxVolume:
return (IS_ARM(board) ? 23 : 7);
case MaxContrast:
if (IS_TARANIS_X7(board))
return 30;
else
return 45;
case MinContrast:
if (IS_TARANIS_X9(board))
return 0;
else
return 10;
case HasSoundMixer:
return (IS_ARM(board) ? 1 : 0);
case ExtraInputs:
Expand Down
4 changes: 3 additions & 1 deletion companion/src/generaledit/generalsetup.cpp
Expand Up @@ -31,7 +31,6 @@ ui(new Ui::GeneralSetup)
QSlider *tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, ui->chkSH, NULL};

if (IS_TARANIS(firmware->getBoard())) {
ui->contrastSB->setMinimum(0);
if (firmware->getId().contains("readonly")) {
uint16_t switchstate = generalSettings.switchUnlockStates;
ui->chkSA->setValue(switchstate & 0x3);
Expand Down Expand Up @@ -216,7 +215,10 @@ ui(new Ui::GeneralSetup)
populateRotEncCB(reCount);
}

ui->contrastSB->setMinimum(firmware->getCapability(MinContrast));
ui->contrastSB->setMaximum(firmware->getCapability(MaxContrast));
ui->contrastSB->setValue(generalSettings.contrast);

ui->battwarningDSB->setValue((double)generalSettings.vBatWarn/10);
ui->backlightautoSB->setValue(generalSettings.backlightDelay*5);
ui->inactimerSB->setValue(generalSettings.inactivityTimer);
Expand Down
10 changes: 10 additions & 0 deletions companion/src/radiodata.cpp
Expand Up @@ -212,6 +212,16 @@ void GeneralSettings::convert(Board::Type before, Board::Type after)
memcpy(switchName[5], switchName[7], sizeof(switchName[5]));
}
}

if (IS_TARANIS(after)) {
unsigned int min_contrast = getCurrentFirmware()->getCapability(MinContrast);
unsigned int max_contrast = getCurrentFirmware()->getCapability(MaxContrast);

if (contrast < min_contrast)
contrast = min_contrast;
else if (contrast > max_contrast)
contrast = max_contrast;
}
}


Expand Down

0 comments on commit 8d47a29

Please sign in to comment.