TB2026-YDS Firmware
Loading...
Searching...
No Matches
screen_settings.c File Reference

Screen (display) settings: brightness slider + auto-sleep delay. More...

#include "screen_settings.h"
#include "navigator.h"
#include "status_bar.h"
#include "gfx.h"
#include "settings.h"
#include "display_oled.h"
#include "power.h"
#include <stdio.h>
#include <string.h>

Macros

#define NVS_KEY   "oled_bri"
#define BRI_MIN   2 /* keep the UI legible at the low end */
#define BRI_MAX   DISPLAY_OLED_BRIGHTNESS_MAX /* 15 */
#define BRI_DFLT   BRI_MAX /* first boot: full brightness (init default) */
#define ACCENT   gfx_rgb(255, 0, 0) /* Settings identity colour (see root_menu) */
#define DIM   gfx_rgb(110, 110, 110)
#define N_SLEEP   (int)(sizeof k_sleep_presets / sizeof k_sleep_presets[0])
#define BRI_HDR_Y   44
#define BAR_X   18
#define BAR_W   140
#define BAR_Y   66
#define BAR_H   6
#define VAL_Y   (BAR_Y + 18)
#define SLEEP_TITLE_Y   116
#define SLEEP_VAL_Y   134

Enumerations

enum  { ZONE_BRI = 0 , ZONE_SLEEP , N_ZONES }

Functions

void screen_settings_restore (void)
 Restore the saved brightness from NVS and apply it to the panel.
screen_tscreen_settings_screen (void)
 Get the singleton Screen settings screen, ready to push onto the navigator.

Detailed Description

Screen (display) settings: brightness slider + auto-sleep delay.

Two vertically stacked zones; UP/DOWN moves the focus between them:

  • Brightness: LEFT/RIGHT dim/brighten the panel. The change is applied live to the SSD1333 Master Current for immediate feedback, and persisted to NVS ("oled_bri") once on exit – only if it actually moved. Restored at boot by screen_settings_restore(), called from the UI task once the panel is up.
  • Sleep : horizontal preset picker (LEFT/RIGHT cycles, wrapping) for the screen auto-sleep delay. This is the same value edited under Settings > Power; it is duplicated here (Screen is the natural home for a display timeout) and stays in sync because both screens read/write the power service.

The bottom of the brightness range is floored at BRI_MIN (never 0): a fully dimmed panel would be unreadable, leaving the user unable to see the slider to raise it back. The sleep delay is persisted through the power service on BACK, only if it actually moved (Rule 13: no NVS write per scroll step).

Note
Développé avec l'assistance de Claude Opus 4.8 (Anthropic), sous la direction de Y. Dos Santos : spécification, revue et validation sur cible par l'auteur.

Macro Definition Documentation

◆ ACCENT

#define ACCENT   gfx_rgb(255, 0, 0) /* Settings identity colour (see root_menu) */

◆ BAR_H

#define BAR_H   6

◆ BAR_W

#define BAR_W   140

◆ BAR_X

#define BAR_X   18

◆ BAR_Y

#define BAR_Y   66

◆ BRI_DFLT

#define BRI_DFLT   BRI_MAX /* first boot: full brightness (init default) */

◆ BRI_HDR_Y

#define BRI_HDR_Y   44

◆ BRI_MAX

#define BRI_MAX   DISPLAY_OLED_BRIGHTNESS_MAX /* 15 */

◆ BRI_MIN

#define BRI_MIN   2 /* keep the UI legible at the low end */

◆ DIM

#define DIM   gfx_rgb(110, 110, 110)

◆ N_SLEEP

#define N_SLEEP   (int)(sizeof k_sleep_presets / sizeof k_sleep_presets[0])

◆ NVS_KEY

#define NVS_KEY   "oled_bri"

◆ SLEEP_TITLE_Y

#define SLEEP_TITLE_Y   116

◆ SLEEP_VAL_Y

#define SLEEP_VAL_Y   134

◆ VAL_Y

#define VAL_Y   (BAR_Y + 18)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ZONE_BRI 
ZONE_SLEEP 
N_ZONES 

Function Documentation

◆ screen_settings_restore()

void screen_settings_restore ( void )

Restore the saved brightness from NVS and apply it to the panel.

Call once at boot, after display_oled_init() (the panel must be up). Falls back to full brightness when nothing is stored yet.

◆ screen_settings_screen()

screen_t * screen_settings_screen ( void )

Get the singleton Screen settings screen, ready to push onto the navigator.

Returns
Pointer to the Screen settings screen.