-
Notifications
You must be signed in to change notification settings - Fork 29
Adding new animation demo to show what can be done when using set_dig… #59
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7f27b57
Adding new animation demo to show what can be done when using set_dig…
577963b
Adding new animation demo to show what can be done by using set_raw_d…
474437f
Converted all tabs to spaces for indentation.
3c5cab7
Rewrote two for loops to be while loops.
8595bed
Removed trailing white space.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| """ Test script for display animations on an HT16K33 with alphanumeric display """ | ||
|
|
||
| from time import sleep | ||
| import board | ||
| import busio | ||
| from adafruit_ht16k33 import segments | ||
|
|
||
| # The number of seconds to delay between writing segments | ||
| DEFAULT_CHAR_DELAY_SEC = 0.2 | ||
|
|
||
| # The number of cycles to go for each animation | ||
| DEFAULT_CYCLES = 1 | ||
|
|
||
| # | ||
| # Segment bits on the HT16K33 with alphanumeric display | ||
| # | ||
|
|
||
| N = 16384 | ||
| M = 8192 | ||
| L = 4096 | ||
| K = 2048 | ||
| J = 1024 | ||
| I = 512 | ||
| H = 256 | ||
| G2= 128 | ||
| G1= 64 | ||
| F = 32 | ||
| E = 16 | ||
| D = 8 | ||
| C = 4 | ||
| B = 2 | ||
| A = 1 | ||
|
|
||
| def animate(digits, bitmasks, delay=DEFAULT_CHAR_DELAY_SEC, cycles=DEFAULT_CYCLES): | ||
| ''' | ||
| Main driver for alphanumeric display animations (WIP!!!) | ||
| Param: digits - a list of the digits to write to, like [0, 1, 3]. The digits are | ||
| 0 to 3 starting at the left most digit. Digits will be written to in sequence. | ||
| Param: bitmasks - a list of the bitmasks to write, in sequence, to the specified digits. | ||
| Param: delay - The delay, in seconds (or fractions of), between writing bitmasks to a digit. | ||
| Param: cycles - The number of cycles (loops) to write an animation. | ||
|
|
||
| Returns: No result | ||
| ''' | ||
| cy = 0 | ||
|
|
||
| while cy < cycles: | ||
| # cy in range(cycles): | ||
| for dig in digits: | ||
| for bits in bitmasks: | ||
| display.set_digit_raw(dig, bits) | ||
| sleep(delay) | ||
|
|
||
| cy += 1 | ||
|
|
||
| def chase_animation(delay=DEFAULT_CHAR_DELAY_SEC, cycles=DEFAULT_CYCLES): | ||
| cy = 0 | ||
|
|
||
| while cy < cycles: | ||
| #for cy in range(cycles): | ||
geekguy-wy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| animate([0, 1, 2, 3], [A, 0], delay) | ||
| animate([3], [B, C, D, 0], delay) | ||
| animate([2, 1, 0], [D, 0], delay) | ||
| animate([0], [E, F, H, G2, 0], delay) | ||
| animate([1, 2], [G1, G2, 0], delay) | ||
| animate([3], [G1, J, A, 0], delay) | ||
| animate([2, 1], [A, 0], delay) | ||
| animate([0], [A, F, E, D, 0], delay) | ||
| animate([1, 2], [D, 0], delay) | ||
| animate([3], [D, C, B, J, G1, 0], delay) | ||
| animate([2, 1], [G2, G1, 0], delay) | ||
| animate([0], [H, 0], delay) | ||
| #animate([0], [M, H, 0x0], delay) | ||
geekguy-wy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| cy += 1 | ||
|
|
||
| # Initialize the I2C bus | ||
| i2c = busio.I2C(board.SCL, board.SDA) | ||
|
|
||
| # Initialize the HT16K33 with alphanumeric display featherwing | ||
| display = segments.Seg14x4(i2c) | ||
|
|
||
| text = "Init" | ||
|
|
||
| display.fill(1) | ||
| sleep(1) | ||
| display.fill(0) | ||
|
|
||
| display.print(text) | ||
| sleep(1) | ||
| display.fill(0) | ||
| print() | ||
|
|
||
| while True: | ||
| # Arrow | ||
| animate([0, 1, 2], [G1+G2]) | ||
| animate([3], [G1+H+K]) | ||
| sleep(1.5) | ||
| display.fill(0) | ||
| sleep(1.5) | ||
|
|
||
| # Flying | ||
| animate([0], [H+J, G1+G2, K+M, G1+G2], 0.2, 5) | ||
| animate([0], [0]) | ||
| sleep(1.5) | ||
| display.fill(0) | ||
| sleep(1.5) | ||
|
|
||
| # Chase and reverse. | ||
| chase_animation(0.1, 5) | ||
| sleep(1.5) | ||
| display.fill(0) | ||
| sleep(1.5) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.