Skip to content

Updated examples for pylint #6

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 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
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
34 changes: 21 additions & 13 deletions examples/display_shapes_sparkline_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
# See the bottom for a code example using the `sparkline` Class.

# # File: display_shapes_sparkline.py
# A sparkline is a scrolling line graph, where any values added to sparkline using `add_value` are plotted.
# A sparkline is a scrolling line graph, where any values added to sparkline using
# `add_value` are plotted.
#
# The `sparkline` class creates an element suitable for adding to the display using `display.show(mySparkline)`
# The `sparkline` class creates an element suitable for adding to the display using
# `display.show(mySparkline)`
# or adding to a `displayio.Group` to be displayed.
#
# When creating the sparkline, identify the number of `max_items` that will be included in the graph.
# When additional elements are added to the sparkline and the number of items has exceeded max_items,
# any excess values are removed from the left of the graph, and new values are added to the right.
# When creating the sparkline, identify the number of `max_items` that will be
# included in the graph.
# When additional elements are added to the sparkline and the number of items has
# exceeded max_items, any excess values are removed from the left of the graph,
# and new values are added to the right.


# The following is an example that shows the
Expand All @@ -23,11 +27,12 @@
# add new values to sparkline `add_value`
# update the sparklines `update`

import time
import random
import board
import displayio
import terminalio
import random
import time


from adafruit_display_shapes.sparkline import Sparkline

if "DISPLAY" not in dir(board):
Expand All @@ -47,7 +52,7 @@

while not spi.try_lock():
spi.configure(baudrate=32000000)
pass

spi.unlock()

display_bus = displayio.FourWire(
Expand Down Expand Up @@ -90,15 +95,18 @@
chartWidth = display.width
chartHeight = display.height

# mySparkline1 uses a vertical y range between 0 to 10 and will contain a maximum of 40 items
# mySparkline1 uses a vertical y range between 0 to 10 and will contain a
# maximum of 40 items
mySparkline1 = Sparkline(
width=chartWidth, height=chartHeight, max_items=40, yMin=0, yMax=10, x=0, y=0
)

# Create a group to hold the sparkline and append the sparkline into the group (myGroup)
# Create a group to hold the sparkline and append the sparkline into the
# group (myGroup)
#
# Note: In cases where display elements will overlap, then the order the elements are added to the
# group will set which is on top. Latter elements are displayed on top of former elemtns.
# Note: In cases where display elements will overlap, then the order the elements
# are added to the group will set which is on top. Latter elements are displayed
# on top of former elemtns.
myGroup = displayio.Group(max_size=1)

# add the sparkline into myGroup
Expand Down
23 changes: 14 additions & 9 deletions examples/display_shapes_sparkline_ticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
# See the bottom for a code example using the `sparkline` Class.

# # File: display_shapes_sparkline.py
# A sparkline is a scrolling line graph, where any values added to sparkline using `add_value` are plotted.
# A sparkline is a scrolling line graph, where any values added to sparkline
# using `add_value` are plotted.
#
# The `sparkline` class creates an element suitable for adding to the display using `display.show(mySparkline)`
# or adding to a `displayio.Group` to be displayed.
# The `sparkline` class creates an element suitable for adding to the display
# using `display.show(mySparkline)` or adding to a `displayio.Group` to be displayed.
#
# When creating the sparkline, identify the number of `max_items` that will be included in the graph.
# When additional elements are added to the sparkline and the number of items has exceeded max_items,
# any excess values are removed from the left of the graph, and new values are added to the right.
# When creating the sparkline, identify the number of `max_items` that will be
# included in the graph.
# When additional elements are added to the sparkline and the number of items
# has exceeded max_items, any excess values are removed from the left of the
# graph, and new values are added to the right.


# The following is an example that shows the
Expand Down Expand Up @@ -100,7 +103,8 @@

# Setup the first bitmap and sparkline
# This sparkline has no background bitmap
# mySparkline1 uses a vertical y range between 0 to 10 and will contain a maximum of 40 items
# mySparkline1 uses a vertical y range between 0 to 10 and will contain a
# maximum of 40 items
mySparkline1 = Sparkline(
width=chartWidth,
height=chartHeight,
Expand Down Expand Up @@ -142,8 +146,9 @@
# Create a group to hold the sparkline, text, rectangle and tickmarks
# append them into the group (myGroup)
#
# Note: In cases where display elements will overlap, then the order the elements are added to the
# group will set which is on top. Latter elements are displayed on top of former elemtns.
# Note: In cases where display elements will overlap, then the order the
# elements are added to the group will set which is on top. Latter elements
# are displayed on top of former elemtns.

myGroup = displayio.Group(max_size=20)

Expand Down
45 changes: 27 additions & 18 deletions examples/display_shapes_sparkline_triple.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
# See the bottom for a code example using the `sparkline` Class.

# # File: display_shapes_sparkline.py
# A sparkline is a scrolling line graph, where any values added to sparkline using `add_value` are plotted.
# A sparkline is a scrolling line graph, where any values added to sparkline
# using `add_value` are plotted.
#
# The `sparkline` class creates an element suitable for adding to the display using `display.show(mySparkline)`
# or adding to a `displayio.Group` to be displayed.
# The `sparkline` class creates an element suitable for adding to the display
# using `display.show(mySparkline)` or adding to a `displayio.Group` to be displayed.
#
# When creating the sparkline, identify the number of `max_items` that will be included in the graph.
# When additional elements are added to the sparkline and the number of items has exceeded max_items,
# any excess values are removed from the left of the graph, and new values are added to the right.
# When creating the sparkline, identify the number of `max_items` that will be
# included in the graph.
# When additional elements are added to the sparkline and the number of items
# has exceeded max_items, any excess values are removed from the left of the
# graph, and new values are added to the right.


# The following is an example that shows the
Expand All @@ -23,11 +26,11 @@
# add new values to sparkline `add_value`
# update the sparklines `update`

import random
import time
import board
import displayio
import terminalio
import random
import time
from adafruit_display_shapes.sparkline import Sparkline
from adafruit_ili9341 import ILI9341
from adafruit_display_text import label
Expand Down Expand Up @@ -75,7 +78,7 @@
display_bus,
width=DISPLAY_WIDTH,
height=DISPLAY_HEIGHT,
rotation=180, # The rotation can be adjusted to match your configuration.
rotation=180, # The rotation can be adjusted to match your configuration.
auto_refresh=True,
native_frames_per_second=90,
)
Expand Down Expand Up @@ -124,7 +127,8 @@


# Setup the second bitmap and sparkline
# mySparkline2 uses a vertical y range between 0 to 1, and will contain a maximum of 10 items
# mySparkline2 uses a vertical y range between 0 to 1, and will contain a
# maximum of 10 items
#
palette2 = displayio.Palette(1) # color palette used for bitmap2 (one color)
palette2[0] = 0x0000FF
Expand All @@ -147,9 +151,12 @@

# Setup the third bitmap and third sparkline
# mySparkline3 contains a maximum of 10 items
# since yMin and yMax are not specified, mySparkline3 uses autoranging for both the top and bottom of the y-axis.
# Note1: Any unspecified edge limit (yMin or yMax) will autorange that edge based on the data in the list.
# Note2: You can read back the value of the y-axis limits by using mySparkline3.yBottom or mySparkline3.yTop
# since yMin and yMax are not specified, mySparkline3 uses autoranging for both
# the top and bottom of the y-axis.
# Note1: Any unspecified edge limit (yMin or yMax) will autorange that edge based
# on the data in the list.
# Note2: You can read back the value of the y-axis limits by using
# mySparkline3.yBottom or mySparkline3.yTop


palette3 = displayio.Palette(1) # color palette used for bitmap (one color)
Expand Down Expand Up @@ -187,12 +194,12 @@
120 + mySparkline3.height,
) # set the text anchored position to the upper right of the graph


# Create a group to hold the three bitmap TileGrids and the three sparklines and
# append them into the group (myGroup)
#
# Note: In cases where display elements will overlap, then the order the elements are added to the
# group will set which is on top. Latter elements are displayed on top of former elemtns.
# Note: In cases where display elements will overlap, then the order the elements
# are added to the group will set which is on top. Latter elements are displayed
# on top of former elemtns.
myGroup = displayio.Group(max_size=20)

myGroup.append(mySparkline1)
Expand All @@ -207,7 +214,8 @@
myGroup.append(textLabel3a)
myGroup.append(textLabel3b)

# Set the display to show myGroup that contains all the bitmap TileGrids and sparklines
# Set the display to show myGroup that contains all the bitmap TileGrids and
# sparklines
display.show(myGroup)

i = 0 # This is a counter for changing the random values for mySparkline3
Expand All @@ -227,7 +235,8 @@
# Note: For mySparkline2, the y-axis range is set from 0 to 1.
# With the random values set between -1 and +2, the values will sometimes
# be out of the y-range. This example shows how the fixed y-range (0 to 1)
# will "clip" values (it will not display them) that are above or below the y-range.
# will "clip" values (it will not display them) that are above or below the
# y-range.
mySparkline2.add_value(random.uniform(-1, 2))

# mySparkline3 is set autoranging for the top and bottom of the Y-axis
Expand Down