Basically each bit of hardware has module, and when initialised it expects an object, which has fields A0..A5,D0..D13. On stuff like Pixl you can leave it off and it uses global, since those are already defined in the global space. If you're using NodeMCU or Nucleo there are built-in object that contain those fields.
So for HATs you could define some object with BCM2/3/etc on it which matches how you wired up your Espruino - then each module for a Pi HAT could use that to figure out which pins to use.
The really neat thing is you can compile Espruino for a Raspberry Pi, so you could even potentially use the HATs with JS on the Pi (although afaik SPI and I2C aren't supported yet, but you could still use software I2C and SPI)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
I know what you mean about the lack of interest in shields. I did add http://www.espruino.com/Arduino but I haven't had much feedback on it.
However what I've been trying to do there might be a really good place to start? For instance on http://www.espruino.com/arduino-motorshield
Basically each bit of hardware has module, and when initialised it expects an object, which has fields
A0..A5,D0..D13
. On stuff like Pixl you can leave it off and it usesglobal
, since those are already defined in the global space. If you're using NodeMCU or Nucleo there are built-in object that contain those fields.I did a similar thing with http://www.espruino.com/Grove as well - albeit just with a 2 element array for that.
So for HATs you could define some object with BCM2/3/etc on it which matches how you wired up your Espruino - then each module for a Pi HAT could use that to figure out which pins to use.
The really neat thing is you can compile Espruino for a Raspberry Pi, so you could even potentially use the HATs with JS on the Pi (although afaik SPI and I2C aren't supported yet, but you could still use software I2C and SPI)