예제 #1
0
    def init_display(self):
        import fontio, displayio, terminalio, board
        from adafruit_st7789 import ST7789
        displayio.release_displays()

        spi = board.SPI()
        tft_cs = board.D12 # arbitrary, pin not used for my display
        tft_dc = board.D2
        tft_backlight = board.D4
        tft_reset=board.D3

        while not spi.try_lock():
            pass
        spi.unlock()

        display_bus = displayio.FourWire(
            spi,
            command=tft_dc,
            chip_select=tft_cs,
            reset=tft_reset,
            baudrate=24000000,
            polarity=1,
            phase=1,
        )

        self.xPixels = 240  # number of xPixels for the display
        self.yPixels = 240  # number of yPixels for the display

        self.display = ST7789(display_bus, width=self.xPixels, height=self.yPixels, 
                              rotation=0, rowstart=80, colstart=0)
        self.display.show(None)
예제 #2
0
def get_display():
    """
    :return: displayio.Display
    """
    from adafruit_st7789 import ST7789
    import board
    displayio.release_displays()
    spi = board.SPI()
    tft_cs = board.D4
    tft_dc = board.D12
    tft_reset = board.D13
    tft_backlight = board.D11
    spi.try_lock()
    spi.configure(baudrate=24000000)
    spi.unlock()
    display_bus = displayio.FourWire(spi,
                                     command=tft_dc,
                                     chip_select=tft_cs,
                                     reset=tft_reset,
                                     baudrate=24000000)
    # https://circuitpython.readthedocs.io/en/4.x/shared-bindings/displayio/Display.html
    display = ST7789(
        display_bus,
        width=320,
        height=240,
        rotation=90,
        backlight_pin=tft_backlight,
        brightness=0,
    )
    return display
예제 #3
0
def get_display():
    displayio.release_displays()

    tft_cs = board.GP21
    tft_dc = board.GP16
    # tft_res = board.GP23
    spi_mosi = board.GP27
    spi_clk = board.GP26
    # https://gist.github.com/wildestpixel/86ac1063bc456213f92972fcd7c7c2e1
    spi = busio.SPI(spi_clk, MOSI=spi_mosi)
    while not spi.try_lock():
        pass
    # Configure SPI was 24MHz by default - Trying 64Mhz, no visible change
    spi.configure(baudrate=64000000)
    spi.unlock()
    display_bus = displayio.FourWire(spi,
                                     command=tft_dc,
                                     chip_select=tft_cs,
                                     baudrate=64000000)
    display = ST7789(display_bus,
                     width=135,
                     height=240,
                     rowstart=40,
                     colstart=53)
    display.rotation = 270
    return display
예제 #4
0
 def _screen_spi(self, clk, mosi, miso, cs, dc):
     displayio.release_displays()
     if self.screen_enabled == False:
         return (None)
     spi = busio.SPI(clock=clk, MOSI=mosi, MISO=miso)
     display_bus = displayio.FourWire(spi,
                                      command=dc,
                                      chip_select=cs,
                                      baudrate=self.screen_spi_baud)
     return (ST7789(display_bus, width=320, height=240, rotation=270))
예제 #5
0
def create_display():
    # Release any resources currently in use for the displays
    displayio.release_displays()

    spi = busio.SPI(board.D12, board.D11)
    tft_cs = board.D9
    tft_dc = board.D10
    tft_rst = board.D6
    display_bus = displayio.FourWire(spi,
                                     command=tft_dc,
                                     chip_select=tft_cs,
                                     reset=tft_rst)
    out_display = ST7789(display_bus, width=240, height=240, rowstart=80)
    return out_display
예제 #6
0
def InitWSPicoLCD():
    spi = busio.SPI(clock=board.GP10, MOSI=board.GP11)

    tft_cs = board.GP9
    tft_dc = board.GP8
    tft_reset = board.GP12
    display_bus = displayio.FourWire(spi,
                                     command=tft_dc,
                                     chip_select=tft_cs,
                                     reset=tft_reset)

    # How do we know what's the correct value for rowstart and colstart?
    display = ST7789(display_bus,
                     rotation=270,
                     width=240,
                     height=135,
                     rowstart=40,
                     colstart=53)
    return display
예제 #7
0
def make_display():
    """Set up the display support.
    Return the Display object.
    """
    spi = board.SPI()
    while not spi.try_lock():
        pass
    spi.configure(baudrate=24000000)  # Configure SPI for 24MHz
    spi.unlock()
    tft_cs = board.D10
    tft_dc = board.D7

    displayio.release_displays()
    display_bus = displayio.FourWire(spi,
                                     command=tft_dc,
                                     chip_select=tft_cs,
                                     reset=board.D9)

    return ST7789(display_bus, width=240, height=240, rowstart=80)
예제 #8
0
#
# SPDX-License-Identifier: MIT

# Turtle Gizmo Christmas Tree
#==| Turtle Gizmo Setup start |========================================
import board
import busio
import displayio
from adafruit_st7789 import ST7789
from adafruit_turtle import Color, turtle
displayio.release_displays()
spi = busio.SPI(board.SCL, MOSI=board.SDA)
display_bus = displayio.FourWire(spi, command=board.TX, chip_select=board.RX)
display = ST7789(display_bus,
                 width=240,
                 height=240,
                 rowstart=80,
                 backlight_pin=board.A3,
                 rotation=180)
turtle = turtle(display)
#==| Turtle Gizmo Setup end |=========================================

# Fractal Christmas Tree:
# https://codegolf.stackexchange.com/questions/15860/make-a-scalable-christmas-tree
#  by Keith Randall
n = 42  # input value for scaling the tree. note: ornaments don't scale
turtle.goto(0, -20)

#star
turtle.left(90)
turtle.forward(3 * n)
turtle.pencolor(Color.YELLOW)
예제 #9
0
import displayio
from adafruit_display_text import label
from adafruit_st7789 import ST7789

# Release any resources currently in use for the displays
displayio.release_displays()

tft_cs = board.GP17
tft_dc = board.GP16
spi_mosi = board.GP19
spi_clk = board.GP18
spi = busio.SPI(spi_clk, spi_mosi)

display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)

display = ST7789(display_bus, width=240, height=240, rowstart=80, rotation=180)

# Make the display context
splash = displayio.Group()
display.show(splash)

color_bitmap = displayio.Bitmap(240, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00  # Bright Green

bg_sprite = displayio.TileGrid(color_bitmap,
                               pixel_shader=color_palette,
                               x=0,
                               y=0)
splash.append(bg_sprite)
예제 #10
0
import terminalio
from adafruit_display_text import label
from adafruit_st7789 import ST7789

spi = board.SPI()
while not spi.try_lock():
    pass
spi.configure(baudrate=24000000) # Configure SPI for 24MHz
spi.unlock()
tft_cs = board.D9
tft_dc = board.D10

displayio.release_displays()
display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D11)

display = ST7789(display_bus, width=320, height=240, rotation=90)

# Make the display context
splash = displayio.Group(max_size=10)
display.show(splash)

color_bitmap = displayio.Bitmap(320, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00 # Bright Green

bg_sprite = displayio.TileGrid(color_bitmap,
                               pixel_shader=color_palette,
                               x=0, y=0)
splash.append(bg_sprite)

# Draw a smaller inner rectangle
    def __init__(self, i2c=None):
        displayio.release_displays()

        if i2c is None:
            i2c = board.I2C()

        # set up on-board seesaw
        self._ss = Seesaw(i2c)
        # left screen
        self._ss.pin_mode(SS_TFTRESET_PIN, self._ss.OUTPUT)
        self._ss.pin_mode(SS_SWITCH1_PIN, self._ss.INPUT_PULLUP)
        self._ss.pin_mode(SS_SWITCH2_PIN, self._ss.INPUT_PULLUP)
        self._ss.pin_mode(SS_SWITCH3_PIN, self._ss.INPUT_PULLUP)

        self._ss.pin_mode(SS_LIGHTSENSOR_PIN, self._ss.INPUT)

        # Manual reset for left screen
        self._ss.digital_write(SS_TFTRESET_PIN, False)
        time.sleep(0.01)
        self._ss.digital_write(SS_TFTRESET_PIN, True)
        time.sleep(0.01)

        # Left backlight pin, on the seesaw
        self._ss.pin_mode(SS_BACKLIGHT_PIN, self._ss.OUTPUT)
        # backlight on full brightness
        self._ss.analog_write(SS_BACKLIGHT_PIN, 255)

        # Left screen spi bus
        left_spi = busio.SPI(board.LEFT_TFT_SCK, MOSI=board.LEFT_TFT_MOSI)
        left_tft_cs = board.LEFT_TFT_CS
        left_tft_dc = board.LEFT_TFT_DC

        left_display_bus = displayio.FourWire(left_spi,
                                              command=left_tft_dc,
                                              chip_select=left_tft_cs)

        self.left_display = ST7789(left_display_bus,
                                   width=240,
                                   height=240,
                                   rowstart=80)

        self.right_backlight = pulseio.PWMOut(board.RIGHT_TFT_LITE,
                                              frequency=5000,
                                              duty_cycle=0)
        self.right_backlight.duty_cycle = 65535

        # right display
        right_spi = busio.SPI(board.RIGHT_TFT_SCK, MOSI=board.RIGHT_TFT_MOSI)
        right_tft_cs = board.RIGHT_TFT_CS
        right_tft_dc = board.RIGHT_TFT_DC

        right_display_bus = displayio.FourWire(
            right_spi,
            command=right_tft_dc,
            chip_select=right_tft_cs,
            reset=board.RIGHT_TFT_RST,
        )

        self.right_display = ST7789(right_display_bus,
                                    width=240,
                                    height=240,
                                    rowstart=80)

        if i2c is not None:
            int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
            try:
                self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c,
                                                                 address=0x19,
                                                                 int1=int1)
            except ValueError:
                self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c,
                                                                 int1=int1)

        self.nose = touchio.TouchIn(board.NOSE)
        self.nose.threshold = 180
예제 #12
0
# left screen backlight
ss.pin_mode(5, ss.OUTPUT)

# display setup for m4sk

displayio.release_displays()

spi1 = busio.SPI(board.RIGHT_TFT_SCK, MOSI=board.RIGHT_TFT_MOSI)
display1_bus = displayio.FourWire(spi1,
                                  command=board.RIGHT_TFT_DC,
                                  chip_select=board.RIGHT_TFT_CS,
                                  reset=board.RIGHT_TFT_RST)
display1 = ST7789(display1_bus,
                  width=240,
                  height=240,
                  rowstart=80,
                  backlight_pin=board.RIGHT_TFT_LITE)

spi2 = busio.SPI(board.LEFT_TFT_SCK, MOSI=board.LEFT_TFT_MOSI)
display2_bus = displayio.FourWire(spi2,
                                  command=board.LEFT_TFT_DC,
                                  chip_select=board.LEFT_TFT_CS)
display2 = ST7789(display2_bus, width=240, height=240, rowstart=80)

# left TFT lite on
ss.analog_write(5, 255)

print("Monster Eyes with CircuitPython")
print("by Marius_450")
FONTSCALE = 2
BACKGROUND_COLOR = 0x00FF00  # Bright Green
FOREGROUND_COLOR = 0xAA0088  # Purple
TEXT_COLOR = 0xFFFF00

# Release any resources currently in use for the displays
displayio.release_displays()

spi = board.SPI()
tft_cs = board.CE0
tft_dc = board.D25

display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
display = ST7789(display_bus,
                 rotation=90,
                 width=240,
                 height=135,
                 rowstart=40,
                 colstart=53)

# Make the display context
splash = displayio.Group(max_size=10)
display.show(splash)

color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
color_palette[0] = BACKGROUND_COLOR

bg_sprite = displayio.TileGrid(color_bitmap,
                               pixel_shader=color_palette,
                               x=0,
                               y=0)
import adafruit_imageload
from adafruit_st7789 import ST7789

displayio.release_displays()

i2c_bus = board.I2C()
ss = Seesaw(i2c_bus)

spi = board.SPI()  # setup for display over SPI
tft_cs = board.D5
tft_dc = board.D6
display_bus = displayio.FourWire(
    spi, command=tft_dc, chip_select=tft_cs, reset=board.D9
)

display = ST7789(display_bus, width=280, height=240, rowstart=20, rotation=270)

screen = displayio.Group()  # Create a Group to hold content
display.show(screen)  # Add it to the Display

# display image
image = displayio.OnDiskBitmap("/img/bootpip0.bmp")
palette = image.pixel_shader
background = displayio.TileGrid(image, pixel_shader=palette)
screen.append(background)

# load cursor on top
cursor_on = True
if cursor_on:
    image, palette = adafruit_imageload.load("/img/cursor_green.bmp")
    palette.make_transparent(0)
예제 #15
0
# Display setup
WIDTH = 240
HEIGHT = 240
displayio.release_displays()

spi = busio.SPI(board.SCL, MOSI=board.SDA)
tft_cs = board.RX
tft_dc = board.TX
tft_backlight = board.A3

display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)

display = ST7789(display_bus,
                 width=WIDTH,
                 height=HEIGHT,
                 rowstart=80,
                 backlight_pin=tft_backlight,
                 rotation=180)

# Load background image
try:
    bg_bitmap, bg_palette = adafruit_imageload.load(BACKGROUND,
                                                    bitmap=displayio.Bitmap,
                                                    palette=displayio.Palette)
# Or just use solid color
except (OSError, TypeError):
    BACKGROUND = BACKGROUND if isinstance(BACKGROUND, int) else 0x000000
    bg_bitmap = displayio.Bitmap(WIDTH, HEIGHT, 1)
    bg_palette = displayio.Palette(1)
    bg_palette[0] = BACKGROUND
background = displayio.TileGrid(bg_bitmap, pixel_shader=bg_palette)
예제 #16
0
    def __init__(self, i2c=None):
        """
        :param i2c: The I2C bus to use, will try board.I2C()
            if not supplied

        """
        displayio.release_displays()

        if i2c is None:
            i2c = board.I2C()

        # set up on-board seesaw
        self._ss = Seesaw(i2c)

        # set up seesaw pins
        self._ss.pin_mode(SS_TFTRESET_PIN, self._ss.OUTPUT)  # left sceen reset

        # buttons abolve left eye
        self._ss.pin_mode(SS_SWITCH1_PIN, self._ss.INPUT_PULLUP)
        self._ss.pin_mode(SS_SWITCH2_PIN, self._ss.INPUT_PULLUP)
        self._ss.pin_mode(SS_SWITCH3_PIN, self._ss.INPUT_PULLUP)

        # light sensor near left eye
        self._ss.pin_mode(SS_LIGHTSENSOR_PIN, self._ss.INPUT)

        # Manual reset for left screen
        self._ss.digital_write(SS_TFTRESET_PIN, False)
        time.sleep(0.01)
        self._ss.digital_write(SS_TFTRESET_PIN, True)
        time.sleep(0.01)

        # Left backlight pin, on the seesaw
        self._ss.pin_mode(SS_BACKLIGHT_PIN, self._ss.OUTPUT)
        # backlight on full brightness
        self._ss.analog_write(SS_BACKLIGHT_PIN, 255)

        # Left screen spi bus
        left_spi = busio.SPI(board.LEFT_TFT_SCK, MOSI=board.LEFT_TFT_MOSI)
        left_tft_cs = board.LEFT_TFT_CS
        left_tft_dc = board.LEFT_TFT_DC

        left_display_bus = displayio.FourWire(
            left_spi, command=left_tft_dc, chip_select=left_tft_cs  # Reset on Seesaw
        )

        self.left_display = ST7789(left_display_bus, width=240, height=240, rowstart=80)

        # right backlight on board
        self.right_backlight = pulseio.PWMOut(
            board.RIGHT_TFT_LITE, frequency=5000, duty_cycle=0
        )
        # full brightness
        self.right_backlight.duty_cycle = 65535

        # right display spi bus
        right_spi = busio.SPI(board.RIGHT_TFT_SCK, MOSI=board.RIGHT_TFT_MOSI)
        right_tft_cs = board.RIGHT_TFT_CS
        right_tft_dc = board.RIGHT_TFT_DC

        right_display_bus = displayio.FourWire(
            right_spi,
            command=right_tft_dc,
            chip_select=right_tft_cs,
            reset=board.RIGHT_TFT_RST,  # reset on board
        )

        self.right_display = ST7789(
            right_display_bus, width=240, height=240, rowstart=80
        )

        # setup accelerometer
        if i2c is not None:
            int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
            try:
                self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(
                    i2c, address=0x19, int1=int1
                )
            except ValueError:
                self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)

        # touchio on nose
        self.nose = touchio.TouchIn(board.NOSE)

        # can be iffy, depending on environment and person.
        # User code can tweak if needed.
        self.nose.threshold = 180
예제 #17
0
파일: code.py 프로젝트: JSCProps/MandoPuter
    TEXT_COLOR = 0xFFFFFF  # it's monochrome, you can only do white
    display_bus = displayio.FourWire(spi,
                                     command=tft_dc,
                                     chip_select=tft_cs,
                                     reset=lcd_rst,
                                     baudrate=1000000)
    display = SSD1306(display_bus,
                      rotation=TEXT_ROTATION,
                      width=128,
                      height=64)
    font = bitmap_font.load_font("mandalor64.bdf")  # 64 pixel tall bitmap font
elif DISPLAY == "1.14 LCD":
    display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
    display = ST7789(display_bus,
                     rotation=TEXT_ROTATION,
                     width=240,
                     height=135,
                     rowstart=40,
                     colstart=53)
    font = bitmap_font.load_font(
        "mandalor135.bdf")  # 135 pixel tall bitmap font
elif DISPLAY == "1.27 OLED":
    display_bus = displayio.FourWire(spi,
                                     command=tft_dc,
                                     chip_select=tft_cs,
                                     reset=lcd_rst,
                                     baudrate=16000000)
    display = SSD1351(display_bus,
                      rotation=TEXT_ROTATION,
                      width=128,
                      height=96)
    font = bitmap_font.load_font("mandalor96.bdf")  # 96 pixel tall bitmap font
tft_cs = board.GP9
spi_clk = board.GP10
spi_mosi = board.GP11
tft_rst = board.GP12
backlight = board.GP13
spi = busio.SPI(spi_clk, spi_mosi)

display_bus = displayio.FourWire(spi,
                                 command=tft_dc,
                                 chip_select=tft_cs,
                                 reset=tft_rst)

display = ST7789(
    display_bus,
    rotation=270,
    width=240,
    height=240,
    rowstart=80,
    backlight_pin=backlight,
)

# Make the display context
splash = displayio.Group()
display.show(splash)

color_bitmap = displayio.Bitmap(240, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00  # Bright Green

bg_sprite = displayio.TileGrid(color_bitmap,
                               pixel_shader=color_palette,
                               x=0,
예제 #19
0
from adafruit_st7789 import ST7789

# Release any resources currently in use for the displays
displayio.release_displays()

spi = busio.SPI(board.SCL, MOSI=board.SDA)
tft_cs = board.RX
tft_dc = board.TX
tft_backlight = board.A3

display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)

display = ST7789(
    display_bus,
    width=240,
    height=240,
    rowstart=80,
    backlight_pin=tft_backlight,
    rotation=180,
)

# Make the display context
splash = displayio.Group(max_size=10)
display.show(splash)

color_bitmap = displayio.Bitmap(240, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00  # Bright Green

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)
# Release any resources currently in use for the displays
displayio.release_displays()

tft_cs = board.GP17
tft_dc = board.GP16
spi_mosi = board.GP19
spi_clk = board.GP18
spi = busio.SPI(spi_clk, spi_mosi)
backlight = board.GP20

display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)

display = ST7789(display_bus,
                 rotation=270,
                 width=320,
                 height=240,
                 backlight_pin=backlight)

# Make the display context
splash = displayio.Group()
display.show(splash)

color_bitmap = displayio.Bitmap(320, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x00FF00  # Bright Green

bg_sprite = displayio.TileGrid(color_bitmap,
                               pixel_shader=color_palette,
                               x=0,
                               y=0)