Posts: 11
Joined: Fri Sep 01, 2017 8:47 pm

gfx hat screen and working by area

Sat Jul 06, 2019 10:07 pm


For my professional project,
i need to display in my lcd, some icon on the top.

By example, one whe eth0 ifup.
idem for wlan0.

i have done this script :
( only for display my icon, it is launched in a bash script, introduced in /etc/network/interfaces for ifup )

Code: Select all

#!/usr/bin/env python
import time
from gfxhat import lcd, backlight, fonts
from PIL import Image, ImageFont, ImageDraw

#Image de demarrage
image ="/home/ethernet.bmp")

for x in range(20):
	for y in range(20):
		pixel = image.getpixel((x, y))
		if pixel == 0:
			pixel = 1
			pixel = 0
		lcd.set_pixel(x, y, pixel)
I have done the same one for wlan0.

But when i lauch one scripts, all informations in the screen are updated.
Can we update by area, to let present informations already in place.

thanks by advance

Posts: 1391
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: gfx hat screen and working by area

Sun Jul 07, 2019 10:02 am

According to your description, there are at least two processes writing to the display
- "Can we update by area, to let present informations already in place" so there is some process writing information
- the ifup-process, triggered by ifup in network configurations. Providing an icon

The gfx-hat/st7567 library maintains a display buffer which is completely written to the display on show(). This display buffer is not shared between processes. The st7567 chip does not allow to read back of data in serial mode, so there is no simple way to synchronize multiple processes with their display buffers.

You can try to extend the hfx-hat library to allow region write. The column address and page address can be set before the data transfer.
Then regions could be separated, but when both processes would start to write 'in parallel', then synchronization is needed. If not, there will be a mess of pixels from time to time.

Another option is to use one "main display process" and the ifup process just sends a notification by a named pipe or other IPC to the main process. Then python display buffer is existing only once. The IPC could be also socket, apache thrift, REST api, ... A REST api allows to use wget in scripts which removes the need to have extra python code.

Return to “Python”