Skip to content

Add 14-segment-specific example, update comments. #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions examples/ht16k33_segments_14x4_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import board
from adafruit_ht16k33 import segments

# Create the display object.
# Display connected to STEMMA QT connector.
display = segments.Seg14x4(board.STEMMA_I2C())
# Display connected to I2C pins.
# display = segments.Seg14x4(board.I2C())

# This section displays four 0's across the display. The code shows four
# different ways to use the set_digit_raw function. Each is labeled below.
# 16-bit Hexadecimal number
display.set_digit_raw(0, 0x2D3F)
time.sleep(0.2)
# 16-bit Binary number
display.set_digit_raw(1, 0b0010110100111111)
time.sleep(0.2)
# 8-bit Binary Tuple
display.set_digit_raw(2, (0b00101101, 0b00111111))
time.sleep(0.2)
# 8-bit Hexadecimal List
display.set_digit_raw(3, [0x2D, 0x3F])
time.sleep(0.2)

# Delay between.
time.sleep(2)

# Scroll "Hello, world!" across the display. Setting the loop parameter to false allows you to
# tell the marquee function to run only once. By default, marquee loops indefinitely.
display.marquee("Hello, world!", loop=False)

# Delay between.
time.sleep(2)

# Scroll special characters, uppercase and lowercase letters, and numbers across
# the display in a loop. This section will continue to run indefinitely.
display.marquee("".join(chr(character) for character in range(ord("!"), ord("z") + 1)))
6 changes: 5 additions & 1 deletion examples/ht16k33_segments_multi_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@
display.set_digit_raw(2, 0x79)
display.set_digit_raw(3, 0b01111001)
else:
# 14-segment raw digits
# 14-segment raw digits. Same character (0) displayed using four different methods.
# 16-bit Hexadecimal number
display.set_digit_raw(0, 0x2D3F)
# 16-bit Binary number
display.set_digit_raw(1, 0b0010110100111111)
# 8-bit Binary Tuple
display.set_digit_raw(2, (0b00101101, 0b00111111))
# 8-bit Hexadecimal List
display.set_digit_raw(3, [0x2D, 0x3F])
time.sleep(2)

Expand Down
6 changes: 5 additions & 1 deletion examples/ht16k33_segments_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@
display.set_digit_raw(2, 0x79)
display.set_digit_raw(3, 0b01111001)
else:
# 14-segment raw digits
# 14-segment raw digits. Same character (0) displayed using four different methods.
# 16-bit Hexadecimal number
display.set_digit_raw(0, 0x2D3F)
# 16-bit Binary number
display.set_digit_raw(1, 0b0010110100111111)
# 8-bit Binary Tuple
display.set_digit_raw(2, (0b00101101, 0b00111111))
# 8-bit Hexadecimal List
display.set_digit_raw(3, [0x2D, 0x3F])
time.sleep(2)

Expand Down