pimoroni / blinkt

Python Library for Blinkt; 8 APA102 LEDs for your Raspberry Pi
https://shop.pimoroni.com/products/blinkt
MIT License
314 stars 103 forks source link

Pylon & web_pixel example added #58

Closed smilbandit closed 6 years ago

smilbandit commented 7 years ago

Pylon was the first file I worked with. Web_pixel is what I bought Blinkt for, but wasn't sure if it's too advanced for the examples folder.

dglaude commented 7 years ago

Maybe you should provide a client for web pixel or at least explain how to use that... If there is a readme in the example folder, you should add a description.

smilbandit commented 7 years ago

I added some comments on how to use web_pixel.

Gadgetoid commented 6 years ago

Your use of Python's HTTP server classes is interesting- it's a slightly different approach from the typical Flask app. Thank you for taking the time to submit it.

However it doesn't work in Python 2/3 which is a bit of a nuisance (for the time being, anyway, sooner or later we'll leave Python 2 behind), it's somewhat confusing to read/understand and I've got plans in the works for a consistent way to implement HTTP APIs in all of our libraries which a stand-alone example might confuse :(

I hate saying outright no to a pull-request, since I recognize it takes time/effort to produce and we don't get a lot of them! Every PR is really, really appreciated, unfortunately I don't think this is a good fit at the moment (although I'm very conflicted, because I like the ground-up style of your example and it could probably be really educational with some improvements).

HOWEVER! I want to implement a Flask Blueprint HTTP API along the same lines as the Scroll pHAT HD one, the creation of which is chronicled here: https://github.com/pimoroni/scroll-phat-hd/pull/41 and the usage of which is documented at the bottom of https://github.com/pimoroni/scroll-phat-hd/blob/master/documentation/REFERENCE.md

Perhaps if you're game for a PR adventure we could work on this together? The pattern is already established (https://github.com/pimoroni/scroll-phat-hd/tree/master/library/scrollphathd/api) we'd just need to tweak it for Blinkt!

smilbandit commented 6 years ago

It's totally fine, I built it for my own reasons and thought I'd share. Wanted a fully GET interface to use in a browser over what looks like POST in the Flask example. I've never used Flask before, and I have no problem learning something new (to me). I'll read up on the doc, write up something basic and make another pull request. In the meantime, i'll put in a PR for just the pylon.py script for the examples.

Gadgetoid commented 6 years ago

Yeah Flask should be able to support GET in addition to post- for a modern RESTful API style setup. It makes for quite messy URLs when it comes to complex parameters, so there's always the struggle to make it tidy.