2 2
TonyMac32

Adafruit CircuitPython

Recommended Posts

This falls somewhere between "how-to", "research", and "development", so I stuck it here.  @adafruit is working to target CircuitPython to Armbian devices, something that will be a bit of a task.  I've been playing with the code to get it working on my Tritium H3, finally did (some extra sudo-ing was needed), so I'll probably toss in a couple board definitions/help here and there if I can.  it had hijacked a C2 thread (not completely, it was at least about using it on the C2), and I thought it best to continue discussion here.

 

@chwe, @sgjava, and @Larry Bank all have various experience with various GPIO tools, their interest may vary.  My current observations, doing some hacking to make it run on my board:

 

  • superuser is necessary to get to the gpio
  • I had to install wheel before blinka or setup failed spectacularly
  • board detection is crazy (I noticed in the PR that it is planned to get worked on)  I had to inject my board name into seemingly 30000000000000 files.   :lol: 

 

Next up is to actually use it to read something/write something, and make a PR or two.

Share this post


Link to post
Share on other sites

https://github.com/sgjava/userspaceio supports C, C++, Python and JVM (Java, Scala, Koltin, etc.). Do we really need another Python lib besides WiringPi and RPi.GPIO? Also, I have non-root access working for pretty much everything.

 

Another thing, from looking at the CircuitPython site it appears to only support micro controllers at this point, not a full blown SBC. For this type of stuff I'm using NodeMCU with Lua which is mature and is hard to beat from a price/performance/usability perspective.

Share this post


Link to post
Share on other sites

Honestly I don't know if we need another of a lot of things, but I can't think of anything I would have to do for this on the Armbian side that wouldn't be useful to your or any other library/user, so I don't see any harm in it.  It does have the (perhaps ominous old-school Windows IE integration?  :lol:) advantage on it's side that Adafruit ships all of their devices with this micropython derivative, so it is inevitable that people moving from an adafruit micro to an orange pi will come on this forum asking questions/support "as seen on" Adafruit's site.  And they've generated a lot of code for  gadgets, I'm sure some of it can be useful outside the context of their specific library.

 

I know I personally wipe out Python and go straight to C on micros, but I'm also sitting here with 20 years of programming experience.  If the people I bought gadgets from had a library and I was new I'd use it.  

 

@sgjava I need to check out your JVM bindings, I never tried doing anything hardware with Java.

Share this post


Link to post
Share on other sites

Yea, I understand trying to consolidate behind a single library, but I prefer using a single API and wrapping that with whatever language I want. It's a matter of perspective I guess. For beginners it may make sense to make it easy to use.

 

@TonyMac32 The Java code performs pretty well using JNA instead of JNI.

Share this post


Link to post
Share on other sites

hiya - yes circuitpython is originally designed to run on small microcontrollers. as we've ported over 100 drivers, libraries and helpers, the light-but-complete API can also be really great for Python 3 computers. that way people can start a project on smaller chips, then 'upgrade' to a SBC when they want video, mp3, full tcpip stack. or they can just take advantage of all the drivers to make IoT SBC with sensors

we sorted out the API about 2 years ago when we started circuitpython, and have been hacking on adding the Py3 support layer over the last few months.

the translation layer repository is here https://github.com/adafruit/Adafruit_Blinka

the new platform detection repo is here https://github.com/adafruit/Adafruit_Python_PlatformDetect - it will be replacing the current platform detection.

 

Share this post


Link to post
Share on other sites
On 12/6/2018 at 10:47 PM, adafruit said:

the new platform detection repo is here https://github.com/adafruit/Adafruit_Python_PlatformDetect - it will be replacing the current platform detection.

from a quick overview, your PlatformDetect looks... a bit messy.. from what I understand it looks like the following?

643090607_UntitledDiagram.png.cc37af80c0e74b8767fa50ed025eaf05.png

 

let's face it.. the majority of your users which use this lib on linux will be RPi users.. the boards are well known, 'cheap' and everywhere available. There are only a few beagles so it makes sense to look at them first before you start with the armbian boards (we support roughly 50 boards).. and if everything fails let the user manually decide which board he has..

 

https://github.com/adafruit/Adafruit_Python_PlatformDetect/blob/672713699e6d21854d65ec8f0d765c8fb125d03b/adafruit_platformdetect/board.py#L85-L87

looks like not that easy to add new boards.. a more general way would be something like:

if self.armbian:

etc... 

for all those RPi thingies something like talking to the threadX would easily tell you that it is a RPi.. no board else will ever talk ThreadX commands.

 

https://github.com/adafruit/Adafruit_Python_PlatformDetect/blob/672713699e6d21854d65ec8f0d765c8fb125d03b/adafruit_platformdetect/board.py#L58-L68

no ESP32 in the future? I don't even buy esp8266 anymore.. The 32 is in a similar price-class and especially for python/micropython a way more powerful..

 

 

IMO your board detection mechanism should look more like this:

312926041_UntitledDiagram.png.024b8301aa9b1b68ecb434e8f57f8804.png

 

 

proc/cpuinfo should give you all you need to distinguish between RPi/BB and 'everything else' and from there you can start a proper way of detecting supported boards on armbian.. your code gets messy as soon as you add more boards on armbian...

 

 

Share this post


Link to post
Share on other sites

sounds good, yeah we're still working out the platform detection stuff, your structure looks good! we also will be adding 96boards support so that's a whole 'nother collection of mysteries :)

for ESP32, blinka will probably work, we just haven't tested it. we'll probably go back to that after getting linux sorted out

Share this post


Link to post
Share on other sites

@chwe it's not in UML????  

 

To be honest I think my head would explode if I ever saw anyone actually publish open source code with modelling and flowcharting.  

 

My coding experience is x86 and ARMv4t assembly language, C, and Java.  Python never interested me in the least, which is why I hadn't been as helpful with these libraries before.  Well, on the 3rd/4th one I guess I need to learn the language so I can teach my little ones.  For these libraries I'm primarily looking at/commenting on structure and use, so I am an educated "noob" as far as the tool is concerned.  @chwe is a bit more knowledgeable, and loves flow charts.

Share this post


Link to post
Share on other sites
13 hours ago, TonyMac32 said:

To be honest I think my head would explode if I ever saw anyone actually publish open source code with modelling and flowcharting.  

:lol:

https://www.draw.io/

it was actually easier than explaining stuff.. :lol:

 

13 hours ago, TonyMac32 said:

For these libraries I'm primarily looking at/commenting on structure and use, so I am an educated "noob" as far as the tool is concerned.  @chwe is a bit more knowledgeable, and loves flow charts. 

I just maintained pyGPIO by accident.. :lol: collecting some bits here and there and bring it together, decide to brush it a bit up and there it is..

 

https://github.com/adafruit/Adafruit_Python_PlatformDetect/blob/0d7e823fd317f4c4dae9e984d8446ee0c46e6aa3/adafruit_platformdetect/board.py#L150-L151

elif chip_id == ap_chip.SUN8I:
	return self._armbian_id()

why not armbian at the bottom and use something like:

else:
	return self._armbian_id()

armbian supports not only sun8i ;)

 

well my interest is somehow limited in the GPIO stuff.. I've a few examples where I need it and for the rest it's highly specific stuff, the average user doesn't need..

If @adafruit decides to design a bench-top NMR for an reasonable prize, I'm in.. :D or a 700/800nm fluorescence detector..

13 hours ago, TonyMac32 said:

My coding experience is x86 and ARMv4t assembly language, C, and Java.  Python never interested me in the least, which is why I hadn't been as helpful with these libraries before.

I'm still a chemist not engineer.. So hopefully you folks are better in it.. :ph34r::lol:

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
2 2