Error When compiling adafruit library for the P2

I have a project that relies on the adafruit neopixel library. It compiles and runs fine on Argon.

When I try and compile for P2, I get the following error. I have no idea how to fix this.

error: invalid user-defined conversion from 'int' to 'SPIClass&' [-fpermissive]
30 | #define D5 5
| ^
src/quaternion_yaw_pitch_roll.ino:53:19: note: in expansion of macro 'D5'
53 | #define PIXEL_PIN D5 //D2,3,4 used by OLED pins
| ^~
src/quaternion_yaw_pitch_roll.ino:65:38: note: in expansion of macro 'PIXEL_PIN'
65 | Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
| ^~~~~~~~~
In file included from ./inc/application.h:54,
from ./inc/Particle.h:5,
from src/quaternion_yaw_pitch_roll.cpp:19:
../wiring/inc/spark_wiring_spi.h:160:3: note: candidate is: 'SPIClass::SPIClass(hal_spi_interface_t)' (near match)
160 | SPIClass(hal_spi_interface_t spi);
| ^~~~~~~~
../wiring/inc/spark_wiring_spi.h:160:3: note: conversion of argument 1 would be ill-formed:
In file included from ../hal/src/rtl872x/pinmap_impl.h:54,
from ../hal/inc/pinmap_hal.h:77,
from ../hal/inc/interrupts_hal.h:39,
from ../wiring/inc/spark_wiring.h:29,
from ./inc/application.h:42,
from ./inc/Particle.h:5,
from src/quaternion_yaw_pitch_roll.cpp:19:
../hal/src/tron/pinmap_defines.h:30:29: error: invalid conversion from 'int' to 'hal_spi_interface_t' [-fpermissive]
30 | #define D5 5
| ^
| |
| int
src/quaternion_yaw_pitch_roll.ino:53:19: note: in expansion of macro 'D5'
53 | #define PIXEL_PIN D5 //D2,3,4 used by OLED pins
| ^~
src/quaternion_yaw_pitch_roll.ino:65:38: note: in expansion of macro 'PIXEL_PIN'
65 | Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
| ^~~~~~~~~
../hal/src/tron/pinmap_defines.h:30:29: error: invalid conversion from 'int' to 'hal_spi_interface_t' [-fpermissive]
30 | #define D5 5
| ^
| |
| int
src/quaternion_yaw_pitch_roll.ino:53:19: note: in expansion of macro 'D5'
53 | #define PIXEL_PIN D5 //D2,3,4 used by OLED pins
| ^~
src/quaternion_yaw_pitch_roll.ino:65:38: note: in expansion of macro 'PIXEL_PIN'
65 | Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
| ^~~~~~~~~
In file included from ./inc/application.h:54,
from ./inc/Particle.h:5,
from src/quaternion_yaw_pitch_roll.cpp:19:
../wiring/inc/spark_wiring_spi.h:160:32: note: initializing argument 1 of 'SPIClass::SPIClass(hal_spi_interface_t)'
160 | SPIClass(hal_spi_interface_t spi);
| ^
src/quaternion_yaw_pitch_roll.ino:65:59: error: conversion to non-const reference type 'class SPIClass&' from rvalue of type 'SPIClass' [-fpermissive]
65 | Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
| ^
In file included from src/quaternion_yaw_pitch_roll.cpp:23:
lib/neopixel/src/neopixel.h:77:43: note: initializing argument 2 of 'Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t, SPIClass&, uint8_t)'
77 | Adafruit_NeoPixel(uint16_t n, SPIClass& spi, uint8_t t=WS2812B);
| ^
src/quaternion_yaw_pitch_roll.ino: In function 'void loop()':
src/quaternion_yaw_pitch_roll.ino:193:28: warning: this statement may fall through [-Wimplicit-fallthrough=]
193 | quaternionToEulerRV(&sensorValue.un.arvrStabilizedRV, &ypr, true);
| ~^
~
src/quaternion_yaw_pitch_roll.ino:194:7: note: here
194 | case SH2_GYRO_INTEGRATED_RV:
| ^~~~
make[2]: *** [../build/target/user/platform-32-msrc/quaternion_yaw_pitch_roll.o] Error 1
make[2]: Leaving directory /firmware/user' make[1]: *** [user] Error 2 make[1]: Leaving directory /firmware/modules/tron/user-part'
make: *** [modules/tron/user-part] Error 2

Hi, what DeviceOS version are you using?

I believe it is being built with 5.6.0. I will double check and make sure.

OK, it's failing 5.6.0, 5.70, 5.9.0

My IDE shows 6.1.1 as an option, but my CLI won't let me.

This is because 6.x does not support the P2 yet.

For the errors, I do know know. Maybe @rickkas7 can assit? Thanks

On the P2, you must use the neopixel library. The README is in Github.

In particular, you cannot use an arbitrary pin for Neopixels. You can't use pin D5, which is why you're getting a compile error.

 * On Photon 2 / P2, only SPI(MOSI) or SPI1(D2) can be used for Neopixel,
 * and only PIXEL_TYPE's WS2812, WS2812B, WS2813 are supported.
 * - MISO (D12), SCK (D13) and SS (D8) can be used as GPIO when using SPI
 * - MISO1 (D3), SCK1 (D4) and SS1 (D5) can be used and GPIO when using SPI1
 * note: You may want to call System.disableFeature(FEATURE_ETHERNET_DETECTION);
 *       to disable automatic Ethernet driver detection, which will cause some
 *       glitches to SPI1 pins D2,D3,D4.

Instead of defining PIXEL_PIN to D5, you need to use one of these:

#define PIXEL_PIN SPI
// #define PIXEL_PIN SPI1
3 Likes

You're my hero. Thank you. I poorly assumed that the devices were fully compatible, even though I have already had to make adjustments for another project. Not a dig at particle, just need to do my homework with new devices.

Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.