Skip to content

Commit

Permalink
Fix mutable default parameter bug when using multiple displays (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
rm-hull committed Nov 15, 2020
1 parent ba68dc6 commit 950ef97
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -4,6 +4,8 @@ ChangeLog
+------------+---------------------------------------------------------------------+------------+
| Version | Description | Date |
+============+=====================================================================+============+
| **3.8.1** | * Fix mutable default parameter bug when using multiple displays | 2020/11/15 |
+------------+---------------------------------------------------------------------+------------+
| **3.8.0** | * Improved diff_to_previous framebuffer performance | 2020/11/06 |
+------------+---------------------------------------------------------------------+------------+
| **3.7.0** | * Drop support for Python 3.5, only 3.6 or newer is supported now | 2020/10/25 |
Expand Down
16 changes: 8 additions & 8 deletions luma/oled/device/__init__.py
Expand Up @@ -40,7 +40,7 @@
from luma.oled.device.color import color_device
from luma.oled.device.greyscale import greyscale_device
import luma.core.error
from luma.core.framebuffer import diff_to_previous, full_frame
from luma.core.framebuffer import full_frame
from luma.core.bitmap_font import embedded_fonts
import luma.oled.const
from luma.oled.device.framebuffer_mixin import __framebuffer_mixin
Expand Down Expand Up @@ -274,7 +274,7 @@ class ssd1331(color_device):
"""

def __init__(self, serial_interface=None, width=96, height=64, rotate=0,
framebuffer=diff_to_previous(), **kwargs):
framebuffer=None, **kwargs):
super(ssd1331, self).__init__(serial_interface, width, height, rotate,
framebuffer, **kwargs)

Expand Down Expand Up @@ -356,7 +356,7 @@ class ssd1351(color_device):
"""

def __init__(self, serial_interface=None, width=128, height=128, rotate=0,
framebuffer=diff_to_previous(), h_offset=0, v_offset=0,
framebuffer=None, h_offset=0, v_offset=0,
bgr=False, **kwargs):

# RGB or BGR order
Expand Down Expand Up @@ -451,7 +451,7 @@ class ssd1322(greyscale_device):
"""

def __init__(self, serial_interface=None, width=256, height=64, rotate=0,
mode="RGB", framebuffer=diff_to_previous(), **kwargs):
mode="RGB", framebuffer=None, **kwargs):
self._column_offset = (480 - width) // 2
super(ssd1322, self).__init__(luma.oled.const.ssd1322, serial_interface,
width, height, rotate, mode, framebuffer,
Expand Down Expand Up @@ -534,7 +534,7 @@ class ssd1362(greyscale_device):
"""

def __init__(self, serial_interface=None, width=256, height=64, rotate=0,
mode="RGB", framebuffer=diff_to_previous(), **kwargs):
mode="RGB", framebuffer=None, **kwargs):
super(ssd1362, self).__init__(luma.oled.const.ssd1362, serial_interface,
width, height, rotate, mode, framebuffer,
nibble_order=1, **kwargs)
Expand Down Expand Up @@ -669,7 +669,7 @@ class ssd1325(greyscale_device):
"""

def __init__(self, serial_interface=None, width=128, height=64, rotate=0,
mode="RGB", framebuffer=diff_to_previous(), **kwargs):
mode="RGB", framebuffer=None, **kwargs):
super(ssd1325, self).__init__(luma.core.const.common, serial_interface,
width, height, rotate, mode, framebuffer,
nibble_order=1, **kwargs)
Expand Down Expand Up @@ -717,7 +717,7 @@ class ssd1327(greyscale_device):
"""

def __init__(self, serial_interface=None, width=128, height=128, rotate=0,
mode="RGB", framebuffer=diff_to_previous(), **kwargs):
mode="RGB", framebuffer=None, **kwargs):
super(ssd1327, self).__init__(luma.core.const.common, serial_interface,
width, height, rotate, mode, framebuffer,
nibble_order=1, **kwargs)
Expand Down Expand Up @@ -834,7 +834,7 @@ class ws0010(parallel_device, character, __framebuffer_mixin):
"""

def __init__(self, serial_interface=None, width=100, height=16, undefined='_', font=None,
selected_font=0, exec_time=1e-6 * 50, rotate=0, framebuffer=diff_to_previous(),
selected_font=0, exec_time=1e-6 * 50, rotate=0, framebuffer=None,
const=luma.oled.const.ws0010, **kwargs):
super(ws0010, self).__init__(const, serial_interface, exec_time=exec_time, **kwargs)
self.capabilities(width, height, rotate)
Expand Down
4 changes: 3 additions & 1 deletion luma/oled/device/framebuffer_mixin.py
Expand Up @@ -19,7 +19,9 @@ class __framebuffer_mixin(object):
"""

def init_framebuffer(self, framebuffer):
if isinstance(framebuffer, str):
if framebuffer is None:
self.framebuffer = luma.core.framebuffer.diff_to_previous()
elif isinstance(framebuffer, str):
import warnings
warnings.warn(
"Specifying framebuffer as a string is now deprecated; Supply an instance of class full_frame() or diff_to_previous() instead",
Expand Down

0 comments on commit 950ef97

Please sign in to comment.