Skip to content
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
40 changes: 21 additions & 19 deletions adafruit_ra8875/ra8875.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def rect(self, x, y, width, height, color):
:param int height: The height of the rectangle
:param int color: The color of the rectangle
"""
self._rect_helper(x, y, width, height, color, False)
self._rect_helper(x, y, x + width - 1, y + height - 1, color, False)

def fill_rect(self, x, y, width, height, color):
"""
Expand All @@ -585,15 +585,15 @@ def fill_rect(self, x, y, width, height, color):
:param int height: The height of the rectangle
:param int color: The color of the rectangle
"""
self._rect_helper(x, y, width, height, color, True)
self._rect_helper(x, y, x + width - 1, y + height - 1, color, True)

def fill(self, color):
"""
Fill the Entire Screen (HW Accelerated)

:param int color: The color to Fill the screen
"""
self._rect_helper(0, 0, self.width, self.height, color, True)
self._rect_helper(0, 0, self.width - 1, self.height - 1, color, True)

def circle(self, x_center, y_center, radius, color):
"""
Expand Down Expand Up @@ -706,7 +706,7 @@ def hline(self, x, y, width, color):
:param int width: The width of the line
:param int color: The color of the line
"""
self.line(x, y, x + width, y, color)
self.line(x, y, x + width - 1, y, color)

def vline(self, x, y, height, color):
"""
Expand All @@ -717,7 +717,7 @@ def vline(self, x, y, height, color):
:param int height: The height of the line
:param int color: The color of the line
"""
self.line(x, y, x, y + height, color)
self.line(x, y, x, y + height - 1, color)

def line(self, x1, y1, x2, y2, color):
"""
Expand Down Expand Up @@ -758,13 +758,14 @@ def round_rect(self, x, y, width, height, radius, color):
"""
self._gfx_mode()
self._curve_helper(x + radius, y + radius, radius, radius, 1, color, False)
self._curve_helper(x + width - radius, y + radius, radius, radius, 2, color, False)
self._curve_helper(x + width - radius - 1, y + radius, radius, radius, 2, color, False)
self._curve_helper(x + radius, y + height - radius, radius, radius, 0, color, False)
self._curve_helper(x + width - radius, y + height - radius, radius, radius, 3, color, False)
self.hline(x + radius, y, width - (radius * 2), color)
self.hline(x + radius, y + height, width - (radius * 2), color)
self._curve_helper(x + width - radius - 1, y + height - radius, radius, radius, 3, color,
False)
self.hline(x + radius, y, width - (radius * 2) - 1, color)
self.hline(x + radius, y + height, width - (radius * 2) - 1, color)
self.vline(x, y + radius, height - (radius * 2), color)
self.vline(x + width, y + radius, height - (radius * 2), color)
self.vline(x + width - 1, y + radius, height - (radius * 2), color)

def fill_round_rect(self, x, y, width, height, radius, color):
"""
Expand All @@ -779,11 +780,12 @@ def fill_round_rect(self, x, y, width, height, radius, color):
"""
self._gfx_mode()
self._curve_helper(x + radius, y + radius, radius, radius, 1, color, True)
self._curve_helper(x + width - radius, y + radius, radius, radius, 2, color, True)
self._curve_helper(x + width - radius - 1, y + radius, radius, radius, 2, color, True)
self._curve_helper(x + radius, y + height - radius, radius, radius, 0, color, True)
self._curve_helper(x + width - radius, y + height - radius, radius, radius, 3, color, True)
self._rect_helper(x + radius, y, x + width - radius, y + height, color, True)
self._rect_helper(x, y + radius, x + width, y + height - radius, color, True)
self._curve_helper(x + width - radius - 1, y + height - radius, radius, radius, 3, color,
True)
self._rect_helper(x + radius, y, x + width - radius - 1, y + height - 1, color, True)
self._rect_helper(x, y + radius, x + width - 1, y + height - radius - 1, color, True)

def _circle_helper(self, x, y, radius, color, filled):
"""General Circle Drawing Helper"""
Expand All @@ -800,17 +802,17 @@ def _circle_helper(self, x, y, radius, color, filled):
self._write_reg(reg.DCR, reg.DCR_CIRC_START | (reg.DCR_FILL if filled else reg.DCR_NOFILL))
self._wait_poll(reg.DCR, reg.DCR_CIRC_STATUS)

def _rect_helper(self, x, y, width, height, color, filled):
def _rect_helper(self, x1, y1, x2, y2, color, filled):
"""General Rectangle Drawing Helper"""
self._gfx_mode()

# Set X and Y
self._write_reg16(0x91, x)
self._write_reg16(0x93, y + self.vert_offset)
self._write_reg16(0x91, x1)
self._write_reg16(0x93, y1 + self.vert_offset)

# Set Width and Height
self._write_reg16(0x95, width)
self._write_reg16(0x97, height + self.vert_offset)
self._write_reg16(0x95, x2)
self._write_reg16(0x97, y2 + self.vert_offset)

self.set_color(color)

Expand Down
8 changes: 4 additions & 4 deletions examples/ra8875_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@
display.circle(100, 100, 50, BLACK)
display.fill_circle(100, 100, 49, BLUE)

display.fill_rect(11, 11, 398, 198, GREEN)
display.fill_rect(10, 10, 400, 200, GREEN)
display.rect(10, 10, 400, 200, BLUE)
display.fill_round_rect(200, 10, 200, 100, 10, RED)
display.round_rect(199, 9, 202, 102, 12, BLUE)
display.round_rect(200, 10, 200, 100, 10, BLUE)
display.pixel(10, 10, BLACK)
display.pixel(11, 11, BLACK)
display.line(10, 10, 200, 100, RED)
display.fill_triangle(200, 15, 250, 100, 150, 125, YELLOW)
display.triangle(200, 15, 250, 100, 150, 125, BLACK)
display.fill_triangle(200, 16, 249, 99, 151, 124, YELLOW)
display.fill_ellipse(300, 100, 100, 40, BLUE)
display.ellipse(300, 100, 100, 40, RED)
display.fill_ellipse(300, 100, 98, 38, BLUE)
display.curve(50, 100, 80, 40, 2, BLACK)
display.fill_curve(50, 100, 78, 38, 2, WHITE)

Expand Down