handle no Display.auto_brightness

This commit is contained in:
Dan Halbert 2022-08-10 13:37:26 -04:00
parent 0345780798
commit c4ed2ec643
5 changed files with 20 additions and 5 deletions

View file

@ -61,7 +61,10 @@ except AttributeError:
AUDIO = audioio.AudioOut(board.SPEAKER) # Speaker
board.DISPLAY.auto_brightness = False
try:
board.DISPLAY.auto_brightness = False
except AttributeError:
pass
TOUCH1 = touchio.TouchIn(board.TOUCH1) # Capacitive touch pads
TOUCH2 = touchio.TouchIn(board.TOUCH2)
TOUCH3 = touchio.TouchIn(board.TOUCH3)

View file

@ -48,7 +48,10 @@ except AttributeError:
AUDIO = audioio.AudioOut(board.SPEAKER) # Speaker
board.DISPLAY.auto_brightness = False
try:
board.DISPLAY.auto_brightness = False
except AttributeError:
pass
# Set up accelerometer on I2C bus, 4G range:
I2C = board.I2C()

View file

@ -63,7 +63,10 @@ def set_backlight(val):
off, and ``1`` is 100% brightness.
"""
val = max(0, min(1.0, val))
board.DISPLAY.auto_brightness = False
try:
board.DISPLAY.auto_brightness = False
except AttributeError:
pass
board.DISPLAY.brightness = val

View file

@ -76,7 +76,10 @@ def set_backlight(val):
off, and ``1`` is 100% brightness.
"""
val = max(0, min(1.0, val))
board.DISPLAY.auto_brightness = False
try:
board.DISPLAY.auto_brightness = False
except AttributeError:
pass
board.DISPLAY.brightness = val
while True:

View file

@ -51,7 +51,10 @@ switch_state = 0
# Value between 0 and 1 where 0 is OFF, 0.5 is 50% and 1 is 100% brightness.
def set_backlight(val):
val = max(0, min(1.0, val))
board.DISPLAY.auto_brightness = False
try:
board.DISPLAY.auto_brightness = False
except AttributeError:
pass
board.DISPLAY.brightness = val