Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 5ed72e7

Browse files
committed
Fixed baudrate in driver, improved/added examples
1 parent 20a56e2 commit 5ed72e7

File tree

3 files changed

+65
-6
lines changed

3 files changed

+65
-6
lines changed

Diff for: adafruit_sharpmemorydisplay.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class SharpMemoryDisplay(adafruit_framebuf.FrameBuffer):
7272
full display must be buffered in memory!"""
7373
# pylint: disable=too-many-instance-attributes,abstract-method
7474

75-
def __init__(self, spi, scs_pin, width, height, *, baudrate=16000000):
75+
def __init__(self, spi, scs_pin, width, height, *, baudrate=8000000):
7676
self._scs_pin = scs_pin
7777
scs_pin.switch_to_output(value=True)
7878
self._baudrate = baudrate

Diff for: examples/sharpmemorydisplay_pillow_demo.py

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""
2+
This demo will fill the screen with white, draw a black box on top
3+
and then print Hello World! in the center of the display
4+
5+
This example is for use on (Linux) computers that are using CPython with
6+
Adafruit Blinka to support CircuitPython libraries. CircuitPython does
7+
not support PIL/pillow (python imaging library)!
8+
"""
9+
10+
import board
11+
import busio
12+
import digitalio
13+
from PIL import Image, ImageDraw, ImageFont
14+
import adafruit_sharpmemorydisplay
15+
16+
# Colors
17+
BLACK = 0
18+
WHITE = 255
19+
20+
# Parameters to Change
21+
BORDER = 5
22+
FONTSIZE = 10
23+
24+
spi = busio.SPI(board.SCK, MOSI=board.MOSI)
25+
scs = digitalio.DigitalInOut(board.D6) # inverted chip select
26+
27+
#display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96)
28+
display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 144, 168)
29+
30+
# Clear display.
31+
display.fill(1)
32+
display.show()
33+
34+
# Create blank image for drawing.
35+
# Make sure to create image with mode '1' for 1-bit color.
36+
image = Image.new('1', (display.width, display.height))
37+
38+
# Get drawing object to draw on image.
39+
draw = ImageDraw.Draw(image)
40+
41+
# Draw a black background
42+
draw.rectangle((0, 0, display.width, display.height), outline=BLACK, fill=BLACK)
43+
44+
# Draw a smaller inner rectangle
45+
draw.rectangle((BORDER, BORDER, display.width - BORDER - 1, display.height - BORDER - 1),
46+
outline=WHITE, fill=WHITE)
47+
48+
# Load a TTF font.
49+
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', FONTSIZE)
50+
51+
# Draw Some Text
52+
text = "Hello World!"
53+
(font_width, font_height) = font.getsize(text)
54+
draw.text((display.width//2 - font_width//2, display.height//2 - font_height//2),
55+
text, font=font, fill=BLACK)
56+
57+
# Display image
58+
display.image(image)
59+
display.show()

Diff for: examples/sharpmemorydisplay_simpletest.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
scs = digitalio.DigitalInOut(board.D6) # inverted chip select
1111

1212
# 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)
13+
# display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96)
14+
display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 144, 168)
1515

1616
print("Pixel test")
1717

@@ -27,7 +27,7 @@
2727
# Set a pixel in the opposite corner position.
2828
display.pixel(display.width-1, display.height-1, 0)
2929
display.show()
30-
time.sleep(0.1)
30+
time.sleep(2)
3131

3232
print("Lines test")
3333
# we'll draw from corner to corner, lets define all the pair coordinates here
@@ -40,7 +40,7 @@
4040
display.line(corner_from[0], corner_from[1],
4141
corner_to[0], corner_to[1], 0)
4242
display.show()
43-
time.sleep(0.1)
43+
time.sleep(2)
4444

4545
print("Rectangle test")
4646
display.fill(1)
@@ -49,7 +49,7 @@
4949
for i in range(11):
5050
display.rect(0, 0, int(w_delta*i), int(h_delta*i), 0)
5151
display.show()
52-
time.sleep(0.1)
52+
time.sleep(2)
5353

5454
print("Text test")
5555
display.fill(1)

0 commit comments

Comments
 (0)