Skip to content

Fixed baud rate in driver, improved/added examples #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion adafruit_sharpmemorydisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class SharpMemoryDisplay(adafruit_framebuf.FrameBuffer):
full display must be buffered in memory!"""
# pylint: disable=too-many-instance-attributes,abstract-method

def __init__(self, spi, scs_pin, width, height, *, baudrate=16000000):
def __init__(self, spi, scs_pin, width, height, *, baudrate=8000000):
self._scs_pin = scs_pin
scs_pin.switch_to_output(value=True)
self._baudrate = baudrate
Expand Down
59 changes: 59 additions & 0 deletions examples/sharpmemorydisplay_pillow_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""
This demo will fill the screen with white, draw a black box on top
and then print Hello World! in the center of the display

This example is for use on (Linux) computers that are using CPython with
Adafruit Blinka to support CircuitPython libraries. CircuitPython does
not support PIL/pillow (python imaging library)!
"""

import board
import busio
import digitalio
from PIL import Image, ImageDraw, ImageFont
import adafruit_sharpmemorydisplay

# Colors
BLACK = 0
WHITE = 255

# Parameters to Change
BORDER = 5
FONTSIZE = 10

spi = busio.SPI(board.SCK, MOSI=board.MOSI)
scs = digitalio.DigitalInOut(board.D6) # inverted chip select

#display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96)
display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 144, 168)

# Clear display.
display.fill(1)
display.show()

# Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color.
image = Image.new('1', (display.width, display.height))

# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)

# Draw a black background
draw.rectangle((0, 0, display.width, display.height), outline=BLACK, fill=BLACK)

# Draw a smaller inner rectangle
draw.rectangle((BORDER, BORDER, display.width - BORDER - 1, display.height - BORDER - 1),
outline=WHITE, fill=WHITE)

# Load a TTF font.
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', FONTSIZE)

# Draw Some Text
text = "Hello World!"
(font_width, font_height) = font.getsize(text)
draw.text((display.width//2 - font_width//2, display.height//2 - font_height//2),
text, font=font, fill=BLACK)

# Display image
display.image(image)
display.show()
10 changes: 5 additions & 5 deletions examples/sharpmemorydisplay_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
scs = digitalio.DigitalInOut(board.D6) # inverted chip select

# pass in the display size, width and height, as well
display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96)
# display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 144, 168)
# display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96)
display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 144, 168)

print("Pixel test")

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

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

print("Rectangle test")
display.fill(1)
Expand All @@ -49,7 +49,7 @@
for i in range(11):
display.rect(0, 0, int(w_delta*i), int(h_delta*i), 0)
display.show()
time.sleep(0.1)
time.sleep(2)

print("Text test")
display.fill(1)
Expand Down