brightnessd: ignore some panels (#135)

Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
Adeeb Shihadeh
2023-05-07 16:45:59 -07:00
committed by GitHub
parent d54e993b51
commit 8ccaa49710
2 changed files with 16 additions and 2 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
Description=Limit display brightness with uptime
[Service]
Restart=always
Restart=on-failure
ExecStart=/usr/local/pyenv/shims/python -u /usr/comma/brightnessd.py
[Install]
+15 -1
View File
@@ -12,6 +12,10 @@ MAX_PERCENT = 90
MIN_PERCENT = 30
HOURLY_PERC_DECREASE = 5
IGNORED_PANELS = [
"dsi_mate10_lite_video_display",
]
def read(path: str) -> int:
try:
with open(path) as f:
@@ -22,9 +26,19 @@ def read(path: str) -> int:
if __name__ == "__main__":
# detect panel type
with open("/sys/module/msm_drm/parameters/dsi_display0") as f:
d = f.read().strip()
panel = d.split(":")[0]
print(f"Detected panel '{panel}'")
if panel in IGNORED_PANELS:
print("panel is ignored, exiting")
exit(0)
# brightness loop
last_perc = None
last_off_ts = time.monotonic()
while True:
try:
# sample brightness and backlight power