Skip to content

Commit 5df1fe0

Browse files
authored
Merge pull request #3048 from adafruit/led_clock
update for led matrix clock
2 parents 834f226 + ec54181 commit 5df1fe0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

LED_Matrix_Clock/code.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
from adafruit_debouncer import Button
2323

2424
timezone = -4 # your timezone offset
25-
alarm_hour = 14 # hour is 24 hour for alarm to denote am/pm
26-
alarm_min = 11 # minutes
25+
alarm_hour = 12 # hour is 24 hour for alarm to denote am/pm
26+
alarm_min = 00 # minutes
2727
alarm_volume = 1 # float 0.0 to 1.0
2828
hour_12 = True # 12 hour or 24 hour time
29+
no_alarm_plz = False
2930
BRIGHTNESS = 128 # led brightness (0-255)
3031

3132
# I2S pins for Audio BFF
@@ -279,13 +280,16 @@ def draw_text(text, color=0xFFFFFF):
279280
BRIGHTNESS = 128
280281
matrix1.set_led_scaling(BRIGHTNESS)
281282
matrix2.set_led_scaling(BRIGHTNESS)
282-
if button.short_count:
283+
if button.short_count == 1:
283284
# short press to set hour and minute
284285
set_alarm = (set_alarm + 1) % 3
285286
if set_alarm == 0:
286287
draw_text(time_str, COLOR)
287288
elif set_alarm == 2:
288289
draw_text(f" :{alarm_min:02}", COLOR)
290+
if button.short_count == 3:
291+
no_alarm_plz = not no_alarm_plz
292+
print(f"alarms off? {no_alarm_plz}")
289293

290294
position = -encoder.position
291295
if position != last_position:
@@ -365,10 +369,11 @@ def draw_text(text, color=0xFFFFFF):
365369
new_time = False
366370
print(time_str)
367371
draw_text(time_str, COLOR)
368-
if f"{am_pm_hour:02}:{mins:02}" == alarm:
372+
if f"{am_pm_hour:02}:{mins:02}" == alarm and not no_alarm_plz:
369373
print("alarm!")
370374
# grab a new wav file from the wavs list
371375
wave = open_audio()
376+
mixer.voice[0].play(wave, loop=True)
372377
active_alarm = True
373378
if active_alarm:
374379
# blink the clock characters
@@ -379,7 +384,3 @@ def draw_text(text, color=0xFFFFFF):
379384
matrix1.set_led_scaling(BRIGHTNESS)
380385
matrix2.set_led_scaling(BRIGHTNESS)
381386
clock_clock = ticks_add(clock_clock, clock_timer)
382-
383-
# loop alarm wav
384-
if active_alarm:
385-
mixer.voice[0].play(wave, loop=True)

0 commit comments

Comments
 (0)