This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

mbed compile error with this constructor

Hi, I'm have compile error that I haven't been able to solve for an nRF51822 on mbed. I'm using this sensor library:

developer.mbed.org/.../

However, it's a bit confusing. The VL53L0X sensor code is actually here: developer.mbed.org/.../VL53L0X

ST makes some kind of shield that is composed of three of these VL53L0X's, and their library is more tailored to work with that. But in my case, I just have one VL53L0X on I2C.

Here's the compile error:

Error: No instance of constructor "VL53L0X::VL53L0X" matches the argument list in "main.cpp"

Here's how the library header file defines the constructor:

VL53L0X(DevI2C &i2c, DigitalOut &pin, PinName pin_gpio1, uint8_t dev_addr = DEFAULT_DEVICE_ADDRESS) : _dev_i2c(&i2c),_gpio0(&pin)

My main.c code (being concise):

DevI2C *device_i2c = new DevI2C(p0, p1);
DigitalOut sensorpin(p3);
PinName myoutpin;

//compile error here - doesn't like my arguments
VL53L0X mySensor(device_i2c, sensorpin, myoutpin, DEFAULT_DEVICE_ADDRESS); 

//VL53L0X mySensor(device_i2c, sensorpin, myoutpin, 0x52); //also does not compile, same error

Compiler does not like my arguments in the constructor, and I don't see which argument is causing the problem. The header file defines the arguments to be an I2C object, a DigitalOut, a Pinname, and an int. I think I have those. What am I not seeing?

Related