-
Notifications
You must be signed in to change notification settings - Fork 18
Add example using line for a moving sparkline graph #14
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
The checkout failed pylint, but the errors where on files that were not modified in this pull request. I think it didn’t get to my new example before it gave up. I haven’t got pylint running on my local machine yet, but will fight through getting it running if you need me to (kattni’s pylint tutorial looks like a godsend based on my first glance at it). |
I looked into these PyLint issues a bit and I'm a perplexed by them. When I try to run PyLint locally I am not getting the same failures:
I'm not sure why I'm getting differing results from the github CI system. Focusing on the issues that it shows in the github check: I think renaming The not enough public methods issue I don't know how to solve other than disabling it. Circle and Line are sub-classes of other things that include public methods I think. They don't change the behavior of any public methods or add any new ones. They only have a modified |
Pylint oddities aside I think this is a neat addition but can be refactored a bit. I would propose that the The example script can remain as is (minus the class) to show an example of usage. I can help update the example to work with built-in displays as well. |
This is great! +1 to the refactor and making the class part of the library. |
I separated out the class into a separate
@FoamyGuy I will appreciate if you will take a look to verify the examples. |
This is great! Thank you for refactoring it into a class similar to the other shapes in the library. I tested all 3 examples on PyPortal and they are are all working for me on that device. I do see a bit of the "ghosting" effect that PTS93 mentioned. I think perhaps it's the previous frame in the process of being deleted maybe? I'm going to try to poke around a bit inside the Sparkline class tomorrow to see if I can understand it a bit better. I do think it will be best to at least provide the option to use built-in display in the sample code. I can submit some PRs on your branch to add this. Maybe we can structure it to try the built-in display first and if it doesn't find one then use the display driver to set it up. That way it can avoid the importing of the driver on devices that don't need it. Unrelated to the specific PR, but once this gets merged in I think it would be great to built some accelerometer examples with it. Also it seems like maybe the Actions system is having some trouble at the time of writing this comment. Hopefully it will eventually run those checks. But worst case scenario I think it should try again with the next commit. |
Thanks for the comments on the ghosting. I alleviated the worst of it by turning the display auto refresh off during the update. However I am somewhat torn about having a separate I actually think it’s simpler to use if the I think the ghosting is just something with how displayio does the redraw. I don’t think it clears the display fully before redrawing. If you plot one full screen bitmap and replace it with another, you can see how displayio is redrawing. I don’t suspect this can be solved inside Sparkline. But I definitely agree that it’s not desirable and I’m all ears for a solution, but I suspect it will need to be done in displayio. As for the display setup to be more generic I will appreciate your input on that. |
update the simpletest to generalize the display setup
Set for auto update upon add_value, updated examples with display checking
Updates for pylint, ran black
updated for pylint
pylint fixes
Updated examples for pylint
Ran black
Pylint updates and ran black
Wow, got this to survive pylint! Anyway, I am satisified with the examples now. Please review and let me know what updates are required to merge. Thanks for all your help! |
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.
Hi, as per PEP8, could you please use snake_case variables instead of camelCase? You shouldn't need to pylint disable "invalid-name" then. This is so we can keep things consistent. Thanks.
Actually, you might still need the invalid-name thing for x and y, which is fine. |
Ok will do. I have to learn the “way of pylint” to save effort next time. Will update and enable that check and let you know. |
@makermelissa per your request, I resolved and and re-enabled "invalid-name" pylint checks for The following Line 42: too-many-arguments |
Thanks @kmatch98. The other disables are fine. I'll test these examples out this afternoon. |
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 on the PyPortal. The first 2 examples worked fine, but on the "triple" one, I get 'DISPLAY_WIDTH' is not defined
and that's probably because DISPLAY is part of board, so that definition is bypassed.
Perhaps you can set DISPLAY_WIDTH to board.DISPLAY.width so that it works on the Titano as well. |
@makermelissa Unfortunately I don't have access to pyPortal or Titano to evaluate this fix. I added your suggested code. If you are willing, please check if this resolves the issue. If there are more complicated changes required, I'll have to rely on @FoamyGuy to verify if this works on the different flavors of pyPortals, he developed this cool way of checking for internal vs external display. |
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.
Tested good. Thanks!
Excellent. Thank you! |
Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes to 1.5.0 from 1.4.1: > Merge pull request adafruit/Adafruit_CircuitPython_Display_Shapes#14 from kmatch98/master
Inspired by this Arduino library for sparklines, here is an example of creating moving sparkline graphs in CircuitPython using the

Line
command.This example includes the
sparkline
class definition and a practical example that creates three different sparklines with bitmap backgrounds.Class usage:
sparkline
A sparkline is instanced with the following input variables:
width
: Width of the sparkline in display pixelsheight
: Height of the sparkline in display pixelsmax_items
: Maximum number of values that will be stored and displayed in the sparklineyMin
: The lower y-range of the bottom of the graph. Set toNone
to autorange the bottom axis (Default=None)yMax
: The upper y-range of top of the graph. Set toNone
to autorange the top axis (Default=None)line_color
: The color value used for displaying the line (Default=0xFFFFFF white)x
: x-position of the upper left corner of the sparkline display, in pixels (Default=0)y
: y-position of the upper left corner of the sparkline display, in pixels (Default=0)This
sparkline
class includes three class functions:add_value
: Add a value to an existing sparklineupdate
: Updates the visual elements of the sparklingvalues
: Returns the current list of values stored in sparkline