adafruit / Adafruit_APDS9960

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

_wire should be initialized before _i2c_init #19

Closed noisyfly closed 5 years ago

noisyfly commented 5 years ago

It should be changed because _i2c_init is called without initialized pointer to TwoWire object. In ESP32 it rise an exception.

ladyada commented 5 years ago

@hoffmannjan check it out!

noisyfly commented 5 years ago

I don't know why Your test failed. I build it with Arduino for ESP32 in version 1.0.1. My original code looks like this:

_boolean Adafruit_APDS9960::begin(uint16_t iTimeMS, apds9960AGain_t aGain, uint8_t addr, TwoWire *theWire) { _wire = theWire; _i2c_init(); _i2caddr = addr; // _wire = theWire;

/ Make sure we're actually connected / uint8_t x = read8(APDS9960ID);

So it is the same as those I send in pull request. I tested it using your example of proximity detection and it works.

hoffmannjan commented 5 years ago

@noisyfly probably due to cache issues with travis, I've restarted build and will test It on devices soon.

hoffmannjan commented 5 years ago

OK works fine, merged:)

ladyada commented 5 years ago

@hoffmannjan thanx - please bump version as well so people get the code updates :)

hoffmannjan commented 5 years ago

@ladyada done :)