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 172a1af

Browse files
committedJun 10, 2022
Merge branch 'main' into bitmaptools_scale
2 parents 95e619f + ffab916 commit 172a1af

14 files changed

+1010
-8
lines changed
 

‎.pre-commit-config.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
5+
repos:
6+
- repo: https://github.com/python/black
7+
rev: 20.8b1
8+
hooks:
9+
- id: black
10+
#- repo: https://github.com/fsfe/reuse-tool
11+
# rev: v0.12.1
12+
# hooks:
13+
# - id: reuse
14+
- repo: https://github.com/pre-commit/pre-commit-hooks
15+
rev: v2.3.0
16+
hooks:
17+
- id: check-yaml
18+
- id: end-of-file-fixer
19+
- id: trailing-whitespace
20+
- repo: https://github.com/pycqa/pylint
21+
rev: pylint-2.7.1
22+
hooks:
23+
- id: pylint
24+
name: pylint (library code)
25+
types: [python]
26+
exclude: "^(docs/|examples/|setup.py$)"
27+
- repo: local
28+
hooks:
29+
- id: pylint_examples
30+
name: pylint (examples code)
31+
description: Run pylint rules on "examples/*.py" files
32+
entry: /usr/bin/env bash -c
33+
args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)']
34+
language: system

‎.pylintrc

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

‎LICENSES/CC-BY-4.0.txt

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

‎LICENSES/MIT.txt

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

‎LICENSES/Unlicense.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or distribute
4+
this software, either in source code form or as a compiled binary, for any
5+
purpose, commercial or non-commercial, and by any means.
6+
7+
In jurisdictions that recognize copyright laws, the author or authors of this
8+
software dedicate any and all copyright interest in the software to the public
9+
domain. We make this dedication for the benefit of the public at large and
10+
to the detriment of our heirs and successors. We intend this dedication to
11+
be an overt act of relinquishment in perpetuity of all present and future
12+
rights to this software under copyright law.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
17+
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
19+
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information,
20+
please refer to <https://unlicense.org/>

‎bitmaptools/Billie.bmp

4.26 KB
Binary file not shown.

‎bitmaptools/Billie.bmp.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2018 Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT

‎bitmaptools/bitmaptools_rotate_bmp.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2022 Tim Cocks
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""
5+
Use bitmaptools.rotozoom() to rotate a bmp image.
6+
"""
7+
import math
8+
import bitmaptools
9+
import board
10+
import displayio
11+
import adafruit_imageload
12+
13+
# use the builtin display
14+
display = board.DISPLAY
15+
16+
# load bmp image into a Bitmap and Palette objects
17+
source_bitmap, source_palette = adafruit_imageload.load("Billie.bmp",
18+
bitmap=displayio.Bitmap,
19+
palette=displayio.Palette)
20+
# Create a TileGrid to show the bitmap
21+
source_tile_grid = displayio.TileGrid(source_bitmap, pixel_shader=source_palette)
22+
23+
# Create destination Bitmap object to hold the rotated image
24+
dest_bitmap = displayio.Bitmap(source_bitmap.height, source_bitmap.height, len(source_palette))
25+
26+
# Create a TileGrid to show the destination Bitmap with the rotated image in it
27+
dest_tile_grid = displayio.TileGrid(dest_bitmap, pixel_shader=source_palette)
28+
29+
# take from source bitmap, put into destination bitmap.
30+
# default values for x,y locations and clipping so whole image is used
31+
# angle argument accepts radians. You can use math module to convert from degrees
32+
bitmaptools.rotozoom(dest_bitmap, source_bitmap, angle=math.radians(270))
33+
34+
# move the rotated image tilegrid over to the right some
35+
dest_tile_grid.x = 100
36+
37+
# Create a Group to show the TileGrids
38+
group = displayio.Group()
39+
40+
# Add the TileGrids to the Group
41+
group.append(source_tile_grid)
42+
group.append(dest_tile_grid)
43+
44+
# Add the Group to the Display
45+
display.show(group)
46+
47+
# Loop forever so you can enjoy your image
48+
while True:
49+
pass
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2022 Tim Cocks
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""
5+
Use bitmaptools.rotozoom() to rotate a bmp image in a circle animated.
6+
"""
7+
import math
8+
import bitmaptools
9+
import board
10+
import displayio
11+
import adafruit_imageload
12+
13+
# use the builtin display
14+
display = board.DISPLAY
15+
16+
# load bmp image into a Bitmap and Palette objects
17+
source_bitmap, source_palette = adafruit_imageload.load("Billie.bmp",
18+
bitmap=displayio.Bitmap,
19+
palette=displayio.Palette)
20+
# Create a TileGrid to show the bitmap
21+
source_tile_grid = displayio.TileGrid(source_bitmap, pixel_shader=source_palette)
22+
23+
# Create destination Bitmap object to hold the rotated image
24+
dest_bitmap = displayio.Bitmap(source_bitmap.height, source_bitmap.height, len(source_palette))
25+
26+
# Create a TileGrid to show the destination Bitmap with the rotated image in it
27+
dest_tile_grid = displayio.TileGrid(dest_bitmap, pixel_shader=source_palette)
28+
29+
# move the rotated image tilegrid over to the right some
30+
dest_tile_grid.x = 100
31+
32+
# Create a Group to show the TileGrids
33+
group = displayio.Group()
34+
35+
# Add the TileGrids to the Group
36+
group.append(source_tile_grid)
37+
group.append(dest_tile_grid)
38+
39+
# Add the Group to the Display
40+
display.show(group)
41+
42+
# Loop forever so you can enjoy your image
43+
while True:
44+
# loop over all the degrees from 0-360
45+
for angle_deg in range(360):
46+
# erase previous frame
47+
dest_bitmap.fill(0)
48+
49+
# take from source bitmap, put into destination bitmap.
50+
# default values for x,y locations and clipping so whole image is used
51+
# angle argument accepts radians. You can use math module to convert from degrees
52+
bitmaptools.rotozoom(dest_bitmap, source_bitmap, angle=math.radians(angle_deg))

‎digitalio/digitalio_blink_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""CircuitPython LED blink example"""
22
import time
33
import board
4-
from digitalio import DigitalInOut, Direction, Pull
4+
from digitalio import DigitalInOut, Direction
55

66
# LED setup.
77
led = DigitalInOut(board.LED)
@@ -12,4 +12,4 @@
1212

1313
while True:
1414
led.value = not led.value
15-
time.sleep(0.25)
15+
time.sleep(0.25)

‎displayio/displayio_colored_screen.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Use a bitmap to change the display background."""
2+
13
import board
24
import displayio
35

@@ -9,7 +11,7 @@
911
# Create a two color palette
1012
palette = displayio.Palette(2)
1113

12-
palette[0] = 0xbb33bb # screen color
14+
palette[0] = 0xBB33BB # screen color
1315

1416
# Create a TileGrid using the Bitmap and Palette
1517
tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)
@@ -25,4 +27,4 @@
2527

2628
# Loop forever so you can enjoy your image
2729
while True:
28-
pass
30+
pass

‎displayio/displayio_shape_corners.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import board
2-
import displayio
31
"""
42
Illustrate usage of displayio.Shape with boundary and mirror.
53
"""
64

5+
import board
6+
import displayio
7+
78
SHAPE_WIDTH = board.DISPLAY.width
89
SHAPE_HEIGHT = board.DISPLAY.height
910
CORNER_SIZE = board.DISPLAY.width // 4
@@ -15,7 +16,7 @@
1516

1617
# set corner pixels out of bounds
1718
for i in range(CORNER_SIZE):
18-
shape.set_boundary(i, CORNER_SIZE-1-i, SHAPE_WIDTH//2-1)
19+
shape.set_boundary(i, CORNER_SIZE - 1 - i, SHAPE_WIDTH // 2 - 1)
1920

2021
palette[0] = 0x0000FF # out of bounds color
2122
palette[1] = 0x00FFFF # shape color

‎displayio/displayio_shape_simpletest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import board
1+
"""
2+
Illustrate usage of displayio.Shape.
3+
"""
24

5+
import board
36
import displayio
47

58
SHAPE_WIDTH = 100
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2021 Randall Bohn (dexter)
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""
5+
Demonstrate usage of the terminalio module.
6+
7+
The module provides a VT100 emulation within a displayo.TileGrid.
8+
A good reference for VT100 "escape" codes is found at
9+
https://www.csie.ntu.edu.tw/~r92094/c++/VT100.html
10+
"""
11+
import random
12+
import time
13+
import board
14+
import displayio
15+
import terminalio
16+
17+
display = board.DISPLAY
18+
group = displayio.Group()
19+
display.show(group)
20+
21+
palette = displayio.Palette(2)
22+
palette[0] = 0x220000
23+
palette[1] = 0x00FFFF
24+
25+
ROWS = 12
26+
COLS = 40
27+
28+
w, h = terminalio.FONT.get_bounding_box()
29+
30+
termgrid = displayio.TileGrid(
31+
terminalio.FONT.bitmap,
32+
pixel_shader=palette,
33+
y=20,
34+
width=COLS,
35+
height=ROWS,
36+
tile_width=w,
37+
tile_height=h,
38+
)
39+
group.append(termgrid)
40+
term = terminalio.Terminal(termgrid, terminalio.FONT)
41+
42+
43+
def world_seed(n):
44+
"""For entertainment purposes only."""
45+
letters = "AEIOUMRFCV"
46+
word = [random.choice(letters) for _ in range(n)]
47+
return "".join(word)
48+
49+
50+
term.write("Terminal %dx%d:\r\n" % (COLS, ROWS))
51+
term.write(" %dx%d pixels.\r\n" % (COLS * w, ROWS * h))
52+
term.write("VT100 protocol.\r\n")
53+
term.write("Both carriage return and line feed are required.\r\n")
54+
while True:
55+
term.write("Your world seed is:\r\n")
56+
for _ in range(10):
57+
term.write(world_seed(12) + " ")
58+
term.write("\r\n")
59+
time.sleep(10)

0 commit comments

Comments
 (0)
Please sign in to comment.