Hello,
So, i’m teaching myself Python and getting there bit by bit. I have a Rainbow Hat and want to create a Python program to display the temperature ONLY only when I press key A and Pressure when I press key B. If I don’t press a key the hat should do nothing.
So, somehow I need to combine the following script sections to run an a continuous loop but I’m struggling so would really appreciate it if somebody could point me in the right direction.
#displays the temperature on the LCD segments
while True:
t = rh.weather.temperature()
rh.display.clear()
rh.display.print_float(t)
rh.display.show()
time.sleep(0.5)
#displays the pressure on the LCD segments
p = rh.weather.pressure()
rh.display.clear()
rh.display.print_float(p)
rh.display.show()
time.sleep(0.5)
#key touch scripts, I want to use A for temperature and B for pressure
@rh.touch.A.press()
def touch_a(channel):
rh.lights.rgb(1, 0, 0)
@rh.touch.A.release()
def release_a(channel):
rh.lights.rgb(0, 0, 0)
@rh.touch.B.press()
def touch_b(channel):
rh.lights.rgb(0, 1, 0)
@rh.touch.B.release()
def release_b(channel):
rh.lights.rgb(0, 0, 0)
Any help will truly be appreciated
Thanks
Scott