Skip to content

Commit 356a378

Browse files
committed
fix backlight bug
1 parent e8f8540 commit 356a378

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

PyPortal_Wakeup_Light/wake_up_light.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
This example uses a PyPortal and rgbw leds for a simple "wake up" light.
33
The strip starts to brighten 30 minutes before set wake up time.
4-
This program assumes a neopixel strip is attached to D4 on the Adafruit PyPortal.
4+
This program assumes a neopixel strip is attached to D3 on the Adafruit PyPortal.
55
"""
66
import time
77
import board
@@ -159,14 +159,14 @@ def formatTime(raw_hours, raw_minutes):
159159
time_str = format_str % (raw_hours, raw_minutes)
160160
return time_str
161161

162-
# backlight function - if screen tapped, turn on back light for 30 seconds?
163162
def backLight():
164163
now = time.localtime()
165164
now_val = time.mktime((now[0], now[1], now[2], now[3], now[4], now[5], now[6], now[7], now[8]))
166165
wake_up_day_val = val_times[now[6]]
167166
# if time is more than 9 hours after current day's wake up time,
168167
# or time is before light start time, backlight off, tap to turn on
169168
if (now_val - wake_up_day_val) > 32400 or (now_val - wake_up_day_val) < -1800:
169+
pyportal.set_backlight(backlight_off)
170170
if pyportal.touchscreen.touch_point:
171171
pyportal.set_backlight(backlight_on)
172172
time.sleep(5)
@@ -209,8 +209,10 @@ def subtract30min(day): # subtract 30 min
209209
backLight()
210210
# start the light 30 min before wake up time
211211
start_light_time = subtract30min(wake_up_day)
212-
# If current day is wake up day and
212+
# If current day is same as wake up day and
213213
# wake up time - 30 minutes equals current time, start the light
214+
print("Wake up day: ", wake_up_day, "Current Day: ", time_now[6])
215+
print("Time: ", time_str_text, "start light time: ", start_light_time)
214216
if wake_up_day == time_now[6] and time_str_text == start_light_time:
215217
print("Starting wake up light")
216218
# turn on backlight

0 commit comments

Comments
 (0)