-
Notifications
You must be signed in to change notification settings - Fork 16
Widget cartesian update line bugfix #62
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 16 commits into
adafruit:main
from
s-light:widget_cartesian__update_line__bugfix
Dec 23, 2021
Merged
Changes from 7 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c24681e
cartesian: fix basic update_line & add example
s-light 5d60353
extract local calculation
s-light af4c74c
debug _calc_local_xy
s-light ff529e6
analyse range checking
s-light 096cf05
fix range checking and add nice errormessages
s-light 3bf14f2
fix graph alignment error
s-light b57349d
rearange for less duplicate code.
s-light c356d2a
add verbose flag for debug output
s-light 9661bce
rename _screen_bitmap to _plot_bitmap, add clear_plot()
s-light 779fc7a
cleanup example
s-light caa160f
rename `update_line` to `add_line`
s-light 38b53df
renamed `clear_plot` to `clear_lines` for better name matching
s-light 529cbea
fix doc strings
s-light f1bf72a
fix missed rename..
s-light 1f4ed4a
fix name
s-light 8d8c94d
change names: `*_line` to `*_plot_line`
s-light 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,69 @@ | ||
# SPDX-FileCopyrightText: 2021 Stefan Krüger | ||
# | ||
# SPDX-License-Identifier: MIT | ||
############################# | ||
""" | ||
This is a basic demonstration of a Cartesian widget for line-ploting | ||
s-light marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
|
||
import time | ||
import board | ||
import displayio | ||
from adafruit_displayio_layout.widgets.cartesian import Cartesian | ||
|
||
# create the display on the PyPortal or Clue or PyBadge(for example) | ||
display = board.DISPLAY | ||
# otherwise change this to setup the display | ||
# for display chip driver and pinout you have (e.g. ILI9341) | ||
|
||
# pybadge display: 160x128 | ||
# Create a Cartesian widget | ||
# https://circuitpython.readthedocs.io/projects/displayio-layout/en/latest/api.html#module-adafruit_displayio_layout.widgets.cartesian | ||
my_plane = Cartesian( | ||
x=11, # x position for the plane | ||
y=0, # y plane position | ||
width=140, # display width | ||
height=110, # display height | ||
xrange=(0, 10), # x range | ||
yrange=(0, 10), # y range | ||
major_tick_stroke=1, # ticks width in pixels | ||
major_tick_length=2, # ticks length in pixels | ||
axes_stroke=1, # axes lines width in pixels | ||
axes_color=0x10A0A0, # axes line color | ||
subticks=True, | ||
) | ||
|
||
my_group = displayio.Group() | ||
my_group.append(my_plane) | ||
display.show(my_group) # add high level Group to the display | ||
|
||
data = [ | ||
# (0, 0), | ||
(1, 1), | ||
# (1, 15), # create out of range error | ||
(2, 1), | ||
(2, 2), | ||
(3, 3), | ||
(4, 3), | ||
(4, 4), | ||
(5, 5), | ||
(6, 5), | ||
(6, 6), | ||
(7, 7), | ||
(8, 7), | ||
(8, 8), | ||
(9, 9), | ||
(10, 9), | ||
(10, 10), | ||
] | ||
|
||
print("examples/displayio_layout_cartesian_lineplot.py") | ||
|
||
my_plane.update_line(0, 0) | ||
for x, y in data: | ||
my_plane.update_line(x, y) | ||
my_plane.update_pointer(x, y) | ||
time.sleep(0.5) | ||
|
||
while True: | ||
pass |
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,52 @@ | ||
# SPDX-FileCopyrightText: 2021 Stefan Krüger | ||
# | ||
# SPDX-License-Identifier: MIT | ||
############################# | ||
""" | ||
This is a basic demonstration of a Cartesian widget for line-ploting | ||
""" | ||
|
||
import time | ||
import board | ||
import displayio | ||
from adafruit_displayio_layout.widgets.cartesian import Cartesian | ||
|
||
# create the display on the PyPortal or Clue or PyBadge(for example) | ||
display = board.DISPLAY | ||
# otherwise change this to setup the display | ||
# for display chip driver and pinout you have (e.g. ILI9341) | ||
|
||
# pybadge display: 160x128 | ||
# Create a Cartesian widget | ||
# https://circuitpython.readthedocs.io/projects/displayio-layout/en/latest/api.html#module-adafruit_displayio_layout.widgets.cartesian | ||
my_plane = Cartesian( | ||
x=20, # x position for the plane | ||
y=0, # y plane position | ||
width=130, # display width | ||
height=105, # display height | ||
xrange=(0, 100), # x range | ||
yrange=(0, 100), # y range | ||
) | ||
|
||
my_group = displayio.Group() | ||
my_group.append(my_plane) | ||
display.show(my_group) # add high level Group to the display | ||
|
||
data = [ | ||
(0, 0), | ||
(10, 10), | ||
(30, 10), | ||
(50, 50), | ||
(70, 30), | ||
(90, 80), | ||
(95, 80), | ||
(100, 100), | ||
] | ||
|
||
print("examples/displayio_layout_cartesian_lineplot.py") | ||
for x, y in data: | ||
my_plane.update_line(x, y) | ||
time.sleep(1) | ||
|
||
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.