Private class for the device (some modules make the class public) with methods on prototype
Public 'connectX' functions - some modules have different connection types (I2C, SPI 3 wire/SPI 4 wire), so I pass in the read/write register functions as arguments to the constructor
It seems to work pretty well for most stuff.
Generally to develop, I either:
Use the Web IDE, add exports={} up the top, and develop with the library and test code in one file.
Use the Espruino command-line tool with -w to watch a file, then put the library in a modules directory.
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.
That's be awesome, thanks!
This is the form I'm writing most device drivers in now, if it helps: https://github.com/espruino/EspruinoDocs/blob/master/devices/BH1745.js
C
for constantsIt seems to work pretty well for most stuff.
Generally to develop, I either:
exports={}
up the top, and develop with the library and test code in one file.-w
to watch a file, then put the library in amodules
directory.hope that helps!