Skip to content

Commit

Permalink
Use smbus2 - fixes #28
Browse files Browse the repository at this point in the history
No noticeable performance impact of using smbus2 over sambas
  • Loading branch information
rm-hull committed Nov 15, 2016
1 parent 8a7080c commit 0643590
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ Then add your user to the i2c group::

Install some packages (python2)::

$ sudo apt-get install i2c-tools python-smbus python-pip libfreetype6-dev libjpeg8-dev
$ sudo apt-get install i2c-tools python-pip libfreetype6-dev libjpeg8-dev
$ sudo pip install pillow

or (python3)::

$ sudo apt-get install i2c-tools python3-smbus python3-pip libfreetype6-dev libjpeg8-dev
$ sudo apt-get install i2c-tools python3-pip libfreetype6-dev libjpeg8-dev
$ sudo pip3 install pillow

Next check that the device is communicating properly (if using a rev.1 board,
Expand Down
4 changes: 2 additions & 2 deletions oled/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
# As before, as soon as the with block completes, the canvas buffer is flushed
# to the device

import smbus
import smbus2
from PIL import Image


Expand All @@ -62,7 +62,7 @@ class device(object):
def __init__(self, bus=None, port=1, address=0x3C, cmd_mode=0x00, data_mode=0x40):
self.cmd_mode = cmd_mode
self.data_mode = data_mode
self.bus = bus or smbus.SMBus(port)
self.bus = bus or smbus2.SMBus(port)
self.addr = address

def command(self, *cmd):
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pillow
pillow
smbus2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
url = "https://github.com/rm-hull/ssd1306",
download_url = "https://github.com/rm-hull/ssd1306/tarball/0.3.2",
packages=['oled'],
install_requires = ["pillow"],
install_requires = ["pillow", "smbus2"],
classifiers = [
"License :: OSI Approved :: MIT License",
"Development Status :: 4 - Beta",
Expand Down

0 comments on commit 0643590

Please sign in to comment.