Last active
November 12, 2018 23:17
-
-
Save docmollo/9da47101278e501f6c3065f5436da47c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import busio | |
import digitalio | |
import board | |
from adafruit_rgb_display import color565 | |
import adafruit_rgb_display.st7735 as st7735 | |
# Setup SPI bus using hardware SPI: | |
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO) | |
# Create the ST7735 display: | |
display = st7735.ST7735R(spi, cs=digitalio.DigitalInOut(board.TFT_CS), | |
dc=digitalio.DigitalInOut(board.TFT_DC), rst=digitalio.DigitalInOut(board.TFT_RESET), | |
height=128, width=128) | |
# Turn on the backlight: | |
tft_backlight = digitalio.DigitalInOut(board.TFT_BACKLIGHT) | |
tft_backlight.direction = digitalio.Direction.OUTPUT | |
tft_backlight.value = True | |
# Initialize the display | |
display.init() | |
# Main loop: | |
while True: | |
# Clear the display | |
display.fill(0) | |
# Draw a red pixel in the center. | |
display.pixel(64, 64, color565(255, 0, 0)) | |
# Pause 2 seconds. | |
time.sleep(2) | |
# Clear the screen blue. | |
display.fill(color565(0, 0, 255)) | |
# Pause 2 seconds. | |
time.sleep(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment