Coder Social home page Coder Social logo

rm-hull / luma.oled Goto Github PK

View Code? Open in Web Editor NEW
786.0 31.0 162.0 21.2 MB

Python module to drive a SSD1306 / SSD1309 / SSD1322 / SSD1325 / SSD1327 / SSD1331 / SSD1351 / SH1106 OLED

Home Page: https://luma-oled.readthedocs.io

License: MIT License

Python 100.00%
python raspberry-pi oled ssd1306 sh1106 ssd1325 ssd1322 ssd1331 spi i2c

luma.oled's Introduction

luma.core | luma.docs | luma.emulator | luma.examples | luma.lcd | luma.led_matrix | luma.oled

luma.oled

Display drivers for SSD1306 / SSD1309 / SSD1322 / SSD1325 / SSD1327 / SSD1331 / SSD1351 / SSD1362 / SH1106 / SH1107 / WS0010

image

image

image

image

image

Python 3 library interfacing OLED matrix displays with the SSD1306, SSD1309, SSD1322, SSD1325, SSD1327, SSD1331, SSD1351, SH1106, SH1107 or WS0010 driver using I2C/SPI/Parallel on the Raspberry Pi and other linux-based single-board computers - it provides a Pillow-compatible drawing canvas, and other functionality to support:

  • scrolling/panning capability,
  • terminal-style printing,
  • state management,
  • color/greyscale (where supported),
  • dithering to monochrome

Documentation

Full documentation with installation instructions and examples can be found on https://luma-oled.readthedocs.io.

A list of tested devices can be found in the wiki.

The display pictured below is a SSD1306 (128 x 64 pixels), and the board is tiny enough to fit inside the RPi case.

mounted

ssd1322

As well as display drivers for various physical OLED devices, there are emulators that run in real-time (with pygame) and others that can take screenshots, or assemble animated GIFs, as per the examples below (source code for these is available in the luma.examples git repository:

clock

invaders

crawl

Upgrade

Version 2.0.0 was released on 11 January 2017: this came with a rename of the github project from ssd1306 to luma.oled to reflect the changing nature of the codebase.

Some core functionality has been moved out to another git repository, luma.core: this has enabled another project to have a facelift: pcd8544 has now been reborn as luma.lcd: the same API can now be used across both projects. Likewise max7219 has been renamed to luma.led_matrix so it can also take advantage of the common API.

The consequence is that any existing code that uses the old ssd1306 package will need to be updated. The changes should be limited to altering import statements only, and are described in the upgrade documentation.

License

The MIT License (MIT)

Copyright (c) 2014-2023 Richard Hull and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

luma.oled's People

Contributors

7754359337 avatar bjerrep avatar boeeerb avatar dhrone avatar doug-burrell avatar ed-french avatar eudoxos avatar fragfutter avatar gadgetoid avatar georgeharker avatar gh123man avatar gsmecher avatar leragequit avatar quicksanddesignstudio avatar rm-hull avatar rogerdahl avatar sharkusk avatar spotlightkid avatar thijstriemstra avatar vpetrigo avatar vxgeeks avatar wjgeorge avatar xes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

luma.oled's Issues

Support 3-wire SPI

From the docs "Supporting 3-wire SPI would be trivial but has not been implemented yet (no devices to test with)."

Extend perfloop.py example to show FPS

perfloop.py currently just shows the transit time through the display() method with a prebuilt image. This is useful for performance testing & regression.

It would be good to measure the FPS in this code and keep a record (or a league table) of the different frame rates of different devices. The table should probably be maintained in the doc/ directory somewhere and included in the index.

PyQt emulator

Being able to produce ImageQt objects and rendering and previewing them in a Qt application would be cool.

The actual emulator should be a QWidget, or wrapped in a QWidget, so it can be re-used in other applications.

Add doc images directory

Let's move all images in the doc directory into doc/images. This will break existing references to these images (on PyPi for example, but also in the docs of course) so this should be done shortly before a new release.

SSD1306 and SH1106 compatibility

Hi! Thank you for this nice piece of software!
I'm trying to use this to drive an SH1106 with a cubie board but i should change it a little bit since
the only thing i can obtain now is some line and a display filled with noise just like in the image here:
adafruit/Adafruit_SSD1306#14

The SH1106 controller has an internal RAM of 132x64 pixel (while the SSD1306 has 128x64 pixel).
It seems, that the 128x64 OLED is centered in most cases within the 132x64 area, that means pixel (2,0) in ram is pixel (0,0) on the display.
Now ebay is filled with these oled displays (often with an unclear description saying SH1106/SSD1306) and after digging a lot on the web, i have found there is now way to use them with a raspberry or a cubie board.
Do you think you could give me some help or add an option to support both display models?

Ref:
http://forum.arduino.cc/index.php?topic=265557.0
http://forum.arduino.cc/index.php?topic=256374.0
http://www.mikrokontroler.pl/system/files/SH1106.PDF

Add mock smbus object & unit tests

Along the lines of #17 (comment), but should capture the stream of commands and data.

Add tests, esp. capture current behaviour of SH1106 driver so that it can be refactored & optimized like the ssd1306 driver has been

Publish docs

ssd1306.readthedocs.io?

I'll add a PR for linking the readme into the docs etc.

96x16 support

Hello!

Please help with I2C SainSmart 96x16 display (0.69).
I can use your program to display out the text, but I need to shift down Y coordinate.
Text is visible if I use this parameters (example):

font = ImageFont.truetype('/usr/share/fonts/truetype/droid/DroidSans.ttf', 16)
draw.text((0, 36), "1234567890", font=font, fill=255)

But text is corrupted at bottom line (about 2 pixels is absent).
I can send photo if it needs.

Use enum package for constants

instead of re-inventing the wheel, let's port the constants in this package to the enum package (available in py>=3.4 and a backport for py2).

Add changelog

CHANGES.rst would be useful (also add to MANIFEST.in).

Blank Canvas

Hello,

thank you very much for this nice piece of Software. I use it with Banana Pi and a SainSmart Display.
Since i`ve got no experience with python and programming in general, i stuck at one thing. It would be nice if you can wrote me a little example eg. the command to flush the canvas.

P.S.: Forgive my bad english, it`s not my native language. :x

Move fonts

AFAIK the fonts are only used in the examples so let's move the fonts in the examples directory. If there's a dependency on a font in the library itself I suggest moving the fonts into the package itself. MANIFEST.in doesn't include the fonts right now so some of the examples will be broken (unless it's moved into the examples directory).

Error while using custom code

Hi!

I'm trying to use your library to show the temp raspi2 and I made my custom code to do it... and it doesn't work.

It throws a traceback:
Traceback (most recent call last): File "cpuTemp_oled.py", line 35, in <module> draw.text((margin,margin),cpuTemp,font=fontName,fill=255) File "/usr/lib/python2.7/dist-packages/PIL/ImageDraw.py", line 271, in text mask = font.getmask(text, self.fontmode) SystemError: error return without exception set

I've tried the examples in the library and it works like a charm (Except for sys info, that as far as I know, needs to have another dependences installed.

What can I do?

pygame requires extra system dependency

Because pygame is a dependency an extra dependency is required, because the installation fails with:

Running pygame-1.9.2rc1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Lxwqwp/pygame-1.9.2rc1/egg-dist-tmp-Td5P4G


WARNING, No "Setup" File Exists, Running "config.py"
Using UNIX configuration...


Hunting dependencies...
sh: 1: sdl-config: not found
sh: 1: sdl-config: not found
sh: 1: sdl-config: not found
WARNING: "sdl-config" failed!
error: Setup script exited with Unable to run "sdl-config". Please make sure a development version of SDL is installed.

I'd really prefer not to define it in setup.py because I don't need it and it's causing problems like this. If it's optional than people can install these extra dependencies, inc. pygame.

example code

The original code used as an example in README.md:
draw.text(30, 40, "Hello World", font=font, fill=255)
caused the following error:
TypeError: text() got multiple values for keyword argument 'fill'

This change worked for me:
draw.text((30, 40), "Hello World", font=font, fill=255)

(BTW, thank you for creating the repo. I'm using it as a base to learn my oled)

Performance

Hello,

I'm just installed the Library and I must say, it works very well! The only question I have is regarding its performance... the sys_info.py example takes around 1s of CPU time:

localhost ~/ssd1306/examples $ time python sys_info.py
real 0m1.416s
user 0m1.060s
sys 0m0.100s

I'm running it on RPI B+ and got Python 2.7 and PIL compiled by myself. I've never used the PIL library, but so I can't tell if the bottle neck is the image draw or the i2c communication.

Does anyone experience the same?

Cheers!

Weird image after initializing ssd1306

Hi everyone,

i'm getting pixel everywhere after initializing with this code:

from oled.device import ssd1306
from oled.render import canvas
from PIL import ImageFont, ImageDraw

device = ssd1306(port=1, address=0x3C)

After using one of the examples i'm getting the same image...
I'm afraid my ssd1306 is broken :(

Hope some could help me.
20161113_105925

ImportError: no module named device

I followed your instructions to the T to get everything installed, but I'm running into a problem whenever I try to use the library. On the first line from oled.device import ..., the python interpreter throws an ImportError saying that it cannot find the module named device. However, if I go to the directory where python modules are installed, I can see oled in the list, and it definitely contains a module called device. What could be the problem?

OO Driver Usage

Hello,

I'm attempting to use the driver using objects.
The problem I am facing is I have my own class that encapsulates calls to the driver, within this class I want to have an instance attribute for the driver and a function that updates the display using the driver instance attribute. However when running the application I get an inappropriate ioctl exception:

File "/usr/local/lib/python2.7/dist-packages/oled/render.py", line 74, in __exit__
 self.device.display(self.image)
File "/usr/local/lib/python2.7/dist-packages/oled/device.py", line 191, in display
 const.PAGEADDR,   0x00, self.pages-1)  # Page start/end address
File "/usr/local/lib/python2.7/dist-packages/oled/device.py", line 73, in command
 self.bus.write_i2c_block_data(self.addr, self.cmd_mode, list(cmd))
IOError: [Errno 25] Inappropriate ioctl for device

The only way I can get it to work is if I create the driver instance in the function rather than in the constructor and reusing it. This is of course inefficient as every time the display is updated a new ssd1306 instance is created.

from oled.device import ssd1306
from oled.render import canvas
from PIL import ImageFont, ImageDraw

class Display:
    def __init__(self):
        self.device = ssd1306(port=1, address=0x3C)
        self.font = ImageFont.load_default()

    def display(self):
        with canvas(self.device) as draw:
            draw.text((0, 0), "Hello World!", font=self.font, fill=255)

Thanks,
George

Ability to Clear Display Before Drawing New Text

I have one of the 4 pin 1.3" OLED(SS1106) and I am trying to find out if there is a way to clear the display before writing text to it. I may be blind but I am just not seeing a way to do that.

Examples issue

Using latest master with py3.4:

$ python maze.py -i spi
Traceback (most recent call last):
  File "maze.py", line 9, in <module>
    from demo_opts import device
  File "/home/pi/projects/pi-test/ssd1306/examples/demo_opts.py", line 41, in <module>
    bcm_RST=args.bcm_reset)
  File "/home/pi/projects/pi-test/ssd1306/oled/serial.py", line 80, in __init__
    self._spi.open(port, device)
AttributeError: 'module' object has no attribute 'open'

Anything else to do? :)

@rm-hull @thijstriemstra Thanks for all the work you've done over the last few days! I have time to chip in now, but it seems you guys have it well in hand. If there's anything you'd like me to take a look at, just create an issue and assign it to me.

sys_info.py - ImportError: The _imagingft C module is not installed

I am using minibian on a RPi3 and followed your instruction until the installation of pillow failed. So I used
apt-get install libjpeg-dev zlib1g-dev and tried the installation of pillow again with pip3 install pillow, this time with success as python3 demo.py and python3 maze.py both worked fine. Trying to run sys_info.py however yielded the following result:

Traceback (most recent call last): File "sys_info.py", line 77, in <module> main() File "sys_info.py", line 74, in main stats(oled) File "sys_info.py", line 65, in stats font2 = ImageFont.truetype('../fonts/C&C Red Alert [INET].ttf', 12) File "/usr/local/lib/python3.4/dist-packages/PIL/ImageFont.py", line 239, in truetype return FreeTypeFont(font, size, index, encoding) File "/usr/local/lib/python3.4/dist-packages/PIL/ImageFont.py", line 128, in __init__ self.font = core.getfont(font, size, index, encoding) File "/usr/local/lib/python3.4/dist-packages/PIL/ImageFont.py", line 37, in __getattr__ raise ImportError("The _imagingft C module is not installed") ImportError: The _imagingft C module is not installed

Random pixels with ssd1306 (Adafruit 128x32)

I am using the current git, running on Odroid-C2. The device is Adafruit 931. Display on/off works fine, but pixels shown are random. This is the command I use:

python3 demo.py --width 128 --height 32 -d ssd1306 -i i2c --i2c-port 2 --i2c-address 60

The pixel pattern is not changing while any example runs (including those which should, I guess, be moving, such as clock.py), and actually is always the same whatever runs. I can give more diagnostics if needed, now I just think ssd1306 is writing to some other place in memory as what is shown does not change at all.

random pixels

Possily related to #26.

Thank you!!!

This isn't a bug. I just wanted to thank you for creating this repo and writing such a wonderful README. I'm just learning how to hack with hardware, and this was an excellent resource!

God bless.

No module named oled.device

Hi, I'm trying to use your code to run my OLED 0.96" display. However, when I run the demo.py I got this error :

Traceback (most recent call last):
File "demo.py", line 6, in <module>
   from demo_opts import device
File "/home/pi/ssd1306/examples/demo_opts.py", line 31, in <module>
   import oled.device
ImportError: No module named oled.device

Do you know what should I do for that ? I've juste cloned your code to my pi in /home/pi/ssd1306 and made no modification.

thanks in advance.

Victor

Move most of README's content to Sphinx docs

Having the documentation in the Sphinx doc directory allows you to link to and document the code. I'd suggest to minimize the documentation in the main README.rst and move (and perhaps split into multiple docs) the bulk of the information to the doc directory. This will be published on readthedocs.io (and should be linked to from the README).

Add viewport functionality

[thinking out loud]

Currently the display device only allows for a drawable canvas which is exactly the same size (in pixels) as the physical device.

Add a viewport device which is composed of a virtual canvas that can be sized arbitrarily, and a physical device. It should adhere to the same interface as ssd1306, but additionally have a method/attribute called position that takes an (x,y) tuple. When viewport.display() is invoked (either with with canvas(virtual) as draw or directly) it updates its underlying virtual image storage, but invokes the physical device to display a portion of the virtual image at the position offset to cover the full size of the phyiscal display.

Likewise when viewport.position = (x,y) is invoked, it should re-trigger a refresh on the physical device at the new position offset.

Example

from oled.device import viewport, ssd1306

virtual = viewport(ssd1306(...), width=1024, height=768)

# initial position is 0,0 - draw text & flush immediately - should show 'hello world'
with canvas(virtual) as draw:
    draw.rectangle((0, 0, 127, 63), outline="white")
    draw.text((10, 10), text="hello world", fill="white")
    draw.text((138, 10), text="the end", fill="white")

# update the viewport one position to the right, causing a refresh, 
# giving a scroll effect to the left
for x in range(128):
    virtual.position = (x, 0)
    time.sleep(0.05) 

# at this point 'the end' will've scrolled into view, and after 2 seconds, 
# underneath that, 'thank you'
time.sleep(2)
with canvas(virtual) as draw:
    draw.text((138, 40), text="Thank you", fill="white")

Considerations

  • what happens if you specify a position outside of the virtual canvas?
  • should the virtual canvas wrap round?

Skewed text with 128x32 OLED

I'm testing with a 128x32 OLED and when running the sys_info demo for example, the text is unreadable. The logo example shows a stretched logo. Is there possibly an error in the width/height calculation of the ssd1306 device?

SPI OLED with 7 pins

One of these 128 x 64 displays arrived but it has 7 pins and it's not clear to me where the SCL and SCA pins are.. Any idea?

Pip installation problem

I installed v1.0.0 from pip and I'm seeing this error:

$ python
Python 3.5.2 (default, Oct 24 2016, 02:11:59) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssd1306
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'ssd1306'
>>> 

But it's actually installed:

$ pip list
...
SQLAlchemy (1.0.15)
ssd1306 (1.0.0)
tabulate (0.7.7)
...
$ pip install ssd1306
Collecting ssd1306
  Downloading ssd1306-1.0.0.tar.gz (2.3MB)
    100% |████████████████████████████████| 2.3MB 219kB/s 
Requirement already satisfied: pillow in /home/foo/.virtualenvs/bar/lib/python3.5/site-packages (from ssd1306)
Requirement already satisfied: smbus2 in /home/foo/.virtualenvs/bar/lib/python3.5/site-packages (from ssd1306)
Requirement already satisfied: spidev in /home/foo/bar/spidev (from ssd1306)
Requirement already satisfied: RPi.GPIO in /home/foo/.virtualenvs/bar/lib/python3.5/site-packages (from ssd1306)
Collecting pygame (from ssd1306)
  Downloading pygame-1.9.2rc1-cp35-cp35m-manylinux1_x86_64.whl (10.0MB)
    100% |████████████████████████████████| 10.0MB 127kB/s 
Building wheels for collected packages: ssd1306
  Running setup.py bdist_wheel for ssd1306 ... done
  Stored in directory: /home/foo/.cache/pip/wheels/05/c6/7a/5a8e80c710167ca0c3cb74ddb082521e0d085cf24c006adb3b
Successfully built ssd1306
Installing collected packages: pygame, ssd1306
Successfully installed pygame-1.9.2rc1 ssd1306-1.0.0

Looks like there aren't any source files installed at all:

$ ls -lha /home/foo/.virtualenvs/bar/lib/python3.5/site-packages/ssd1306-1.0.0.dist-info
total 44K
drwxrwxr-x   2 foo foo 4,0K dec  5 21:55 .
drwxrwxr-x 132 foo foo  12K dec  5 21:55 ..
-rw-rw-r--   1 foo foo 2,6K dec  5 21:55 DESCRIPTION.rst
-rw-rw-r--   1 foo foo    4 dec  5 21:55 INSTALLER
-rw-rw-r--   1 foo foo 3,6K dec  5 21:55 METADATA
-rw-rw-r--   1 foo foo 1,3K dec  5 21:55 metadata.json
-rw-rw-r--   1 foo foo 1,3K dec  5 21:55 RECORD
-rw-rw-r--   1 foo foo    5 dec  5 21:55 top_level.txt
-rw-rw-r--   1 foo foo   96 dec  5 21:55 WHEEL

smbus OSError when device is not connected

When you try to create a new device, and it's not connected, you'll get a cryptic traceback, e.g.:

File ":/oled/device.py", line 179, in __init__
File ":/oled/device.py", line 73, in command
File ":/smbus/util.py", line 59, in validator
File ":/smbus/smbus.py", line 275, in write_i2c_block_data
OSError: 5

Are you seeing this as well? Can a less cryptic, more usable error be raised here?

Testing bug fix on SH1106 device

Hi @xes,

I pushed some bug fixes and added some more examples (see 08317bc) - can you run them against your SH1106 device to confirm the changes I made have worked OK?

There was a bug in rendering images (I think i made an assumption pixels were either 255 or 0, but 1-bit images like the pi_logo example are 0 or 1).

Anyway, there's now a setup.py which you could try testing against if you dont mind please.

P.s. I guess you'll neeed to edit the example files to reassign the correct device class.

Failing tests on Python 3.5

On Ubuntu 16.04 with Python 3.5.2. This isn't the target platform obviously but I still think the tests should either skip or succeed.

============================================================= FAILURES ==============================================================
_________________________________________________________ test_i2c_cleanup __________________________________________________________

    def test_i2c_cleanup():
        serial = i2c(bus=smbus, address=0x9F)
        serial.cleanup()
>       smbus.close.assert_called_once()

tests/test_serial.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Mock name='mock.close' id='139995073637848'>, name = 'assert_called_once'

    def __getattr__(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
            raise AttributeError(name)
        if not self._mock_unsafe:
            if name.startswith(('assert', 'assret')):
>               raise AttributeError(name)
E               AttributeError: assert_called_once

/usr/local/lib/python3.5/unittest/mock.py:583: AttributeError
_________________________________________________________ test_spi_cleanup __________________________________________________________

    def test_spi_cleanup():
        serial = spi(gpio=gpio, spi=spidev, port=9, device=1)
        serial.cleanup()
        verify_spi_init(9, 1)
>       spidev.close.assert_called_once()

tests/test_serial.py:109: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Mock name='mock.close' id='139995073628592'>, name = 'assert_called_once'

    def __getattr__(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
            raise AttributeError(name)
        if not self._mock_unsafe:
            if name.startswith(('assert', 'assret')):
>               raise AttributeError(name)
E               AttributeError: assert_called_once

/usr/local/lib/python3.5/unittest/mock.py:583: AttributeError
___________________________________________________________ test_display ____________________________________________________________

    def test_display():
        device = sh1106(serial)
        serial.reset_mock()
    
        recordings = []
    
        def data(data):
            recordings.append({'data': data})
    
        def command(*cmd):
            recordings.append({'command': list(cmd)})
    
        serial.command = Mock(side_effect=command)
        serial.data = Mock(side_effect=data)
    
        # Use the same drawing primitives as the demo
        with canvas(device) as draw:
            baseline_data.primitives(device, draw)
    
>       serial.data.assert_called()

tests/test_sh1106.py:35: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Mock name='mock.data' id='139995111772848'>, name = 'assert_called'

    def __getattr__(self, name):
        if name in {'_mock_methods', '_mock_unsafe'}:
            raise AttributeError(name)
        elif self._mock_methods is not None:
            if name not in self._mock_methods or name in _all_magics:
                raise AttributeError("Mock object has no attribute %r" % name)
        elif _is_magic(name):
            raise AttributeError(name)
        if not self._mock_unsafe:
            if name.startswith(('assert', 'assret')):
>               raise AttributeError(name)
E               AttributeError: assert_called

/usr/local/lib/python3.5/unittest/mock.py:583: AttributeError

Create document with devices that work

We all have devices that worked and when you're starting out with these displays, having a list of devices that are confirmed to work is a great help. I suggest putting it in the wiki (and make it public to edit) but I'm not sure if it's possible to add images there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.