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

  1. Building the library from the source code requires CMake.

    on Linux
    sudo apt install cmake
    
  2. Clone the repository:

    git clone https://github.com/2bndy5/CirquePinnacle.git
    
  3. Navigate into the repository folder and create a build folder. Then navigate into the build folder.

    cd CirquePinnacle
    mkdir build && cd build
    
  4. Configure CMake to build the library:

    cmake ../src
    
    Optional arguments
    -DPINNACLE_SPI_SPEED=6000000

    The SPI speed can be set with -DPINNACLE_SPI_SPEED=xxx to 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=OFF

    To reduce the compile size of the CirquePinnacle library, you can use -DPINNACLE_ANYMEAS_SUPPORT=OFF when the application won’t use the Pinnacle’s anymeas mode.

  5. 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).

  1. First make sure the created build folder is empty.

    Be sure to do this from within the build folder!!!
    rm -r ./*
    
  2. Configure CMake to build the examples:

    cmake ../examples/linux
    
    Optional arguments
    -DUSE_I2C=ON

    If using the I2C interface (PinnacleTouchI2C), then you can enable this for the examples with -DUSE_I2C=ON.

  3. Build the examples:

    make
    
  4. Run 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 slaveSelectPin value

spidev adapter

0

0

0

/dev/spidev0.0

0

1

1

/dev/spidev0.1

1

0

10

/dev/spidev1.0

1

1

11

/dev/spidev1.1

1

2

12

/dev/spidev1.2

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().

To use /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 ...
}
  1. Use 0 for /dev/i2c-0. Default is 1 for /dev/i2c-1.

  2. Explicitly pass a reference of the TwoWire object to PinnacleTouchI2C::begin().