Skip to content

Commit

Permalink
Improve homescreen backlighting to depend on external light
Browse files Browse the repository at this point in the history
Instead of relying on what power remains in the battery, rely instead on the external lighting to adapt the brightness of the screen.
Note that this might need a bit more fine-tuning.
  • Loading branch information
Thibault committed Aug 9, 2016
1 parent 33f50ba commit 5dfac57
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions apps/home/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def draw_wifi(back_colour, rssi, connected, connecting, win_wifi):
def backlight_adjust():
if ugfx.backlight() == 0:
ugfx.power_mode(ugfx.POWER_ON)
l = pyb.ADC(16).read()
if (l > 90):
ugfx.backlight(100)
elif (l > 20):
ugfx.backlight(70)
l = onboard.get_light()

lum_percent = int(l * 100 / 4096)
if (lum_percent > 30):
ugfx.backlight(lum_percent)
else:
ugfx.backlight(30)

Expand Down Expand Up @@ -298,11 +298,9 @@ def home_main():
inactivity_limit = 120
else:
inactivity_limit = 30
if battery_percent > 120: #if charger plugged in
if ugfx.backlight() == 0:
ugfx.power_mode(ugfx.POWER_ON)
ugfx.backlight(100)
elif inactivity > inactivity_limit:

# If charger is not plugged in and we're inactive, turn screen off
if battery_percent < 120 and inactivity > inactivity_limit:
low_power()
else:
backlight_adjust()
Expand Down

0 comments on commit 5dfac57

Please # to comment.