l293d icon indicating copy to clipboard operation
l293d copied to clipboard

[WIP] Micropython support

Open alxwrd opened this issue 6 years ago • 6 comments

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 of Config 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 Micropythons machine that mirrors RPi.GPIO. I also added a testgpio 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?

alxwrd avatar Aug 18 '18 16:08 alxwrd

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:

jmsv avatar Aug 20 '18 10:08 jmsv

@alxwrd any progress? 😄

jmsv avatar Oct 04 '18 19:10 jmsv

: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.

alxwrd avatar Oct 04 '18 20:10 alxwrd

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?

jmsv avatar Oct 04 '18 21:10 jmsv

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.

alxwrd avatar Oct 04 '18 22:10 alxwrd

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?

jmsv avatar Oct 05 '18 01:10 jmsv