https://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#PXL_.28Platform_eXtended_Library.29_for_low_level_native_access_to_GPIO.2C_I.C2.B2C.2C_SPI.2C_PWM.2C_UART.2C_V4L2.2C_displays_and_sensorsThanks! I'll play with that a bit.
For the HDMI screens clearly the Linux OS will provide the support but I don't want the user desktop and yet I'd like to be able to easily build say a screen like the chart image, develop, test on a full blown Pi or Beagle with larger screen and then install into say a PiZeroW for either SPI or a PC.Framework to use SPI lcd screens on linux is http://asphyre.net/products/pxl.
Here is another example of how easy it is to develop and test on the PC with either Linux or Windows and why I want to use Lazarus as is.That's one of the reasons why I advise sticking to LCL.
The Beagle has a cable attached to a proto cape that runs to a board with a DS1822 temperature sensor/serial# chip.Have this in mind: https://www.cnx-software.com/2020/07/13/fake-ds18b20-temperature-sensors-counterfeit-clones/
The LED display was an afterthought.You made me smile showing 3 decimals for the temperature. ;)
Have this in mind: https://www.cnx-software.com/2020/07/13/fake-ds18b20-temperature-sensors-counterfeit-clones/
You made me smile showing 3 decimals for the temperature. ;)
This product requires either Embarcadero Delphi XE 8 (or any later version) or
FreePascal 3.0 with Lazarus 1.4 (or any later versions).
Raspberry PI
- Fast access to CPU timer, GPIO, I²C, SPI and UART using direct manipulation of SoC registers.
- V4L2 video/image capture using onboard and USB cameras.
- OpenGL ES rendering with and without X server, including drawing to bitmaps. One of examples shows how to render your visual scene with GPU and then pass it to external display via SPI wiring!
- ...and many other features that are available for generic singleboard platforms.
BeagleBone Black
- Easy access to native Linux Sysfs interfaces such as GPIO, PWM, ADC, I²C, SPI and UART.
- Serial cameras such as VC0706 and LSY201.
- I²C and SPI displays such as SSD1306, SSD1351, PCB8544 (Nokia), HX8357 and ILI9340.
- Character LCDs with direct pin wiring.
- Support for Software SPI and UART (bit-banging).
- Support for SC16IS7x0 (UART controller connected via I²C or SPI), including extra GPIO pins.
- Support for sensors such as BMP180, DHT22, L3GD20, LSM303 and SHT10.
- Networking communications through UDP protocol.
- Video/image capturing through generic V4L2 interface.
- Software rendering for visual effects and user interfaces.
Yes. And thanks for that link.This product requires either Embarcadero Delphi XE 8 (or any later version) or
FreePascal 3.0 with Lazarus 1.4 (or any later versions).
I have mentioned it for Pi and BB using Laz/Fpc.
You can completely avoid PXL if you use LCL, since there are other libs for access to GPIO, SPI, I2C, serial...
https://wiki.freepascal.org/Hardware_Access
But the LCL and the link to2nd link is more adequate for your needs, especially this subtopic:
https://wiki.freepascal.org/Hardware_Access (https://wiki.freepascal.org/Hardware_Access)
seem more to address windows parallel ports than what is required for the Beagle.
debian@ebb:~/lazarus/pxl/Samples/FreePascal/SingleBoard/Generic/DisplaySPI$ sudo ./DisplaySPI
[sudo] password for debian:
An unhandled exception occurred at $00032BB0:
ESysfsSPITransfer: Cannot transfer <1> data byte(s) through SPI bus.
$00032BB0 TSYSFSSPI__TRANSFER, line 247 of /home/debian/lazarus/pxl/Source/PXL.Sysfs.SPI.pas
$00032AC4 TSYSFSSPI__WRITE, line 228 of /home/debian/lazarus/pxl/Source/PXL.Sysfs.SPI.pas
As yet I have not yet figured out the issue with fpioctl() and why I get faults. It might well be again something to do with permissions.Alright. Been a few days and I'm closer to getting the LCD display working with the Pi and Beagle via the pxl library. I've now got the GPIO group permissions set on the beagle so that I can run the applications from inside the IDE. But the PXL.sysfs.SPI library would fail consistently on both the Pi and the Beagle during the Transfer() function which calls fpioctl().
John
pi@raspberrypi:~/projects/lazarus/TC $ sudo ./TC
Reading temperature, press any key to exit...
Temperature: 21.75C 71.15F
Temperature: 21.75C 71.15F
Temperature: 21.75C 71.15F
I have not yet figured out the issue with fpioctl() and why I get faults. It might well be again something to do with permissions.fpioctl should be mapped to linux ioctl calls, so this might be helpful for understanding SPI_IOC_MESSAGE and debugging:
I must admit that I am confused what works for you and what doesn't.Here's the rundown.
pi@raspberrypi:~/projects/lazarus/TC $ groupsBut still requires sudo to run the application as shown in the previous posting while the BBB now can debug from both inside and out of the IDE.
pi adm dialout cdrom sudo audio video plugdev games users input netdev lpadmin gpio i2c spi
debian@ebb:~/lazarus/TC$ ./TCI'm going to have to go back through my postings to the Beaglebone group to see what else I may have done to get it to work without sudo. It too was having that problem but no longer.
Reading temperature, press any key to exit...
Temperature: 21.5C 70.7F
Temperature: 21.5C 70.7F
Regarding fpioctl failure, the returned value is important. I just checked the source code (https://github.com/spotify/linux/blob/master/drivers/spi/spidev.c) for spidev. fpioctl is going to end in spidev_ioctl.
spidev_ioctl which it checks for and the errno it could return:
and finally it executes the command.
As you noted in your previous post, the driver path could be wrong. You might want to correct this code in PXL sample:
constructor TApplication.Create; begin FGPIO := TSysfsGPIO.Create; FDataPort := TSysfsSPI.Create('/dev/spidev1.0');
For a SPI device with chipselect C on bus B, you should see:
/dev/spidevB.C
One of the links (https://www.kernel.org/doc/Documentation/spi/spidev) posted above by Avra explains:That document is written for the low level Linux expert and doesn't help someone who has no idea how to 'bind' something. Nor does it give any clue as to whether it's referring to a Beagle or a Pi or one of the other ARM based systems. Unfortunately.QuoteFor a SPI device with chipselect C on bus B, you should see:
/dev/spidevB.C
Which one to choose?If we have a system with a single SPI bus where 3 chip select lines are available for that bus, we would have 0.0, 0.1 and 0.2. Choosing one of them will actually just select which one of the 3 predefined chip select lines will be used.
pi@raspberrypi:~/projects/lazarus/TC $ ls /dev/spi*
/dev/spidev0.0 /dev/spidev0.1
Or here:
debian@ebb:~/lazarus/TC$ ls /dev/spi*
/dev/spidev1.0 /dev/spidev1.1 /dev/spidev2.0 /dev/spidev2.1
/dev/spi:
0.0 0.1 1.0 1.1
I also want to port this:https://github.com/botheredbybees/kilnController (https://github.com/botheredbybees/kilnController)Nice and useful Pi project, although I would have personally done it with ESP32.
along with it's parent reflow oven controller to Lazarus.
The more of these types of projects out there the more we can bring people into the much easier Delphi/Lazarus programming world. IMHO.That's why I decided to bring SocketCAN to FreePascal when I saw in the forum thread (which has started it all) that many tried but gave up because of lack of SocketCAN experience, although I had everything I needed in C and Python already.
I don't think the Beagle by itself can select 1 of 4 SPI devices.With little trick you can connect as much as you wish:
Schematics accessible by clicking on each green block.Ah, good old Protel. Brings back some memories...
http://www.autoartisans.com/ELS/ (http://www.autoartisans.com/ELS/)
My goal with the displays and sensors is to be able to create a Window'd type screenYou can still use LCL for such design. You create a form in designer with the same dimensions as your display, and update it in runtime as normal. You just don't show it, and have a thread or timer which periodically transfers bitmap to SPI or I2C display. You can even cache last shown bitmap to decide which display parts do not need an update.
Exactly. Instead of having an HDMI that shows the entire desktop for an embedded system we're really just interested in a subset of the main screen. Hence write to a canvas and as you say, periodically update the SPI/I2C display(s).My goal with the displays and sensors is to be able to create a Window'd type screenYou can still use LCL for such design. You create a form in designer with the same dimensions as your display, and update it in runtime as normal. You just don't show it, and have a thread or timer which periodically transfers bitmap to SPI or I2C display. You can even cache last shown bitmap to decide which display parts do not need an update.