From b6e52f5ee3850fb476ef6f8bb204252420fcc56b Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Wed, 12 Aug 2026 07:25:11 +1000 Subject: [PATCH] fix(v14): OLED brightness wraps above 235 (#7633) Co-authored-by: Peter Feerick <5500713+pfeerick@users.noreply.github.com> Co-authored-by: Claude Sonnet 5 --- companion/src/firmwares/boards.cpp | 8 ++++++-- companion/src/generaledit/generalsetup.cpp | 9 +++++++++ companion/src/generaledit/generalsetup.ui | 17 ++--------------- radio/src/targets/taranis/hal.h | 2 +- radio/src/targets/taranis/lcd_driver_spi.cpp | 6 +++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/companion/src/firmwares/boards.cpp b/companion/src/firmwares/boards.cpp index eba1055bf..114b6d4b1 100644 --- a/companion/src/firmwares/boards.cpp +++ b/companion/src/firmwares/boards.cpp @@ -390,7 +390,9 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) IS_RADIOMASTER_ZORRO(board); case MaxContrast: - if (IS_TARANIS_SMALL(board)) + if (getCapability(board, LcdOLED)) + return 254; + else if (IS_TARANIS_SMALL(board)) return 30; else return 45; @@ -399,7 +401,9 @@ int Boards::getCapability(Board::Type board, Board::Capability capability) return 23; case MinContrast: - if (IS_TARANIS_X9(board)) + if (getCapability(board, LcdOLED)) + return 2; + else if (IS_TARANIS_X9(board)) return 0; else return 10; diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index abd60277c..6462c3143 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -141,6 +141,15 @@ ui(new Ui::GeneralSetup) ui->contrastSB->setMaximum(Boards::getCapability(board, Board::MaxContrast)); ui->contrastSB->setValue(generalSettings.contrast); + if (Boards::getCapability(board, Board::LcdOLED)) { + // OLED radios have no backlight - "contrast" is the panel brightness + ui->label_contrast->setText(tr("Brightness")); + ui->BLBright_SB->hide(); + ui->BLBright_SB->setDisabled(true); + ui->label_BLBright->hide(); + ui->blAlarm_LB->setText(tr("Flash display on alarm")); + } + ui->battwarningDSB->setValue((double)generalSettings.vBatWarn / 10); ui->backlightautoSB->setValue(generalSettings.backlightDelay * 5); ui->inactimerSB->setValue(generalSettings.inactivityTimer); diff --git a/companion/src/generaledit/generalsetup.ui b/companion/src/generaledit/generalsetup.ui index b50148ce0..2a9408a5a 100644 --- a/companion/src/generaledit/generalsetup.ui +++ b/companion/src/generaledit/generalsetup.ui @@ -327,9 +327,6 @@ Mode 4: 0 - - - Contrast @@ -659,12 +656,7 @@ p, li { white-space: pre-wrap; } - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> + ms @@ -1740,12 +1732,7 @@ p, li { white-space: pre-wrap; } - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> + 1 diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index 31940ab82..2ad186512 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -754,7 +754,7 @@ #define BACKLIGHT_CCMR1 TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 // Channel 1, PWM #define BACKLIGHT_CCER TIM_CCER_CC1E #define BACKLIGHT_COUNTER_REGISTER BACKLIGHT_TIMER->CCR1 -#elif defined(RADIO_T8) || defined(RADIO_TPROV2) || defined(RADIO_TPROS) || defined(RADIO_FAMILY_T20) || defined(RADIO_T14) || defined(RADIO_BUMBLEBEE) || defined(RADIO_GX12) +#elif defined(RADIO_T8) || defined(RADIO_TPROV2) || defined(RADIO_TPROS) || defined(RADIO_FAMILY_T20) || defined(RADIO_T14) || defined(RADIO_BUMBLEBEE) || defined(RADIO_GX12) || defined(RADIO_V14) // No backlight: OLED display #elif defined(RADIO_COMMANDO8) #define BACKLIGHT_TIMER_FREQ (PERI1_FREQUENCY * TIMER_MULT_APB1) diff --git a/radio/src/targets/taranis/lcd_driver_spi.cpp b/radio/src/targets/taranis/lcd_driver_spi.cpp index 5de7d8d95..572ad9ffd 100644 --- a/radio/src/targets/taranis/lcd_driver_spi.cpp +++ b/radio/src/targets/taranis/lcd_driver_spi.cpp @@ -37,7 +37,7 @@ #if OLED_SCREEN #define LCD_CONTRAST_OFFSET 0 -#elif defined(RADIO_FAMILY_JUMPER_T12) || defined(MANUFACTURER_RADIOMASTER) || defined(RADIO_COMMANDO8) || defined(RADIO_TPRO) || defined(RADIO_T12MAX) || defined(RADIO_V14) || defined(RADIO_V14LCD) +#elif defined(RADIO_FAMILY_JUMPER_T12) || defined(MANUFACTURER_RADIOMASTER) || defined(RADIO_COMMANDO8) || defined(RADIO_TPRO) || defined(RADIO_T12MAX) || defined(RADIO_V14LCD) #define LCD_CONTRAST_OFFSET -10 #else #define LCD_CONTRAST_OFFSET 160 @@ -177,7 +177,7 @@ void lcdStart() lcdWriteCommand(0x0A); // Set Vop lcdWriteCommand(0xa6); // Set display mode #else - #if defined(RADIO_V14) || defined(RADIO_V14LCD) + #if defined(RADIO_V14LCD) lcdWriteCommand(0xe2); // (14) Soft reset lcdWriteCommand(0xa1); // Set seg lcdWriteCommand(0xc0); // Set com @@ -439,7 +439,7 @@ void lcdSetRefVolt(uint8_t val) WAIT_FOR_DMA_END(); #endif -#if defined(RADIO_V14) || defined(RADIO_V14LCD) +#if defined(RADIO_V14LCD) lcdWriteCommand(0x81); // Set Vop lcdWriteCommand(val+LCD_CONTRAST_OFFSET+20);// 0-255 #else