l293d
l293d copied to clipboard
[WIP] Micropython support
hello :wave: !!
This adds support for using l293d
with Micropython.

Changes
-
I've stripped back the
Config
class, as it was using some features that Micropython doesn't support (__dict__
,with_metaclass
hacks). Now an instance ofConfig
is created on module load, and__getattr__
and__setattr__
are class methods. -
I've created a
gpio
submodule to handle loading in what to use for GPIO. This allowed me to make a wrapper for Micropythonsmachine
that mirrorsRPi.GPIO
. I also added atestgpio
that is used when nothing GPIO related can be imported (might be useful for #62).
WIP
Currently a work in progress as there are some things I need to figure out:
- [ ] PWM works differently in Micropython, there doesn't seem to be a concept of 100% duty cycle (always on). The range is 0 - 1023, but I need to do some experiments with
RPi.GPIO
to see what it supports. - [ ] Documentation. I managed to scrape by with the current docs, and a pin diagram for my board. I don't know how good this can be though. I currently have an esp8266, but that's not the only supported board.
- [x] I'm not sure what to do about pin numbering. The current checks make sense for a Raspberry Pi, but might not for a different board. Should these checks be removed?
This is a great idea! I don't have experience with MicroPython so I'm not sure what to do about pin numbering etc. but I'm looking forward to seeing this develop :100:
@alxwrd any progress? 😄
:sweat_smile: soon™
Just need to find some time to have a play with RPi.GPIO to see how I can get the PWM apis to line up.
I've just had some thoughts about fixing up the tests at least. I might jump on that now.
Sounds awesome!
If needed we could refactor out calls to RPi.GPIO
to our own interface and make the actual GPIO calls based on environment?
Are the tests specific to Micropython support or would that be a separate PR?
Oops, sorry! I meant the test(s) failing for this PR. I still need to have a good think about testing in general.
With the gpio interface, that was my thinking with db5940d, it makes micropython behave like RPi. But yea, going foward might be good to look at a general interface for both.
Missed that, oops - yep that's the kind of thing I meant. Looks cool ✨
Ah tests are looking better now, all 8 of them 😬 this package could definitely do with some more :joy: do you have any ideas for how we could test this new stuff?