Skip to content

Doesn't identify passed pins as pins on raspberry pi with blinka #19

Closed
@Neradoc

Description

@Neradoc

Running on a Pi 3 (python 3.7.3).

import board
import adafruit_rgbled
rgb = adafruit_rgbled.RGBLED(board.D1, board.D2, board.D3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.local/lib/python3.7/site-packages/adafruit_rgbled.py", line 110, in __init__
    raise TypeError("Must provide a pin, PWMOut, or PWMChannel.")
TypeError: Must provide a pin, PWMOut, or PWMChannel.

This line does not identify pins correctly:

if hasattr(self._rgb_led_pins[i], "frequency"):
self._rgb_led_pins[i].duty_cycle = 0
elif str(type(self._rgb_led_pins[i])) == "<class 'Pin'>":
self._rgb_led_pins[i] = PWMOut(self._rgb_led_pins[i])
self._rgb_led_pins[i].duty_cycle = 0
else:
raise TypeError("Must provide a pin, PWMOut, or PWMChannel.")

>>> type(board.D1)
<class 'adafruit_blinka.microcontroller.bcm283x.pin.Pin'>

Is there a compatible way to actually test if it's a pin ? Just try/except it ?
In Circuitpython a pin is an instance of microcontroller.Pin (for isinstance), but not currently in Blinka.
If we are going with strings, there's board.D1.__class__.__name__ == "Pin" ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestDigitalOcean's HacktoberfestbugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions