Linux Support¶
This library can be used on any Linux device that exposes GPIO pins.
Automated install script¶
There is a file named install-linux.sh that automates the process outlined in Installing from Source section.
To use this script the file permission must be modified (only once):
chmod u+x install-linux.sh
Now you can run the script and follow the prompts:
./install-linux.sh
Installing from Source¶
Building the library from the source code requires CMake.
on Linux¶sudo apt install cmakeClone the repository:
git clone https://github.com/2bndy5/CirquePinnacle.gitNavigate into the repository folder and create a build folder. Then navigate into the build folder.
cd CirquePinnacle mkdir build && cd buildConfigure CMake to build the library:
cmake ../src -DPINNACLE_DRIVER=linux_kernelThe
-DPINNACLE_DRIVERwill force the build to use 1 of the supported hardware drivers. This can also be specified using an environment variable namedPINNACLE_DRIVER. With out this specified, CMake will look for required dependencies and use the first driver found. Supported options include (in order of precedence):bcm2xxxis a bit slower and only works on RPi boards (requiressudopermission to execute).pigpiorequires the PiGPIO library installed (requiressudopermission to execute).mraarequires the MRAA library installed.linux_kernel(default fallback) is recommended for best user experience and cross-platform/architecture compatibility.
Optional arguments
-DPINNACLE_SPI_SPEED=6000000The SPI speed can be set with
-DPINNACLE_SPI_SPEED=xxxto lower the default speed/baudrate used on the SPI bus. Default value is the officially recommended 6 MHz; maximum supported is 13 MHz.-DPINNACLE_ANYMEAS_SUPPORT=OFFTo reduce the compile size of the CirquePinnacle library, you can use
-DPINNACLE_ANYMEAS_SUPPORT=OFFwhen the application won’t use the Pinnacle’s anymeas mode.
Build and install the library:
make sudo make install
Run an example¶
After the library is installed, open one of the linux examples (located in examples/linux) and change the pin numbers accordingly. The following steps will use a build folder created in the CirquePinnacle repository’s root folder (as created in step 3 above).
First make sure the created build folder is empty.
Be sure to do this from within the build folder!!! ¶rm -r ./*Configure CMake to build the examples:
cmake ../examples/linux -DPINNACLE_DRIVER=linux_kernelAgain, specify the driver used to build the library (see step 4 above) is recommended because some drivers require the built applications to be linked to pre-installed libraries.
Optional arguments
-DUSE_I2C=ONIf using the I2C interface (
PinnacleTouchI2C), then you can enable this for the examples with-DUSE_I2C=ON.-DUSE_SW_DR=ONIf not using a physical GPIO pin for the Data Ready pin, then you can use
-DUSE_SW_DR=ONwhich will automatically make the examples usePINNACLE_SW_DRvalue for thedataReadyPinparameters to thePinnacleTouchSPI()andPinnacleTouchI2C()constructors. The anymeas_mode example is automatically excluded from the build targets since it requires a hardware Data Ready pin.
Build the examples:
makeRun an example:
./relative_modeRemember that both
PINNACLE_DRIVERsbcm2xxxandpigpiowill requiresudopermission.
SlaveSelect pin¶
Using the SPI bus’ SS pin (Slave Select, aka Chip Select) on a Linux platform is a bit different
from the Arduino platform because the Linux kernel controls the pin during bus transactions.
Therefore, the pin number passed to the PinnacleTouchSPI() constructor should
follow the form ab where a is the SPI bus number and b is the specified bus’ SS pin
(often labeled CE<b> on Raspberry Pi pinout diagrams).
bus ID |
CE number |
constructor’s |
spidev adapter |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note
Support for the auxiliary (AKA secondary) SPI bus (/dev/spidev1.x) is only well supported in
the linux_kernel driver. Other drivers have their own set of limitations when it comes to
using /dev/spidev1.x.
Using a non-default I2C bus¶
The default I2C bus used is /dev/i2c-1. However, some boards may use a different I2C bus number
as a default. This can be remedied by passing the correct bus number to cirque_pinnacle_arduino_wrappers::TwoWire::begin().
/dev/i2c-0 bus¶#include <CirquePinnacle.h>
#define DR_PIN 25
PinnacleTouchI2C trackpad(DR_PIN);
int main() {
// specify the I2C bus
cirque_pinnacle_arduino_wrappers::Wire.begin(0); // (1)!
if (!trackpad.begin(&cirque_pinnacle_arduino_wrappers::Wire)) { // (2)!
return 1; // failed to initialize the trackpad
}
// continue the program as usual ...
}
Use
0for/dev/i2c-0. Default is1for/dev/i2c-1.Explicitly pass a reference of the
TwoWireobject toPinnacleTouchI2C::begin().