Screen dimming: add a 15% idle-dim level

Add SCREEN_DIM_15 (Off / 100 / 50 / 30 / 15). The value now needs 3 bits, so
repurpose the spare BIT_UNUSED_2 as BIT_SCREEN_DIM_2; existing codeplugs (bit 2
clear) keep their level, no reset.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marcus Kida 2026-07-07 08:16:04 +02:00
parent e50993b98f
commit 7f5f3ab06f
5 changed files with 9 additions and 6 deletions

View file

@ -7,6 +7,7 @@ single running list until the first versioned release.
## Unreleased
- **Screen dimming:** added a **15%** idle-dim level (Off / 100 / 50 / 30 / 15).
- **DM-1701 build support** — the Docker build is now parameterized by platform;
`./build-firmware.sh DM1701` produces `OpenDM1701.bin` (Baofeng DM-1701 /
Retevis RT-84). Not officially tested yet.

View file

@ -129,7 +129,7 @@ typedef enum
{
BIT_INVERSE_VIDEO = (SETTINGS_BITS_BANK_0 | (1 << 0)),
BIT_PTT_LATCH = (SETTINGS_BITS_BANK_0 | (1 << 1)),
BIT_UNUSED_2 = (SETTINGS_BITS_BANK_0 | (1 << 2)),
BIT_SCREEN_DIM_2 = (SETTINGS_BITS_BANK_0 | (1 << 2)), // high bit of the 3-bit screen-dim level
BIT_BATTERY_VOLTAGE_IN_HEADER = (SETTINGS_BITS_BANK_0 | (1 << 3)),
BIT_SETTINGS_UPDATED = (SETTINGS_BITS_BANK_0 | (1 << 4)),
BIT_TX_RX_FREQ_LOCK = (SETTINGS_BITS_BANK_0 | (1 << 5)),
@ -139,7 +139,7 @@ typedef enum
BIT_POWEROFF_SUSPEND = (SETTINGS_BITS_BANK_0 | (1 << 8)),
#endif
BIT_SATELLITE_MANUAL_AUTO = (SETTINGS_BITS_BANK_0 | (1 << 9)),
BIT_SCREEN_DIM_0 = (SETTINGS_BITS_BANK_0 | (1 << 10)), // low bit of the 2-bit screen-dim level
BIT_SCREEN_DIM_0 = (SETTINGS_BITS_BANK_0 | (1 << 10)), // low bit of the 3-bit screen-dim level
#if defined(PLATFORM_MD9600)
BIT_SPEAKER_CLICK_SUPPRESS = (SETTINGS_BITS_BANK_0 | (1 << 11)),
#endif
@ -153,7 +153,7 @@ typedef enum
BIT_VISUAL_VOLUME = (SETTINGS_BITS_BANK_0 | (1 << 18)),
#endif
BIT_SECONDARY_LANGUAGE = (SETTINGS_BITS_BANK_0 | (1 << 19)),
BIT_SCREEN_DIM_1 = (SETTINGS_BITS_BANK_0 | (1 << 20)), // high bit of the 2-bit screen-dim level
BIT_SCREEN_DIM_1 = (SETTINGS_BITS_BANK_0 | (1 << 20)), // middle bit of the 3-bit screen-dim level
BIT_DISPLAY_CHANNEL_DISTANCE = (SETTINGS_BITS_BANK_0 | (1 << 21)),
#if defined(PLATFORM_MD2017)
BIT_TRACKBALL_ENABLED = (SETTINGS_BITS_BANK_0 | (1 << 22)),
@ -420,6 +420,7 @@ typedef enum
SCREEN_DIM_100, // stay at 100% of configured brightness when idle
SCREEN_DIM_50, // dim to 50%
SCREEN_DIM_30, // dim to 30%
SCREEN_DIM_15, // dim to 15%
SCREEN_DIM_NUM
} screenDimLevel_t;
uint8_t settingsGetScreenDimLevel(void);

View file

@ -607,13 +607,14 @@ bool settingsIsOptionBitSet(bitfieldOptions_t bit)
// no new settings field (existing codeplugs keep both bits clear = SCREEN_DIM_OFF).
uint8_t settingsGetScreenDimLevel(void)
{
return (settingsIsOptionBitSet(BIT_SCREEN_DIM_0) ? 1 : 0) | (settingsIsOptionBitSet(BIT_SCREEN_DIM_1) ? 2 : 0);
return (settingsIsOptionBitSet(BIT_SCREEN_DIM_0) ? 1 : 0) | (settingsIsOptionBitSet(BIT_SCREEN_DIM_1) ? 2 : 0) | (settingsIsOptionBitSet(BIT_SCREEN_DIM_2) ? 4 : 0);
}
void settingsSetScreenDimLevel(uint8_t level)
{
settingsSetOptionBit(BIT_SCREEN_DIM_0, ((level & 1) != 0));
settingsSetOptionBit(BIT_SCREEN_DIM_1, ((level & 2) != 0));
settingsSetOptionBit(BIT_SCREEN_DIM_2, ((level & 4) != 0));
}
void settingsSetDirty(void)

View file

@ -467,7 +467,7 @@ int displayGetIdleBacklightPercentage(void)
{
if (nonVolatileSettings.backlightMode == BACKLIGHT_MODE_AUTO)
{
static const uint8_t dimPercent[SCREEN_DIM_NUM] = { 0, 100, 50, 30 };
static const uint8_t dimPercent[SCREEN_DIM_NUM] = { 0, 100, 50, 30, 15 };
uint8_t level = settingsGetScreenDimLevel();
if (level != SCREEN_DIM_OFF)

View file

@ -249,7 +249,7 @@ static void updateScreen(bool isFirstRun)
case DISPLAY_SCREEN_DIM:
{
const char *dimOpts[] = { currentLanguage->off, "100%", "50%", "30%" };
const char *dimOpts[] = { currentLanguage->off, "100%", "50%", "30%", "15%" };
leftSide = "Screen Dim";
rightSideConst = dimOpts[settingsGetScreenDimLevel()];
}