Backlight(backlight_sysfs_path: Union[str, PathLike[str], None] = None, board_type: rpi_backlight.BoardType = <BoardType.RASPBERRY_PI: 1>)¶
Main class to access and control the display backlight power and brightness.
":emulator:"to use with rpi-backlight-emulator.
The display brightness in range 0-100.
>>> backlight = Backlight() >>> backlight.brightness # Display is at 50% brightness 50 >>> backlight.brightness = 100 # Set to full brightness
Getter: Return the display brightness. Setter: Set the display brightness. Type: float
fade(duration: float) → Generator[T_co, T_contra, V_co]¶
Context manager for temporarily changing the fade duration.
>>> backlight = Backlight() >>> with backlight.fade(duration=0.5): ... backlight.brightness = 1 # Fade to 100% brightness for 0.5s ... >>> with backlight.fade(duration=0): ... backlight.brightness = 0 # Set to 0% brightness without fading, use if you have set `backlight.fade_duration` > 0
The brightness fade duration in seconds, defaults to 0. Also see
>>> backlight = Backlight() >>> backlight.fade_duration # Fading is disabled by default 0 >>> backlight.fade_duration = 0.5 # Set to 500ms
Getter: Return the fade duration. Setter: Set the fade duration. Type: float
Turn the display on and off.
>>> backlight = Backlight() >>> backlight.power # Display is on True >>> backlight.power = False # Turn display off
Getter: Return whether the display is powered on or off. Setter: Set the display power on or off. Type: bool
Enum to specify a board type in the
Tinker Board 2
Start the command line interface.
Start the graphical user interface.
detect_board_type() → Optional[BoardType]¶
Try to detect the board type based on the model string in
Context manager to create a temporary “fake sysfs” containing all relevant files. Used for tests and emulation.
>>> with FakeBacklightSysfs() as backlight_sysfs: ... backlight = Backlight(backlight_sysfs_path=backlight_sysfs.path) ... # use `backlight` as usual