Skip to content

Commit 475b29f

Browse files
committed
Merge branch 'FeatherMatrix8x16' of https://github.com/colincoder/Adafruit_Python_LED_Backpack into FeatherMatrix8x16
2 parents 3e8f52e + acac143 commit 475b29f

File tree

4 files changed

+161
-0
lines changed

4 files changed

+161
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ build
33
*.pyc
44
setuptools-*
55
dist/*
6+
/Adafruit_LED_Backpack/Matrix8x16Featherwing.py

examples/displayflashingdot.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright (c) 2018 Colin Stearman
2+
# Author: Colin Stearman
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the 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,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
22+
23+
# Draw or clear a 2x2 square at top right without changing the rest of the display
24+
# python displayflashingdot.py {0|1}
25+
# 0 clears, 1 sets
26+
27+
import sys
28+
import time
29+
30+
from PIL import Image
31+
from PIL import ImageDraw
32+
33+
from Adafruit_LED_Backpack import FeatherMatrix8x16
34+
35+
# Create display instance on default I2C address (0x70) and bus number.
36+
display = FeatherMatrix8x16.FeatherMatrix8x16()
37+
38+
# Alternatively, create a display with a specific I2C address and/or bus.
39+
# display = Matrix8x16.Matrix8x16(address=0x74, busnum=1)
40+
41+
# Initialize the display. Must be called once before using the display.
42+
display.begin()
43+
display.read_display() # read the display into the internal buffer
44+
image = display.get_image() # get the buffer
45+
draw = ImageDraw.Draw(image)
46+
47+
v = int(sys.argv[1])
48+
if v == 0:
49+
dot = 0
50+
else:
51+
dot = 255
52+
draw.rectangle((6,14,7,15), outline=dot, fill=0)
53+
display.set_image(image)
54+
display.write_display()
55+
print "Dot " + ("Displayed" if dot else "Cleared")
56+
sys.exit(0)

examples/displaynumber.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright (c) 2018 Colin Stearman
2+
# Author: Colin Stearman
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the 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,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
22+
# display a number
23+
# python displaynumber.py {n}
24+
# 0 <= n <= 99
25+
# n outside that range displays --
26+
27+
import sys
28+
import time
29+
30+
from PIL import Image
31+
from PIL import ImageDraw
32+
33+
from Adafruit_LED_Backpack import FeatherMatrix8x16
34+
35+
# Create display instance on default I2C address (0x70) and bus number.
36+
display = FeatherMatrix8x16.FeatherMatrix8x16()
37+
38+
# Alternatively, create a display with a specific I2C address and/or bus.
39+
# display = Matrix8x16.Matrix8x16(address=0x74, busnum=1)
40+
41+
# Initialize the display. Must be called once before using the display.
42+
display.begin()
43+
image = Image.new('1', (8, 16))
44+
draw = ImageDraw.Draw(image)
45+
46+
v = int(sys.argv[1])
47+
display.setnumber(v,image)
48+
#draw.rectangle((6,14,7,15), outline=255, fill=0)
49+
display.set_image(image)
50+
display.write_display()
51+
print "Number Displayed"
52+
sys.exit(0)

examples/displaytext.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright (c) 2018 Colin Stearman
2+
# Author: Colin Stearman
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the 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,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
22+
# display a text string in marquee fashion a given number of times
23+
# python displaytext.py "text to display" {n}
24+
# n is optional and set the number of repeats, defaults to 1
25+
26+
import sys
27+
import time
28+
29+
from PIL import Image
30+
from PIL import ImageDraw
31+
32+
from Adafruit_LED_Backpack import FeatherMatrix8x16
33+
34+
# Create display instance on default I2C address (0x70) and bus number.
35+
display = FeatherMatrix8x16.FeatherMatrix8x16()
36+
37+
# Alternatively, create a display with a specific I2C address and/or bus.
38+
# display = Matrix8x16.Matrix8x16(address=0x74, busnum=1)
39+
40+
# Initialize the display. Must be called once before using the display.
41+
display.begin()
42+
image = Image.new('1', (8, 16))
43+
44+
count = len(sys.argv)
45+
v = sys.argv[1]
46+
if count > 2:
47+
repeat = int(sys.argv[2])
48+
else:
49+
repeat = 1
50+
display.print_str(image,v,repeat)
51+
print "Text Displayed"
52+
sys.exit(0)

0 commit comments

Comments
 (0)