Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.

Circuitpython as Arduino library
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Circuitpython as Arduino library

by hypercubed on Wed Jul 08, 2020 8:34 pm

I am looking for an interpreted language that can run on a SAMD processor (Feather M4 in my case) that can be implemented as an Arduino library
Specifically I would like to be able to take a string or a file and run it using a function in Arduino code
Bitlash seems like the best fit but it doesnt work on SAMD boards.
Some similar examples Ive seen include uLisp, pyMite, and ESP8266-lua.
So here's my question:
Is there a way to modify CircuitPython so that it has Bitlash-like capabilities and can be imported as a library into Arduino?
(I was thinking of maybe downloading the source code and adding a wrapper program that contains functions that can be run in arduino and send code to the interpreter)

Posts: 5
Joined: Mon Jul 06, 2020 11:15 am

Re: Circuitpython as Arduino library

by adafruit_support_mike on Thu Jul 09, 2020 4:29 am

It's probably possible, but would be a serious project in its own right.

If you want to build something yourself and aren't too concerned about the specific language, I'd suggest taking a look at Forth. It's a postfix, stack-based language (addition looks like '1 2 +') which is extremely good for embedded projects and small memory footprints. Another good alternative would be Scheme, a minimal version of Lisp, which uses prefix notation (+ 1 2). I think the smallest Forth interpreter weighs in less than 100 bytes, but I can't find a reference offhand.

These two files start with a 650-byte C program that interprets a language called FIRST, then uses that to define a Forth-like language called THIRD:

Most of the second file (780 lines) is human-speech text describing the principles of both languages, and how they're implemented.

Languages that use infix notation (1+2) like C and Python make the CPU do a lot of work just converting the human notation into something executable.. parsing the syntax and building an abstract syntax tree. In both Forth and Lisp, the human notation *is* the abstract syntax tree. John McCarthy created Lisp almost by accident while trying to work out a good way to describe the abstract syntax tree for a more complex infix language.. his notation turned out to be so useful in its own right that he never got around to developing the infix version.

Posts: 61422
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.