Compile for multiple DeviceOS versions

I would like to do the following but at compile time using #ifdef.

Is there a way to tell the compiler the deviceOS version.

the online compiler uses the “–target x.x.x” option, so how to we get that flag into the code?

	if (System.versionNumber() < 0x001050000) {
		Wire.beginTransmission(MCP23017_ADDRESS | i2caddr);
	}
	else {
		Wire.beginTransmission(WireTransmission(MCP23017_ADDRESS | i2caddr).timeout(100));
	}

Heres what I would like. (psuedo code)

	#ifdef DEVICEOS < 0x001050000
		Wire.beginTransmission(MCP23017_ADDRESS | i2caddr);
    #else
		Wire.beginTransmission(WireTransmission(MCP23017_ADDRESS | i2caddr).timeout(100));
	#endif

Thanks
Marshall

always the way, you post, then find the answer!

https://docs.particle.io/reference/device-os/firmware/electron/#checking-for-features

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.