3
3
import busio
4
4
import neopixel
5
5
import adafruit_drv2605
6
- from digitalio import DigitalInOut , Direction
6
+ import adafruit_led_animation . color as color
7
7
import adafruit_ble
8
8
from adafruit_ble .advertising .standard import SolicitServicesAdvertisement
9
9
from adafruit_ble .services .standard import CurrentTimeService
10
10
from adafruit_ble_apple_notification_center import AppleNotificationCenterService
11
+ from digitalio import DigitalInOut , Direction
11
12
12
13
# setup for onboard NeoPixel
13
14
pixel_pin = board .NEOPIXEL
44
45
hour = 0 # used to track when it is on the hour for the mindfulness reminder
45
46
mindful = False # state used to track if it is time for mindfulness
46
47
vibration = 16 # vibration effect being used for the haptic motor
47
- BLUE = (0 , 0 , 255 ) # color blue for the NeoPixel
48
- PURPLE = (255 , 0 , 255 ) # color purple for the NeoPixel
49
- RED = (255 , 0 , 0 ) # color red for the NeoPixel
50
- ORANGE = (255 , 255 , 0 ) # color orange
51
- YELLOW = (255 , 150 , 0 ) # color yellow
52
- GREEN = (0 , 255 , 0 ) # color green
53
- CYAN = (0 , 255 , 255 ) # color cyan
54
- PINK = (255 , 0 , 127 ) # color pink
55
- WHITE = (255 , 255 , 255 ) # color white
56
- clear = (0 , 0 , 0 ) # allows for NeoPixel to be turned 'off'
57
48
58
49
APP_COLORS = {
59
- "com.basecamp.bc3-ios" : YELLOW , # Basecamp
60
- "com.apple.MobileSMS" : GREEN , # Texts
61
- "com.hammerandchisel.discord" : PURPLE , # Discord
62
- "com.apple.mobilecal" : CYAN , # Calendar
63
- "com.apple.mobilephone" : GREEN , # Phone
64
- "com.google.ios.youtube" : ORANGE , # YouTube
65
- "com.burbn.instagram" : PINK , # Instagram
66
- "com.apple.mobilemail" : CYAN # Apple Email
50
+ "com.basecamp.bc3-ios" : color . YELLOW , # Basecamp
51
+ "com.apple.MobileSMS" : color . GREEN , # Texts
52
+ "com.hammerandchisel.discord" : color . PURPLE , # Discord
53
+ "com.apple.mobilecal" : color . CYAN , # Calendar
54
+ "com.apple.mobilephone" : color . GREEN , # Phone
55
+ "com.google.ios.youtube" : color . ORANGE , # YouTube
56
+ "com.burbn.instagram" : color . MAGENTA , # Instagram
57
+ "com.apple.mobilemail" : color . CYAN # Apple Email
67
58
}
68
59
69
60
# function for blinking NeoPixel
@@ -102,7 +93,7 @@ def vibe(num_zzz, effect, delay):
102
93
# NeoPixel is red when not connected to BLE
103
94
while not ble .connected :
104
95
blue_led .value = False
105
- pixel .fill (RED )
96
+ pixel .fill (color . RED )
106
97
pixel .show ()
107
98
print ("Connected" )
108
99
@@ -130,14 +121,14 @@ def vibe(num_zzz, effect, delay):
130
121
if current_notification and current_notification .removed :
131
122
# Stop showing the latest and show that there are no new notifications.
132
123
current_notification = None
133
- pixel .fill (clear )
124
+ pixel .fill (color . BLACK )
134
125
pixel .show ()
135
126
136
127
if not current_notification and not all_ids and not cleared :
137
128
# updates cleared state for notification
138
129
cleared = True
139
130
# turns off NeoPixel when notifications are clear
140
- pixel .fill (clear )
131
+ pixel .fill (color . BLACK )
141
132
pixel .show ()
142
133
143
134
elif all_ids :
@@ -153,7 +144,7 @@ def vibe(num_zzz, effect, delay):
153
144
# if the notification is from an app that is not
154
145
# defined in APP_COLORS then the NeoPixel will be white
155
146
if current_notification .app_id not in APP_COLORS :
156
- notif_color = WHITE
147
+ notif_color = color . WHITE
157
148
# if the notification is from an app defined in
158
149
# APP_COLORS then the assigned color will show
159
150
else :
@@ -173,7 +164,7 @@ def vibe(num_zzz, effect, delay):
173
164
if notification .message :
174
165
print ("Message:" , notification .message )
175
166
# NeoPixel blinks and then stays on until cleared
176
- blink_pixel (2 , 0.5 , notif_color , clear )
167
+ blink_pixel (2 , 0.5 , notif_color , color . BLACK )
177
168
pixel .fill (notif_color )
178
169
pixel .show ()
179
170
# if it's on the hour:
@@ -183,16 +174,16 @@ def vibe(num_zzz, effect, delay):
183
174
# haptic motor vibrates
184
175
vibe (5 , vibration , 1 )
185
176
# NeoPixel blinks and then stays on
186
- blink_pixel (5 , 1 , BLUE , clear )
177
+ blink_pixel (5 , 1 , color . BLUE , color . BLACK )
187
178
mindful = True
188
- pixel .fill (BLUE )
179
+ pixel .fill (color . BLUE )
189
180
pixel .show ()
190
181
print ("hour = " , hour )
191
182
# if it's no longer on the hour:
192
183
if cts .current_time [4 ] == (hour + 1 ) and mindful :
193
184
# NeoPixel turns off
194
185
mindful = False
195
- pixel .fill (clear )
186
+ pixel .fill (color . BLACK )
196
187
pixel .show ()
197
188
print ("mindful time over" )
198
189
0 commit comments