Skip to content

implement parameter update for add_values() #50

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
merged 2 commits into from
Jul 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions adafruit_display_shapes/sparkline.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,14 @@ def clear_values(self) -> None:
self.pop()
self._spark_list = [] # empty the list

def add_value(self, value: float) -> None:
def add_value(self, value: float, update: bool = True) -> None:
"""Add a value to the sparkline.
:param value: The value to be added to the sparkline
:param update: trigger recreation of primitives

Note: when adding multiple values it is more efficient to call
this method with parameter 'update=False' and then to manually
call the update()-method
"""

if value is not None:
Expand All @@ -110,7 +115,8 @@ def add_value(self, value: float) -> None:
): # if list is full, remove the first item
self._spark_list.pop(0)
self._spark_list.append(value)
self.update()
if update:
self.update()

# pylint: disable=no-else-return
@staticmethod
Expand Down