I feel like I'm missing something obvious here and need it pointed out. I'm trying to create an instance of a struct that's a member of a class contained within a library that's been included in the current file, but inside a class I've defined myself. If I do this outside of the class, it works, but inside the class it appears to try to instantiate the struct as if it was a member of the parent class it's in.
The library is for a BME280 sensor and the struct is to pass chip settings to the constructor of the main class that drives the sensor. Not even sure how to word this problem, but hopefully the code illustrates what I'm trying to say.
If I instantiate this struct outside of a class it works fine,
#include <BME280I2C.h>
// BME280 sensor settings
BME280I2C::Settings settings(
BME280::OSR_X16,
BME280::OSR_X16,
BME280::OSR_X16,
BME280::Mode_Forced,
BME280::StandbyTime_1000ms,
BME280::Filter_Off,
BME280::SpiEnable_False,
BME280I2C::I2CAddr_0x76 // I2C address. I2C specific.
);
class UsermodBME280 : public Usermod {
private:
BME280I2C bme(settings);
};
but if I try to do this within the class it seems to try and instantiate the struct as if it was a member of the UsermodBME280
class itself.
#include <BME280I2C.h>
class UsermodBME280 : public Usermod {
private:
// BME280 sensor settings
BME280I2C::Settings settings(
BME280::OSR_X16,
BME280::OSR_X16,
BME280::OSR_X16,
BME280::Mode_Forced,
BME280::StandbyTime_1000ms,
BME280::Filter_Off,
BME280::SpiEnable_False,
BME280I2C::I2CAddr_0x76 // I2C address. I2C specific.
);
BME280I2C bme(settings);
};
IntelliSense illustrates what I mean: https://i.stack.imgur.com/14ql5.png
Can I do this? If so, what am I doing wrong?