Exemplo n.º 1
0
print(display_st7789.__name__ + " version: " + display_st7789.__version__)
print()

# 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, MOSI=spi_mosi)

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

display = display_st7789.ST7789(
    display_bus, width=240, height=135, rowstart=40, colstart=53, rotation=90)

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

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

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

# Draw a smaller inner rectangle
inner_bitmap = displayio.Bitmap(238, 133, 16)
Exemplo n.º 2
0
tft_cs = board.GP5
tft_dc = board.GP22
#tft_res = board.GP23
spi_mosi = board.GP3
spi_clk = board.GP2

spi = busio.SPI(spi_clk, MOSI=spi_mosi)

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

# Create the ST7789 display:
display = adafruit_st7789.ST7789(
    display_bus,
    width=240,
    height=240,
    rowstart=80,
    colstart=0,
    rotation=180,
)

group = displayio.Group(max_size=10)
display.show(group)

bitmap = displayio.Bitmap(240, 240, 135)

palette = displayio.Palette(240)
for p in range(240):
    palette[p] = (0x10000 * p) + (0x100 * p) + p

for y in range(240):
    for x in range(240):
Exemplo n.º 3
0
    def __init__(
            self,
            GPIO_RESET=None,
            GPIO_MOSI=board.GP27,
            GPIO_CLK=board.GP26,
            GPIO_CS=board.GP21,
            GPIO_DC=board.GP20,
            GPIO_BL=board.GP22,
            DISPLAY_WIDTH=135,
            DISPLAY_HEIGHT=240,
            xButtonPin=board.GP14,
            yButtonPin=board.GP15,
            aButtonPin=None,  #board.GP14,
            bButtonPin=None):  #board.GP15):
        # Release any resources currently in use for the displays
        displayio.release_displays()
        # COLOUR     ORIGINAL TYPE
        self.tft_res = GPIO_RESET  # BROWN      GP--     RESET
        self.spi_mosi = GPIO_MOSI  # ORANGE     GP19     SCL
        self.spi_clk = GPIO_CLK  # YELLOW     GP18     SDA
        self.tft_cs = GPIO_CS  # GREEN      GP17     CS
        self.tft_dc = GPIO_DC  # BLUE       GP16     DC

        self.spi = busio.SPI(self.spi_clk, MOSI=self.spi_mosi)

        self.display_bus = displayio.FourWire(self.spi,
                                              command=self.tft_dc,
                                              chip_select=self.tft_cs,
                                              reset=self.tft_res)
        self.SCREEN_WIDTH = DISPLAY_WIDTH
        self.SCREEN_HEIGHT = DISPLAY_HEIGHT

        self.display = adafruit_st7789.ST7789(self.display_bus,
                                              width=DISPLAY_WIDTH,
                                              height=DISPLAY_HEIGHT,
                                              rowstart=40,
                                              colstart=53)
        if GPIO_BL != None:
            self.backLight = PWMOut(GPIO_BL,
                                    frequency=PWM_FREQ,
                                    duty_cycle=DIM_VALUE)
        self.Buttons = []
        if xButtonPin != None:
            self.xButton = DigitalInOut(xButtonPin)
            self.xButton.direction = Direction.INPUT
            self.xButton.pull = Pull.UP
            self.Buttons.append(self.xButton)
        if yButtonPin != None:
            self.yButton = DigitalInOut(yButtonPin)
            self.yButton.direction = Direction.INPUT
            self.yButton.pull = Pull.UP
            self.Buttons.append(self.yButton)
        if aButtonPin != None:
            self.aButton = DigitalInOut(aButtonPin)
            self.aButton.direction = Direction.INPUT
            self.aButton.pull = Pull.UP
            self.Buttons.append(self.aButton)
        if bButtonPin != None:
            self.bButton = DigitalInOut(bButtonPin)
            self.bButton.direction = Direction.INPUT
            self.bButton.pull = Pull.UP
            self.Buttons.append(self.bButton)

        if len(self.Buttons) > 0:
            self.TimeDown = [-1] * DISPLAY_BUTTON_COUNT
            self.TimeUp = [-1] * DISPLAY_BUTTON_COUNT
            self.Waiting = [False] * DISPLAY_BUTTON_COUNT
            self.ButtonStates = [self.TimeDown, self.TimeUp, self.Waiting]