sharpmemorydisplay_simpletest.py
1 import time 2 import board 3 import busio 4 import digitalio 5 6 import adafruit_sharpmemorydisplay 7 8 # Initialize SPI bus and control pins 9 spi = busio.SPI(board.SCK, MOSI=board.MOSI) 10 scs = digitalio.DigitalInOut(board.D6) # inverted chip select 11 12 # pass in the display size, width and height, as well 13 # display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96) 14 display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 144, 168) 15 16 print("Pixel test") 17 18 # Clear the display. Always call show after changing pixels to make the display 19 # update visible! 20 display.fill(1) 21 display.show() 22 23 # Set a pixel in the origin 0,0 position. 24 display.pixel(0, 0, 0) 25 # Set a pixel in the middle position. 26 display.pixel(display.width // 2, display.width // 2, 0) 27 # Set a pixel in the opposite corner position. 28 display.pixel(display.width - 1, display.height - 1, 0) 29 display.show() 30 time.sleep(2) 31 32 print("Lines test") 33 # we'll draw from corner to corner, lets define all the pair coordinates here 34 corners = ( 35 (0, 0), 36 (0, display.height - 1), 37 (display.width - 1, 0), 38 (display.width - 1, display.height - 1), 39 ) 40 41 display.fill(1) 42 for corner_from in corners: 43 for corner_to in corners: 44 display.line(corner_from[0], corner_from[1], corner_to[0], corner_to[1], 0) 45 display.show() 46 time.sleep(2) 47 48 print("Rectangle test") 49 display.fill(1) 50 w_delta = display.width / 10 51 h_delta = display.height / 10 52 for i in range(11): 53 display.rect(0, 0, int(w_delta * i), int(h_delta * i), 0) 54 display.show() 55 time.sleep(2) 56 57 print("Text test") 58 display.fill(1) 59 display.text(" hello world!", 0, 0, 0) 60 display.text(" This is the", 0, 8, 0) 61 display.text(" CircuitPython", 0, 16, 0) 62 display.text("adafruit library", 0, 24, 0) 63 display.text(" for the SHARP", 0, 32, 0) 64 display.text(" Memory Display :) ", 0, 40, 0) 65 display.show()