Skip to content

Commit

Permalink
Use glob to handle arbitrary I2C bus in sysfs path
Browse files Browse the repository at this point in the history
  • Loading branch information
jwanga authored Dec 1, 2024
1 parent 80f9e47 commit 5ae2bc8
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions rpi_backlight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pathlib import Path
from tempfile import gettempdir
from typing import Generator, Union, Optional
from glob import iglob

from . import utils

Expand All @@ -28,15 +29,7 @@ class BoardType(Enum):


_BACKLIGHT_SYSFS_PATHS = {
BoardType.RASPBERRY_PI: (
"/sys/class/backlight/4-0045/"
if Path("/sys/class/backlight/4-0045/").exists()
else "/sys/class/backlight/6-0045/"
if Path("/sys/class/backlight/6-0045/").exists()
else "/sys/class/backlight/10-0045/"
if Path("/sys/class/backlight/10-0045/").exists()
else "/sys/class/backlight/rpi_backlight/"
),
BoardType.RASPBERRY_PI: next(iglob("/sys/class/backlight/*-0045/"), "/sys/class/backlight/rpi_backlight/"),
BoardType.TINKER_BOARD: "/sys/devices/platform/ff150000.i2c/i2c-3/3-0045/",
BoardType.TINKER_BOARD_2: "/sys/devices/platform/ff3e0000.i2c/i2c-8/8-0045/",
BoardType.GENERIC: "/sys/class/backlight/backlight/",
Expand Down

0 comments on commit 5ae2bc8

Please sign in to comment.