How to override constructor variables in a library? [SOLVED]


#1

The library SparkFunBME280 contains the folowing code in SparkFunBME280.cpp:

//Constructor -- Specifies default configuration
BME280::BME280( void )
{
	//Construct with these default settings if nothing is specified

	//Select interface mode
	settings.commInterface = I2C_MODE; //Can be I2C_MODE, SPI_MODE
	//Select address for I2C.  Does nothing for SPI
	settings.I2CAddress = 0x77; //Ignored for SPI_MODE
	//Select CS pin for SPI.  Does nothing for I2C
	settings.chipSelectPin = 10;
	settings.runMode = 0;
	settings.tempOverSample = 0;
	settings.pressOverSample = 0;
	settings.humidOverSample = 0;

}

Could someone please tell me how to change the value of settings.I2CAddress in my own code? By default it is set to 0x77 but my chip uses 0x76. I tried saying

bme.SensorSettings.I2CAddress = 0x76 ;

(where “bme” is the object I created) but that’s apparently wrong. I understand that this is probably something really basic that any C programmer would know, but I’m not a C programmer. Thanks.

Update: Never mind. After much trial and error, I discovered the proper syntax is:

bme.settings.I2CAddress = 0x76 ;


#2

Thank you for posting your solution!