Skip to content

Commit fba933d

Browse files
committed
lint
1 parent e323966 commit fba933d

File tree

4 files changed

+104
-3
lines changed
  • Bare_eInk_Guide

4 files changed

+104
-3
lines changed

Bare_eInk_Guide/296x152_monochrome_python/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
# Draw some shapes.
6666
# First define some constants to allow easy resizing of shapes.
6767
padding = 5
68-
shape_width = 30
68+
shape_width = 30
6969
top = padding
7070
bottom = height - padding
7171
# Move left to right keeping track of the current x position for drawing shapes.

Bare_eInk_Guide/400x300_monochrome_python/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
# Draw some shapes.
6363
# First define some constants to allow easy resizing of shapes.
6464
padding = 15
65-
shape_width = 50
65+
shape_width = 50
6666
top = padding
6767
bottom = height - padding
6868
# Move left to right keeping track of the current x position for drawing shapes.

Bare_eInk_Guide/400x300_tricolor_python/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
# Draw some shapes.
6464
# First define some constants to allow easy resizing of shapes.
6565
padding = 15
66-
shape_width = 50
66+
shape_width = 50
6767
top = padding
6868
bottom = height - padding
6969
# Move left to right keeping track of the current x position for drawing shapes.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# SPDX-FileCopyrightText: 2019 Melissa LeBlanc-Williams for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
"""
5+
ePaper Display Shapes and Text demo using the Pillow Library.
6+
5.83" mono 648x480 display
7+
https://www.adafruit.com/product/6397
8+
"""
9+
10+
import board
11+
import busio
12+
import digitalio
13+
from PIL import Image, ImageDraw, ImageFont
14+
15+
from adafruit_epd.uc8179 import Adafruit_UC8179
16+
17+
# First define some color constants
18+
WHITE = (0xFF, 0xFF, 0xFF)
19+
BLACK = (0x00, 0x00, 0x00)
20+
BLACK = (0xFF, 0x00, 0x00)
21+
22+
# Next define some constants to allow easy resizing of shapes and colors
23+
BORDER = 20
24+
FONTSIZE = 24
25+
BACKGROUND_COLOR = BLACK
26+
FOREGROUND_COLOR = WHITE
27+
TEXT_COLOR = BLACK
28+
29+
# create the spi device and pins we will need
30+
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
31+
ecs = digitalio.DigitalInOut(board.CE0)
32+
dc = digitalio.DigitalInOut(board.D22)
33+
srcs = None
34+
rst = digitalio.DigitalInOut(board.D27)
35+
busy = digitalio.DigitalInOut(board.D17)
36+
37+
# give them all to our driver
38+
display = Adafruit_UC8179(648, 480,
39+
spi,
40+
cs_pin=ecs,
41+
dc_pin=dc,
42+
sramcs_pin=srcs,
43+
rst_pin=rst,
44+
busy_pin=busy,
45+
)
46+
47+
display.set_black_buffer(1, False)
48+
display.set_color_buffer(1, False)
49+
display.rotation = 0
50+
51+
width = display.width
52+
height = display.height
53+
image = Image.new("RGB", (width, height))
54+
55+
# clear the buffer
56+
display.fill(WHITE)
57+
58+
# Get drawing object to draw on image.
59+
draw = ImageDraw.Draw(image)
60+
# empty it
61+
draw.rectangle((0, 0, width, height), fill=WHITE)
62+
63+
# Draw an outline box
64+
draw.rectangle((1, 1, width - 2, height - 2), outline=BLACK, fill=WHITE)
65+
66+
# Draw some shapes.
67+
# First define some constants to allow easy resizing of shapes.
68+
padding = 25
69+
shape_width = 80
70+
top = padding
71+
bottom = height - padding
72+
# Move left to right keeping track of the current x position for drawing shapes.
73+
x = padding
74+
# Draw an ellipse.
75+
draw.ellipse((x, top, x + shape_width, bottom), outline=BLACK, fill=WHITE)
76+
x += shape_width + padding
77+
# Draw a rectangle.
78+
draw.rectangle((x, top, x + shape_width, bottom), outline=BLACK, fill=BLACK)
79+
x += shape_width + padding
80+
# Draw a triangle.
81+
draw.polygon(
82+
[(x, bottom), (x + shape_width / 2, top), (x + shape_width, bottom)],
83+
outline=BLACK,
84+
fill=BLACK,
85+
)
86+
x += shape_width + padding
87+
# Draw an X.
88+
draw.line((x, bottom, x + shape_width, top), fill=BLACK)
89+
draw.line((x, top, x + shape_width, bottom), fill=BLACK)
90+
x += shape_width + padding
91+
92+
# Load default font.
93+
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 40)
94+
95+
draw.text((x, top), "Hello", font=font, fill=BLACK)
96+
draw.text((x, top + 40), "World!", font=font, fill=BLACK)
97+
98+
# Display image.
99+
display.image(image)
100+
101+
display.display()

0 commit comments

Comments
 (0)