File tree 1 file changed +18
-7
lines changed
Circuit_Playground_Bluefruit_Pumpkin
1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change 3
3
4
4
import time
5
5
import board
6
+ import digitalio
6
7
import neopixel
7
- from adafruit_ble .uart_server import UARTServer
8
+
9
+ from adafruit_ble import BLERadio
10
+ from adafruit_ble .advertising .standard import ProvideServicesAdvertisement
11
+ from adafruit_ble .services .nordic import UARTService
12
+
8
13
from audiopwmio import PWMAudioOut as AudioOut
9
14
from audiocore import WaveFile
10
15
24
29
YELLOW = (255 ,230 , 0 )
25
30
BLUE = (0 , 0 , 255 )
26
31
# setup bluetooth
27
- uart_server = UARTServer ()
32
+ ble = BLERadio ()
33
+ uart_service = UARTService ()
34
+ advertisement = ProvideServicesAdvertisement (uart_service )
28
35
29
36
# External Audio Stuff
37
+ speaker_enable = digitalio .DigitalInOut (board .SPEAKER_ENABLE )
38
+ speaker_enable .direction = digitalio .Direction .OUTPUT
39
+ speaker_enable .value = True
40
+
30
41
audio = AudioOut (board .SPEAKER ) # Speaker
31
42
wave_file = None
32
43
@@ -51,17 +62,17 @@ def play_wav(name, loop=False):
51
62
52
63
while True :
53
64
# set CPXb up so that it can be discovered by the app
54
- uart_server .start_advertising ()
55
- while not uart_server .connected :
65
+ ble .start_advertising (advertisement )
66
+ while not ble .connected :
56
67
pass
57
68
58
69
# Now we're connected
59
70
60
- while uart_server .connected :
71
+ while ble .connected :
61
72
62
- if uart_server .in_waiting :
73
+ if uart_service .in_waiting :
63
74
try :
64
- packet = Packet .from_stream (uart_server )
75
+ packet = Packet .from_stream (uart_service )
65
76
except ValueError :
66
77
continue # or pass.
67
78
You can’t perform that action at this time.
0 commit comments