-
Notifications
You must be signed in to change notification settings - Fork 28
Add ability to use custom characters for 7-segment display #96
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9b1359d
Add ability to use custom character dictionary
tekktrik cd3e723
Add example file prototype for custom characters
tekktrik f494274
Merge remote-tracking branch 'upstream/main' into feature/custom-char…
tekktrik f330123
Finalize example for custom characters
tekktrik f7b3251
Added custom_chars as argument
tekktrik d6cd31e
Reformatted per pre-commit
tekktrik a686c64
Move index assignment using POSITIONS
tekktrik 1de6cec
Update example file with time.sleep()
tekktrik d242e18
Merge branch 'main' into feature/custom-characters
tekktrik 7730768
Change import order in example
tekktrik e0c43fb
Update examples/ht16k33_segments_7x4customchars.py
tekktrik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Basic example of setting digits on a LED segment display. | ||
# This example and library is meant to work with Adafruit CircuitPython API. | ||
# Author: Alec Delaney | ||
# License: Public Domain | ||
|
||
# Import all board pins. | ||
import time | ||
import board | ||
import busio | ||
from adafruit_ht16k33 import segments | ||
|
||
# Create the character dictionary | ||
# You can use the list normally referenced as a starting point | ||
custom_chars = {} | ||
typical_list_values = segments.NUMBERS | ||
typical_list_chars = list("0123456789abcdef-") | ||
for char, value in zip(typical_list_chars, typical_list_values): | ||
custom_chars[char] = value | ||
|
||
# Add the custom characters you want | ||
custom_chars["s"] = 0b01101101 | ||
custom_chars["r"] = 0b01010000 | ||
custom_chars["o"] = 0b00111111 | ||
custom_chars["l"] = 0b00110000 | ||
custom_chars["i"] = 0b00010000 | ||
custom_chars["n"] = 0b01010100 | ||
custom_chars["g"] = 0b01101111 | ||
|
||
# Create the I2C interface. | ||
i2c = busio.I2C(board.SCL, board.SDA) | ||
display = segments.Seg7x4(i2c, char_dict=custom_chars) | ||
|
||
# Clear the display. | ||
display.fill(0) | ||
|
||
# Now you can print custom text | ||
display.print("cool") | ||
time.sleep(3) | ||
|
||
# You can also marquee custom text | ||
display.marquee("scrolling... ", 0.2) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dug for a bit and found that it is making it to here and calling
_set_buffer()
with values that seem okay to me, but nothing seems to happen on the segment display. Possibly it's an auto_write issue?I'm putting it down for now but will circle back eventually to look more if you don't end up getting a solution once you've got your hardware for testing.