Toggle Navigation
Hatchery
Eggs
weather_live
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import bme680, utime, display, buttons bme680.init() disp = display.open() MAIN_VIEW = 0 UNIT_VIEW = 1 CREDITS_VIEW = 2 viewmode = MAIN_VIEW pressed = False while True: disp.clear() pressed = (buttons.read(buttons.TOP_RIGHT) & buttons.TOP_RIGHT !=0 ) and not pressed if viewmode == MAIN_VIEW: temperature, humidity, pressure, resistance = bme680.get_data() disp.print("Temp: " + str(temperature), posy=0, fg=[255, 255, 255]) disp.print("Hum: " + str(humidity) ,posy=20, fg=[0, 255, 255]) disp.print("Pre: " + str(pressure) ,posy=40, fg=[255, 0, 255]) disp.print("Re: " + str(resistance) ,posy=60, fg=[255, 255, 0]) # SELECT GO THROUGH MENU if pressed: viewmode = UNIT_VIEW elif viewmode == UNIT_VIEW: disp.print("Temp in C", posy=0, fg=[255, 255, 255]) disp.print("Hum in r.h.",posy=20, fg=[0, 255, 255]) disp.print("Pre in hPa",posy=40, fg=[255, 0, 255]) disp.print("Re in Ohm",posy=60, fg=[255, 255, 0]) # SELECT GO THROUGH MENU if pressed: viewmode = CREDITS_VIEW elif viewmode == CREDITS_VIEW: disp.print("Powered by", posy=0, fg=[255, 255, 255]) disp.print(" Dark",posy=20, fg=[50, 50, 50]) disp.print(" Systems",posy=40, fg=[50, 50, 50]) # SELECT GO THROUGH MENU if pressed: viewmode = MAIN_VIEW disp.update() utime.sleep(0.1)