Waveshare e-paper screen

I am trying to get Xojo to talk to a Waveshare e-paper screen. I have some python code which can do this, but I cannot see how to import libraries to this, or use Xojo to control SPI channels.

Some python example code is

epd = epd2in7.EPD()
epd.init()
epd.Clear(0xFF)

font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24)

# Drawing on the Horizontal image
Himage = Image.new('1', (epd.height, epd.width), 255)  # 255: clear the frame
draw = ImageDraw.Draw(Himage)
draw.text((10, 0), 'WEBSITE STATUS ', font = font24, fill = 0)

Is there a way to do this directly from Xojo?

Dave

You’d have to find out how the python code is talking to the display. If it’s using a shared library then you could implement the same calls to it in Xojo but it would take some knowledge of how it’s put together. If it’s talking a protocol over SPI or something like that then you’d need to port the low level library python code to Xojo to do the same thing. It’s certainly doable, but it might be a lot of work depending on how it’s implemented.

or output a picture from xojo as file and let python display it.

Thats a really good idea actually :slight_smile: probably doesn’t have to be a huge image or huge resolution. It should be easy enough to execute a shell script to launch the python helper app and tell it where you saved the picture!

You could even use the python library in Xojo by using Einhurgur’s python3 plugin where you could pass info back and forth to small python scripts all inside the app. Thats probably overkill though. Packaging a few helper scripts along with it is not a huge problem.

That’s what I am currently doing it, although I don’t want python and it’s vulnerabilities installed on my servers.

It looks like the waveshare e-paper screens are all SPI interface? The Xojo docs for the Pi show that it wraps the WiringPi library so as long as that is installed you should be able to use the SPI interface. More info on that here:

https://documentation.xojo.com/topics/raspberry_pi/gpio.html

the install and setup for the wiringPi library you have probably already done or the thing might not work in the first place, but they are here:

I don’t see any specific spi libraries for xojo, so I’m not sure off the top of my head if there is something built in we can use or if we need to wrap the spi calls in a declare to the wiring pi library. The best example, actually the only example that I could find but I did not do an exhaustive search anywhere, was Einhugers talking to a barometric pressure sensor over SPI. He uses a declare to the wiringpi library.

If you have a look at the official Xojo GPIO module that also talks to the wiringpi library it also uses declares so perhaps that is the best way to go. You can download their classes and code and have a look at how they are doing it too, though these are not specifically SPI declares, they will show the format and what works and how to create a re-usable xojo class to talk to the thing:

now the tricky bit will be to rebuild code that will talk directly to the display. I don’ t know how it’s commands differ from a standard LCD or anything else but I doubt you can reuse any of that other code that might be out there. The low level commands are documented on the data sheet for the display which is here:

well, thats for the 2.7 inch, you may have to dig up the proper one for your display. Unfortunately they are pretty low level. You should be able to send them using the spi library and xojo but it’s not going to be particularly pretty to figure out and get working.

You can look at the very low level python code that talks directly to the display and it doesn’t look like it would be too horrific of a job to port it to xojo. Those modules are in the waveshare github repository here:

https://github.com/waveshare/e-Paper/tree/master/RaspberryPi%26JetsonNano/python/lib/waveshare_epd

pick the one that is for your particular device and start porting to xojo. Most of the stuff is pretty straight forward but I do see some low level bit manipulation in there that might be confusing to just read and convert.

If you create another open source github project and talk to people here on the list about it there might be some help forthcoming from the rest of the community :slight_smile: But it won’t happen overnight. I don’t even have one of these displays to play with.

Actually, I take back the part about using WiringPi, it looks like it’s deprecated and not going to be updated. It appears that there are already excellent Xojo classes to wrap the SPI communications using the pigpio libraries. I would have a look at this:

https://gitlab.com/UBogun/Xojo-pigpio

and use that to make the low level SPI calls instead of a declare to wiring pi!

All the rest still applies however.

Slightly off topic and I’m not trying to say that you’re wrong here, but “what” vulnerabilities? We’ve been using Python since 2.3.2 and any attack vectors in our projects were simply due to my team’s coding mistakes rather than anything in Python. Since you control any modules that your apps use, and (unless you are rolling your own stripped down Linux install) all Linux distros depend on Python for almost every aspect of their tools, you’ll have Python on the system.