diff --git a/adafruit_sharpmemorydisplay.py b/adafruit_sharpmemorydisplay.py index fdd323f..7453b57 100644 --- a/adafruit_sharpmemorydisplay.py +++ b/adafruit_sharpmemorydisplay.py @@ -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 diff --git a/examples/sharpmemorydisplay_pillow_demo.py b/examples/sharpmemorydisplay_pillow_demo.py new file mode 100644 index 0000000..96f47d8 --- /dev/null +++ b/examples/sharpmemorydisplay_pillow_demo.py @@ -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() diff --git a/examples/sharpmemorydisplay_simpletest.py b/examples/sharpmemorydisplay_simpletest.py index 0b7d092..a8b8b4d 100644 --- a/examples/sharpmemorydisplay_simpletest.py +++ b/examples/sharpmemorydisplay_simpletest.py @@ -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") @@ -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 @@ -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) @@ -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)