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

Closer integration with pinout.xyz ? #609

Closed
lurch opened this issue Nov 30, 2017 · 6 comments
Closed

Closer integration with pinout.xyz ? #609

lurch opened this issue Nov 30, 2017 · 6 comments

Comments

@lurch
Copy link
Contributor

lurch commented Nov 30, 2017

Looking at e.g. https://pinout.xyz/pinout/scorezero it just occurred to me how awesome it would be if GpioZero could take some of the data from the https://github.com/gadgetoid/Pinout.xyz repo and use that to auto-generate GpioZero python classes? 😁
E.g. if https://raw.githubusercontent.com/Gadgetoid/Pinout.xyz/master/src/en/overlay/scorezero.md was modified to specify that it should create a ButtonBoard, then GpioZero could somehow auto-generate:

class ScoreZero(ButtonBoard):
    """
    Could have some auto-generated description here, similar to https://pinout.xyz/pinout/scorezero
    """
    def __init__(self, pin_factory=None):
        super(ScoreZero, self).__init__(
            start=5,
            select=6,
            up=22,
            right=23,
            down=24,
            left=25,
            b=26,
            a=27,
            order=('start', 'select', 'up', 'right', 'down', 'left', 'b', a'),
            pin_factory=pin_factory
        )

ping @bennuttall @Gadgetoid
Perhaps this also links in with #548 , but without the 'connections' stuff?

@Gadgetoid And on a related note, perhaps you could extend pinout.xyz so that for those boards fully supported by GpioZero, you add a link to their GpioZero class docs? :-)
E.g. https://pinout.xyz/pinout/traffic_hat could have a link to https://gpiozero.readthedocs.io/en/stable/api_boards.html#traffic-hat

@bennuttall And I guess in a similar fashion, https://gpiozero.readthedocs.io/en/stable/api_boards.html#traffic-hat could provide a link to https://pinout.xyz/pinout/traffic_hat ?

@Gadgetoid
Copy link
Contributor

This is a bonkers idea, but it seems possible. I'm definitely keen to make as much API functionality available as I can for the next phase of Pinout growth. One of the key ideas behind bringing boards to Pinout was always to aggregate data so we could use it for the greater good. Anything that achieves that goal is awesome!

@lurch
Copy link
Contributor Author

lurch commented Nov 30, 2017

BTW @Gadgetoid I just happened to spot that https://pinout.xyz/pinout/rtk_motor_controller does have a link to its GpioZero docs (cool!), but it'd be better if it linked to http://gpiozero.readthedocs.io/en/stable/api_boards.html#ryanteck-mcb-robot rather than http://gpiozero.readthedocs.io/en/v1.3.1/api_boards.html#ryanteck-mcb-robot

@lurch
Copy link
Contributor Author

lurch commented Nov 30, 2017

At the very least, the lovingly curated pinout data on https://pinout.xyz will make it easier for Python developers to hand-write the corresponding GpioZero classes :)

@bennuttall
Copy link
Member

This is a bonkers idea, but it seems possible.

I want those to be my last words.

@bennuttall
Copy link
Member

Regarding a ScoreZero implementation, I started working on one the other night. but my idea required adding a DPad class for the up/down/left/right, and then required ButtonBoard to be nestable, hence #607, rather than just a linear ButtonBoard. Any thoughts?

@lurch
Copy link
Contributor Author

lurch commented Dec 1, 2017

Without nestable ButtonBoard classes, I guess you could group the buttons by doing:

class ScoreZero(CompositeDevice):
    def __init__(self, pin_factory=None):
        super(ScoreZero, self).__init__(
            dpad=ButtonBoard(
                up=22,
                right=23,
                down=24,
                left=25,
                order=('up', 'right', 'down', left'),
                pin_factory=pin_factory
            ),
            buttons=ButtonBoard(
                start=5,
                select=6,
                b=26,
                a=27,
                order=('start', 'select', 'a', 'b'),
                pin_factory=pin_factory
            ),
            order=('dpad', 'buttons'),
            pin_factory=pin_factory
        )

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

3 participants