pull/194/head
ZodiusInfuser 2021-08-23 16:28:27 +01:00
rodzic 88a9449e0a
commit a98252993d
1 zmienionych plików z 25 dodań i 15 usunięć

Wyświetl plik

@ -2,11 +2,11 @@ import plasma
from plasma import plasma2040
import time
# Import helpers for RGB LEDs, Buttons, and Analog
from pimoroni import RGBLED, Button, Analog
# Import helpers for RGB LEDs and Buttons
from pimoroni import RGBLED, Button
# Import bme68x and I2C helper
from breakout_bme68x import BreakoutBME68X, STATUS_HEATER_STABLE
from breakout_bme68x import BreakoutBME68X
from pimoroni_i2c import PimoroniI2C
# Press "A" to cycle to the next mode.
@ -50,7 +50,7 @@ HUMIDITY_HUE_END = 0.667
# led_strip = plasma.APA102(NUM_LEDS, 0, 0, plasma2040.DAT, plasma2040.CLK)
# WS2812 / NeoPixel™ LEDs
# led_strip = plasma.WS2812(NUM_LEDS, 0, 0, plasma2040.DAT)
led_strip = plasma.WS2812(NUM_LEDS, 0, 0, plasma2040.DAT)
button_a = Button(plasma2040.BUTTON_A, repeat_time=0)
@ -65,10 +65,12 @@ bme = BreakoutBME68X(i2c)
ALL, TEMPERATURE, PRESSURE, HUMIDITY = range(4)
# Maps a value from one range to another
def map(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
# Sets a section of the led strip to show a hue gradient based on the provided percent
def colour_gauge(percent, start_led, end_led, start_hue, end_hue):
if end_led > start_led:
@ -128,20 +130,28 @@ while True:
if mode == ALL:
led.set_rgb(127, 127, 127)
if a_pressed: mode = TEMPERATURE
elif b_pressed: mode = HUMIDITY
if a_pressed:
mode = TEMPERATURE
elif b_pressed:
mode = HUMIDITY
elif mode == TEMPERATURE:
led.set_rgb(255, 0, 255)
if a_pressed: mode = PRESSURE
elif b_pressed: mode = ALL
if a_pressed:
mode = PRESSURE
elif b_pressed:
mode = ALL
elif mode == PRESSURE:
led.set_rgb(255, 255, 0)
if a_pressed: mode = HUMIDITY
elif b_pressed: mode = TEMPERATURE
if a_pressed:
mode = HUMIDITY
elif b_pressed:
mode = TEMPERATURE
elif mode == HUMIDITY:
led.set_rgb(0, 255, 255)
if a_pressed: mode = ALL
elif b_pressed: mode = PRESSURE
if a_pressed:
mode = ALL
elif b_pressed:
mode = PRESSURE