Exemplo n.º 1
0
def Screen(backlight_control=True, baudrate=100000000, spi=None):
    """__init__
    :param bool backlight_control: determines whether this class should handle the screen's backlight (default True)
    (this is useful to set to False if you want to control the brightness with pwm in your own code)
    :param int baudrate: sets the baudrate for the spi connection to the display (default 100000000)
    (baudrate doesn't need to be this high for the display to function, it's just nice to have a quick screen refresh by default)
    This class is used to setup the envirowing screen with displayio and return a display object
    """

    import board
    import pimoroni_physical_feather_pins
    import displayio
    from adafruit_st7735r import ST7735R

    # if not supplied an spi object, make our own
    if not spi:
        spi = board.SPI()  # define which spi bus the screen is on

    spi.try_lock()  # try to get control of the spi bus
    spi.configure(
        baudrate=baudrate)  # tell the spi bus how fast it's going to run
    spi.unlock()  # unlocks the spi bus so displayio can control it

    displayio.release_displays(
    )  # release any displays that may exist from previous code run

    if backlight_control:
        display_bus = displayio.FourWire(
            spi,
            command=pimoroni_physical_feather_pins.pin19(),
            chip_select=pimoroni_physical_feather_pins.pin20(),
            reset=pimoroni_physical_feather_pins.pin21(
            ))  # define the display bus
    else:
        display_bus = displayio.FourWire(
            spi,
            command=pimoroni_physical_feather_pins.pin19(),
            chip_select=pimoroni_physical_feather_pins.pin20(
            ))  # define the display bus

    display = ST7735R(
        display_bus,
        width=160,
        height=80,
        colstart=26,
        rowstart=1,
        rotation=270,
        invert=True
    )  # define the display (these values are specific to the envirowing's screen)

    return display
Exemplo n.º 2
0
def Screen(tests, num_test_bytes, write_tests_to_nvm, reset):
    try:
        import board, pimoroni_physical_feather_pins, displayio
        from adafruit_st7735r import ST7735R
        #region Screen setup
        """
        This region of code is used to setup the envirowing screen with displayio
        """

        spi = board.SPI()  # define which spi bus the screen is on
        spi.try_lock()  # try to get control of the spi bus
        spi.configure(
            baudrate=100000000)  # tell the spi bus how fast it's going to run
        # baudrate doesn't need to be this high in practice, it's just nice to have a quick screen refresh in this case
        spi.unlock()  # unlocks the spi bus so displayio can control it
        tft_dc = pimoroni_physical_feather_pins.pin19(
        )  # define which pin the command line is on
        tft_cs = pimoroni_physical_feather_pins.pin20(
        )  # define which pin the chip select line is on

        displayio.release_displays(
        )  # release any displays that may exist from previous code run
        display_bus = displayio.FourWire(spi,
                                         command=tft_dc,
                                         chip_select=tft_cs,
                                         reset=pimoroni_physical_feather_pins.
                                         pin21())  # define the display bus

        display = ST7735R(
            display_bus,
            width=160,
            height=80,
            colstart=26,
            rowstart=1,
            rotation=270,
            invert=True
        )  # define the display (these values are specific to the envirowing's screen)

        #endregion Screen setup
        if display:
            tests["Screen"]["Passed"] = True
            print("Passed with", display)
        else:
            tests["Screen"]["Passed"] = False
            print("Failed")
    except Exception as e:
        tests["Screen"]["Passed"] = False
        print("Failed with ", e)
    finally:
        tests["Screen"]["Test Run"] = True
        write_tests_to_nvm(tests, num_test_bytes)
        reset()
Exemplo n.º 3
0
def display_results(tests):
    import board, pimoroni_physical_feather_pins, displayio
    from adafruit_st7735r import ST7735R
    #region Screen setup
    """
    This region of code is used to setup the envirowing screen with displayio
    """

    spi = board.SPI() # define which spi bus the screen is on
    spi.try_lock() # try to get control of the spi bus
    spi.configure(baudrate=100000000) # tell the spi bus how fast it's going to run
    # baudrate doesn't need to be this high in practice, it's just nice to have a quick screen refresh in this case
    spi.unlock() # unlocks the spi bus so displayio can control it
    tft_dc = pimoroni_physical_feather_pins.pin19() # define which pin the command line is on
    tft_cs = pimoroni_physical_feather_pins.pin20() # define which pin the chip select line is on

    displayio.release_displays() # release any displays that may exist from previous code run
    display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=pimoroni_physical_feather_pins.pin21()) # define the display bus

    display = ST7735R(display_bus, width=160, height=80, colstart=26, rowstart=1, rotation=270, invert=True) # define the display (these values are specific to the envirowing's screen)
    
    #endregion Screen setup

    failed = []
    for test in tests.keys():
        if test not in ("Finished", "Read"):
            if not tests[test]["Passed"]:
                failed.append(test)
    
    if not failed:
        print("All Tests Passed!")
    else:
        print("These tests failed:")
        print(", ".join(failed))
    tests["Read"] = True
    write_tests_to_nvm(tests, num_test_bytes)
    while True:
        pass
Exemplo n.º 4
0

softassert = softassert()

#region Screen setup
"""
This region of code is used to setup the envirowing screen with displayio
"""

spi = board.SPI()  # define which spi bus the screen is on
spi.try_lock()  # try to get control of the spi bus
spi.configure(
    baudrate=100000000)  # tell the spi bus how fast it's going to run
# baudrate doesn't need to be this high in practice, it's just nice to have a quick screen refresh in this case
spi.unlock()  # unlocks the spi bus so displayio can control it
tft_dc = pimoroni_physical_feather_pins.pin19(
)  # define which pin the command line is on
tft_cs = pimoroni_physical_feather_pins.pin20(
)  # define which pin the chip select line is on

displayio.release_displays(
)  # release any displays that may exist from previous code run
display_bus = displayio.FourWire(
    spi,
    command=tft_dc,
    chip_select=tft_cs,
    reset=pimoroni_physical_feather_pins.pin21())  # define the display bus

display = ST7735R(
    display_bus,
    width=160,
    height=80,