-
Notifications
You must be signed in to change notification settings - Fork 39
New parameter and example creation for testing and future reference #115
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
FoamyGuy
merged 10 commits into
adafruit:master
from
jposada202020:base_alignement_proposal
Feb 19, 2021
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ba68b8a
New parameter and example creation for testing and future reference
jposada202020 3fbb43a
License identification in example
jposada202020 10d5823
Change in import order
jposada202020 2744279
Change example
jposada202020 b6cf39c
Changes including scale and Alignment
jposada202020 06238ab
Erase Space
jposada202020 7d61825
Merge branch 'adafruit_master' into base_alignement_proposal
jposada202020 ac3f4b7
Pylint and Black
jposada202020 a7101c8
New Example logic to show parameters cases at the same time
jposada202020 448ae32
Black changes
jposada202020 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,79 @@ | ||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries | ||
# SPDX-License-Identifier: MIT | ||
|
||
""" | ||
This examples shows the use of base_alignment parameter. | ||
""" | ||
|
||
import time | ||
import board | ||
import displayio | ||
from adafruit_bitmap_font import bitmap_font | ||
from adafruit_display_text import label | ||
|
||
|
||
display = board.DISPLAY | ||
|
||
# Font definition. You can choose any two fonts available in your system | ||
MEDIUM_FONT = bitmap_font.load_font("Helvetica-Bold-16.bdf") | ||
BIG_FONT = bitmap_font.load_font("LeagueSpartan-Bold-16.bdf") | ||
|
||
# Test parameters | ||
TEXT_BACKGROUND_COLOR = 0x990099 | ||
TEXT_COLOR = 0x00FF00 | ||
X_COL_POS = [10, 90] # X position of the Label boxes | ||
TEST_TEXT = [ | ||
"aApPqQ.", | ||
"ppppppp", | ||
"llllll", | ||
"oooooo", | ||
"ñúÇèüß", | ||
] # Iteration text for testing | ||
LOCALISATION_Y = [40, 80, 120, 160, 200] # Y coordinate of the text labels | ||
NUMBER_TEXT_LABELS = len(LOCALISATION_Y) * len( | ||
X_COL_POS | ||
) # Calculation for Display.Group function | ||
TIME_BETWEEN_TEXTS = 5 # Seconds | ||
BASE_ALIGNMENT_OPTIONS = [False, True] | ||
|
||
# Test | ||
for behaviour in BASE_ALIGNMENT_OPTIONS: | ||
for text_test in TEST_TEXT: | ||
main_group = displayio.Group(max_size=NUMBER_TEXT_LABELS + 1) | ||
for position in LOCALISATION_Y: | ||
text = label.Label( | ||
font=MEDIUM_FONT, | ||
text=text_test, | ||
color=TEXT_COLOR, | ||
background_tight=True, | ||
background_color=TEXT_BACKGROUND_COLOR, | ||
x=X_COL_POS[0], | ||
y=position, | ||
base_alignment=behaviour, | ||
) | ||
main_group.append(text) | ||
text = label.Label( | ||
font=BIG_FONT, | ||
text=text_test, | ||
color=TEXT_COLOR, | ||
background_tight=False, | ||
background_color=TEXT_BACKGROUND_COLOR, | ||
x=X_COL_POS[1], | ||
y=position, | ||
base_alignment=behaviour, | ||
) | ||
main_group.append(text) | ||
display.show(main_group) | ||
display.refresh() | ||
time.sleep(TIME_BETWEEN_TEXTS) | ||
|
||
|
||
bitmap = displayio.Bitmap(280, 5, 2) | ||
palette = displayio.Palette(2) | ||
palette[0] = 0x004400 | ||
palette[1] = 0x00FFFF | ||
tile_grid2 = displayio.TileGrid(bitmap, pixel_shader=palette, x=10, y=160) | ||
main_group.append(tile_grid2) | ||
|
||
while True: | ||
pass |
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.