-
Notifications
You must be signed in to change notification settings - Fork 15
Add cartesian widget #22
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
Conversation
Wow, this is cool. I took a brief look at this (but haven’t run it on hardware yet) and a couple of items for discussion and consideration. (Feel free to disagree with any of this. I always think having something that meets the majority of the needs is good to get in place so people can get use out of it, and then you can always optimize later if needed.) I’m curious how you think this will be used. I could imagine that one widget is the two axes (or maybe two separate “axis” widgets?) and a separate widget is the actual data graph. If we keep the axes and graph data as separate items then you can separately update the data graph without it messing up your axes bitmap. Also, I’d consider evaluating the vectorio library for your axes. It has tools for drawing rectangles, so you could possibly use vectorio for your axes and tick marks. I haven’t done a direct comparison in meters use between a bitmap and vectorio but that could be an option. As for the other details, it looks like the tick marks aren’t evenly distributed. Also adding labels will be useful now that you have rotation labels working! This will be a great addition. As soon as you offer folks two axes, next they will want plots. That is progress! |
One other thing to mention added a If you use a bitmap for the axes, I think it will be better to use If the line has a stroke > 1 you will need to write mutiple times with bitmaptools.draw_line to make the line wider, maybe writing a rectangle function would be useful for a lot of uses. |
UsesI think the best use is to plot values vs time, as MU, Arduino , maybe we can add line and other types of things. VectorioYes, I have not tried that when I was doing the ticks, but if you see the new version I am using vectorio for the pointer, so that is perfect I will take a look into that. See 057a96c TicksYes, ticks, I think the best think is to create a "screen" factor to evenly distribute them. I will add that for sure, thanks for the recommendation. see a36b27c Axes linesThanks, I did not know that, for sure I will change that. Thanks for the recommendations. TestsI know is bare bones but please try the last commit with the example provided, now you can add the position, the dimensions and animate the pointer. I will work on this and all your recommendations. All recommendations are welcome, thanks |
# TODO Replace with drawline/vectorio [ ] # TODO Make a rectangle function [ ] # TODO Include functions to equal space ticks [ ] # TODO Make labels and text [ ] # TODO Make Styles applicable [ ] # TODO Animate when overflow [ ]
# TODO Replace with drawline/vectorio [ ] # TODO Make a rectangle function [ ] # TODO Include functions to equal space ticks [ ] # TODO Make labels and text [ ] # TODO Make Styles applicable [ ] # TODO Animate when overflow [ ]
# TODO Replace with drawline/vectorio [ ] # TODO Make a rectangle function [ ] # TODO Include functions to equal space ticks [ ] # TODO Make labels and text [ ] # TODO Make Styles applicable [ ] # TODO Animate when overflow [ ]
# TODO Make a rectangle function [ ] # TODO Include functions to equal space ticks [ ] # TODO Make labels and text [ ] # TODO Make Styles applicable [ ] # TODO Animate when overflow [ ] # TODO Add Subticks functionality [ ]
# TODO Include functions to equal space ticks [ ] # TODO Make labels and text [ ] # TODO Make Styles applicable [ ] # TODO Animate when overflow [ ] # TODO Add Subticks functionality [ ]
# TODO Include functions to equal space ticks [ ] # TODO Make labels and text [ ] # TODO Make Styles applicable [ ] # TODO Animate when overflow [ ] # TODO Add Subticks functionality [ ]
# TODO Include functions to equal space ticks [ ] # TODO Make labels and text [ ] # TODO Make Styles applicable [ ] # TODO Animate when overflow [ ] # TODO Add Subticks functionality [ ]
# TODO Include functions to equal space ticks [ ] # TODO Make labels and text [ ] # TODO Make Styles applicable [ ] # TODO Animate when overflow [ ] # TODO Add Subticks functionality [ ]
# TODO Make labels and text [ ] # TODO Make Styles applicable [ ] # TODO Animate when overflow [ ] # TODO Add Subticks functionality [ ] # TODO ticks evenly distributed [√]
# TODO Make Styles applicable [ ] # TODO Animate when overflow [ ] # TODO Add Subticks functionality [ ] # TODO Updater to use local coordinates [ ]
# TODO Make Styles applicable [ ] # TODO Animate when overflow [ ] # TODO Add Subticks functionality [ ] # TODO Updater to use local coordinates [ ]
# TODO Animate when overflow [ ] # TODO Add Subticks functionality [√] # TODO Updater to use local coordinates [√]
This is ready for review, after feedback and changes I will work on the plot moving with the data. Thanks |
# TODO Animate when overflow [ ]
# TODO Animate when overflow [ ]
# Conflicts: # docs/api.rst # docs/examples.rst
Wow the graphics are looking good. I’m excited to see all the graphs that I can make with it. I am getting the matplotlib vibes here too! I’ll spend some time tomorrow on this one. |
This is looking really good. Most of what I have is just minor tweaks. Only a couple things are "must-do" and the rest can are considered cleanup. Note: I did all my testing with the simpletest version. Must-do:
Tweaks:
if bitmaptool:
bitmaptools.fill_region(bitmap, x0, y0, x0+width-1, y0+height-1, color_index) I don't think it's necessary to use
This is a great addition. I can already envision new subclasses for all different kinds of graphs. |
@kmatch98
This is a great addition. I can already envision new subclasses for all different kinds of graphs. Thank you. me too this is a lot of fun :) |
@i built locallly the docs and they work, however a second check would not hurt. thanks. |
@jposada202020 I am trying this out tonight. I think there may be an issue with ticks and axes lines that use 1px stroke width. In the simpletest the tick stroke size is 1 pixel and the are not shown: I modified the example to use 1px for the axes stroke as well and I see similar results where those lines don't get drawn. I do see many images above with the 1px lines though so I suspect maybe this is from a more recent change. |
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.
This is awesome @jposada202020. Thanks for working on this!
I noticed a small issue, and have a few suggested improvements in the simpletest.
@@ -247,6 +247,24 @@ def __init__( | |||
self._screen_palette[4] = 0xFFFFFF | |||
self._screen_palette[5] = self._background_color | |||
|
|||
self._corner_bitmap = displayio.Bitmap(10, 10, 5) |
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.
@FoamyGuy Here is the inclusion to solve the corner issue, I tested with different strokes, however a second pair of eyes would not hurt
I resolve the issue with the corner, I was trying to create another bitmap to fill it, to tell the truth, other options will not work, as all the logic to convert from scale, to pixel to range is bases on the position of the [0,0] coordinates, and the widget is coordinates starts above. But maybe there is other ideas, but always open to new suggestions :) Thank you @FoamyGuy for the recommendations, and suggestions and for taking the time, to verify this. |
:return: None | ||
rtype: None | ||
""" | ||
local_x = int((x - self._xrange[0]) * self._factorx) |
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 experimented a bit with the pointer position to try to get 0,0 matching the bottom left corner.
I updated this line like this:
local_x = int((x - self._xrange[0]) * self._factorx) - 2
and it seems to be lining up correctly for me like this in a few quick tests. Do you think this would cause trouble in some situations @jposada202020? or would it be an okay fix to use?
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.
@FoamyGuy I think is perfect, doing the equalizer I realized that we need a buffer
to correct all the float to int conversion, I think it is perfect, errors will be added at the end, kmatch uses a nudge
variable to do this. Maybe following this line of thought instead of adding the 2
we could add the nudge
correction, what do you think?
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.
@jposada202020 That sounds good to me
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.
@FoamyGuy Thanks, I add the nudge
parameter
I think we need to use the nudge parameters inside |
# Conflicts: # docs/examples.rst
You are right. I did not put it in the update function. |
Corrected and tested with Axes=1 and ticks=1. Thanks for reviewing @FoamyGuy |
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 tested out the latest version and it's working well for me. Thanks for all of your work on this @jposada202020.
I found one reference to the style function that was removed in the advanced example. Once that is taken care of I think this will be ready to merge.
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.
Looks good to me. Tested successfully with:
Adafruit CircuitPython 6.2.0-rc.0 on 2021-04-01; Adafruit PyPortal with samd51j20
Thanks for this great new widget @jposada202020. I'm excited to see what kinds of charts folks use it for!
Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout to 1.9.0 from 1.8.0: > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#22 from jposada202020/cartesian
Purpose of this PR is to include a Cartesian Plane to the DisplaIO layout. This will help to plot values in a (x,y) form.
Inspired by the Dial Widget from @kmatch98