[Lazarus] conditionals for detecting hardware platforms?

Bo Berglund bo.berglund at gmail.com
Mon Feb 29 11:33:14 CET 2016


I am programming with FreePascal and Lazarus towards a Raspberry Pi2
target platform. Doing so on the RPi2 itself is possible and basically
works fine, except that the system is a bit sluggish at times and
there are other inconveniences as well.
So I moved to a Linux Mint 17.3 Mate system in a virtual computer
(VMWare) on my Windows7 PC instead.

Most of what I am doing concerns non-hardware dependent things and
works fine as far as I can see.
But there is one snag, and this is the GPIO handling where obviously
the GPIO access is not possible on a PC platform...

So I need to put some kind of conditional into my code to redirect the
GPIO calls to some simulator I will have to build. (I am assuming that
there is no such thing available already of course).

So I would like to know how I can create a conditional that uses the
real GPIO if the build is done on the RPi2 itself and for the
simulator otherwise.
Something like:

uses
  ...
  {$IFDEF RPi2Hardware}
  PiGpio,
  {ELSE}
  PiGpioSim,
  {$ENDIF}

Then I could create a PiGpioSim unit as a simulator that defines the
same object class but does not target the actual hardware on RPi2 but
some other mechanism that I can monitor while debugging in the
development PC.

Is there something like "RPi2Hardware" already set up that can be used
to check for this?


-- 
Bo Berglund
Developer in Sweden





More information about the Lazarus mailing list