• 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

    • Private C for constants
    • 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.

    hope that helps!

  • There's a little error in BH1745.js var MEASUREMENT_TIMES = [ 160,320,640,1280,1560,5120 ]. 1560 should be 2560 i think.


Avatar for Gordon @Gordon started