Yes, the library PXL is known to me. Immediately after buying a Raspberry Pi board in May 2017 I started looking for libraries. To make use of Raspberry Pi, I also gradually bought: HAT boards (Waveshare), mini-modules (
Grove - Seedstudio,
Gravity - DFRobot) and various trinkets (stepper motors, servos, photovoltaic cells, etc.). A little of this accumulated over the last 4 years.
First of all, I started looking for libraries that could be used in Lazarus. First I looked at the
Lazarus on Raspberry Pi, in particular the
External Links section. From there I found my way to the
PXL library website. I also looked at other libraries written in Object Pascal. But right now, PXL has perhaps the greatest capabilities (plus carefully written code and some pretty good documentation).
For inspiration, I also searched for libraries created in other programming languages, for example:
-
Wiring Pi,
-
libgpiod,
-
MRAA,
-
The Pi4J Project,
-
Rpi.GPIO.
Unfortunately, the Wiring Pi library was of no use to me. It can be useful for people who need minimalism. But creating more complex C applications is a "painful journey." Moving this library to Object Pascal or creating wrappers seems to me pointless (it uses, among others, the
sysfs GPIO interface and specific references to Broadcom SoC).
I looked at the
libgpiod library just to get to know GPIO support using the
chardev character interface in Linux. I looked at the
MRAA library files only cursorily, to look at I2C and SPI support in Linux. I have to find something about support for the
1-wire bus in Linux. I found something in Linux source files, but it's probably for kernel use:
w1.h).
The
Pi4J library is quite confusing. Using it resembles dealing with some complicated matters in state offices. The following description comes to my mind:
to get a specific object, call the factory, then ask it to return a specific builder to you, when you get it, ask him to build a specific object according to a set of guidelines, the builder will create this object on their basis and will hand it over to you - this is bureaucracy. Well, Java is known for that.
I haven't looked at
Rpi.GPIO yet (I haven't had enough patience with Python).
What I need (or what I'm trying to strive for) are two groups of classes:
1. base classes that support GPIO, PWM and serial buses: I2C, SPI, 1-wire,
2. target classes that includes a handling code of specific integrated circuits (e.g.: MCP23017, PCA9698, MAX14830, etc.).
To achieve the first goal, I am trying to use operating system interfaces (Linux for now). In this way, I plan to extend this library to support other SBCs (
Up Squared, etc.) without changing the rest of the classes (i.e. target ones). For the second goal, I want to create a set using the details from datasheets provided by chip manufacturers (chip address, register numbers in the chip, etc.) Of course, this is easy to write on the forum ("speech is cheap"), but it takes time to implement. Also, if the library had to be easily extensible, it requires some thought, so the internal structure of the base classes will probably change a few more times (mostly changes inside the main base classes).
The difficulty at this time is in identifying SBC and Soc. I need this to determine the details of the GPIO connector (how many pins, what signals are available, what modes the GPIO line works, etc.). I put the details in arrays of constants (lookup tables). Probably almost all libraries have uses this approach.
In the case of SBC based on Intel processors (e.g.
Up Squared) under Linux it is not too bad (Linux plug-and-play). There is a bigger problem with ARM-based SBCs. It turned out that there is no plug-and-play mechanism on the ARM platforms (which I didn't know before). Information about the hardware and its configuration depends on the presence of the DTB (
device tree) file loaded at system startup. If some Linux distribution does not contain this information, there may be a hardware identification problem. Since this information may not be in the system, of course you can tell the programmer to add conditional compilation symbols to the project options. But this slightly reduces the convenience of creating a program. So far, I don't see any other option.