194
« on: August 17, 2016, 04:08:43 pm »
Not as such,
I'm trying to create a persistent I2C object (persists between timed events). But I can't get it to work.
The object works if you create it in the event. If you create it at boot (or any other time), it doesn't work in Shared Events (resets). I was looking at memory to see what was happening, but maybe got lead astray by the "odd memory behavior".
So ignoring weird memory things, how do you create a shared I2C object, that can be used in a Shared event without having to re-create it every time?
If I re-create it every time, then everything that is stored in the I2c module (calibration factors etc) have to be re-read into local variables each time you want to read the sensor. You also have to set up the resolution, filtering, period, etc. etc. Not really the point of a class.
I should be able to do this once (when the instance of the class is created as an object (in New)), then just call the readTemperature() method to read the I2C register and calculate the temperature or whatever.
I don't want to have to create a new object every time I want to read anything over I2C.
If I make everything Shared (ie don't use Public/Private at all), and don't create an instance of the object, it works - but then you can only use it for one sensor...
Any Suggestions?