Skip to content

_set_item() doesn't support integer values #27

Closed
@siddacious

Description

@siddacious

Currently when calling _set_item with an integer value such as one out of FancyLED's color.pack(), or even the example given in the docstring of _set_item, 0xFFFFFF.

Example/repro code:

import adafruit_dotstar
import board

led = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
led[0] = 0xFFFFFF
Traceback (most recent call last):
  File "code.py", line 5, in <module>
  File "adafruit_dotstar.py", line 190, in __setitem__
  File "adafruit_dotstar.py", line 160, in _set_item
TypeError: object of type 'int' has no len()

The issue is that the line in question is assuming that value is a tuple when it can be an int, as mentioned in the docstring. I have a fix I can submit as a PR; basically the function will already convert value to a tuple as rgb, we just need to check the length of rgb instead of value.

The same issue is there in the NeoPixel library though I haven't tested it yet. I can create an issue and PR there as well if this one is accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions