rm-hull / luma.lcd Goto Github PK
View Code? Open in Web Editor NEWPython module to drive PCD8544, HT1621, ST7735, ST7567 and UC1701X-based LCDs
Home Page: https://luma-lcd.readthedocs.io
License: MIT License
Python module to drive PCD8544, HT1621, ST7735, ST7567 and UC1701X-based LCDs
Home Page: https://luma-lcd.readthedocs.io
License: MIT License
Hi,
I am trying different libraries, Adafruit one (https://learn.adafruit.com/nokia-5110-3310-lcd-python-library/overview) and yours.
when I run any example, the screen
is blank and afterwards the Adafruit examples also show blank screen until I restart the screen - maybe something to do with the contrast setting, but am stuck.?
Please HELP, thanks.
How do i add for example the ST7920 oled screen ?
No point in keeping the backlight external to the device, embed it in the device
it's called 5V LCD Module 6Bit 8-Segment 3-wires SPI HT1621 Module Character LCD for Arduino
.
On ebay: http://www.ebay.com/itm/351939450953
https://github.com/rm-hull/luma.lcd/blob/master/luma/lcd/device.py#L215. Shouldn't it read v_offset not h_offset.
LCD Pin | LCD Name | RPi Pin | RPi Function | Remarks |
---|---|---|---|---|
1 | VIN | P01-01 | 3V3 | 3.3V Power |
2 | 3V3 | P01-01 | 3V3 | 3.3V Power |
3 | GND | P01-06 | GND | Ground |
4 | SCLK | P0-23 | GPIO 11 (SCLK) | Serial Clock |
5 | MOSI | P01-19 | GPIO 10 (MOSI) | Serial Data |
6 | CS | P01-24 | GPIO 8 (CE0) | Chip Select |
7 | EXTMD | P01-14 | 3V3 | External mode (ON = external clock) |
8 | DISP | P01-16 | GPIO 23 | Display ON/OFF signal |
9 | EXTIN | P01-12 | GPIO 18 (PWM0) | PWM clock - external clock when EXTMD = ON |
Raspberry pi 2B
Linux raspberrypi 4.19.42-v7+ #1219 SMP
Is there an option to modify the frame rate?
Hello,
I've found your Luma.LCD project in PyPi. I've tested your drivers with an ili9341 based touchscreen and it works great. Unfortunately I've not found until now a working solution for the resistive touch of the display. I've tried several python drivers including RPi-XPT2046-Touchscreen by Matthew London https://github.com/MatthewLowden/RPi-XPT2046-Touchscreen-Python . It works great stand alone but not together with your Luma.LCD drivers.
Do you have a recommendation for a XPT2046 touch driver for me which can be work together with Luma.LCD?
Hi! I have this 1.44" SPI 128x128 TFT LCD Display (RED PCB V1.1) with following specs:
conf/st7735.conf:
--display=st7735
--interface=spi
--spi-bus-speed=16000000
--gpio-reset=24
--gpio-data-command=23
--gpio-backlight=18
--width=128
--height=128
When running an example sudo python examples/3d_box.py -f conf/st7735.conf
, there is nothing on the screen! Even the backlight is not enabled.
After I connect gpio-backlight
pin directly to 3.3V source - it works fine
Notes:
It seems that code can't reach/control some of the required GPIO or numbering is wrong. (I've used BCM numbering)
When I follow 'Python usage' instructions nothing happens when I try 'draw.rectangle' or 'draw.text'
When I try to get the 'device' object details in runtime (run with -f conf/st7735.conf), I see the unexpected arguments for screen size (my LCD has width=128, height=128):
luma.lcd.device.st7735 at 0x765da3b0 (
bounding_box = (0, 0, 159, 127),
framebuffer = luma.core.framebuffer.diff_to_previous at 0x765da7f0 (
bounding_box = (0, 0, 160, 128),
image = PIL.Image.Image at 0x76359b90 (
category = 0,
format = None,
format_description = None,
height = 128,
im = ImagingCore at 0x76d6afa0 (
bands = 3,
id = 22136808,
mode = 'RGB',
ptr = PyCapsule at 0x7655f020 (),
size = (160, 128),
unsafe_ptrs = ((...), (...), (...), (...), (...), ..., (...), (...), (...), (...), (...))
),
...,
palette = None,
pyaccess = None,
readonly = 0,
size = (160, 128),
width = 160
)
),
height = 128,
mode = 'RGB',
rotate = 0,
size = (160, 128),
width = 160
)
Do you have any suggestions?
Hello,
Please consider to add to the pre-requisites section the following, as it is not installed by default:
sudo apt-get install python-pip
Best regards,
Pedro
Hi, guys,
first, this library is wonderfull, great job! second, I need to clone the project on MS Windows machine, but on this operating system (any version!!!) a file can't be named "aux.xx" (xx stand for anything you want) so the file aux.py can't be created.
So, my request is: it is possible to rename this file to _aux.py for example?
Thanks in advice!
Bye
Currently a lot of dependencies are installed (for pygame) that only is used/tested in luma.emulator afaik. Removing these dependencies from the travis build and letting it run in a container-based env should speed up the build.
I'm using this https://www.amazon.com/gp/product/B01J76ZGMY ST7735 on my ODROID C1+ which I have SSD1306 and SSD1331 working fine. When I use the examples or a sample program I wrote it leaves pixel artifacts on the bottom and right side of the display. See attached image:
Also the back light only works on "high" using the examples. "low" displays a black screen.
root@saturn /tmp/pcd8544/examples # ./demo.py
Traceback (most recent call last):
File "./demo.py", line 24, in <module>
image.demo()
File "/tmp/pcd8544/examples/image.py", line 8, in demo
drawing()
File "/tmp/pcd8544/examples/image.py", line 48, in drawing
lcd.image(im)
File "/usr/local/lib/python2.7/dist-packages/pcd8544/lcd.py", line 118, in image
data([BITREVERSE[ord(x)] ^ mask for x in list(rim.tostring())])
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 686, in tostring
"Please call tobytes() instead.")
Exception: tostring() has been removed. Please call tobytes() instead.
I am totally new to Raspberry Pi, and I got the display working (I am able to run the examples) I am on Raspberry Pi 4, and my refresh rate is decent. I was wondering how to use the lcd to display the desktop/ if it could be done. Thanks!
root@saturn /tmp/pcd8544/examples # ./sys_info.py
Traceback (most recent call last):
File "./sys_info.py", line 78, in <module>
main()
File "./sys_info.py", line 75, in main
stats()
File "./sys_info.py", line 63, in stats
lcd.text(cpu_usage())
File "./sys_info.py", line 39, in cpu_usage
uptime = datetime.now() - datetime.fromtimestamp(psutil.BOOT_TIME)
AttributeError: 'module' object has no attribute 'BOOT_TIME'
root@saturn /tmp/pcd8544/examples #
and
Traceback (most recent call last):
File "./sys_info.py", line 78, in <module>
main()
File "./sys_info.py", line 75, in main
stats()
File "./sys_info.py", line 65, in stats
lcd.text(mem_usage())
File "./sys_info.py", line 45, in mem_usage
usage = psutil.phymem_usage()
AttributeError: 'module' object has no attribute 'phymem_usage'
and
Traceback (most recent call last):
File "./sys_info.py", line 79, in <module>
main()
File "./sys_info.py", line 76, in main
stats()
File "./sys_info.py", line 70, in stats
lcd.text(network('wlan0'))
File "./sys_info.py", line 57, in network
stat = psutil.network_io_counters(pernic=True)[iface]
AttributeError: 'module' object has no attribute 'network_io_counters'
It needs to use
datetime.fromtimestamp(psutil.boot_time()
usage = psutil.virtual_memory()
stat = psutil.net_io_counters(pernic=True)[iface]
It also doesn't work if there's no wlan0 interface. The RPi I'm running on only has eth0. You can use
#!/usr/bin/python
import fcntl, socket, struct
def getHwAddr(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', ifname[:15]))
return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
try:
print (getHwAddr('eth0'))
except:
print ("eth0 interface not found")
try:
print (getHwAddr('wlan0'))
except:
print ("wlan0 interface not found")
To determine whether an interface exists.
as per: rm-hull/luma.core@1db7b2a
Dear All:
the system cannot find the following lib. Could someone give me a hint?
import pytest
| from baseline_data import get_reference_data, primitives
| from helpers import Mock, serial, call, setup_function, assert_invalid_dimensions # noqa: F401
The ST7567 1.8 LCD is not lighted up even I wired it as exactly what the document said.
How to turn on the backlight?
It mentioned that GPIO18 can be used for backlight how to wire and code that?
Thanks a lot.
xipo
I have this 1.44" inch Serial 128x128 SPI Full Color TFT LCD Display with following specs:
ST7735S
SPI interface
Pins:
but the docs at https://luma-lcd.readthedocs.io/en/latest/install.html#st7735 mention 16 pins.
Did I get an incompatible device because I'm confused how to hook it up.
I've wired up a pcd8544 device and connected it to an RPi2 with latest kernel and Python 3.5.3. When running an example, e.g. python examples/3d_box.py -i spi --display pcd8544
it enables the backlight but doesn't show the actual 3d_box demo, it shows a line at the bottom that randomly appears on the screen. Other demo's don't show anything at all, only the backlight is enabled. Do all demo's work for you?
Raspberry pi 2B
Linux raspberrypi 4.19.42-v7+ #1219 SMP
To display example perfloop.py.
ST7735 screen display example perfloop.py in inverted colours
Background is white.
Red is Yellow
Green is Purple
Blue is Green
Hi, I have a Raspberrypi zero w and 1.14 inch st7789 LCD, I wander do you have plan to support st7789 driver?
Hi,
running the examples produces strange output on the display. Strange = something like it seems to generate the picture all over again, but the pict are some sort of nonsense-pixels. Hard to explain.
I tried to use the ST7735 display driver or the conf file for it ... no success.
Using the files from waveshare works, but i would like to use this luma :-)
Also other displays like SH1306 works with luma for me. So only this one is not working.
Please help.
Jürgen
platform linux2 -- Python 2.7.9, pytest-3.0.6, py-1.4.32, pluggy-0.4.0 -- /home/pi/projects/pi-test/luma.lcd/.tox/py27/bin/python2.7
cachedir: .cache
rootdir: /home/pi/projects/pi-test/luma.lcd, inifile:
plugins: cov-2.4.0
collected 12 items
tests/test_backlight.py::test_unsupported_platform FAILED
tests/test_backlight.py::test_init PASSED
tests/test_backlight.py::test_enable_on PASSED
tests/test_backlight.py::test_enable_off PASSED
tests/test_pcd8544.py::test_init_84x48 PASSED
tests/test_pcd8544.py::test_hide PASSED
tests/test_pcd8544.py::test_show PASSED
tests/test_pcd8544.py::test_display PASSED
tests/test_st7735.py::test_init_160x128 PASSED
tests/test_st7735.py::test_hide PASSED
tests/test_st7735.py::test_show PASSED
tests/test_st7735.py::test_display PASSED
================================================================ FAILURES ================================================================
_______________________________________________________ test_unsupported_platform ________________________________________________________
def test_unsupported_platform():
with pytest.raises(luma.core.error.UnsupportedPlatform) as ex:
> backlight(bcm_LIGHT=19)
E Failed: DID NOT RAISE <class 'luma.core.error.UnsupportedPlatform'>
tests/test_backlight.py:30: Failed
================================================== 1 failed, 11 passed in 5.92 seconds ===================================================
ERROR: InvocationError: '/home/pi/projects/pi-test/luma.lcd/.tox/py27/bin/coverage run -m py.test -v'
I use a st7735 device on a RPI3b.
It's working if I use the get_device() function from demo_opts.py as in luma.examples.
I use the following command :
python3 tst_luma.py --display st7735 --interface=spi --spi-bus-speed=16000000 --gpio-reset=24 --gpio-data-command=23 --gpio-backlight=18 --width=160 --height=128 --backlight-active=high --rotate=3
I'd like to define the rotation of the screen in my program.
I tried these following lines instead of get_device() but it doesn't work. Nothing is happening.
from luma.core.interface.serial import spi
from luma.lcd.device import st7735
serial = spi(port=0, device=0, gpio_DC=23, gpio_RST=24, cs_high=True, bus_speed_hz=16000000)
device = st7735(serial_interface=serial, width=160, height=128, rotate=3)
What am I doing wrong?
Thanks in advance
Tried hard to set it up, Made some modification's but have still many issues.
HD44780U Data Sheet: http://www.adafruit.com/datasheets/HD44780.pdf
Do you anticipate supporting the ILI9341 TFT display? I'm looking for a bigger display for a weather station.
Any ideas what could be causing this? It was working when I last used it a few months ago.
Hi guys. First of all, congratulations for the library, it's very very useful. I tested it with my screen and I found that the initialization (init() method) is not correct, as the screen is initialized with no contrast by default. I think there is an error in the initialization code, although I didn't find it. If I set the contrast manually with lcd.set_contrast(0xBE), then the text of the examples is displayed.
Here is my code:
from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.lcd.device import st7735
serial = spi(height=128, width=128, h_offset=1, v_offset=2, bgr=True)
device = st7735(serial)
with canvas(device) as draw:
draw.rectangle(device.bounding_box, outline="white", fill="black")
draw.text((30,40), "Hello World", fill="red")
and here is my error message:
Traceback (most recent call last):
File "gui.py", line 5, in <module>
serial = spi(height=128, width=128, h_offset=1, v_offset=2, bgr=True)
TypeError: __init__() got an unexpected keyword argument 'width'
Any idea what I am doing wrong? The unexpected keyword argument is different each time and I can run the examples fine.
https://luma-lcd.readthedocs.io/en/latest/api-documentation.html is not rendering the classes correctly it seems.
Hello! Does your library supports Banana PI?
A RuntimeError('This module can only be run on a Raspberry Pi!')
is thrown when running the SPI examples on a non-raspberrypi. This should be a better luma.core.error
.
E.g.:
$ python examples/3d_box.py -i spi
Traceback (most recent call last):
File "examples/3d_box.py", line 129, in <module>
device = get_device()
File "/home/luma.examples/examples/demo_opts.py", line 142, in get_device
device = Device(Serial(), **vars(args))
File "/home/luma.examples/examples/demo_opts.py", line 119, in spi
gpio=self.gpio)
File "/home/luma.core/luma/core/serial.py", line 133, in __init__
self._gpio = gpio or self.__rpi_gpio__()
File "/home/luma.core/luma/core/serial.py", line 161, in __rpi_gpio__
import RPi.GPIO
File "/home/foo/.virtualenvs/photobooth-gui/lib/python3.5/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
I have some pin clashes in my project over GPIO 18 and would like to change the backlight control pin on the ST7735. It seems this pin is used for PWM so GPIO 12 (also PWM) should do the job. Firstly, am I correct and if I am could you please advise me how to change the code to use this pin instead.
Thanks,
Louis
Edit - I think I have answered my own question, changing the pin number on this (https://github.com/rm-hull/luma.lcd/blob/master/luma/lcd/aux.py#L23) line should do.
RPi 3 B+ running Arch Linux Arm
Linux alarmpi 4.19.25-2-ARCH #1 SMP PREEMPT Tue Feb 26 01:20:52 UTC 2019 armv7l GNU/Linux
I have written a test program to learn how to use your libraries, test.py:
import time
import RPi.GPIO as GPIO
from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.lcd.device import st7735
from luma.lcd.aux import backlight
from PIL import ImageFont
serial = spi(port=0, device=0, gpio_DC=25, gpio_RST=27)
device = st7735(serial, width=128, height=128, h_offset=1, v_offset=2, bgr=True, persist=True)
gpio_LIGHT = 24
light = backlight(gpio=GPIO, gpio_LIGHT=gpio_LIGHT, active_low=False)
font = ImageFont.truetype("Roboto-Bold.ttf", 14)
light.enable(True)
# Box and text rendered in portrait mode
with canvas(device) as draw:
draw.rectangle(device.bounding_box, outline="white", fill="black")
draw.text((10, 50), "Hello World", fill="yellow", font=font)
draw.text((10, 30), "Hello World", fill="white", font=font)
input()
light.enable(False)
time.sleep(2)
I expected that the graphics will remain on screen and backlight will turn off and stay off after python script concludes.
I used persist=True
in the device setup expecting that the image would stay on the screen, but it did not, the screen becomes blank white. I also tried adding a switch at the end to turn the backlight off expecting it to stay off, but again, backlight is ON and screen is white. Finally, I added a 2 second delay at the very end to be able to see if the backlight control was working. It was, but the screen turns white with the backlight ON after the script ends.
I think that the cleanup of the gpio pins, turning them to tri-state inputs, causes the active high backlight to activate due to a 3.3V pullup in the circuit on the HAT, and the RESET to appear to go low, which would reset the chip.
Am I using the persist option correctly?
Anything else I should try?
Thanks
-Ted
It has the following specs but I'd like to know for sure how to hook it up:
1.8" Serial Port SPI TFT LCD Display Module
Size: 1.8 inch
Dot Matrix: 128*160
Module Size: 44.96(length)X53.47mm(width)
Display Area Size: 35.04(length)28.03mm(width)
Input Voltage: 5V/3.3V
Pin Definition: 1-RST 2-CE 3-D/C 4-DIN 5-CLK 6-UCC 7-BL 8-GND
It has PCB backplane with power IC, SD card socket
It need 4 IO port at least to drive.
The module port is compatible with 1602 LCD and Nokia 5110/3310 LCD Display port.
package included:1pc 1.8" SPI TFT LCD Display Module Serial 128160 PCB Adapter Power IC SD Socket
Howto run the exampe on the newly added ILI9341?
This does not work ?
python clock.py --display ili9341 --interface spi --width 320 --height 240
https://github.com/rm-hull/luma.lcd/blob/master/luma/lcd/__init__.py does not mention the newest driver but I'd vote to leave out the various compatible drivers in that docstring because we'll have to update it every time because it's easy to forget.
Would you accept a PR to implement PWM backlight LED control? I've hacked it together locally in my project leveraging luma.lcd
.
One important consideration is that RPi.GPIO
doesn't support hardware PWM, so I had to substitute pigpio
as the GPIO library (I'm also using gpiozero.PWMLED
for convenience).
the top package is currently called 'src' but should be 'pcd8544'.
Almost all of the libraries I use (inc some of yours) are compatible with RPi.GPIO. Is it possible to use that instead of wiringPi?
Hi there!
Thanks for your lib! Maybe you'll have some highlight on my initialization issue...
I bought the PCD8544 board which can be plug very easily on the Raspi, as you can see here:
https://github.com/pevandenburie/PCD8544/blob/master/PCD8544.pdf
The provided C demo (wiringPi based) works well.
However, I failed use your PCD8544 python wrapper...
To match the given layout:
CLK = GPIO17
D/C = GPIO27
CS = GPIO22
Din = GPIO18
RST = GPIO23
I tried following initialization:
LCDInit(CLK = 17, DIN = 18, DC = 27, RST = 23, LIGHT = 0, CE = 22);
I thought Light was just hardwired to 3.3V, and CE = CS.
But I got nothing on screen… Any idea on what I missed ?
Many thanks!
Hi Richard,
I have a question about best practices with the luma library, not sure where else to post it. I need to layout the screen real estate into regions that I can update, e.g. A status bar with a Wifi icon, a title bar, and an area in the middle for dynamic text. I looked at the savepoint example and I was thinking of that approach for redrawing on the same canvas for each of the regions. While I think that might work, I can't see how to update the canvas with an image (wifi icon). I only see pasting the icon onto a background image and then displaying the background image as a whole. Just wondering if there is a best practice here so I don't spend a lot of time down a rabbit hole.
Also, assuming the above is possible, is there a way to have a virtual terminal (scrolling text) as one of my regions?
Thx
I am trying to figure out why it is not working on me. Installation was fine but when I run any of the examples nothing happens.
Any help is appreciated!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.