我只是想进入Rasppi,Python等的新世界,但是面对我现在完全迷失并试图找到一些指导的情况。
对于我的情况,我连接了(RGB)LCD显示屏,以显示我的软件脚本的一些输出。即使我可以在上面获得文本和图形对象,但仍有一个问题可以显示徽标或其他简单图片之类的图像。
我已经尝试了几天,但使用了不同的功能和示例,但是尚未突破。作为快速'n肮脏的代码线,可以进入相同的轨道(这只是测试目的 - 没有生产力的用法!),请按照示例代码行:
from PIL import Image, ImageFont
from luma.core.virtual import viewport
from demo_opts import get_device
from luma.core.render import canvas
from luma.core.interface.serial import spi
from luma.lcd.device import st7735
s = spi(port=0, device=0, cs_high=True, gpio_DC=23, gpio_RST=24)
device=st7735(s,rotate=0,width=160,height=128,h_offset=0,v_offset=0,bgr=False)
print ("Starting...")
img = Image.open("img/starwars.png")
img = img.resize((120,40),Image.BILINEAR)
screen = viewport(device, width=device.width, height=device.height)
while True:
for _ in range(2):
with canvas(screen) as draw:
draw.bitmap((20, 0), img) #works
draw.arc((20,20,50,50), 0, 90) #works
可以正常工作:除非我使用简单
starwars.png 。当使用另一种文件格式(彩色图片,不同的文件格式等)时,我面临着无法解决的不同类型的错误 - 例如,不良的透明掩码,没有出现。我知道这里的位图功能很棘手,因为它只是通过预先构造的图像格式迫使掩盖掩盖。但是我无法得出任何其他函数,但要在LCD上显示任何其他图像。
问题:有什么想法继续前进?陷阱在哪里?该领域的初学者有什么技巧吗? :)
旁注:
我还尝试使用此库和示例:
但是,使用此代码线,LCD甚至根本没有触发。
感谢任何反馈这样的盲人乘客和新秀:-)
I'm just trying to get into new world of RaspPi, Python etc. but facing situation where I am fully lost now and trying to find some guidance.
For my scenario, I connected an (RGB) LCD display in order to show some output from my software scripts. Even though I can get Texts and graphical objects on it, there is still an issue to show-up images like logo or other simple pictures.
I tried for several days now w/ different functions and examples but there is not break-through yet. As a quick 'n dirty code-line to get on the same track (this is just testing purposes - no productive usage!), please follow the example code lines herewith:
from PIL import Image, ImageFont
from luma.core.virtual import viewport
from demo_opts import get_device
from luma.core.render import canvas
from luma.core.interface.serial import spi
from luma.lcd.device import st7735
s = spi(port=0, device=0, cs_high=True, gpio_DC=23, gpio_RST=24)
device=st7735(s,rotate=0,width=160,height=128,h_offset=0,v_offset=0,bgr=False)
print ("Starting...")
img = Image.open("img/starwars.png")
img = img.resize((120,40),Image.BILINEAR)
screen = viewport(device, width=device.width, height=device.height)
while True:
for _ in range(2):
with canvas(screen) as draw:
draw.bitmap((20, 0), img) #works
draw.arc((20,20,50,50), 0, 90) #works
It works fine unless I am using the simple
starwars.png. When using another file format (colored picture, different file format etc.), I'm faced w/ different kind of errors I could not yet resolve - e.g. bad transparency mask, no show-up. I'm aware that bitmap-function is tricky here, as it just forces a masking by pre-given image format. But I could not derive any other function yet to get any other image been shown on the LCD.
Question: Any idea how to move on? Where's the pitfall? Any tips for an beginner in that area? :)
Side note:
I also tried to use this library and examples:
https://github.com/pimoroni/st7735-python/blob/1a70d3ae7eee6f376de430c944ff4e95d294543e/examples/image.py
However, using this code line, the LCD is not even triggered at all.
Thanks for any feedback for such a blind passenger and rookie :-)
发布评论