def test_fourlines(name, full_refresh=False):
    test_splotter = plotter.ScreenPlotter([red, green, blue, red+green+blue],
                                          min_value=0, max_value=100, top_space=10+10,
                                          display=screen, auto_show=False)

    # add a colour coded text label for each reading
    test_splotter.group.append(label.Label(terminalio.FONT,
                                           text="A: {:.0f}",
                                           color=red, x=0, y=5, max_glyphs=15))
    test_splotter.group.append(label.Label(terminalio.FONT,
                                           text="B: {:.0f}",
                                           color=green, x=50, y=5, max_glyphs=15))
    test_splotter.group.append(label.Label(terminalio.FONT,
                                           text="C: {:.0f}",
                                           color=blue, x=110, y=5, max_glyphs=15))
    test_splotter.group.append(label.Label(terminalio.FONT,
                                           text=name + (" CLS" if full_refresh else ""),
                                           color=0xffffff, x=0, y=5))
    screen.show(test_splotter.group)

    for idx in range(200):
        time.sleep(0.050)
        test_splotter.update((idx * 2 + 50) % 121,
                             (idx * 2 + 20) % 101,
                             idx * 4 % 101,
                             50,
                             draw=not full_refresh)
        if full_refresh:
            test_splotter.draw(full_refresh=full_refresh)
def test_altandmiss(name, full_refresh=False):
    """Draw three lines which alternate values to allow visual check on scrolling.
       Also misses values on third line.
    """
    test_splotter = plotter.ScreenPlotter([red+green, green+blue, red+(blue>>1)],
                                          top_space=10+10,
                                          display=screen, auto_show=False)

    test_splotter.group.append(label.Label(terminalio.FONT,
                                           text=name + (" CLS" if full_refresh else ""),
                                           color=0xffffff, x=0, y=5))
    screen.show(test_splotter.group)

    for idx in range(180):
        if idx >= 140:
            time.sleep(0.25)

        values = [40960 - idx % 2 * 2048,
                  24576 + idx % 4 * 1024]
        if idx % 4 >= 2:
            values.append(32768)
        test_splotter.update(*values,
                             draw=not full_refresh)
        if full_refresh:
            test_splotter.draw(full_refresh=full_refresh)
def test_threeflatlines(name, full_refresh=False):
    test_splotter = plotter.ScreenPlotter([red, green, blue],
                                          min_value=0, max_value=100, top_space=10,
                                          display=screen)

    test_splotter.group.append(label.Label(terminalio.FONT,
                                           text=name + (" CLS" if full_refresh else ""),
                                           color=0xffffff, x=0, y=5))

    for _ in range(200):
        time.sleep(0.050)
        test_splotter.update(0,
                             50,
                             100,
                             draw=not full_refresh)

        if full_refresh:
            test_splotter.draw(full_refresh=full_refresh)
def test_twolinesfewdraws(name, full_refresh=False):
    """Only issue a draw every 4 updates to see how library handles it.
       Current implementation (Dec-2020) misses pixels until it starts scrolling.
    """
    test_splotter = plotter.ScreenPlotter([red+green, green+blue],
                                          min_value=0, max_value=1000, top_space=10+10,
                                          display=screen, auto_show=False)

    test_splotter.group.append(label.Label(terminalio.FONT,
                                           text=name + (" CLS" if full_refresh else ""),
                                           color=0xffffff, x=0, y=5))
    screen.show(test_splotter.group)

    for idx in range(200 + 32):
        time.sleep(0.050)
        test_splotter.update((idx * 50 + 20) % 1001,
                             (idx * 2 + 300) % 1001,
                             draw=False)
        # draw every 4 columns for first 200 columns but skip after that to
        # test going beyond internal circular buffer size
        if idx % 4 == 0 and idx < 200:
            test_splotter.draw(full_refresh=full_refresh)

    test_splotter.draw(full_refresh=full_refresh)
import time

from pimoroni_envirowing import gas
from pimoroni_envirowing.screen import plotter

import terminalio
from adafruit_display_text import label

# colours for the plotter are defined as rgb values in hex, with 2 bytes for each colour
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF

# the max value is set to 3.3 as its the max voltage the feather can read
splotter = plotter.ScreenPlotter([red, green, blue],
                                 max_value=3.3,
                                 min_value=0.5,
                                 top_space=10)

# add a colour coded text label for each reading
splotter.group.append(
    label.Label(terminalio.FONT,
                text="OX:{}",
                color=red,
                x=0,
                y=5,
                max_glyphs=15))
splotter.group.append(
    label.Label(terminalio.FONT,
                text="RED:{}",
                color=green,
                x=50,
pwm = pulseio.PWMOut(pimoroni_physical_feather_pins.pin21())

# start the screen at 50% brightness
pwm.duty_cycle = 2**15

# set up mic input
mic = analogio.AnalogIn(pimoroni_physical_feather_pins.pin8())

# colours for the plotter are defined as rgb values in hex, with 2 bytes for each colour
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF

# Setup bme280 screen plotter
# the max value is set to 70 as it is the screen height in pixels after the labels (top_space) (this is just to make a calculation later on easier)
bme280_splotter = plotter.ScreenPlotter([red, green, blue, red+green+blue], max_value=70, min_value=0, top_space=10, display=screen)

# add a colour coded text label for each reading
bme280_splotter.group.append(label.Label(terminalio.FONT, text="{:0.1f} C".format(bme280.temperature), color=red, x=0, y=5, max_glyphs=15))
bme280_splotter.group.append(label.Label(terminalio.FONT, text="{:0.1f} hPa".format(bme280.pressure), color=green, x=50, y=5, max_glyphs=15))
bme280_splotter.group.append(label.Label(terminalio.FONT, text="{:0.1f} %".format(bme280.humidity), color=blue, x=120, y=5, max_glyphs=15))
#bme280_splotter.group.append(label.Label(terminalio.FONT, text="{:0.2f} m".format(bme280.altitude), color=red+green+blue, x=40, y=20, max_glyphs=15)) # uncomment for altitude estimation

# if the pms5003 is connected
if is_pms5003:
    # Set up the pms5003 screen plotter
    # the max value is set to 1000 as a nice number to work with
    pms5003_splotter = plotter.ScreenPlotter([green, blue, red+blue+green], max_value=1000, min_value=0, top_space=10, display=screen)

    # add a colour coded text label for each reading
    pms5003_splotter.group.append(label.Label(terminalio.FONT, text="PM2.5: {:d}", color=green, x=0, y=5, max_glyphs=15))
import terminalio, displayio
from adafruit_display_text import label

# colours for the plotter are defined as rgb values in hex, with 2 bytes for each colour
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF

# set up the sensor
pms5003 = PMS5003()

# Set up the plotter
# the max value is set to 1000 as a nice number to work with
splotter = plotter.ScreenPlotter([green, blue, red + blue + green],
                                 max_value=1000,
                                 min_value=0,
                                 top_space=10)

# add a colour coded text label for each reading
splotter.group.append(
    label.Label(terminalio.FONT,
                text="PM2.5: {:d}",
                color=green,
                x=0,
                y=5,
                max_glyphs=15))
splotter.group.append(
    label.Label(terminalio.FONT,
                text="PM10: {:d}",
                color=blue,
                x=80,
Example #8
0
# set up the screen
screen = screen.Screen(backlight_control=False)

# set up connection with the sensor
i2c_dev = not_SMBus()
ltr559 = LTR559(i2c_dev=i2c_dev)

# define our pwm pin (for changing the screen brightness)
pwm = pulseio.PWMOut(pimoroni_physical_feather_pins.pin21())

# start the screen at 50% brightness
pwm.duty_cycle = 2**15

# set up the plotter
splotter = plotter.ScreenPlotter([green, blue],
                                 display=screen,
                                 max_value=1,
                                 top_space=10)

# add a colour coded text label for each reading
splotter.group.append(
    label.Label(terminalio.FONT,
                text="Sound",
                color=green,
                x=0,
                y=5,
                max_glyphs=15))
splotter.group.append(
    label.Label(terminalio.FONT,
                text="Light",
                color=blue,
                x=80,
Example #9
0
blue = 0x0000FF

# set up the sensor
scd30 = SCD30(board.I2C())

# The SCD-30 is more accurate if given local air pressure in mb (hPa)
# which is available from the BME280 on the Enviro+ FeatherWing
# The altitude in metres is a less accurate way of compensating for pressure
# The altitude is remembered if the power is removed and is best set
# only when needed to avoid wear on SCD-30 NVRAM
#scd30.ambient_pressure = 1021
#scd30.altitude = 123

# Set up the plotter
splotter = plotter.ScreenPlotter([green],
                                 max_value=3000,
                                 min_value=0,
                                 top_space=10)

# add a colour coded text label for each reading
splotter.group.append(
    label.Label(terminalio.FONT,
                text="CO2: {:.0f} ppm",
                color=green,
                x=0,
                y=5,
                max_glyphs=15))

while True:
    # take readings
    co2ppm = scd30.CO2
    splotter.update(co2ppm)
# colours for the plotter are defined as rgb values in hex, with 2 bytes for each colour
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF

# set up the connection with the sensor
i2c = busio.I2C(board.SCL, board.SDA)
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c, address=0x76)

# average global sea level pressure, for more accurate readings change this to your local sea level pressure (measured in hPa)
bme280.sea_level_pressure = 1013.25

# the max value is set to 70 as it is the screen height in pixels after the labels (top_space) (this is just to make a calculation later on easier)
splotter = plotter.ScreenPlotter([red, green, blue, red + green + blue],
                                 max_value=70,
                                 min_value=0,
                                 top_space=10)

# add a colour coded text label for each reading
splotter.group.append(
    label.Label(terminalio.FONT,
                text="{:0.1f} C".format(bme280.temperature),
                color=red,
                x=0,
                y=5,
                max_glyphs=15))
splotter.group.append(
    label.Label(terminalio.FONT,
                text="{:0.1f} hPa".format(bme280.pressure),
                color=green,
                x=50,
# start the screen at 50% brightness
pwm.duty_cycle = 2**15

# set up mic input
#mic = analogio.AnalogIn(pimoroni_physical_feather_pins.pin8())

# colours for the plotter are defined as rgb values in hex, with 2 bytes for each colour
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF

# Setup bme280 screen plotter
# the max value is set to 70 as it is the screen height in pixels after the labels (top_space) (this is just to make a calculation later on easier)
bme280_splotter = plotter.ScreenPlotter([red, green, blue, red + green + blue],
                                        max_value=70,
                                        min_value=0,
                                        top_space=10,
                                        display=screen)

# add a colour coded text label for each reading
bme280_splotter.group.append(
    label.Label(terminalio.FONT,
                text="{:0.1f} F".format(bme280.temperature * 1.8 + 21),
                color=red,
                x=0,
                y=5,
                max_glyphs=15))
bme280_splotter.group.append(
    label.Label(terminalio.FONT,
                text="{:0.1f} hPa".format(bme280.pressure),
                color=green,