Skip to content

Commit 4ceb9ca

Browse files
authored
Merge branch 'master' into master
2 parents 9a72954 + 812002d commit 4ceb9ca

File tree

125 files changed

+167649
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+167649
-32
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cache:
1515

1616
env:
1717
global:
18-
- ARDUINO_IDE_VERSION="1.8.7"
18+
- ARDUINO_IDE_VERSION="1.8.11"
1919
- PRETTYNAME="Adafruit Learning System Guides"
2020
- PLATFORM_CHECK_ONLY_ON_FILE=true
2121

Activity_Generator/code.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""ACTIVITY GENERATOR for Adafruit CLUE"""
2+
3+
import time
4+
import random
5+
from adafruit_clue import clue
6+
from things import activities
7+
from things import subjects
8+
9+
screen = clue.simple_text_display(text_scale=4, colors=(clue.WHITE,))
10+
11+
screen[1].text = "ACTIVITY"
12+
screen[2].text = "GENERATOR"
13+
screen.show()
14+
time.sleep(1.5)
15+
16+
screen[0].text = "make a"
17+
screen[2].text = "about"
18+
screen[1].color = clue.RED
19+
screen[3].color = clue.GREEN
20+
screen[4].color = clue.BLUE
21+
22+
activity = "???"
23+
subject_a = "???"
24+
subject_b = "???"
25+
two_subjects = True
26+
27+
def random_pick(items):
28+
index = random.randint(0, len(items)-1)
29+
return items[index]
30+
31+
while True:
32+
33+
if clue.button_a:
34+
activity = random_pick(activities)
35+
subject_a = random_pick(subjects)
36+
subject_b = random_pick(subjects)
37+
time.sleep(0.25)
38+
if clue.button_b:
39+
two_subjects = not two_subjects
40+
time.sleep(0.5)
41+
42+
screen[1].text = activity
43+
screen[3].text = subject_a
44+
45+
if two_subjects:
46+
screen[4].text = subject_b
47+
else:
48+
screen[4].text = ""
49+
50+
screen.show()

Activity_Generator/things.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
activities = [
2+
"DRAWING",
3+
"SONG",
4+
"STORY",
5+
"VIDEO",
6+
]
7+
8+
subjects = [
9+
"COMPUTER",
10+
"ALIEN",
11+
"LASER",
12+
"FOOD",
13+
"TREE",
14+
"DREAM",
15+
"WEATHER",
16+
"DOG",
17+
"CAT",
18+
"BIRD",
19+
"HORSE",
20+
"BLANKET",
21+
"TIME",
22+
"PLANT",
23+
"LEAF",
24+
"EAR",
25+
"HAND",
26+
"FEET",
27+
"TEETH",
28+
"PHONE",
29+
"SPACE",
30+
"ROBOT",
31+
"GHOST",
32+
"FUTURE",
33+
"PROBLEM",
34+
"MUSIC",
35+
"NOISE",
36+
"METAL",
37+
"ROCK",
38+
"AIR",
39+
"HOPE",
40+
"FEAR",
41+
"LOVE",
42+
"DANGER",
43+
"COOKIE",
44+
"BREAD",
45+
"WATER",
46+
"HAT",
47+
"ROUND",
48+
"SQUARE",
49+
"SUCCESS",
50+
"LIGHT",
51+
"RUNNING",
52+
"TALKING",
53+
"SLEEPING",
54+
"FLYING",
55+
"SINGING",
56+
"ACTING",
57+
]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""Sensor demo for Adafruit Feather Sense. Prints data from each of the sensors."""
2+
import time
3+
import array
4+
import math
5+
import board
6+
import audiobusio
7+
import adafruit_apds9960.apds9960
8+
import adafruit_bmp280
9+
import adafruit_lis3mdl
10+
import adafruit_lsm6ds
11+
import adafruit_sht31d
12+
13+
i2c = board.I2C()
14+
15+
apds9960 = adafruit_apds9960.apds9960.APDS9960(i2c)
16+
bmp280 = adafruit_bmp280.Adafruit_BMP280_I2C(i2c)
17+
lis3mdl = adafruit_lis3mdl.LIS3MDL(i2c)
18+
lsm6ds33 = adafruit_lsm6ds.LSM6DS33(i2c)
19+
sht31d = adafruit_sht31d.SHT31D(i2c)
20+
microphone = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA,
21+
sample_rate=16000, bit_depth=16)
22+
23+
def normalized_rms(values):
24+
minbuf = int(sum(values) / len(values))
25+
return int(math.sqrt(sum(float(sample - minbuf) *
26+
(sample - minbuf) for sample in values) / len(values)))
27+
28+
apds9960.enable_proximity = True
29+
apds9960.enable_color = True
30+
31+
# Set this to sea level pressure in hectoPascals at your location for accurate altitude reading.
32+
bmp280.sea_level_pressure = 1013.25
33+
34+
while True:
35+
samples = array.array('H', [0] * 160)
36+
microphone.record(samples, len(samples))
37+
38+
print("\nFeather Sense Sensor Demo")
39+
print("---------------------------------------------")
40+
print("Proximity:", apds9960.proximity)
41+
print("Red: {}, Green: {}, Blue: {}, Clear: {}".format(*apds9960.color_data))
42+
print("Temperature: {:.1f} C".format(bmp280.temperature))
43+
print("Barometric pressure:", bmp280.pressure)
44+
print("Altitude: {:.1f} m".format(bmp280.altitude))
45+
print("Magnetic: {:.3f} {:.3f} {:.3f} uTesla".format(*lis3mdl.magnetic))
46+
print("Acceleration: {:.2f} {:.2f} {:.2f} m/s^2".format(*lsm6ds33.acceleration))
47+
print("Gyro: {:.2f} {:.2f} {:.2f} dps".format(*lsm6ds33.gyro))
48+
print("Humidity: {:.1f} %".format(sht31d.relative_humidity))
49+
print("Sound level:", normalized_rms(samples))
50+
time.sleep(0.3)

BLE_Heart_Rate_Trainer/ble_heart_rate_trainer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@
3535
# Seven Segment FeatherWing setup
3636
i2c = board.I2C()
3737
display_A = Seg7x4(i2c, address=0x70) # this will be the BPM display
38-
display_A.brightness = 15
3938
display_A.fill(0) # Clear the display
4039
# Second display has A0 address jumpered
4140
display_B = Seg7x4(i2c, address=0x71) # this will be the % target display
42-
display_B.brightness = 15
4341
display_B.fill(0) # Clear the display
4442

4543
# display_A "b.P.M."

BLE_Sensornet/clue_sensornet.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""This uses the CLUE as a Bluetooth LE sensor node."""
2+
3+
import time
4+
from adafruit_clue import clue
5+
import adafruit_ble_broadcastnet
6+
7+
print("This is BroadcastNet CLUE sensor:", adafruit_ble_broadcastnet.device_address)
8+
9+
while True:
10+
measurement = adafruit_ble_broadcastnet.AdafruitSensorMeasurement()
11+
12+
measurement.temperature = clue.temperature
13+
measurement.pressure = clue.pressure
14+
measurement.relative_humidity = clue.humidity
15+
measurement.acceleration = clue.acceleration
16+
measurement.magnetic = clue.magnetic
17+
18+
print(measurement)
19+
adafruit_ble_broadcastnet.broadcast(measurement)
20+
time.sleep(60)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""This uses the Feather Sense as a Bluetooth LE sensor node."""
2+
3+
import time
4+
import adafruit_ble_broadcastnet
5+
import board
6+
import adafruit_lsm6ds # accelerometer
7+
import adafruit_sht31d # humidity sensor
8+
import adafruit_bmp280 # barometric sensor
9+
import adafruit_lis3mdl # magnetic sensor
10+
11+
i2c = board.I2C()
12+
13+
sense_accel = adafruit_lsm6ds.LSM6DS33(i2c)
14+
sense_humid = adafruit_sht31d.SHT31D(i2c)
15+
sense_barometric = adafruit_bmp280.Adafruit_BMP280_I2C(i2c)
16+
sense_magnet = adafruit_lis3mdl.LIS3MDL(i2c)
17+
18+
print("This is BroadcastNet Feather Sense sensor:", adafruit_ble_broadcastnet.device_address)
19+
20+
while True:
21+
measurement = adafruit_ble_broadcastnet.AdafruitSensorMeasurement()
22+
23+
measurement.temperature = sense_barometric.temperature
24+
measurement.pressure = sense_barometric.pressure
25+
measurement.relative_humidity = sense_humid.relative_humidity
26+
measurement.acceleration = sense_accel.acceleration
27+
measurement.magnetic = sense_magnet.magnetic
28+
29+
# print(measurement)
30+
adafruit_ble_broadcastnet.broadcast(measurement)
31+
time.sleep(60)

BLE_Synth/cpb_amp_code.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
'''BLE Synth
2+
File for the Circuit Playground Bluefruit
3+
Amp Portion'''
4+
from adafruit_circuitplayground.bluefruit import cpb
5+
from adafruit_led_animation.animation import Comet, AnimationGroup,\
6+
AnimationSequence
7+
import adafruit_led_animation.color as color
8+
from adafruit_ble import BLERadio
9+
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
10+
from adafruit_ble.services.nordic import UARTService
11+
from adafruit_bluefruit_connect.packet import Packet
12+
from adafruit_bluefruit_connect.color_packet import ColorPacket
13+
from adafruit_bluefruit_connect.button_packet import ButtonPacket
14+
15+
# easily call for NeoPixels to be off
16+
off = (0, 0, 0)
17+
# state to debounce on CPB end
18+
tone = False
19+
20+
# Setup for comet animation
21+
COMET_SPEED = 0.04 # Lower numbers increase the animation speed
22+
CPB_COMET_TAIL_LENGTH = 5 # The length of the comet on the Circuit Playground Bluefruit
23+
CPB_COMET_BOUNCE = False # Set to True to make the comet "bounce" the opposite direction on CPB
24+
25+
animations = AnimationSequence(
26+
AnimationGroup(
27+
Comet(cpb.pixels, COMET_SPEED, off, tail_length=CPB_COMET_TAIL_LENGTH,
28+
bounce=CPB_COMET_BOUNCE)))
29+
30+
# note frequencies
31+
C4 = 261.63
32+
Csharp4 = 277.18
33+
D4 = 293.66
34+
Dsharp4 = 311.13
35+
E4 = 329.63
36+
F4 = 349.23
37+
Fsharp4 = 369.99
38+
G4 = 392
39+
Gsharp4 = 415.3
40+
A4 = 440
41+
Asharp4 = 466.16
42+
B4 = 493.88
43+
44+
# note array
45+
note = [C4, Csharp4, D4, Dsharp4, E4, F4,
46+
Fsharp4, G4, Gsharp4, A4, Asharp4, B4]
47+
48+
# colors to recieve from color packet & for neopixels
49+
color_C = color.RED
50+
color_Csharp = color.ORANGE
51+
color_D = color.YELLOW
52+
color_Dsharp = color.GREEN
53+
color_E = color.TEAL
54+
color_F = color.CYAN
55+
color_Fsharp = color.BLUE
56+
color_G = color.PURPLE
57+
color_Gsharp = color.MAGENTA
58+
color_A = color.GOLD
59+
color_Asharp = color.PINK
60+
color_B = color.WHITE
61+
62+
# color array
63+
color = [color_C, color_Csharp, color_D, color_Dsharp, color_E,
64+
color_F, color_Fsharp, color_G, color_Gsharp, color_A,
65+
color_Asharp, color_B]
66+
67+
# Setup BLE connection
68+
ble = BLERadio()
69+
uart = UARTService()
70+
advertisement = ProvideServicesAdvertisement(uart)
71+
72+
while True:
73+
# connect via BLE
74+
ble.start_advertising(advertisement) # Start advertising.
75+
was_connected = False
76+
while not was_connected or ble.connected:
77+
if ble.connected: # If BLE is connected...
78+
was_connected = True
79+
# start animations
80+
animations.animate()
81+
# look for packets
82+
if uart.in_waiting:
83+
try:
84+
packet = Packet.from_stream(uart) # Create the packet object.
85+
except ValueError:
86+
continue
87+
# if it's a color packet:
88+
if isinstance(packet, ColorPacket):
89+
for i in range(12):
90+
colors = color[i]
91+
notes = note[i]
92+
# if the packet matches one of our colors:
93+
if packet.color == colors and not tone:
94+
# animate with that color
95+
animations.color = colors
96+
# play matching note
97+
cpb.start_tone(notes)
98+
tone = True
99+
# if it's a button packet aka feather's button has been released:
100+
elif isinstance(packet, ButtonPacket) and packet.pressed:
101+
if packet.button == ButtonPacket.RIGHT and tone:
102+
tone = False
103+
# stop playing the note
104+
cpb.stop_tone()
105+
# turn off the neopixels but keep animation active
106+
animations.color = off

0 commit comments

Comments
 (0)