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