adafruit / Adafruit_APDS9960

Arduino drivers for APDS9960 gesture sensor
Other
37 stars 45 forks source link

The Arduino code has no option to use alternate pins on the micro contorller #30

Closed gommdt closed 3 years ago

gommdt commented 3 years ago

I am porting my code from Circuit Python to Arduino C due to motor speed issues. Circuit Python allows you to use alternate pins for the SCL and SDA, I am currently using RX and TX. I have been diving into the source files and cannot find a way to change the pins unless I rewrite the Wire.h files.

Adding this functionality would allow the use of multiple 9960 sensors, but in my case, I am using a featherwing that is blocking any other sensor from using the same i2c bus.

ladyada commented 3 years ago

you can pass an optional Wire here https://github.com/adafruit/Adafruit_APDS9960/blob/master/Adafruit_APDS9960.h#L178 but you need to create a new Wire object which is not nearly as easy as it is in circuitpython (one of the reasons we made sure it was easy there!)

here is a guide on how https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports

if you have more questions, post to forums or discord!