Skip to content

Commit 8ad22e4

Browse files
authored
Update code.py
1 parent 7e61cec commit 8ad22e4

File tree

1 file changed

+21
-44
lines changed

1 file changed

+21
-44
lines changed

Vertical_Garden_Barometer/code.py

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
"""
32
Read the barometric reading in the air
43
Visualize air reading changes over time as a color animation on a NeoPixel strip
@@ -15,7 +14,6 @@
1514
from adafruit_display_text import label
1615
from adafruit_bitmap_font import bitmap_font
1716

18-
1917
num_leds = 79 #number of LEDs in your strip
2018
timeToCheck = 100 # set the amount of time between sensor checks. 7800 is approx. 1 hour
2119

@@ -31,15 +29,15 @@
3129

3230
"""
3331
# THERMOMETER RANGES (C)
34-
# set desired temperature range -- the NeoPixel palette choice will be determined by these thresholds
32+
# set desired temperature range - NeoPixel palette choice determined by these thresholds
3533
deviceType = 1
3634
min_reading = 25
3735
med_reading = 27
3836
high_reading= 31
3937
max_reading = 33
4038
"""
4139

42-
#get an initial sensor reading
40+
# get an initial sensor reading
4341
if deviceType ==0:
4442
reading = clue.pressure
4543
else:
@@ -50,8 +48,8 @@
5048
reading2 = reading1
5149
reading3 = reading2
5250
counter = 0
53-
toggle = 1 #for on/off switch on button A
54-
displayOn = 1 #to turn the display on and off with button B
51+
toggle = 1 # for on/off switch on button A
52+
displayOn = 1 # to turn the display on and off with button B
5553

5654
clue.display.brightness = 0.8
5755
clue_display = displayio.Group(max_size=4)
@@ -98,34 +96,13 @@
9896
clue.display.show(clue_display)
9997

10098
# Define color Palettes
101-
waterPalette = [
102-
0x00d9ff,
103-
0x006f82,
104-
0x43bfb9,
105-
0x0066ff]
106-
icePalette = [
107-
0x8080FF,
108-
0x8080FF,
109-
0x8080FF,
110-
0x0000FF,
111-
0xC88AFF]
112-
sunPalette = [
113-
0xffaa00,
114-
0xffdd00,
115-
0x7d5b06,
116-
0xfffca8]
117-
firePalette = [
118-
0xff0000,
119-
0xff5500,
120-
0x8a3104,
121-
0xffaa00 ]
122-
forestPalette = [
123-
0xccffa8,
124-
0x69f505,
125-
0x05f551,
126-
0x2c8247]
127-
128-
#set up default initial palettes, just for startup
99+
waterPalette = [0x00d9ff, 0x006f82, 0x43bfb9, 0x0066ff]
100+
icePalette = [0x8080FF, 0x8080FF, 0x8080FF, 0x0000FF, 0xC88AFF]
101+
sunPalette = [0xffaa00, 0xffdd00, 0x7d5b06, 0xfffca8]
102+
firePalette = [0xff0000, 0xff5500, 0x8a3104, 0xffaa00 ]
103+
forestPalette = [0xccffa8, 0x69f505, 0x05f551, 0x2c8247]
104+
105+
# set up default initial palettes, just for startup
129106
palette = forestPalette
130107
palette2 = waterPalette
131108
palette3 = icePalette
@@ -149,15 +126,15 @@
149126
pixels.brightness = 1.0
150127
clue.display.brightness = 0.8
151128
if clue.button_b:
152-
#Toggle only the display on and off
129+
# Toggle only the display on and off
153130
if displayOn == 0:
154131
clue.display.brightness = 0.8
155132
displayOn = 1
156133
else:
157134
clue.display.brightness = 0
158135
displayOn = 0
159136

160-
#assign color palette to NeoPixel section 1 based on the current reading reading
137+
# assign color palette to NeoPixel section 1 based on the current reading reading
161138
if reading1 < min_reading:
162139
palette = firePalette
163140
elif reading1 > min_reading and reading1 < med_reading:
@@ -168,7 +145,7 @@
168145
palette = waterPalette
169146
else:
170147
palette = icePalette
171-
#Map colors to pixels. Adjust range numbers to light up specific pixels. This configuration
148+
# Map colors to pixels. Adjust range numbers to light up specific pixels. This configuration
172149
# maps to a reflected gradient, with pixel 0 in the upper left corner
173150
# Load each pixel's color from the palette using an offset, run it
174151
# through the gamma function, pack RGB value and assign to pixel.
@@ -226,35 +203,35 @@
226203
timer_label.text = "{}".format(counter)
227204
clue.display.show(clue_display)
228205

229-
#Is it time to update?
206+
# Is it time to update?
230207
if counter > timeToCheck:
231-
#This moves the current data to the "1 hour old" section of pixels and the "1 hour old" data
232-
#to the "2 hours old" section of pixels
208+
# This moves the current data to the "1 hour old" section of pixels and the "1 hour old"
209+
# data to the "2 hours old" section of pixels
233210
palette3 = palette2
234211
palette2 = palette
235212
reading3 = reading2
236213
reading2 = reading1
237214
reading1 = reading
238-
#take a new sensor reading and reset the counter
215+
# take a new sensor reading and reset the counter
239216
if deviceType == 0:
240217
reading = clue.pressure
241218
else:
242219
reading = clue.temperature
243220
counter = 0
244-
#if reading is rising, show rising image and position text at the bottom
221+
# if reading is rising, show rising image and position text at the bottom
245222
if reading1 > reading2:
246223
sinking_sprite.x = 300
247224
reading_label.y = 134
248225
reading2_label.y = 164
249226
reading3_label.y = 194
250227
timer_label.y = 224
251-
#if reading is falling, show sinking image and position text at the top
228+
# if reading is falling, show sinking image and position text at the top
252229
elif reading2 < reading3: #reading is falling
253230
sinking_sprite.x = 0
254231
reading_label.y = 24
255232
reading2_label.y = 54
256233
reading3_label.y = 84
257234
timer_label.y = 114
258-
#otherwise keep counting up
235+
# otherwise keep counting up
259236
else:
260237
counter = counter + 1

0 commit comments

Comments
 (0)