From 0f24eb2e0e4d10cb128b4c861596d6fb53ffd5c5 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 6 Jun 2016 00:58:18 +0200 Subject: [PATCH] use python implementation for backlight (for now) --- src/trezor/ui/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/trezor/ui/__init__.py b/src/trezor/ui/__init__.py index ba86b3599..a9999f49f 100644 --- a/src/trezor/ui/__init__.py +++ b/src/trezor/ui/__init__.py @@ -7,6 +7,17 @@ from trezor import loop display = Display() +# workaround for missing display.backlight in stmhal +def backlight(val: int): + import sys + if sys.platform == 'trezor': + import pyb + timer = pyb.Timer(1, freq=1000) + val = max(0, min(100, val * 100 // 255)) + timer.channel(1, pyb.Timer.PWM_INVERTED, pin=pyb.Pin.board.LCD_PWM, pulse_width_percent=val) + else: + display.backlight(val) + def rgbcolor(r: int, g: int, b: int) -> int: return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)