Open maubuz opened 2 years ago
Hello,
Could you please refer to the code here in "beta" branch for i2c.py and try again? https://github.com/Seeed-Studio/grove.py/commit/994c0467fe1e40b94e597536ab7760381b51cf2c#diff-52f36dd5ac4814c063e9adea411aa5764d3c963850457d2a022155f7172ada9c
Also test with this code in "beta" branch: https://github.com/Seeed-Studio/grove.py/blob/beta/grove/i2c.py
Thank you
I know it's been a long time but thanks for the suggestions. I tested the two suggestions and they both work in my case. Any ideas of when that code would be merged with master
?
For those interested in getting this package working with multiple i2c buses immediately, as proposed by @nikolozka in #12 , I suggest the following changes in grove/i2c.py
:
Modify lines 50 and 51:
if not Bus.instance:
Bus.instance = smbus.SMBus(bus)
To:
if not self.instance:
self.instance = smbus.SMBus(bus)
To find where grove/i2c.py
is installed, try pip show grove.py
.
PR #66 created. Feel free to reject if upcoming changes make this obsolete.
This issue was reported by @nikolozka in Issue #12.
The issue is still in the code and I would like to submit a PR for it, however, I'm trying to understand the reasoning behind this.
Why is
instance
being used as a class attribute? It effectively makes theBus
class a singleton class. Are there any advantages to doing this that I'm missing?To reproduce this problem: