Simple test

Ensure your device works with this simple test.

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