#from Setup import Setup
#from APIConnection import APIConnection
from neopixel import NeoPixel
from machine import Pin
from machine import I2C
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd
import time
def main():
# wifi_connection = Setup()
# wifi_connection.setup()
# try:
# wifi_connection.connect()
# except KeyboardInterrupt:
# wifi_connection.machine.reset()
# metadata = APIConnection()
# metadata.get_api_data()
# for i in range(len(metadata.metadata)):
# print(metadata.metadata[i])
# print(metadata.exposure)
# print(metadata.summary)
counter = 0
grb_tuple = (0,0,0)
# button = machine.Pin(6,machine.Pin.IN, machine.Pin.PULL_UP)
I2C_ADDR = 39
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16
sda = machine.Pin(0)
scl = machine.Pin(1) # NOTE: It is important you change this to match the SDA and SCL pins you are using.
i2c_controller = 0 # Also change this to match the controller you are using (Listed on the Raspberry Pi Pico W Pinout as "I2C0" or "I2C1")
# You will need to wire the LCD to your Pi Pico, ensuring that each pin goes to the correct header. The pinout should be written on the LCDs PCB.
# You can use either 5V power via VBUS or 3.3V power via either VSYS or 3V(OUT).
i2c = I2C(i2c_controller, sda=sda, scl=scl, freq=400000)
print(i2c.scan())
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)
testString = "Test"
while True:
# if metadata.metadata[counter][3] == "Low":
# grb_tuple = (0,255,0)
# elif metadata.metadata[counter][3] == "Moderate":
# grb_tuple = (255,200,0)
# elif metadata.metadata[counter][3] == "Considerable":
# grb_tuple = (255,80,0)
# elif metadata.metadata[counter][3] == "High":
# grb_tuple = (255,0,0)
# else:
# grb_tuple = (48,25,52)
if counter == 0:
grb_tuple = (255,0,0)
elif counter == 1:
grb_tuple = (0,255,0)
else:
grb_tuple = (0,0,255)
np = NeoPixel(30,0,0,"GRB")
np.fill(grb_tuple)
np.show()
lcd.putstr(testString)
if button.value() == 0:
continue
else:
if counter == 2:
counter = 0
else:
counter = counter +1
time.sleep(0.4)
if __name__ == "__main__":
main()