Skip to content

Commit 3d875b2

Browse files
authored
Merge pull request #107 from kattni/14-segment-example
Add 14-segment-specific example, update comments.
2 parents 162daa3 + 00dded2 commit 3d875b2

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
import time
5+
import board
6+
from adafruit_ht16k33 import segments
7+
8+
# Create the display object.
9+
# Display connected to STEMMA QT connector.
10+
display = segments.Seg14x4(board.STEMMA_I2C())
11+
# Display connected to I2C pins.
12+
# display = segments.Seg14x4(board.I2C())
13+
14+
# This section displays four 0's across the display. The code shows four
15+
# different ways to use the set_digit_raw function. Each is labeled below.
16+
# 16-bit Hexadecimal number
17+
display.set_digit_raw(0, 0x2D3F)
18+
time.sleep(0.2)
19+
# 16-bit Binary number
20+
display.set_digit_raw(1, 0b0010110100111111)
21+
time.sleep(0.2)
22+
# 8-bit Binary Tuple
23+
display.set_digit_raw(2, (0b00101101, 0b00111111))
24+
time.sleep(0.2)
25+
# 8-bit Hexadecimal List
26+
display.set_digit_raw(3, [0x2D, 0x3F])
27+
time.sleep(0.2)
28+
29+
# Delay between.
30+
time.sleep(2)
31+
32+
# Scroll "Hello, world!" across the display. Setting the loop parameter to false allows you to
33+
# tell the marquee function to run only once. By default, marquee loops indefinitely.
34+
display.marquee("Hello, world!", loop=False)
35+
36+
# Delay between.
37+
time.sleep(2)
38+
39+
# Scroll special characters, uppercase and lowercase letters, and numbers across
40+
# the display in a loop. This section will continue to run indefinitely.
41+
display.marquee("".join(chr(character) for character in range(ord("!"), ord("z") + 1)))

examples/ht16k33_segments_multi_display.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,14 @@
6868
display.set_digit_raw(2, 0x79)
6969
display.set_digit_raw(3, 0b01111001)
7070
else:
71-
# 14-segment raw digits
71+
# 14-segment raw digits. Same character (0) displayed using four different methods.
72+
# 16-bit Hexadecimal number
7273
display.set_digit_raw(0, 0x2D3F)
74+
# 16-bit Binary number
7375
display.set_digit_raw(1, 0b0010110100111111)
76+
# 8-bit Binary Tuple
7477
display.set_digit_raw(2, (0b00101101, 0b00111111))
78+
# 8-bit Hexadecimal List
7579
display.set_digit_raw(3, [0x2D, 0x3F])
7680
time.sleep(2)
7781

examples/ht16k33_segments_simpletest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@
6464
display.set_digit_raw(2, 0x79)
6565
display.set_digit_raw(3, 0b01111001)
6666
else:
67-
# 14-segment raw digits
67+
# 14-segment raw digits. Same character (0) displayed using four different methods.
68+
# 16-bit Hexadecimal number
6869
display.set_digit_raw(0, 0x2D3F)
70+
# 16-bit Binary number
6971
display.set_digit_raw(1, 0b0010110100111111)
72+
# 8-bit Binary Tuple
7073
display.set_digit_raw(2, (0b00101101, 0b00111111))
74+
# 8-bit Hexadecimal List
7175
display.set_digit_raw(3, [0x2D, 0x3F])
7276
time.sleep(2)
7377

0 commit comments

Comments
 (0)