Skip to content
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

Human-readable list of supported devices #133

Open
thijstriemstra opened this issue Nov 3, 2017 · 9 comments
Open

Human-readable list of supported devices #133

thijstriemstra opened this issue Nov 3, 2017 · 9 comments
Assignees

Comments

@thijstriemstra
Copy link
Collaborator

thijstriemstra commented Nov 3, 2017

device.py contains:

__all__ = ["max7219", "ws2812", "neopixel", "neosegment", "apa102"]

but this cannot be used in the documentation project headline for example. Having a method that returns proper names of these devices instead would be useful.

@rm-hull
Copy link
Owner

rm-hull commented Jan 2, 2018

I seem to think we (mis)used Python's __all__ variable so that the demos could introspect which devices were available. [https://docs.python.org/3/tutorial/modules.html#importing-from-a-package]

What do mean by proper names?

@thijstriemstra
Copy link
Collaborator Author

@rm-hull the names in the project description is what I'm trying to get into the documentation

 (MAX7219) and RGB NeoPixels (WS2812 / APA102) 

@thijstriemstra
Copy link
Collaborator Author

thijstriemstra commented Mar 18, 2019

@thijstriemstra
Copy link
Collaborator Author

Similar to the approach in luma.oled: https://github.com/rm-hull/luma.oled/blob/3.1.0/doc/conf.py#L69

@thijstriemstra
Copy link
Collaborator Author

thijstriemstra commented Mar 18, 2019

I suggest something like __devices__ or __deviceNames..

__all__ = ["max7219", "ws2812", "neopixel", "neosegment", "apa102"]

__deviceNames__ = {
    "max7219": "MAX7219",
    "ws2812": "WS2812",
    "neopixel": "Neopixel",
    "neosegment": "Neosegment",
    "apa102": "APA102"
}

And then some method that retrieves the device name by classname etc.

Or we could add a label class var to the devices with the label name.

class max7219(device):
    """
    Serial interface to a series of 8x8 LED matrixes daisychained together with
    MAX7219 chips.
    On creation, an initialization sequence is pumped to the display to properly
    configure it. Further control commands can then be called to affect the
    brightness and other settings.
    """

    label = 'MAX7219'

Note that whatever approach has to work for all other libraries as well.

Thoughts @rm-hull?

@rm-hull
Copy link
Owner

rm-hull commented Mar 18, 2019

How about

__deviceNames__ = { ... }

__all__ = __deviceNames__.keys()

?

@thijstriemstra
Copy link
Collaborator Author

That's fine with me as well. I'll make a PR.

@thijstriemstra thijstriemstra self-assigned this Mar 18, 2019
@thijstriemstra
Copy link
Collaborator Author

thijstriemstra commented Mar 18, 2019

Actually, I'd rather not mess around with __all__ and make it depend on other code. I've seen this result in strange bugs (GC) that we don't want to get into. I'd rather keep __all__ hard-coded + new __deviceNames__ with duplication, or use the device.label thing. Thoughts @rm-hull ?

@rm-hull
Copy link
Owner

rm-hull commented Mar 18, 2019

Ok, no problem. Don’t mind which approach tbh ... maybe go with

keep __all__ hard-coded + new __deviceNames__ with duplication

to keep them located together

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants