CircuitPython boards are great because they run python duh, but also because they are simple to use. You plug it in to a computer, it shows up as a small "thumb drive" type device that stores the .py file. You edit that file, save it and the board runs your new code, easy peasy.
But what if we want to take our Circuit Python development on the go with our Android phone or tablet? Lets grab an OTG cable and find out. Ah DRAT!! we get this nasty message about unsupported storage. It turns out the Circuit Python boards are using an older file format system (FAT12 maybe?) and Android does not seem to support this.
Well shucks, I guess our hopes and dreams of mobile Circuit Python development are pretty well crushed aren't they? Not so fast! could there be another way?
Idea: Instead of using the board like a filesystem, we can connect via serial to the board and use the REPL to help us load and save python code.
If you are ready to dive in right away you can get the app from this Play Store link or scan this QR code:
The easiest way to learn the ropes is with the Adafruit Learning System guide. Check it out to get started.
If you want to learn more about the application and how it came to be then read on here, and check out the project logs.
Luckily [felHR85] has created this super useful USB Serial library that we can use to get connected and communicating with the board. Once the communication was established then entering the REPL was pretty straight forward. To load the code we use REPL to open code.py and dump it's contents into serial output so we can read it on the Android side. Saving proved to be a bit trickier, I ran into errors trying to write the entire file at once. Currently It's writing one line at a time, again using statements in the REPL. Once it's done you can send ctrl-D to reload and run your new code.
All of my testing thus far has been on Circuit Playground Express, but it should support other boards too. If you have direct knowledge of how it works (or doesn't) on other specific boards or with certain Android devices please feel free to share.
The Github linked in the project is for the Android app, there is a debug APK file in the repo if you just want to try out the app and don't have access to Play store.
If you do use the application please let us know how it goes!
WARNING: This app is in the alpha stage, it may not work at all for you. Or worse it may work improperly and erase, or overwrite with non-sense the code on your board. Please keep an extra copy of any important code stored on your PC or somewhere other than the Circuit Python board. That way you can always remount to read-only and save your working code on the board using the standard file transfer method.
Hi FoamyGuy
Really nice app. I have used with an Adafruit CPX and it is working great.
I was wondering as I'm moving to some other Python based boards (ESP8266 ), would it be possible to allow your app to work with any board which provide REPL over USB CDC serial ?
Thanks
Best regards