Skip to content

Commit 5c95f45

Browse files
authored
Merge branch 'master' into add-fona-sms-bme
2 parents 0da9ae7 + 6f30e6f commit 5c95f45

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

BLE_Vibration_Bracelet/code.py.py renamed to BLE_Vibration_Bracelet/code.py

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
import busio
44
import neopixel
55
import adafruit_drv2605
6-
from digitalio import DigitalInOut, Direction
6+
import adafruit_led_animation.color as color
77
import adafruit_ble
88
from adafruit_ble.advertising.standard import SolicitServicesAdvertisement
99
from adafruit_ble.services.standard import CurrentTimeService
1010
from adafruit_ble_apple_notification_center import AppleNotificationCenterService
11+
from digitalio import DigitalInOut, Direction
1112

1213
# setup for onboard NeoPixel
1314
pixel_pin = board.NEOPIXEL
@@ -44,26 +45,16 @@
4445
hour = 0 # used to track when it is on the hour for the mindfulness reminder
4546
mindful = False # state used to track if it is time for mindfulness
4647
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'
5748

5849
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
6758
}
6859

6960
# function for blinking NeoPixel
@@ -102,7 +93,7 @@ def vibe(num_zzz, effect, delay):
10293
# NeoPixel is red when not connected to BLE
10394
while not ble.connected:
10495
blue_led.value = False
105-
pixel.fill(RED)
96+
pixel.fill(color.RED)
10697
pixel.show()
10798
print("Connected")
10899

@@ -130,14 +121,14 @@ def vibe(num_zzz, effect, delay):
130121
if current_notification and current_notification.removed:
131122
# Stop showing the latest and show that there are no new notifications.
132123
current_notification = None
133-
pixel.fill(clear)
124+
pixel.fill(color.BLACK)
134125
pixel.show()
135126

136127
if not current_notification and not all_ids and not cleared:
137128
# updates cleared state for notification
138129
cleared = True
139130
# turns off NeoPixel when notifications are clear
140-
pixel.fill(clear)
131+
pixel.fill(color.BLACK)
141132
pixel.show()
142133

143134
elif all_ids:
@@ -153,7 +144,7 @@ def vibe(num_zzz, effect, delay):
153144
# if the notification is from an app that is not
154145
# defined in APP_COLORS then the NeoPixel will be white
155146
if current_notification.app_id not in APP_COLORS:
156-
notif_color = WHITE
147+
notif_color = color.WHITE
157148
# if the notification is from an app defined in
158149
# APP_COLORS then the assigned color will show
159150
else:
@@ -173,7 +164,7 @@ def vibe(num_zzz, effect, delay):
173164
if notification.message:
174165
print("Message:", notification.message)
175166
# 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)
177168
pixel.fill(notif_color)
178169
pixel.show()
179170
# if it's on the hour:
@@ -183,16 +174,16 @@ def vibe(num_zzz, effect, delay):
183174
# haptic motor vibrates
184175
vibe(5, vibration, 1)
185176
# NeoPixel blinks and then stays on
186-
blink_pixel(5, 1, BLUE, clear)
177+
blink_pixel(5, 1, color.BLUE, color.BLACK)
187178
mindful = True
188-
pixel.fill(BLUE)
179+
pixel.fill(color.BLUE)
189180
pixel.show()
190181
print("hour = ", hour)
191182
# if it's no longer on the hour:
192183
if cts.current_time[4] == (hour + 1) and mindful:
193184
# NeoPixel turns off
194185
mindful = False
195-
pixel.fill(clear)
186+
pixel.fill(color.BLACK)
196187
pixel.show()
197188
print("mindful time over")
198189

0 commit comments

Comments
 (0)