Comments (3)
I had a blank (white) screen as well, in my case I believe this had to do with the different color space of my Black/White/Red inkyPHAT screen compared to the Black/White version.
How I fixed it:
-
Make sure imagemagick is installed:
sudo apt-get install imagemagick
-
Copy the
InkypHAT-250x122.png
example file from the inky library to theinkystock/data/
directory -
Save the following code as
convert.py
to theinkystock/inkystock/
subdirectory
#!/usr/bin/env python3
# Modified from https://github.com/RubenLagrouw/inkyconv
from os import remove
from PIL import Image as PILImage
import subprocess
class Convert:
def convert(imgpath, outpath, example='data/InkypHAT-250x122.png', dimensions=(250, 122)):
subprocess.run(
'convert {in_file} -auto-orient -geometry {x}x{y}^ -gravity center -crop {x}x{y}+0+0 -strip -type Palette -remap {ex} -dither FloydSteinberg temp.png'
.format(in_file=imgpath, x=dimensions[0], y=dimensions[1], ex=example), shell=True)
img = PILImage.open("temp.png")
cR = [255, 0, 0]
cB = [0, 0, 0]
cW = [255, 255, 255]
new_pixdata = []
old_pixdata = img.getdata()
palette_old = img.getpalette()
if palette_old == None: # Grayscale Image
for pix in old_pixdata:
if pix == 0:
new_pixdata.append(0)
else:
new_pixdata.append(1)
img = PILImage.new("P", dimensions)
else: # Coloured Image
p_conv = {0: palette_old[0:3],
1: palette_old[3:6],
2: palette_old[6:9]}
for pix in old_pixdata:
if pix not in p_conv:
print('Pixel out of range: {}'.format(pix))
new_pixdata.append(0)
elif p_conv[pix] == cW:
new_pixdata.append(0)
elif p_conv[pix] == cB:
new_pixdata.append(1)
elif p_conv[pix] == cR:
new_pixdata.append(2)
img.putdata(new_pixdata)
img.putpalette(cW + cB + cR) # Goal palette
remove('temp.png')
if not outpath.lower().endswith('.png'):
outpath += '.png'
img.save(outpath)
return 0
if __name__ == '__main__':
import sys
if len(sys.argv) != 3:
print('Improper amount of arguments')
sys.exit(-1)
convert(sys.argv[1], sys.argv[2])
- In
inkystock/inkystock/paint.py
, add the following methods to thePillow
class:
class Pillow(Painter):
def open(self, path):
return PILImage.open(path)
def display_no_invert(self, image: PillowImage):
board = auto()
board.set_image(image)
board.show()
-
In
inkystock/main.py
, import the new convert.py class:
from inkystock.convert import Convert
-
At the end of the
main()
method, change
image.render().save(config.outputs.local)
to
image.invert().render().save(config.outputs.local)
-
After that line, add the following:
# Correct the color space of the image
Convert.convert(config.outputs.local, "./data/out_converted.png")
img = painter.open("./data/out_converted.png")
- Change
painter.display(image)
topainter.display_no_invert(img)
This will covert the locally saved PNG file (data/out.png
) to the correct color space using ImageMagic and then display the converted file on the inkyPHAT. I'm sure there is a better/easier solution, but this works :)
from inkystock.
It's interesting that you've had this problem with an Inky display – after checking the supplier it looks like they've updated the display since I last bought some, which may account for the problems you're seeing:
We started rolling out a higher resolution SSD1608 e-paper screen on Inky pHAT from late 2020 (250x122 pixels instead of 212x104!). These new screens require different drivers, but the library should autodetect the right drivers for your screen. You might run into problems using third party software to drive the display if you have one of these newer boards.
I'll probably get one of the newer displays (because shiny new stuff!) but will take a look at the code for the new displays either way, there may be some fairly simple changes to make to correct the issue.
from inkystock.
Think this should be fixed now!
from inkystock.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inkystock.