Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ChangeLog
+------------+---------------------------------------------------------------------+------------+
| Version | Description | Date |
+============+=====================================================================+============+
| **1.1.0** | * Add LS013B4DN04 Monochrome LCD display driver | 2018/01/01 |
+------------+---------------------------------------------------------------------+------------+
| **1.0.3** | * Changed version number to inside ``luma/lcd/__init__.py`` | 2017/11/23 |
+------------+---------------------------------------------------------------------+------------+
| **1.0.2** | * Documentation and dependencies updates | 2017/10/30 |
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The MIT License (MIT)
---------------------

Copyright (c) 2013-17 Richard Hull & Contributors
Copyright (c) 2013-18 Richard Hull & 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
Expand Down
16 changes: 9 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ luma.lcd **|**

Luma.LCD
========
**PCD8544, ST7735, HT1621, UC1701X Display Drivers**
**PCD8544, ST7735, HT1621, UC1701X, LS013B4DN04 Display Drivers**

.. image:: https://travis-ci.org/rm-hull/luma.lcd.svg?branch=master
:target: https://travis-ci.org/rm-hull/luma.lcd
Expand All @@ -26,12 +26,12 @@ Luma.LCD
.. image:: https://img.shields.io/pypi/v/luma.lcd.svg
:target: https://pypi.python.org/pypi/luma.lcd

.. image:: https://img.shields.io/maintenance/yes/2017.svg?maxAge=2592000
.. image:: https://img.shields.io/maintenance/yes/2018.svg?maxAge=2592000

Python library interfacing LCD displays with the PCD8544, ST7735, HT1621 and
UC1701X driver using SPI on the Raspberry Pi and other linux-based single-board
computers - it provides a Pillow-compatible drawing canvas, and other
functionality to support:
Python library interfacing LCD displays with the PCD8544, ST7735, HT1621,
UC1701X and LS013B4DN04 driver using SPI 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,
Expand All @@ -49,6 +49,8 @@ All modules can be picked up on ebay with a breakout board for a few pounds.

.. image:: https://raw.github.com/rm-hull/luma.lcd/master/doc/images/uc1701x.png

.. image:: https://raw.github.com/rm-hull/luma.lcd/master/doc/images/ls013b4dn04.jpg

Documentation
-------------
Full documentation with installation instructions and examples can be found on
Expand All @@ -58,7 +60,7 @@ License
-------
The MIT License (MIT)

Copyright (c) 2013-17 Richard Hull & Contributors
Copyright (c) 2013-18 Richard Hull & 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
Expand Down
Binary file added doc/images/ls013b4dn04.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Luma.LCD: Display drivers for PCD8544, ST7735, HT1621, UC1701X
==============================================================
Luma.LCD: Display drivers for PCD8544, ST7735, HT1621, UC1701X, LS013B4DN04
===========================================================================
.. image:: https://travis-ci.org/rm-hull/luma.lcd.svg?branch=master
:target: https://travis-ci.org/rm-hull/luma.lcd

.. image:: https://coveralls.io/repos/github/rm-hull/luma.lcd/badge.svg?branch=master
:target: https://coveralls.io/github/rm-hull/luma.lcd?branch=master

.. image:: https://img.shields.io/maintenance/yes/2017.svg?maxAge=2592000
.. image:: https://img.shields.io/maintenance/yes/2018.svg?maxAge=2592000

.. image:: https://img.shields.io/pypi/pyversions/luma.lcd.svg
:target: https://pypi.python.org/pypi/luma.lcd
Expand Down
20 changes: 19 additions & 1 deletion doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,25 @@ SCK SPI clock P01-23 GPIO 11 (SCLK)
SDA SPI data P01-19 GPIO 10 (MOSI)
RS Data/command P01-16 GPIO 23
RST Reset P01-18 GPIO 24
CS SPI chip select P01-24 GPIO 8 (CE0) Chip Select
CS SPI chip select P01-24 GPIO 8 (CE0)
============= ================= ======== ==============

LS013B4DN04
"""""""""""
Also known as Adafruit_1393

============= ================= ======== ==============
LCD Pin Remarks RPi Pin RPi Function
============= ================= ======== ==============
VIN +3.3V P01-01 3V3
3V3 +3.3V P01-01 3V3
GND Ground P01-06 GND
SCLK SPI clock P0-23 GPIO 11 (SCLK)
MOSI SPI data P01-19 GPIO 10 (MOSI)
CS SPI chip select P01-24 GPIO 8 (CE0)
EXTMD External mode P01-14 GND
DISP Display on/off P01-16 GPIO 23
EXTIN PWM clock P01-12 GPIO 18 (PWM0)
============= ================= ======== ==============

Installing from PyPI
Expand Down
13 changes: 9 additions & 4 deletions doc/intro.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Introduction
------------
Interfacing small LCD displays with the PCD8544, ST7735, HT1621 and UC1701X
driver in Python using SPI on the Raspberry Pi and other linux-based
single-board computers: the library provides a Pillow-compatible drawing
canvas, and other functionality to support:
Interfacing small LCD displays with the PCD8544, ST7735, HT1621, UC1701X and
LS013B4DN04 driver in Python using SPI on the Raspberry Pi and other
linux-based single-board computers: the library provides a Pillow-compatible
drawing canvas, and other functionality to support:

* scrolling/panning capability,
* terminal-style printing,
Expand Down Expand Up @@ -36,6 +36,10 @@ switchable backlight:

.. image:: images/uc1701x.png

The LS013B4DN04 display supports a resolution of 96 x 96 monochrome pixels:

.. image:: images/ls013b4dn04.jpg

.. seealso::
Further technical information for the specific device can be found in the
datasheet below:
Expand All @@ -44,6 +48,7 @@ switchable backlight:
- :download:`ST7735 <tech-spec/ST7735.pdf>`
- :download:`HT1621 <tech-spec/HT1621.pdf>`
- :download:`UC1701X <tech-spec/UC1701X.pdf>`
- :download:`LS013B4DN04 <tech-spec/LS013B4DN04.pdf>`

As well as display drivers for the physical device, there are emulators that
run in real-time (with pygame) and others that can take screenshots, or
Expand Down
44 changes: 24 additions & 20 deletions doc/python-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ Python usage

Pixel Drivers
^^^^^^^^^^^^^

The PCD8544 is driven with python using the implementation in the
:py:class:`luma.lcd.device.pcd8544` class. Likewise, to drive the ST7735 or
UC1701X, use the :py:class:`luma.lcd.device.st7735` or
:py:class:`luma.lcd.device.uc1701x` class respectively. Usage is very simple if
you have ever used `Pillow <https://pillow.readthedocs.io/en/latest/>`_ or PIL.
:py:class:`luma.lcd.device.pcd8544` class. Likewise, to drive the ST7735,
UC1701X or LS013B4DN04, use the :py:class:`luma.lcd.device.st7735`,
:py:class:`luma.lcd.device.uc1701x`, :py:class:`luma.lcd.device.ls013b4dn04` or
class respectively. Usage is very simple if you have ever used `Pillow
<https://pillow.readthedocs.io/en/latest/>`_ or PIL.

First, import and initialise the device:

.. code:: python

from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.lcd.device import pcd8544, st7735, uc1701x
from luma.lcd.device import pcd8544, st7735, uc1701x, ls013b4dn04

serial = spi(port=0, device=0, gpio_DC=23, gpio_RST=24)
device = pcd8544(serial)
Expand All @@ -24,8 +26,9 @@ The display device should now be configured for use. Note, all the example code
snippets in this section are interchangeable between PCD8544 and ST7735
devices.

The :py:class:`~luma.lcd.device.pcd8544`, :py:class:`~luma.lcd.device.st7735` and
:py:class:`~luma.lcd.device.uc1701x` classes all expose a
The :py:class:`~luma.lcd.device.pcd8544`, :py:class:`~luma.lcd.device.st7735`,
:py:class:`~luma.lcd.device.uc1701x` and
:py:class:`~luma.lcd.device.ls013b4dn04` classes all expose a
:py:meth:`~luma.lcd.device.pcd8544.display` method which takes an image with
attributes consistent with the capabilities of the device. However, for most
cases, for drawing text and graphics primitives, the canvas class should be
Expand Down Expand Up @@ -67,9 +70,10 @@ colour RGB images, whereby 24-bit RGB images are downscaled to 18-bit RGB.
Landscape / Portrait Orientation
""""""""""""""""""""""""""""""""
By default the PCD8544, ST7735 and UC1701X displays will all be oriented in
landscape mode (84x48, 160x128 and 128x64 pixels respectively). Should you have
an application that requires the display to be mounted in a portrait aspect,
then add a :py:attr:`rotate=N` parameter when creating the device:
landscape mode (84x48, 160x128 and 128x64 pixels respectively). The LS013B4DN04
supports a native resolution of 96x96 pixels. Should you have an application
that requires the display to be mounted in a portrait aspect, then add a
:py:attr:`rotate=N` parameter when creating the device:

.. code:: python

Expand All @@ -93,9 +97,9 @@ properties reflect the rotated dimensions rather than the physical dimensions.

Seven-Segment Drivers
^^^^^^^^^^^^^^^^^^^^^
The HT1621 is driven with the :py:class:`luma.lcd.device.ht1621` class, but is
not accessed directly: it should be wrapped with the :py:class:`luma.core.virtual.sevensegment`
wrapper, as follows:
The HT1621 is driven with the :py:class:`luma,lcd.device.ht1621` class, but is
not accessed directly: it should be wrapped with the
:py:class:`luma.core.virtual.sevensegment` wrapper, as follows:

.. code:: python

Expand All @@ -104,13 +108,13 @@ wrapper, as follows:

device = ht1621()
seg = sevensegment(device)
The **seg** instance now has a :py:attr:`~luma.led_matrix.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
can write:


The **seg** instance now has a
:py:attr:`~luma.led_matrix.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 can write:

.. code:: python

Expand Down
Binary file added doc/tech-spec/LS013B4DN04.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion luma/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2013-17 Richard Hull and contributors
# Copyright (c) 2013-18 Richard Hull and contributors
# See LICENSE.rst for details.

from pkgutil import extend_path
Expand Down
2 changes: 1 addition & 1 deletion luma/lcd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2013-17 Richard Hull and contributors
# Copyright (c) 2013-18 Richard Hull and contributors
# See LICENSE.rst for details.

"""
Expand Down
2 changes: 1 addition & 1 deletion luma/lcd/aux.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2013-17 Richard Hull and contributors
# Copyright (c) 2013-18 Richard Hull and contributors
# See LICENSE.rst for details.


Expand Down
6 changes: 5 additions & 1 deletion luma/lcd/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2013-17 Richard Hull and contributors
# Copyright (c) 2013-18 Richard Hull and contributors
# See LICENSE.rst for details.


Expand All @@ -21,3 +21,7 @@ class ht1621(object):
class uc1701x(object):
DISPLAYON = 0xAF
DISPLAYOFF = 0xAE


class ls013b4dn04(object):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add docstring with version nr added.

pass
90 changes: 88 additions & 2 deletions luma/lcd/device.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2013-17 Richard Hull and contributors
# Copyright (c) 2013-18 Richard Hull and contributors
# See LICENSE.rst for details.

"""
Expand Down Expand Up @@ -43,7 +43,7 @@
from luma.lcd.segment_mapper import dot_muncher


__all__ = ["pcd8544", "st7735", "ht1621", "uc1701x"]
__all__ = ["pcd8544", "st7735", "ht1621", "uc1701x", "ls013b4dn04"]


class pcd8544(device):
Expand Down Expand Up @@ -427,3 +427,89 @@ def contrast(self, value):
"""
assert(0 <= value <= 255)
self.command(0x81, value >> 2)


class ls013b4dn04(device):
"""
Serial interface to a monochrome LS013B4DN04 LCD display.

On creation, an initialization sequence is pumped to the display to properly
configure it. Further control commands can then be called to affect the
brightness and other settings.

:param serial_interface: The serial interface (usually a
:py:class:`luma.core.interface.serial.spi` instance) to delegate sending
data and commands through.
:param rotate: An integer value of 0 (default), 1, 2 or 3 only, where 0 is
no rotation, 1 is rotate 90° clockwise, 2 is 180° rotation and 3
represents 270° rotation.
:type rotate: int

.. versionadded:: 1.1.0
"""
def __init__(self, serial_interface=None, rotate=0, **kwargs):
super(ls013b4dn04, self).__init__(luma.lcd.const.ls013b4dn04, serial_interface)
self.capabilities(96, 96, rotate)
self._mask = [1 << (i % 8) for i in reversed(range(self._w))]
self._offsets = [(i // 8) for i in range(self._w)]
self._vcom = 0x40

self.clear()
self.show()

def toggleVCOM(self):
self._vcom = 0x40 if self._vcom == 0 else 0x00

def reverseByte(self, n):
return int('{:08b}'.format(n)[::-1], 2)

def display(self, image):
"""
Takes a 1-bit :py:mod:`PIL.Image` and dumps it to the LS013B4DN04
LCD display.
"""
assert(image.mode == self.mode)
assert(image.size == self.size)

image = self.preprocess(image)
image_data = list(image.getdata())
off = self._offsets
mask = self._mask

self.toggleVCOM()
buf = [0x80 | self._vcom]

for line in range(self._h):
addr = self.reverseByte(line + 1)
row = bytearray(self._w // 8)

frm = line * self._w
to = frm + self._w
for idx, pix in enumerate(image_data[frm:to]):
if pix > 0:
row[off[idx]] |= mask[idx]

buf.append(addr)
buf += list(row)
buf.append(0x00)

buf.append(0x00)
print(buf)
self.data(buf)

def clear(self):
self.toggleVCOM()
self.command(0x20 | self._vcom, 0x00)

def show(self):
pass

def hide(self):
pass

def contrast(self, value):
"""
Sets the LCD contrast
"""
assert(0 <= value <= 255)
pass
2 changes: 1 addition & 1 deletion luma/lcd/segment_mapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Richard Hull and contributors
# Copyright (c) 2017-18 Richard Hull and contributors
# See LICENSE.rst for details.

_DIGITS = {
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def find_version(*file_paths):
version=version,
author="Richard Hull",
author_email="richard.hull@destructuring-bind.org",
description=("A library to drive PCD8544, HT1621, ST7735 and UC1701X-based LCDs"),
description=("A library to drive PCD8544, HT1621, ST7735, UC1701X and LS013B4DN04-based LCDs"),
long_description="\n\n".join([README, CONTRIB, CHANGES]),
license="MIT",
keywords="raspberry pi rpi lcd nokia 5110 display screen pcd8544 st7735 uc1701x ht1621 spi 84x48 160x128",
keywords="raspberry pi rpi lcd nokia 5110 display screen pcd8544 st7735 uc1701x ht1621 ls013b4dn04 spi 84x48 160x128",
url="https://github.com/rm-hull/luma.lcd",
download_url="https://github.com/rm-hull/luma.lcd/tarball/" + version,
namespace_packages=["luma"],
Expand Down
2 changes: 1 addition & 1 deletion tests/baseline_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2013-17 Richard Hull and contributors
# Copyright (c) 2013-18 Richard Hull and contributors
# See LICENSE.rst for details.

import io
Expand Down
Loading