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 ../srcOptional 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/linuxOptional arguments
-DUSE_I2C=ONIf using the I2C interface (
PinnacleTouchI2C), then you can enable this for the examples with-DUSE_I2C=ON.
Build the examples:
makeRun an example:
./relative_mode
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 |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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().