print("Hello, Pi Pico!")
import board
import busio
import neopixel
import time
import adafruit_ahtx0
#i2c = busio.I2C(scl=board.GP36, sda=board.GP37)
#tempsensor = adafruit_ahtx0_AHTx0(i2c)
#i dont use the sensor in this demo
pxr = neopixel.NeoPixel(board.GP19, 9, brightness=0.5) #8+inbuilt neopixel
pxl = neopixel.NeoPixel(board.GP14, 8, brightness=0.5)
#not the pins on the ESP32-S3-DevkitC, but whatever
def ramp(neo):
for b in range (3):
for px in neo:
px = (16+b*16, 16+b*16, 16+b*16) #slowly power on, idk if my caacitor is good enough
time.sleep(0.5)
ramp(pxr)
ramp(pxl)
testHum = 50
testTemp = 22
#define testing value, testHum 50 should correspond to finIndex 4
#testTemp 22 is cca (111,55,32) i think
def env():
humIndex = round(testHum/10)
if humIndex < 3:
finIndex = abs(round(humIndex/2)) # max finIndex 1 at humIndex 2, max hum 0.24
print(f"low humIndex")
elif (humIndex > 6):
finIndex = round(humIndex/2)+2
else:
finIndex = humIndex-1
print("normal")
tempAdjust = testTemp/30
print(tempAdjust)
tempColor = (finIndex, (64+64*tempAdjust, 32+32*tempAdjust,32))
print(tempColor)
return tempColor
def bars(pxbar, offset, tarlen, color):
for i in range(offset, tarlen+offset):
pxbar[i] = color
envs = (0,(0,0,0))
while True:
lastenv = envs
envs = env()
if envs != lastenv:
bars(pxr, 1, envs[0], envs[1])
#on the real project, the right bar uses pin 38
#associated with onboard neopixel, which i want to skip
#with this offset
bars(pxl, 0, envs[0], envs[1])
time.sleep(2)