Skip to content
This repository was archived by the owner on Apr 20, 2022. It is now read-only.
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
5 changes: 5 additions & 0 deletions adafruit_pypixelbuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ def __init__(self, n, buf, byteorder="BGR", brightness=1.0, # pylint: disable=t
for i in range(0, self._pixels * 4, 4):
self._bytearray[i + self._offset] = DOTSTAR_LED_START_FULL_BRIGHT

@property
def buf(self):
"""The brightness adjusted pixel buffer data."""
return bytearray([int(i * self.brightness) for i in self._bytearray])
Copy link
Member

Choose a reason for hiding this comment

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

This will double apply brightness if two buffers were given. In single mode, we should really use the raw bytearray rather than bytearray.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In single mode, is _rawbytearray set to None? And for _bytearray, how would it get updated for brightness change if you did this:

pixels.fill(0xFF0000)
pixels.brightness = 0.1
pixels.show()

Copy link
Member

Choose a reason for hiding this comment

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

Yes? I think we'd be better off simplifying it to always being two buffers. Although it'll take more memory up front, we won't have to reallocate every show and it'll simplify the logic. Are you interested in making that change @caternuson ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Always two buffers? That would be a great simplification. But can it really be done that simply for all supported HW platforms?

Copy link
Member

Choose a reason for hiding this comment

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

As @ladyada pointed out elsewhere we don't always want two buffers because we've taught folks to set brightness=1 to save memory. I'll take a crack at only grabbing the second buffer on setting brightness != 1 tomorrow.


@staticmethod
def parse_byteorder(byteorder):
"""
Expand Down