Skip to content

Commit

Permalink
Move seven segment code to luma.core
Browse files Browse the repository at this point in the history
  • Loading branch information
rm-hull committed Apr 14, 2017
1 parent fc07987 commit ad6a267
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 309 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ ChangeLog
+------------+------------------------------------------------------------------------+------------+
| Version | Description | Date |
+============+========================================================================+============+
| **0.9.0** | * Add support for APA102 RGB neopixels | |
| **0.10.0** | * **BREAKING CHANGE:** Move sevensegment class to | 2017/04/14 |
| | ``luma.core.virtual`` package | |
+------------+------------------------------------------------------------------------+------------+
| **0.9.0** | * Add support for APA102 RGB neopixels | 2017/03/30 |
+------------+------------------------------------------------------------------------+------------+
| **0.8.0** | * Change MAX7219's block_orientation to support ±90° angle correction | 2017/03/19 |
| | * Deprecate "vertical" and "horizontal" block_orientation | |
Expand Down
6 changes: 3 additions & 3 deletions doc/python-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,22 +220,22 @@ representation is corrected to reverse the 90° phase shift.

7-Segment LED Displays
^^^^^^^^^^^^^^^^^^^^^^
For the 7-segment device, initialize the :py:class:`luma.led_matrix.virtual.sevensegment`
For the 7-segment device, initialize the :py:class:`luma.core.virtual.sevensegment`
class, and wrap it around a previously created :py:class:`~luma.led_matrix.device.max7219`
device:

.. code:: python
from luma.core.serial import spi, noop
from luma.core.render import canvas
from luma.core.virtual import sevensegment
from luma.led_matrix.device import max7219
from luma.led_matrix.virtual import sevensegment
serial = spi(port=0, device=0, gpio=noop())
device = max7219(serial, cascaded=2)
seg = sevensegment(device)
The **seg** instance now has a :py:attr:`~luma.led_matrix.virtual.sevensegment.text`
The **seg** instance now has a :py:attr:`~luma.core.virtual.sevensegment.text`
property which may be assigned, and when it does will update all digits
according to the limited alphabet the 7-segment displays support. For example,
assuming there are 2 cascaded modules, we have 16 character available, and so
Expand Down
9 changes: 4 additions & 5 deletions examples/7segment_scroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
"""

import time
from luma.core.emulator import pygame
from luma.core.virtual import viewport
from luma.led_matrix.virtual import sevensegment

from luma.emulator.device import pygame
from luma.core.virtual import viewport, sevensegment
from luma.led_matrix.segment_mapper import dot_muncher

blurb = """
Have you ever been to American wedding?
Expand Down Expand Up @@ -59,7 +58,7 @@
def main():
device = pygame(width=24, height=8, transform="sevensegment", scale=1)
virtual = viewport(device, width=1024, height=8)
seg = sevensegment(virtual)
seg = sevensegment(virtual, segment_mapper=dot_muncher)

for line in blurb.split("\n"):
seg.text = (" " * device.width) + line
Expand Down
3 changes: 1 addition & 2 deletions examples/sevensegment_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
from datetime import datetime

from luma.led_matrix.device import max7219
from luma.led_matrix.virtual import sevensegment
from luma.core.serial import spi, noop
from luma.core.virtual import viewport
from luma.core.virtual import viewport, sevensegment


def date(seg):
Expand Down
2 changes: 2 additions & 0 deletions luma/led_matrix/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from luma.core.util import deprecation
import luma.core.error
import luma.led_matrix.const
from luma.led_matrix.segment_mapper import dot_muncher


__all__ = ["max7219", "ws2812", "neopixel", "apa102"]
Expand All @@ -55,6 +56,7 @@ def __init__(self, serial_interface=None, width=8, height=8, cascaded=None, rota
height = 8

self.capabilities(width, height, rotate)
self.segment_mapper = dot_muncher

if width <= 0 or width % 8 != 0 or height <= 0 or height % 8 != 0:
raise luma.core.error.DeviceDisplayModeError(
Expand Down
83 changes: 0 additions & 83 deletions luma/led_matrix/helpers.py

This file was deleted.

92 changes: 0 additions & 92 deletions luma/led_matrix/virtual.py

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def read_file(fname):
download_url="https://github.com/rm-hull/luma.led_matrix/tarball/" + version,
namespace_packages=["luma"],
packages=["luma.led_matrix"],
install_requires=["luma.core>=0.7.4", "ws2812"],
install_requires=["luma.core>=0.8.1", "ws2812"],
setup_requires=pytest_runner,
tests_require=["mock", "pytest", "pytest-cov"],
extras_require={
Expand Down
Binary file removed tests/reference/golden_ratio.png
Binary file not shown.
81 changes: 0 additions & 81 deletions tests/test_observable.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_segment_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# See LICENSE.rst for details.


from luma.led_matrix.helpers import mutable_string
from luma.core.util import mutable_string
from luma.led_matrix.segment_mapper import dot_muncher, regular


Expand Down

0 comments on commit ad6a267

Please sign in to comment.