Skip to content

Use a 512 bytes buffer for the fill operations #9

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
Nov 3, 2017
Merged

Use a 512 bytes buffer for the fill operations #9

merged 1 commit into from
Nov 3, 2017

Conversation

deshipu
Copy link
Contributor

@deshipu deshipu commented Nov 3, 2017

Right now we are using 1024 bytes (512 16-bit pixels), and it doesn't
really give us any speed advantage, since the DMA buffer is only 512
bytes anyways.

@@ -80,7 +80,7 @@ def fill_rectangle(self, x, y, width, height, color):
w = min(self.width - x, max(1, width))
h = min(self.height - y, max(1, height))
self._block(x, y, x + w - 1, y + h - 1, b'')
chunks, rest = divmod(w * h, 512)
chunks, rest = divmod(w * h, 256)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment explaining the buffer choice size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it into a constant and added explanation.

@@ -80,7 +80,7 @@ def fill_rectangle(self, x, y, width, height, color):
w = min(self.width - x, max(1, width))
h = min(self.height - y, max(1, height))
self._block(x, y, x + w - 1, y + h - 1, b'')
chunks, rest = divmod(w * h, 512)
chunks, rest = divmod(w * h, 256)
pixel = self._encode_pixel(color)
if chunks:
data = pixel * 512
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 256 also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I should slow down a little.

Right now we are using 1024 bytes (512 16-bit pixels), and it doesn't
really give us any speed advantage, since the DMA buffer is only 512
bytes anyways.
Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dhalbert dhalbert merged commit 8b5e71b into adafruit:master Nov 3, 2017
tannewt pushed a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants