Skip to content

Commit

Permalink
adding_axes
Browse files Browse the repository at this point in the history
  • Loading branch information
jposada202020 committed Feb 10, 2023
1 parent 8444a43 commit 68e2c4a
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions uplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
__repo__ = "https://github.com/adafruit/CircuitPython_uplot.git"


# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments, too-many-instance-attributes)


class Uplot(displayio.Group):
Expand Down Expand Up @@ -63,9 +63,13 @@ def __init__(self, x=0, y=0, width=None, height=None):
self._axesybitmap_height = self._height - 30
self._axesybitmap_width = 20

self._axesxbitmap = displayio.Bitmap(self._axesxbitmap_width, self._axesxbitmap_height, 2)
self._axesybitmap = displayio.Bitmap(self._axesybitmap_width, self._axesybitmap_height, 4)
#self._axesybitmap.fill(2)
self._axesxbitmap = displayio.Bitmap(
self._axesxbitmap_width, self._axesxbitmap_height, 2
)
self._axesybitmap = displayio.Bitmap(
self._axesybitmap_width, self._axesybitmap_height, 4
)
# self._axesybitmap.fill(2)
self.append(
displayio.TileGrid(
self._plotbitmap, pixel_shader=self._axes_palette, x=0, y=0
Expand Down Expand Up @@ -104,16 +108,36 @@ def axes(self, line_color=1):
:param line_color: index of the color palette
:return: None
"""
draw_line(self._axesxbitmap, 0, self._axesxbitmap_height//2, self._axesxbitmap_width, self._axesxbitmap_height//2, line_color)
draw_line(self._axesybitmap, self._axesybitmap_width-1, 0, self._axesybitmap_width-1, self._axesybitmap_height, line_color)
draw_line(
self._axesxbitmap,
0,
self._axesxbitmap_height // 2,
self._axesxbitmap_width,
self._axesxbitmap_height // 2,
line_color,
)
draw_line(
self._axesybitmap,
self._axesybitmap_width - 1,
0,
self._axesybitmap_width - 1,
self._axesybitmap_height,
line_color,
)

self.append(
displayio.TileGrid(
self._axesxbitmap, pixel_shader=self._axes_palette, x=15, y=self._yorigin
self._axesxbitmap,
pixel_shader=self._axes_palette,
x=15,
y=self._yorigin,
)
)
self.append(
displayio.TileGrid(
self._axesybitmap, pixel_shader=self._axesy_palette, x=15- self._axesybitmap_width, y=self._height-self._axesybitmap_height - self._axesxbitmap_height
self._axesybitmap,
pixel_shader=self._axesy_palette,
x=15 - self._axesybitmap_width,
y=self._height - self._axesybitmap_height - self._axesxbitmap_height,
)
)

0 comments on commit 68e2c4a

Please sign in to comment.