Skip to content

Commit

Permalink
Add copyright headers and docstrings. (#32)
Browse files Browse the repository at this point in the history
A few other drive-by fixes.
  • Loading branch information
corranwebster authored Oct 28, 2024
1 parent 1adcc65 commit fe63d24
Show file tree
Hide file tree
Showing 61 changed files with 671 additions and 76 deletions.
3 changes: 3 additions & 0 deletions ci/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT
6 changes: 6 additions & 0 deletions ci/rgb565_to_png.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Basic conversion utility to take raw RGB565 to .png format."""

import array
from pathlib import Path

Expand Down
61 changes: 33 additions & 28 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
Expand All @@ -6,37 +10,37 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'Tempe'
copyright = '2024, Unital Software'
author = 'Unital Software'
release = '0.1'
project = "Tempe"
copyright = "2024, Unital Software"
author = "Unital Software"
release = "0.1"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
'autoapi.extension',
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"autoapi.extension",
"sphinx_design",
]

templates_path = ['_templates']
templates_path = ["_templates"]
exclude_patterns = []

# -- Options for intersphinx -------------------------------------------------

intersphinx_mapping = {
'micropython': ('https://docs.micropython.org/en/latest', None),
'python': ('https://docs.python.org/3', None)
"micropython": ("https://docs.micropython.org/en/latest", None),
"python": ("https://docs.python.org/3", None),
}

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'pydata_sphinx_theme'
html_static_path = ['_static']
html_theme = "pydata_sphinx_theme"
html_static_path = ["_static"]
html_theme_options = {
"use_edit_page_button": True,
"icon_links": [
Expand Down Expand Up @@ -66,29 +70,30 @@
# -- Options for autodoc -----------------------------------------------------
import sys
import os
sys.path.insert(0, os.path.abspath('../../src')) # add my lib modules

sys.path.insert(0, os.path.abspath("../../src")) # add my lib modules

autodoc_mock_imports = [
'machine',
'uasyncio',
'utime',
'framebuf',
"machine",
"uasyncio",
"utime",
"framebuf",
]
autosummary_generate = True

# -- Options for autoapi -----------------------------------------------------
autoapi_dirs = ['../../src']
autoapi_root = 'api'
autoapi_file_patterns = ['*.pyi', '*.py']
autoapi_dirs = ["../../src"]
autoapi_root = "api"
autoapi_file_patterns = ["*.pyi", "*.py"]
autoapi_options = [
'members',
'undoc-members',
'private-members',
'show-inheritance',
'show-module-summary',
'imported-members',
"members",
"undoc-members",
"private-members",
"show-inheritance",
"show-module-summary",
"imported-members",
]
autoapi_ignore = ["*_data_view_math*"]

add_module_names = False
python_maximum_signature_line_length = 60
python_maximum_signature_line_length = 60
50 changes: 29 additions & 21 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,32 @@ visualization tasks on small, 16-bit+ color screens.
License
-------

MIT License

Copyright (c) 2024 Unital Software

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.
Most of the code is licensed using the MIT license:

MIT License

Copyright (c) 2024 Unital Software

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.

The bitmap fonts included with the Tempe source are derived from Roboto and
are licensed with the Apache License 2.0: see
`github.com/unital/tempe/blob/main/src/tempe/fonts/README.rst <https://github.com/unital/tempe/blob/main/src/tempe/fonts/README.rst>`_
for details.

3 changes: 3 additions & 0 deletions examples/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT
6 changes: 6 additions & 0 deletions examples/data/environmental.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Example data from an environment sensor."""

from array import array

timestamps = array("L", [1729500000 + 600 * i for i in range(288)])
Expand Down
3 changes: 3 additions & 0 deletions examples/devices/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT
6 changes: 6 additions & 0 deletions examples/devices/st7789.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Example Display class for SPI-based ST7789 screens."""

from machine import SPI, Pin
import uasyncio
import utime
Expand Down
3 changes: 3 additions & 0 deletions examples/example_fonts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT
4 changes: 4 additions & 0 deletions examples/example_fonts/roboto32boldnumbers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: Apache

# Code generated by modified font_to_py.py.
# Font: Roboto-Bold.ttf Char set: +-.0123456789BCHKMiz°
# Cmd: ./font_to_py.py -c 0123456789+-.°CKiBMHz Roboto-Bold.ttf 32 roboto32boldnumbers.py
Expand Down
39 changes: 39 additions & 0 deletions examples/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Example showing basic display of text."""

from array import array

from tempe.surface import Surface
from tempe.text import Text
from tempe.shapes import Rectangles
from tempe.display import FileDisplay
from tempe.font import TempeFont
from tempe.fonts import roboto16bold


# a buffer one quarter the size of the screen
working_buffer = array("H", bytearray(2 * 320 * 61))

surface = Surface()

# fill the background with white pixels
background = Rectangles([(0, 0, 320, 240)], [0xFFFF])
surface.add_shape("BACKGROUND", background)

# draw some black text in the main drawing layer
font = TempeFont(roboto16bold)
hello_tempe = Text(
[(10, 10)], [0x0000], ["Hello Tempe!"], font=font, clip=(0, 0, 120, 60)
)
surface.add_shape("DRAWING", hello_tempe)

# set up the display object
display = FileDisplay("hello_world.rgb565", (320, 240))

# refresh the display
with display:
display.clear()
surface.refresh(display, working_buffer)
6 changes: 6 additions & 0 deletions examples/line_plot_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Example showing how to create a line plot from Tempe Shapes."""

from array import array
import gc

Expand Down
6 changes: 6 additions & 0 deletions examples/lines_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Example showing support for thick lines."""

import asyncio
from array import array
import framebuf
Expand Down
6 changes: 6 additions & 0 deletions examples/polar_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Example showing support for polar geometries."""

import asyncio
from array import array
import framebuf
Expand Down
8 changes: 7 additions & 1 deletion examples/polar_plot_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Example showing how to build a polar plot from Tempe Shapes."""

from array import array
import gc
from math import sqrt, log
Expand Down Expand Up @@ -231,7 +237,7 @@ async def init_display():
# if we have an actual screen, use it
main(surface, working_buffer)

elif __name__ != '__test__':
elif __name__ != "__test__":
from tempe.display import FileDisplay

# set up the display object
Expand Down
8 changes: 7 additions & 1 deletion examples/scatter_plot_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Example showing how to create a scatter plot from Tempe Shapes."""

from array import array
import gc
from math import sqrt, log
Expand Down Expand Up @@ -398,7 +404,7 @@ async def init_display():
# if we have an actual screen, use it
main(surface, working_buffer)

elif __name__ != '__test__':
elif __name__ != "__test__":
from tempe.display import FileDisplay

# set up the display object
Expand Down
6 changes: 6 additions & 0 deletions examples/shapes_examples.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Example showing core Tempe Shapes."""

import asyncio
from array import array
import framebuf
Expand Down
9 changes: 9 additions & 0 deletions examples/temperature_screen.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Example showing live updating of microcontroller state.
Note: this is currently not working as it uses earlier version of code.
"""

from array import array
import asyncio
import gc
Expand Down
6 changes: 6 additions & 0 deletions examples/update_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Example showing asyncio updating of a surface."""

import asyncio
from array import array
from machine import ADC, Pin, SPI, RTC
Expand Down
3 changes: 3 additions & 0 deletions src/tempe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT
4 changes: 4 additions & 0 deletions src/tempe/_data_view_math.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Classes that implement numerical operations on DataViews.
These classes are largely an internal implementation detail.
Expand Down
4 changes: 4 additions & 0 deletions src/tempe/_data_view_math.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

"""Internal implementation for numeric operations on DataViews."""

__all__ = []
4 changes: 4 additions & 0 deletions src/tempe/_speedups.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

import micropython


Expand Down
4 changes: 4 additions & 0 deletions src/tempe/bitmaps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2024-present Unital Software <info@unital.dev>
#
# SPDX-License-Identifier: MIT

from array import array
import framebuf

Expand Down
Loading

0 comments on commit fe63d24

Please sign in to comment.