Arduino Support¶
This library was primarily written for the Arduino IDE. Therefore, it uses the SPI and I2C bus implementations from the Arduino framework (as provided by various board support – AKA “Arduino Cores”).
Using a non-default SPI or I2C bus¶
It is possible to use a specific SPI bus on boards that expose more than 1 SPI bus. As noted above,
the SPIClass
interface may vary depending on the targeted board.
The following code snippet exemplifies the necessary steps:
#include <CirquePinnacle.h>
#include <SPI.h>
#define SS_PIN 2
#define DR_PIN 7
SPIClass my_spi_obj; // (1)!
PinnacleTouchSPI trackpad(DR_PIN, SS_PIN);
void begin()
{
Serial.begin(115200);
while (!Serial) {
// some boards need this for the prompts to show immediately after boot
}
my_spi_obj.begin(); // (2)!
if (!trackpad.begin(&my_spi_obj)) { // (3)!
Serial.println(F("Cirque Pinnacle not responding!"));
while (true) {} // hold program in infinite loop
}
// continue program as usual...
}
Instantiate a
SPIClass
object for use with a specific SPI bus.Initialize the SPI bus using
SPIClass::begin()
method. The arguments passed to this function may differ depending on the Arduino core used (for a certain family of boards).Developers are encouraged to identify the use of
SPIClass::begin()
(or anySPIClass::set<pin>()
) as instructed by the utilized Arduino core’s SPI library.Pass a reference of the instantiated
SPIClass
object toPinnacleTouchSPI::begin()
.
It is possible to use a specific I2C bus on boards that expose more than 1 I2C bus. As noted above,
the TwoWire
interface may vary depending on the targeted board.
The following code snippet exemplifies the necessary steps:
#include <CirquePinnacle.h>
#include <Wire.h>
#define DR_PIN 7
TwoWire my_i2c_obj; // (1)!
PinnacleTouchI2C trackpad(DR_PIN);
void begin()
{
Serial.begin(115200);
while (!Serial) {
// some boards need this for the prompts to show immediately after boot
}
my_i2c_obj.begin(); // (2)!
if (!trackpad.begin(&my_i2c_obj)) { // (3)!
Serial.println(F("Cirque Pinnacle not responding!"));
while (true) {} // hold program in infinite loop
}
// continue program as usual...
}
Instantiate a
TwoWire
object for use with a specific I2C bus.Initialize the I2C bus using
TwoWire::begin()
method. The arguments passed to this function may differ depending on the Arduino core used (for a certain family of boards).Developers are encouraged to identify the use of
TwoWire::begin()
(or anyTwoWire::set<pin>()
) as instructed by the utilized Arduino core’s I2C library.Pass a reference of the instantiated
TwoWire
object toPinnacleTouchI2C::begin()
.