Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
257 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
__pycache__/ | ||
sphinx/_build/ | ||
*.py[cod] | ||
*.swp | ||
dist/ | ||
sdist/ | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
eggs/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
*.deb | ||
*.dsc | ||
*.build | ||
*.changes | ||
*.orig.* | ||
testing/ | ||
MANIFEST | ||
.idea | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
library/test/scrollphat/ | ||
library/debian/ | ||
packaging/*tar.xz | ||
.DS_Store | ||
sphinx.virtualenv |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
|
||
from PIL import Image | ||
import sys | ||
|
||
sys.path.insert(0, '../library/') | ||
|
||
from inky import what as inkywhat | ||
|
||
inkywhat.set_colour('yellow') | ||
|
||
print("""Inky wHAT: Logo | ||
Displays the Inky wHAT logo. | ||
""") | ||
|
||
if len(sys.argv) < 2: | ||
print("""Usage: {} <colour> | ||
Valid colours: red, yellow, black | ||
""".format(sys.argv[0])) | ||
sys.exit(0) | ||
|
||
colour = sys.argv[1].lower() | ||
inkywhat.set_colour(colour) | ||
|
||
inkywhat.set_border(inkywhat.BLACK) | ||
|
||
if colour == 'black': | ||
img = Image.open("InkyPhat-212x104-bw.png") | ||
else: | ||
img = Image.open("InkyPhat-212x104.png") | ||
|
||
inkywhat.set_image(img) | ||
|
||
inkywhat.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
|
||
from PIL import Image | ||
import sys | ||
|
||
sys.path.insert(0, '../library/') | ||
|
||
from inky import phat as inkyphat | ||
|
||
inkyphat.set_colour('yellow') | ||
|
||
print("""Inky pHAT: Logo | ||
Displays the Inky pHAT logo. | ||
""") | ||
|
||
if len(sys.argv) < 2: | ||
print("""Usage: {} <colour> | ||
Valid colours: red, yellow, black | ||
""".format(sys.argv[0])) | ||
sys.exit(0) | ||
|
||
colour = sys.argv[1].lower() | ||
inkyphat.set_colour(colour) | ||
|
||
inkyphat.set_border(inkyphat.BLACK) | ||
|
||
if colour == 'black': | ||
img = Image.open("InkyPhat-212x104-bw.png") | ||
else: | ||
img = Image.open("InkyPhat-212x104.png") | ||
|
||
inkyphat.set_image(img) | ||
|
||
inkyphat.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import sys | ||
|
||
sys.path.insert(0, '../library/') | ||
|
||
import inky | ||
|
||
phat = inky.Inky(resolution=(104,212), colour='red') | ||
|
||
phat.setup() | ||
|
||
for x in range(104): | ||
for y in range(212): | ||
phat.set_pixel(x, y, 1) | ||
|
||
phat.update() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import inky | ||
|
||
__version__ = '0.0.1' | ||
|
||
_colour = None | ||
_flip_h = False | ||
_flip_v = True | ||
|
||
WIDTH = 212 | ||
HEIGHT = 104 | ||
|
||
WHITE = 0 | ||
BLACK = 1 | ||
RED = YELLOW = 2 | ||
|
||
phat = None | ||
|
||
|
||
def setup(): | ||
global phat | ||
if phat is not None: | ||
return | ||
phat = inky.Inky( | ||
resolution=(HEIGHT, WIDTH), | ||
colour=_colour, | ||
h_flip=_flip_h, | ||
v_flip=_flip_v) | ||
|
||
|
||
def set_colour(colour): | ||
global _colour | ||
_colour = colour | ||
|
||
|
||
def set_border(color): | ||
pass | ||
|
||
|
||
def set_image(image): | ||
"""Copy an image to the Inky pHAT.""" | ||
setup() | ||
# Two dimensional list | ||
if isinstance(image, list): | ||
w, h = len(image), len(image[0]) | ||
w = min(w, WIDTH) | ||
h = min(h, HEIGHT) | ||
for x in range(w): | ||
for y in range(h): | ||
pixel = image[x][y] | ||
phat.set_pixel(y, x, pixel) | ||
return | ||
|
||
# PIL image | ||
if getattr(image, 'size') and getattr(image, 'getpixel'): | ||
w, h = image.size | ||
w = min(w, WIDTH) | ||
h = min(h, HEIGHT) | ||
for x in range(w): | ||
for y in range(h): | ||
pixel = image.getpixel((x, y)) | ||
phat.set_pixel(y, x, pixel) | ||
return | ||
|
||
|
||
def show(): | ||
"""Show the image on the Inky pHAT.""" | ||
setup() | ||
phat.setup() | ||
phat.update() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import inky | ||
|
||
__version__ = '0.0.1' | ||
|
||
_colour = None | ||
_flip_h = False | ||
_flip_v = False | ||
|
||
WIDTH = 400 | ||
HEIGHT = 300 | ||
|
||
WHITE = 0 | ||
BLACK = 1 | ||
RED = YELLOW = 2 | ||
|
||
what = None | ||
|
||
|
||
def setup(): | ||
global what | ||
if what is not None: | ||
return | ||
what = inky.Inky( | ||
resolution=(WIDTH, HEIGHT), | ||
colour=_colour, | ||
h_flip=_flip_h, | ||
v_flip=_flip_v) | ||
|
||
|
||
def set_colour(colour): | ||
global _colour | ||
_colour = colour | ||
|
||
|
||
def set_border(color): | ||
pass | ||
|
||
|
||
def set_image(image): | ||
"""Copy an image to the Inky wHAT.""" | ||
setup() | ||
# Two dimensional list | ||
if isinstance(image, list): | ||
w, h = len(image), len(image[0]) | ||
w = min(w, WIDTH) | ||
h = min(h, HEIGHT) | ||
for x in range(w): | ||
for y in range(h): | ||
pixel = image[x][y] | ||
what.set_pixel(y, x, pixel) | ||
return | ||
|
||
# PIL image | ||
if getattr(image, 'size') and getattr(image, 'getpixel'): | ||
w, h = image.size | ||
w = min(w, WIDTH) | ||
h = min(h, HEIGHT) | ||
for x in range(w): | ||
for y in range(h): | ||
pixel = image.getpixel((x, y)) | ||
what.set_pixel(x, y, pixel) | ||
return | ||
|
||
|
||
def show(): | ||
"""Show the image on the Inky wHAT.""" | ||
setup() | ||
what.setup() | ||
what.update() | ||
|