Closed zaforic closed 4 years ago
also hit this issue... thanks for reporting it or I would still be stuck. after replacing /usr/local/lib/python3.5/dist-packages/Adafruit_SSD1306/SSD1306.py with the git version i was up and running.
curl https://raw.githubusercontent.com/adafruit/Adafruit_Python_SSD1306/master/Adafruit_SSD1306/SSD1306.py > /usr/local/lib/python3.5/dist-packages/Adafruit_SSD1306/SSD1306.py
Please update your pip package so your users have a clean experience!
hiya, this library is being deprecated - we have a similar library that works with Python3 and modern linux computers. please check out this guide for more info https://learn.adafruit.com/monochrome-oled-breakouts/python-wiring
Platform/operating system (i.e. Raspberry Pi with Raspbian operating system, Windows 32-bit, Windows 64-bit, Mac OSX 64-bit, etc.):
Raspbian: Linux ##### 4.9.61-v7+ #1049 SMP Fri Nov 10 15:32:51 GMT 2017 armv7l GNU/Linux Distributor ID: Raspbian Description: Raspbian GNU/Linux 9.1 (stretch) Release: 9.1 Codename: stretch
Python version (run
python -version
orpython3 -version
):pip: 9.0.1 python: 2.7.13
Error message you are receiving, including any Python exception traces:
disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST)
File "/usr/local/lib/python2.7/dist-packages/Adafruit_SSD1306/SSD1306.py", line 285, in init
gpio, spi, i2c_bus, i2c_address, i2c)
File "/usr/local/lib/python2.7/dist-packages/Adafruit_SSD1306/SSD1306.py", line 88, in init
self._gpio.setup(self._rst, GPIO.OUT)
File "/usr/local/lib/python2.7/dist-packages/Adafruit_GPIO/GPIO.py", line 188, in setup
pull_up_down=self._pud_mapping[pull_up_down])
ValueError: Channel must be an integer or list/tuple of integers
Traceback (most recent call last): File "stats.py", line 29, in
List the steps to reproduce the problem below (if possible attach code or commands to run):
pip install Adafruit-GPIO Adafruit-SSD1306 apt-get install python-pilkit apt-get install python-imaging
Run the script below and you will get the error message. I replaced the SSD1306.py script with the one from this repo and everything works. It appears the pip repo is out of date from this repo.
** CODE ***** import time import Adafruit_GPIO.SPI as SPI import Adafruit_SSD1306 import subprocess import signal import sys
from PIL import Image from PIL import ImageDraw from PIL import ImageFont
def signal_term_handler(signal, frame): disp.command(Adafruit_SSD1306.SSD1306_DISPLAYOFF) sys.exit(0)
Setup Signal Handler
signal.signal(signal.SIGTERM, signal_term_handler)
Raspberry Pi pin configuration:
RST = None # on the PiOLED this pin isnt used
Note the following are only used with SPI:
DC = 23 SPI_PORT = 0 SPI_DEVICE = 0
128x32 display with hardware I2C:
disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST)
Initialize library.
disp.begin()
Clear display.
disp.clear() disp.display()
Create blank image for drawing.
width = disp.width height = disp.height image = Image.new('1', (width, height))
Get drawing object to draw on image.
draw = ImageDraw.Draw(image)
Draw a black filled box to clear the image.
draw.rectangle((0,0,width,height), outline=0, fill=0)
Draw some shapes.
padding = -2 top = padding bottom = height-padding x = 0
Load default font.
font = ImageFont.load_default()
try: while True:
except KeyboardInterrupt: disp.command(Adafruit_SSD1306.SSD1306_DISPLAYOFF)