11
11
#
12
12
# REQUIREMENTS:
13
13
# should use M4 (or higher)
14
- # use CircuitPython 5.3 .0+
14
+ # use CircuitPython 6.0 .0+
15
15
#
16
16
#
17
17
# HARDWARE:
39
39
# Or for software I2C (ESP8266) use this line instead:
40
40
# import bitbangio as io
41
41
42
- #import adafruit_ds3231
42
+ # import adafruit_ds3231
43
43
import adafruit_pcf8523
44
44
45
45
# SD card
46
- import adafruit_sdcard
46
+ import sdcardio
47
47
import storage
48
48
49
49
# NeoPixel
50
- #import neopixel
50
+ # import neopixel
51
51
52
52
53
53
# Use any pin that is not taken by SPI
60
60
# On Atmel M0, M4, 328p or 32u4 it's on GPIO 10
61
61
# On Teensy 3.x it's on GPIO 10
62
62
63
- SD_CS = board .D10 # for M4
63
+ SD_CS = board .D10 # for M4
64
64
65
65
# Connect to the card and mount the filesystem.
66
66
spi = io .SPI (board .SCK , board .MOSI , board .MISO )
67
- cs = digitalio .DigitalInOut (SD_CS )
68
- sdcard = adafruit_sdcard .SDCard (spi , cs )
67
+ sdcard = sdcardio .SDCard (spi , SD_CS )
69
68
vfs = storage .VfsFat (sdcard )
70
69
storage .mount (vfs , "/sd" )
71
70
72
71
73
72
# Use the filesystem as normal! Our files are under /sd
74
73
# This helper function will print the contents of the SD
75
74
75
+
76
76
def print_directory (path , tabs = 0 ):
77
77
for file in os .listdir (path ):
78
78
stats = os .stat (path + "/" + file )
@@ -92,7 +92,7 @@ def print_directory(path, tabs=0):
92
92
prettyprintname += file
93
93
if isdir :
94
94
prettyprintname += "/"
95
- print (' {0:<40} Size: {1:>10}' .format (prettyprintname , sizestr ))
95
+ print (" {0:<40} Size: {1:>10}" .format (prettyprintname , sizestr ))
96
96
97
97
# recursively print directory contents
98
98
if isdir :
@@ -106,15 +106,15 @@ def print_directory(path, tabs=0):
106
106
107
107
data = open ("/sd/cheer.mp3" , "rb" )
108
108
mp3 = audiomp3 .MP3Decoder (data )
109
- #a = audioio.AudioOut(board.A0) # mono
110
- a = audioio .AudioOut (board .A0 , right_channel = board .A1 ) # stereo sound through A0 & A1
109
+ # a = audioio.AudioOut(board.A0) # mono
110
+ a = audioio .AudioOut (board .A0 , right_channel = board .A1 ) # stereo sound through A0 & A1
111
111
112
112
113
113
i2c = io .I2C (board .SCL , board .SDA ) # Change to the appropriate I2C clock & data
114
114
# pins here!
115
115
116
116
# Create the RTC instance:
117
- #rtc = adafruit_ds3231.DS3231(i2c)
117
+ # rtc = adafruit_ds3231.DS3231(i2c)
118
118
rtc = adafruit_pcf8523 .PCF8523 (i2c )
119
119
120
120
# Lookup table for names of days (nicer printing).
@@ -141,7 +141,7 @@ def print_directory(path, tabs=0):
141
141
# pylint: enable-msg=bad-whitespace
142
142
143
143
# setup NeoPixel
144
- #pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
144
+ # pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
145
145
146
146
147
147
# Main loop:
@@ -159,14 +159,14 @@ def print_directory(path, tabs=0):
159
159
if t .tm_hour == playhour and t .tm_min == playmin :
160
160
print ("it is time!" )
161
161
# turn NeoPixel green
162
- #pixel[0] = (0, 255, 0)
162
+ # pixel[0] = (0, 255, 0)
163
163
# play the file
164
164
print ("playing" )
165
165
a .play (mp3 )
166
166
while a .playing :
167
167
pass
168
168
print ("stopped" )
169
169
# turn NeoPixel off
170
- #pixel[0] = (0, 0, 0)
170
+ # pixel[0] = (0, 0, 0)
171
171
172
172
time .sleep (1 ) # wait a second
0 commit comments