|
1 | 1 | """ |
2 | 2 | This example uses a PyPortal and rgbw leds for a simple "wake up" light. |
3 | 3 | 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. |
5 | 5 | """ |
6 | 6 | import time |
7 | 7 | import board |
@@ -159,14 +159,14 @@ def formatTime(raw_hours, raw_minutes): |
159 | 159 | time_str = format_str % (raw_hours, raw_minutes) |
160 | 160 | return time_str |
161 | 161 |
|
162 | | -# backlight function - if screen tapped, turn on back light for 30 seconds? |
163 | 162 | def backLight(): |
164 | 163 | now = time.localtime() |
165 | 164 | now_val = time.mktime((now[0], now[1], now[2], now[3], now[4], now[5], now[6], now[7], now[8])) |
166 | 165 | wake_up_day_val = val_times[now[6]] |
167 | 166 | # if time is more than 9 hours after current day's wake up time, |
168 | 167 | # or time is before light start time, backlight off, tap to turn on |
169 | 168 | if (now_val - wake_up_day_val) > 32400 or (now_val - wake_up_day_val) < -1800: |
| 169 | + pyportal.set_backlight(backlight_off) |
170 | 170 | if pyportal.touchscreen.touch_point: |
171 | 171 | pyportal.set_backlight(backlight_on) |
172 | 172 | time.sleep(5) |
@@ -209,8 +209,10 @@ def subtract30min(day): # subtract 30 min |
209 | 209 | backLight() |
210 | 210 | # start the light 30 min before wake up time |
211 | 211 | 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 |
213 | 213 | # 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) |
214 | 216 | if wake_up_day == time_now[6] and time_str_text == start_light_time: |
215 | 217 | print("Starting wake up light") |
216 | 218 | # turn on backlight |
|
0 commit comments