Skip to content
This repository was archived by the owner on Apr 20, 2022. It is now read-only.
This repository was archived by the owner on Apr 20, 2022. It is now read-only.

Discrepancy in setting dotstar brightness byte #25

@dunkmann00

Description

@dunkmann00

The dotstar brightness byte is exposed to the user as a float, but then internally converted into an integer, so it needs to be rounded.

In pypixelbuf the brightness is always rounded up using an approach equivalent to math.ceil:

# same as math.ceil(brightness * 31) & 0b00011111
# Idea from https://www.codeproject.com/Tips/700780/Fast-floor-ceiling-functions
w = (32 - int(32 - w * 31) & 0b00011111) | DOTSTAR_LED_START

However, in pixelbuf the brightness is rounded down by truncating:
https://github.com/adafruit/circuitpython/blob/41fe62929f268bfc1f2b06be8b649409234d9d1a/shared-module/_pixelbuf/PixelBuf.c#L181-L185

If rounding down is desired I can make a pull request to correct this? Or if not, I can file an issue in CP and update pixelbuf to round up!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions