Skip to content

Commit

Permalink
Switch from smbus to smbus2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Oct 30, 2023
1 parent fdf941e commit 0e21bc7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions i2cdevice/__init__.py
Expand Up @@ -162,8 +162,8 @@ def __init__(self, i2c_address, i2c_dev=None, bit_width=8, registers=None):
self._i2c = i2c_dev

if self._i2c is None:
import smbus
self._i2c = smbus.SMBus(1)
import smbus2
self._i2c = smbus2.SMBus(1)

for register in registers:
self.locked[register.name] = False
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Expand Up @@ -36,7 +36,9 @@ classifiers = [
"Topic :: Software Development :: Libraries",
"Topic :: System :: Hardware",
]
dependencies = []
dependencies = [
"smbus2"
]

[project.urls]
GitHub = "https://www.github.com/pimoroni/i2cdevice-python"
Expand Down Expand Up @@ -111,6 +113,6 @@ ignore = [
]

[tool.pimoroni]
apt_packages = ["python3-rpi.gpio", "python3-smbus"]
apt_packages = []
configtxt = []
commands = []
2 changes: 1 addition & 1 deletion tests/test_defaultbus.py
Expand Up @@ -8,7 +8,7 @@ class SMBus():


def test_smbus_io():
sys.modules['smbus'] = SMBus
sys.modules['smbus2'] = SMBus
device = Device(0x00, i2c_dev=None, registers=(
Register('test', 0x00, fields=(
BitField('test', 0xFF),
Expand Down

0 comments on commit 0e21bc7

Please sign in to comment.