Skip to content

Cartesian how to use the update_line function? #61

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
s-light opened this issue Dec 15, 2021 · 1 comment · Fixed by #62
Closed

Cartesian how to use the update_line function? #61

s-light opened this issue Dec 15, 2021 · 1 comment · Fixed by #62

Comments

@s-light
Copy link
Contributor

s-light commented Dec 15, 2021

there is a update_line function in the Cartesian class.
but i have not found any documentation about it -

i would expect to be able to draw some kind of linegraph with multiple points.
but looking at the code and testing that does not happen..

it seems that the first time the function is called it setups self.plot_line_point and adds the given point.
and after this it draws a line from this first point to the given point.
resulting in a star-like graph.

i tested and the only thing missing is a self.plot_line_point.append((local_x, local_y)) after the call to bitmaptools.draw_line(

my minimal testcode:

# SPDX-FileCopyrightText: 2021 Stefan Krüger
#
# SPDX-License-Identifier: MIT
#############################
"""
Simple Test for line-ploting with the Cartesian widget.
"""

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


# 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=30,  # x position for the plane
    y=2,  # y plane position
    width=128,  # display width
    height=105,  # display height
    xrange=(0, 90),
    yrange=(0, 90),
)

my_group = displayio.Group()
my_group.append(my_plane)
display.show(my_group)  # add high level Group to the display

positions = [
    (0, 0),
    (10, 10),
    (20, 50),
    (30, 60),
    (40, 40),
    (50, 80),
    (60, 20),
    (70, 60),
    (80, 30),
    (90, 90),
]

print("displayIO__layout_widget_cartesian_lineplot.py")
for x, y in positions:
    my_plane.update_line(x, y)
    time.sleep(1)

while True:
    pass

@FoamyGuy @kattni should i submit a pull request for this?

@FoamyGuy
Copy link
Contributor

@s-light Yes that would be awesome if you want to submit PR for that. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants