Skip to content

Commit 7dbea72

Browse files
authored
Merge branch 'master' into ulab
2 parents f699eb9 + 65d591c commit 7dbea72

File tree

31 files changed

+953
-32
lines changed

31 files changed

+953
-32
lines changed

Adafruit_Feather_Sense/feather_sense_sensor_demo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222

2323
def normalized_rms(values):
2424
minbuf = int(sum(values) / len(values))
25-
return math.sqrt(sum(float(sample - minbuf) *
26-
(sample - minbuf) for sample in values) / len(values))
25+
return int(math.sqrt(sum(float(sample - minbuf) *
26+
(sample - minbuf) for sample in values) / len(values)))
2727

2828
apds9960.enable_proximity = True
2929
apds9960.enable_color = True
30+
31+
# Set this to sea level pressure in hectoPascals at your location for accurate altitude reading.
3032
bmp280.sea_level_pressure = 1013.25
3133

3234
while True:
@@ -35,7 +37,7 @@ def normalized_rms(values):
3537

3638
print("\nFeather Sense Sensor Demo")
3739
print("---------------------------------------------")
38-
print("Proximity:", apds9960.proximity())
40+
print("Proximity:", apds9960.proximity)
3941
print("Red: {}, Green: {}, Blue: {}, Clear: {}".format(*apds9960.color_data))
4042
print("Temperature: {:.1f} C".format(bmp280.temperature))
4143
print("Barometric pressure:", bmp280.pressure)

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."
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import time
2+
import board
3+
import digitalio
4+
import analogio
5+
from adafruit_clue import clue
6+
7+
# Turn off the NeoPixel
8+
clue.pixel.fill(0)
9+
10+
# Motor setup
11+
motor = digitalio.DigitalInOut(board.P2)
12+
motor.direction = digitalio.Direction.OUTPUT
13+
14+
# Soil sense setup
15+
analog = analogio.AnalogIn(board.P1)
16+
17+
def read_and_average(analog_in, times, wait):
18+
analog_sum = 0
19+
for _ in range(times):
20+
analog_sum += analog_in.value
21+
time.sleep(wait)
22+
return analog_sum / times
23+
24+
clue_display = clue.simple_text_display(title=" CLUE Plant", title_scale=1, text_scale=3)
25+
clue_display.show()
26+
27+
while True:
28+
# Take 100 readings and average them
29+
analog_value = read_and_average(analog, 100, 0.01)
30+
# Calculate a percentage (analog_value ranges from 0 to 65535)
31+
percentage = analog_value / 65535 * 100
32+
# Display the percentage
33+
clue_display[0].text = "Soil: {} %".format(int(percentage))
34+
# Print the values to the serial console
35+
print((analog_value, percentage))
36+
37+
if percentage < 50:
38+
motor.value = True
39+
clue_display[1].text = "Motor ON"
40+
clue_display[1].color = (0, 255, 0)
41+
time.sleep(0.5)
42+
43+
# always turn off quickly
44+
motor.value = False
45+
clue_display[1].text = "Motor OFF"
46+
clue_display[1].color = (255, 0, 0)
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Bonsai Buckaroo + CLUE Plant Care Bot
2+
3+
import time
4+
import board
5+
from digitalio import DigitalInOut, Direction
6+
from analogio import AnalogIn
7+
from adafruit_clue import clue
8+
from adafruit_display_text import label
9+
import displayio
10+
import terminalio
11+
import pulseio
12+
13+
moist_level = 50 # adjust this value as needed for your plant
14+
15+
board.DISPLAY.brightness = 0.8
16+
clue.pixel.fill(0) # turn off NeoPixel
17+
18+
clue_display = displayio.Group(max_size=4)
19+
20+
# draw the dry plant
21+
dry_plant_file = open("dry.bmp", "rb")
22+
dry_plant_bmp = displayio.OnDiskBitmap(dry_plant_file)
23+
dry_plant_sprite = displayio.TileGrid(dry_plant_bmp, pixel_shader=displayio.ColorConverter())
24+
clue_display.append(dry_plant_sprite)
25+
26+
# draw the happy plant on top (so it can be moved out of the way when needed)
27+
happy_plant_file = open("happy.bmp", "rb")
28+
happy_plant_bmp = displayio.OnDiskBitmap(happy_plant_file)
29+
happy_plant_sprite = displayio.TileGrid(happy_plant_bmp, pixel_shader=displayio.ColorConverter())
30+
clue_display.append(happy_plant_sprite)
31+
32+
# Create text
33+
# first create the group
34+
text_group = displayio.Group(max_size=3, scale=3)
35+
# Make a label
36+
title_label = label.Label(terminalio.FONT, text="CLUE Plant", color=0x00FF22)
37+
# Position the label
38+
title_label.x = 10
39+
title_label.y = 4
40+
# Append label to group
41+
text_group.append(title_label)
42+
43+
soil_label = label.Label(terminalio.FONT, text="Soil: ", color=0xFFAA88, max_glyphs=10)
44+
soil_label.x = 4
45+
soil_label.y = 64
46+
text_group.append(soil_label)
47+
48+
motor_label = label.Label(terminalio.FONT, text="Motor off", color=0xFF0000, max_glyphs=9)
49+
motor_label.x = 4
50+
motor_label.y = 74
51+
text_group.append(motor_label)
52+
53+
clue_display.append(text_group)
54+
board.DISPLAY.show(clue_display)
55+
56+
motor = DigitalInOut(board.P2)
57+
motor.direction = Direction.OUTPUT
58+
59+
buzzer = pulseio.PWMOut(board.SPEAKER, variable_frequency=True)
60+
buzzer.frequency = 1000
61+
62+
sense_pin = board.P1
63+
analog = AnalogIn(board.P1)
64+
65+
def read_and_average(ain, times, wait):
66+
asum = 0
67+
for _ in range(times):
68+
asum += ain.value
69+
time.sleep(wait)
70+
return asum / times
71+
72+
time.sleep(5)
73+
74+
while True:
75+
# take 100 readings and average them
76+
aval = read_and_average(analog, 100, 0.01)
77+
# calculate a percentage (aval ranges from 0 to 65535)
78+
aperc = aval / 65535 * 100
79+
# display the percentage
80+
soil_label.text = "Soil: {} %".format(int(aperc))
81+
print((aval, aperc))
82+
83+
if aperc < moist_level:
84+
happy_plant_sprite.x = 300 # move the happy sprite away
85+
time.sleep(1)
86+
motor.value = True
87+
motor_label.text = "Motor ON"
88+
motor_label.color = 0x00FF00
89+
buzzer.duty_cycle = 2**15
90+
time.sleep(0.5)
91+
92+
# always turn off quickly
93+
motor.value = False
94+
motor_label.text = "Motor off"
95+
motor_label.color = 0xFF0000
96+
buzzer.duty_cycle = 0
97+
98+
if aperc >= moist_level:
99+
happy_plant_sprite.x = 0 # bring back the happy sprite

Buckaroo_Plant_Care_Bot/dry.bmp

113 KB
Binary file not shown.

Buckaroo_Plant_Care_Bot/happy.bmp

113 KB
Binary file not shown.

Burning_Fire_Wizard_Staff/README.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Burning_Fire_Wizard_Staff
2+
3+
Code to accompany this tutorial:
4+
https://learn.adafruit.com/burning-fire-wizard-staff
5+
6+
Prop-Maker based Burning Wizard Staff
7+
Adafruit invests time and resources providing this open source code.
8+
Please support Adafruit and open source hardware by purchasing
9+
products from Adafruit!
10+
Written by Kattni Rembor, Erin St Blaine & Limor Fried for Adafruit Industries
11+
Copyright (c) 2020 Adafruit Industries
12+
Licensed under the MIT license.
13+
All text above must be included in any redistribution.

0 commit comments

Comments
 (0)