Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e8d51c4

Browse files
committedDec 22, 2018
working tested with 96x96 display
0 parents  commit e8d51c4

15 files changed

+1120
-0
lines changed
 

‎.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__pycache__
2+
_build
3+
*.pyc
4+
.env
5+
build*
6+
bundles

‎.pylintrc

Lines changed: 433 additions & 0 deletions
Large diffs are not rendered by default.

‎.readthedocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
python:
2+
version: 3
3+
requirements_file: requirements.txt

‎.travis.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This is a common .travis.yml for generating library release zip files for
2+
# CircuitPython library releases using circuitpython-build-tools.
3+
# See https://github.com/adafruit/circuitpython-build-tools for detailed setup
4+
# instructions.
5+
6+
dist: xenial
7+
language: python
8+
python:
9+
- "3.6"
10+
11+
cache:
12+
pip: true
13+
14+
deploy:
15+
provider: releases
16+
api_key: $GITHUB_TOKEN
17+
file_glob: true
18+
file: $TRAVIS_BUILD_DIR/bundles/*
19+
skip_cleanup: true
20+
overwrite: true
21+
on:
22+
tags: true
23+
24+
install:
25+
- pip install -r requirements.txt
26+
- pip install circuitpython-build-tools Sphinx sphinx-rtd-theme
27+
- pip install --force-reinstall pylint==1.9.2
28+
29+
script:
30+
- pylint adafruit_sharpmemorydisplay.py
31+
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*.py)
32+
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-sharpmemorydisplay --library_location .
33+
- cd docs && sphinx-build -E -W -b html . _build/html && cd ..

‎CODE_OF_CONDUCT.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Adafruit Community Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and leaders pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level or type of
9+
experience, education, socio-economic status, nationality, personal appearance,
10+
race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
We are committed to providing a friendly, safe and welcoming environment for
15+
all.
16+
17+
Examples of behavior that contributes to creating a positive environment
18+
include:
19+
20+
* Be kind and courteous to others
21+
* Using welcoming and inclusive language
22+
* Being respectful of differing viewpoints and experiences
23+
* Collaborating with other community members
24+
* Gracefully accepting constructive criticism
25+
* Focusing on what is best for the community
26+
* Showing empathy towards other community members
27+
28+
Examples of unacceptable behavior by participants include:
29+
30+
* The use of sexualized language or imagery and sexual attention or advances
31+
* The use of inappropriate images, including in a community member's avatar
32+
* The use of inappropriate language, including in a community member's nickname
33+
* Any spamming, flaming, baiting or other attention-stealing behavior
34+
* Excessive or unwelcome helping; answering outside the scope of the question
35+
asked
36+
* Trolling, insulting/derogatory comments, and personal or political attacks
37+
* Public or private harassment
38+
* Publishing others' private information, such as a physical or electronic
39+
address, without explicit permission
40+
* Other conduct which could reasonably be considered inappropriate
41+
42+
The goal of the standards and moderation guidelines outlined here is to build
43+
and maintain a respectful community. We ask that you don’t just aim to be
44+
"technically unimpeachable", but rather try to be your best self.
45+
46+
We value many things beyond technical expertise, including collaboration and
47+
supporting others within our community. Providing a positive experience for
48+
other community members can have a much more significant impact than simply
49+
providing the correct answer.
50+
51+
## Our Responsibilities
52+
53+
Project leaders are responsible for clarifying the standards of acceptable
54+
behavior and are expected to take appropriate and fair corrective action in
55+
response to any instances of unacceptable behavior.
56+
57+
Project leaders have the right and responsibility to remove, edit, or
58+
reject messages, comments, commits, code, issues, and other contributions
59+
that are not aligned to this Code of Conduct, or to ban temporarily or
60+
permanently any community member for other behaviors that they deem
61+
inappropriate, threatening, offensive, or harmful.
62+
63+
## Moderation
64+
65+
Instances of behaviors that violate the Adafruit Community Code of Conduct
66+
may be reported by any member of the community. Community members are
67+
encouraged to report these situations, including situations they witness
68+
involving other community members.
69+
70+
You may report in the following ways:
71+
72+
In any situation, you may send an email to <support@adafruit.com>.
73+
74+
On the Adafruit Discord, you may send an open message from any channel
75+
to all Community Helpers by tagging @community helpers. You may also send an
76+
open message from any channel, or a direct message to @kattni#1507,
77+
@tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or
78+
@Andon#8175.
79+
80+
Email and direct message reports will be kept confidential.
81+
82+
In situations on Discord where the issue is particularly egregious, possibly
83+
illegal, requires immediate action, or violates the Discord terms of service,
84+
you should also report the message directly to Discord.
85+
86+
These are the steps for upholding our community’s standards of conduct.
87+
88+
1. Any member of the community may report any situation that violates the
89+
Adafruit Community Code of Conduct. All reports will be reviewed and
90+
investigated.
91+
2. If the behavior is an egregious violation, the community member who
92+
committed the violation may be banned immediately, without warning.
93+
3. Otherwise, moderators will first respond to such behavior with a warning.
94+
4. Moderators follow a soft "three strikes" policy - the community member may
95+
be given another chance, if they are receptive to the warning and change their
96+
behavior.
97+
5. If the community member is unreceptive or unreasonable when warned by a
98+
moderator, or the warning goes unheeded, they may be banned for a first or
99+
second offense. Repeated offenses will result in the community member being
100+
banned.
101+
102+
## Scope
103+
104+
This Code of Conduct and the enforcement policies listed above apply to all
105+
Adafruit Community venues. This includes but is not limited to any community
106+
spaces (both public and private), the entire Adafruit Discord server, and
107+
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
108+
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
109+
interaction at a conference.
110+
111+
This Code of Conduct applies both within project spaces and in public spaces
112+
when an individual is representing the project or its community. As a community
113+
member, you are representing our community, and are expected to behave
114+
accordingly.
115+
116+
## Attribution
117+
118+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119+
version 1.4, available at
120+
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
121+
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
122+
123+
For other projects adopting the Adafruit Community Code of
124+
Conduct, please contact the maintainers of those projects for enforcement.
125+
If you wish to use this code of conduct for your own project, consider
126+
explicitly mentioning your moderation policy or making a copy with your
127+
own moderation policy so as to avoid confusion.

‎LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018 ladyada for Adafruit Industries
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.rst

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Introduction
2+
============
3+
4+
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-sharpmemorydisplay/badge/?version=latest
5+
:target: https://circuitpython.readthedocs.io/projects/sharpmemorydisplay/en/latest/
6+
:alt: Documentation Status
7+
8+
.. image:: https://img.shields.io/discord/327254708534116352.svg
9+
:target: https://discord.gg/nBQh6qu
10+
:alt: Discord
11+
12+
.. image:: https://travis-ci.com/adafruit/Adafruit_CircuitPython_SHARPMemoryDisplay.svg?branch=master
13+
:target: https://travis-ci.com/adafruit/Adafruit_CircuitPython_SHARPMemoryDisplay
14+
:alt: Build Status
15+
16+
A display control library for Sharp 'memory' displays
17+
18+
Dependencies
19+
=============
20+
This driver depends on:
21+
22+
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
23+
24+
Please ensure all dependencies are available on the CircuitPython filesystem.
25+
This is easily achieved by downloading
26+
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
27+
28+
Usage Example
29+
=============
30+
31+
See the examples folder for a demonstration of drawing pixels, lines and text
32+
33+
Contributing
34+
============
35+
36+
Contributions are welcome! Please read our `Code of Conduct
37+
<https://github.com/adafruit/Adafruit_CircuitPython_SHARPMemoryDisplay/blob/master/CODE_OF_CONDUCT.md>`_
38+
before contributing to help this project stay welcoming.
39+
40+
Building locally
41+
================
42+
43+
Zip release files
44+
-----------------
45+
46+
To build this library locally you'll need to install the
47+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
48+
49+
.. code-block:: shell
50+
51+
python3 -m venv .env
52+
source .env/bin/activate
53+
pip install circuitpython-build-tools
54+
55+
Once installed, make sure you are in the virtual environment:
56+
57+
.. code-block:: shell
58+
59+
source .env/bin/activate
60+
61+
Then run the build:
62+
63+
.. code-block:: shell
64+
65+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-sharpmemorydisplay --library_location .
66+
67+
Sphinx documentation
68+
-----------------------
69+
70+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
71+
install dependencies (feel free to reuse the virtual environment from above):
72+
73+
.. code-block:: shell
74+
75+
python3 -m venv .env
76+
source .env/bin/activate
77+
pip install Sphinx sphinx-rtd-theme
78+
79+
Now, once you have the virtual environment activated:
80+
81+
.. code-block:: shell
82+
83+
cd docs
84+
sphinx-build -E -W -b html . _build/html
85+
86+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
87+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
88+
locally verify it will pass.

‎adafruit_sharpmemorydisplay.py

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2018 ladyada for Adafruit Industries
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
"""
23+
`adafruit_sharpmemorydisplay`
24+
====================================================
25+
26+
A display control library for Sharp 'memory' displays
27+
28+
* Author(s): ladyada
29+
30+
Implementation Notes
31+
--------------------
32+
33+
**Hardware:**
34+
35+
* `Adafruit SHARP Memory Display Breakout - 1.3 inch 168x144 Monochrome
36+
<https://www.adafruit.com/product/3502>`_
37+
38+
* `Adafruit SHARP Memory Display Breakout - 1.3 inch 96x96 Monochrome
39+
<https://www.adafruit.com/product/1393>`_
40+
41+
**Software and Dependencies:**
42+
43+
* Adafruit CircuitPython firmware for the supported boards:
44+
https://github.com/adafruit/circuitpython/releases
45+
46+
"""
47+
48+
from micropython import const
49+
import adafruit_framebuf
50+
51+
__version__ = "0.0.0-auto.0"
52+
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SharpMemoryDisplay.git"
53+
54+
_SHARPMEM_BIT_WRITECMD = const(0x80) # in lsb
55+
_SHARPMEM_BIT_VCOM = const(0x40) # in lsb
56+
_SHARPMEM_BIT_CLEAR = const(0x20) # in lsb
57+
58+
def reverse_bit(num):
59+
"""Turn an LSB byte to an MSB byte, and vice versa. Used for SPI as
60+
it is LSB for the SHARP, but 99% of SPI implementations are MSB only!"""
61+
result = 0
62+
for _ in range(8):
63+
result <<= 1
64+
result += (num & 1)
65+
num >>= 1
66+
return result
67+
68+
69+
class SharpMemoryDisplay(adafruit_framebuf.FrameBuffer):
70+
"""A driver for sharp memory displays, you can use any size but the
71+
full display must be buffered in memory!"""
72+
# pylint: disable=too-many-instance-attributes
73+
74+
def __init__(self, spi, scs_pin, width, height, *, baudrate=16000000):
75+
self._scs_pin = scs_pin
76+
scs_pin.switch_to_output(value=True)
77+
self._baudrate = baudrate
78+
# The SCS pin is active HIGH so we can't use bus_device. exciting!
79+
self._spi = spi
80+
# prealloc for when we write the display
81+
self._buf = bytearray(1)
82+
83+
# even tho technically this display is LSB, we have to flip the bits
84+
# when writing out SPI so lets just do flipping once, in the buffer
85+
self.buffer = bytearray((width // 8) * height)
86+
super().__init__(self.buffer, width, height, buf_format=adafruit_framebuf.MHMSB)
87+
88+
# Set the vcom bit to a defined state
89+
self._vcom = True
90+
91+
def show(self):
92+
"""write out the frame buffer via SPI, we use MSB SPI only so some
93+
bit-swapping is rquired. The display also uses inverted CS for some
94+
reason so we con't use bus_device"""
95+
96+
# CS pin is inverted so we have to do this all by hand
97+
while not self._spi.try_lock():
98+
pass
99+
self._spi.configure(baudrate=self._baudrate)
100+
self._scs_pin.value = True
101+
102+
# toggle the VCOM bit
103+
self._buf[0] = _SHARPMEM_BIT_WRITECMD
104+
if self._vcom:
105+
self._buf[0] |= _SHARPMEM_BIT_VCOM
106+
self._vcom = not self._vcom
107+
self._spi.write(self._buf)
108+
109+
slice_from = 0
110+
line_len = self.width//8
111+
for line in range(self.height):
112+
self._buf[0] = reverse_bit(line+1)
113+
self._spi.write(self._buf)
114+
self._spi.write(memoryview(self.buffer[slice_from:slice_from+line_len]))
115+
slice_from += line_len
116+
self._buf[0] = 0
117+
self._spi.write(self._buf)
118+
self._spi.write(self._buf) # we send one last 0 byte
119+
self._scs_pin.value = False
120+
self._spi.unlock()

‎docs/_static/favicon.ico

4.31 KB
Binary file not shown.

‎docs/api.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
.. If you created a package, create one automodule per module in the package.
3+
4+
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
5+
.. use this format as the module name: "adafruit_foo.foo"
6+
7+
.. automodule:: adafruit_sharpmemorydisplay
8+
:members:

‎docs/conf.py

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import os
4+
import sys
5+
sys.path.insert(0, os.path.abspath('..'))
6+
7+
# -- General configuration ------------------------------------------------
8+
9+
# Add any Sphinx extension module names here, as strings. They can be
10+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
11+
# ones.
12+
extensions = [
13+
'sphinx.ext.autodoc',
14+
'sphinx.ext.intersphinx',
15+
'sphinx.ext.napoleon',
16+
'sphinx.ext.todo',
17+
]
18+
19+
# TODO: Please Read!
20+
# Uncomment the below if you use native CircuitPython modules such as
21+
# digitalio, micropython and busio. List the modules you use. Without it, the
22+
# autodoc module docs will fail to generate with a warning.
23+
# autodoc_mock_imports = ["digitalio", "busio"]
24+
25+
26+
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
27+
28+
# Add any paths that contain templates here, relative to this directory.
29+
templates_path = ['_templates']
30+
31+
source_suffix = '.rst'
32+
33+
# The master toctree document.
34+
master_doc = 'index'
35+
36+
# General information about the project.
37+
project = u'Adafruit SHARPMemoryDisplay Library'
38+
copyright = u'2018 ladyada'
39+
author = u'ladyada'
40+
41+
# The version info for the project you're documenting, acts as replacement for
42+
# |version| and |release|, also used in various other places throughout the
43+
# built documents.
44+
#
45+
# The short X.Y version.
46+
version = u'1.0'
47+
# The full version, including alpha/beta/rc tags.
48+
release = u'1.0'
49+
50+
# The language for content autogenerated by Sphinx. Refer to documentation
51+
# for a list of supported languages.
52+
#
53+
# This is also used if you do content translation via gettext catalogs.
54+
# Usually you set "language" from the command line for these cases.
55+
language = None
56+
57+
# List of patterns, relative to source directory, that match files and
58+
# directories to ignore when looking for source files.
59+
# This patterns also effect to html_static_path and html_extra_path
60+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
61+
62+
# The reST default role (used for this markup: `text`) to use for all
63+
# documents.
64+
#
65+
default_role = "any"
66+
67+
# If true, '()' will be appended to :func: etc. cross-reference text.
68+
#
69+
add_function_parentheses = True
70+
71+
# The name of the Pygments (syntax highlighting) style to use.
72+
pygments_style = 'sphinx'
73+
74+
# If true, `todo` and `todoList` produce output, else they produce nothing.
75+
todo_include_todos = False
76+
77+
# If this is True, todo emits a warning for each TODO entries. The default is False.
78+
todo_emit_warnings = True
79+
80+
napoleon_numpy_docstring = False
81+
82+
# -- Options for HTML output ----------------------------------------------
83+
84+
# The theme to use for HTML and HTML Help pages. See the documentation for
85+
# a list of builtin themes.
86+
#
87+
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
88+
89+
if not on_rtd: # only import and set the theme if we're building docs locally
90+
try:
91+
import sphinx_rtd_theme
92+
html_theme = 'sphinx_rtd_theme'
93+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
94+
except:
95+
html_theme = 'default'
96+
html_theme_path = ['.']
97+
else:
98+
html_theme_path = ['.']
99+
100+
# Add any paths that contain custom static files (such as style sheets) here,
101+
# relative to this directory. They are copied after the builtin static files,
102+
# so a file named "default.css" will overwrite the builtin "default.css".
103+
html_static_path = ['_static']
104+
105+
# The name of an image file (relative to this directory) to use as a favicon of
106+
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
107+
# pixels large.
108+
#
109+
html_favicon = '_static/favicon.ico'
110+
111+
# Output file base name for HTML help builder.
112+
htmlhelp_basename = 'AdafruitSharpmemorydisplayLibrarydoc'
113+
114+
# -- Options for LaTeX output ---------------------------------------------
115+
116+
latex_elements = {
117+
# The paper size ('letterpaper' or 'a4paper').
118+
#
119+
# 'papersize': 'letterpaper',
120+
121+
# The font size ('10pt', '11pt' or '12pt').
122+
#
123+
# 'pointsize': '10pt',
124+
125+
# Additional stuff for the LaTeX preamble.
126+
#
127+
# 'preamble': '',
128+
129+
# Latex figure (float) alignment
130+
#
131+
# 'figure_align': 'htbp',
132+
}
133+
134+
# Grouping the document tree into LaTeX files. List of tuples
135+
# (source start file, target name, title,
136+
# author, documentclass [howto, manual, or own class]).
137+
latex_documents = [
138+
(master_doc, 'AdafruitSHARPMemoryDisplayLibrary.tex', u'AdafruitSHARPMemoryDisplay Library Documentation',
139+
author, 'manual'),
140+
]
141+
142+
# -- Options for manual page output ---------------------------------------
143+
144+
# One entry per manual page. List of tuples
145+
# (source start file, name, description, authors, manual section).
146+
man_pages = [
147+
(master_doc, 'AdafruitSHARPMemoryDisplaylibrary', u'Adafruit SHARPMemoryDisplay Library Documentation',
148+
[author], 1)
149+
]
150+
151+
# -- Options for Texinfo output -------------------------------------------
152+
153+
# Grouping the document tree into Texinfo files. List of tuples
154+
# (source start file, target name, title, author,
155+
# dir menu entry, description, category)
156+
texinfo_documents = [
157+
(master_doc, 'AdafruitSHARPMemoryDisplayLibrary', u'Adafruit SHARPMemoryDisplay Library Documentation',
158+
author, 'AdafruitSHARPMemoryDisplayLibrary', 'One line description of project.',
159+
'Miscellaneous'),
160+
]

‎docs/examples.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Simple test
2+
------------
3+
4+
Ensure your device works with this simple test.
5+
6+
.. literalinclude:: ../examples/sharpmemorydisplay_simpletest.py
7+
:caption: examples/sharpmemorydisplay_simpletest.py
8+
:linenos:

‎docs/index.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.. include:: ../README.rst
2+
3+
Table of Contents
4+
=================
5+
6+
.. toctree::
7+
:maxdepth: 4
8+
:hidden:
9+
10+
self
11+
12+
.. toctree::
13+
:caption: Examples
14+
15+
examples
16+
17+
.. toctree::
18+
:caption: API Reference
19+
:maxdepth: 3
20+
21+
api
22+
23+
.. toctree::
24+
:caption: Tutorials
25+
26+
.. toctree::
27+
:caption: Related Products
28+
29+
* `Adafruit SHARP Memory Display Breakout - 1.3 inch 168x144 Monochrome <https://www.adafruit.com/product/3502>`_
30+
31+
* `Adafruit SHARP Memory Display Breakout - 1.3 inch 96x96 Monochrome <https://www.adafruit.com/product/1393>`_
32+
33+
34+
.. toctree::
35+
:caption: Other Links
36+
37+
Download <https://github.com/adafruit/Adafruit_CircuitPython_SHARPMemoryDisplay/releases/latest>
38+
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
39+
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
40+
Discord Chat <https://adafru.it/discord>
41+
Adafruit Learning System <https://learn.adafruit.com>
42+
Adafruit Blog <https://blog.adafruit.com>
43+
Adafruit Store <https://www.adafruit.com>
44+
45+
Indices and tables
46+
==================
47+
48+
* :ref:`genindex`
49+
* :ref:`modindex`
50+
* :ref:`search`
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import time
2+
import board
3+
import busio
4+
import digitalio
5+
6+
import adafruit_sharpmemorydisplay
7+
8+
# Initialize SPI bus and control pins
9+
spi = busio.SPI(board.SCK, MOSI=board.MOSI)
10+
scs = digitalio.DigitalInOut(board.D6) # inverted chip select
11+
12+
# pass in the display size, width and height, as well
13+
display = adafruit_sharpmemorydisplay.SharpMemoryDisplay(spi, scs, 96, 96)
14+
15+
print("Pixel test")
16+
17+
# Clear the display. Always call show after changing pixels to make the display
18+
# update visible!
19+
display.fill(1)
20+
display.show()
21+
22+
# Set a pixel in the origin 0,0 position.
23+
display.pixel(0, 0, 0)
24+
# Set a pixel in the middle position.
25+
display.pixel(display.width//2, display.width//2, 0)
26+
# Set a pixel in the opposite corner position.
27+
display.pixel(display.width-1, display.height-1, 0)
28+
display.show()
29+
time.sleep(0.1)
30+
31+
print("Lines test")
32+
# we'll draw from corner to corner, lets define all the pair coordinates here
33+
corners = ((0, 0), (0, display.height-1), (display.width-1, 0),
34+
(display.width-1, display.height-1))
35+
36+
display.fill(1)
37+
for corner_from in corners:
38+
for corner_to in corners:
39+
display.line(corner_from[0], corner_from[1],
40+
corner_to[0], corner_to[1], 0)
41+
display.show()
42+
time.sleep(0.1)
43+
44+
print("Rectangle test")
45+
display.fill(1)
46+
w_delta = display.width / 10
47+
h_delta = display.height / 10
48+
for i in range(11):
49+
display.rect(0, 0, int(w_delta*i), int(h_delta*i), 0)
50+
display.show()
51+
time.sleep(0.1)
52+
53+
print("Text test")
54+
display.fill(1)
55+
display.text(' hello world!', 0, 0, 0)
56+
display.text(' This is the', 0, 8, 0)
57+
display.text(' CircuitPython', 0, 16, 0)
58+
display.text('adafruit library', 0, 24, 0)
59+
display.text(' for the SHARP', 0, 32, 0)
60+
display.text(' Memory Display :) ', 0, 40, 0)
61+
display.show()

‎requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Adafruit-Blinka
2+
adafruit-circuitpython-framebuf

0 commit comments

Comments
 (0)
Please sign in to comment.