Earlier in this article series I showed how to install NodeJS -- it was pretty simple with an install script. However, I thought I better show how I actually worked with NodeJS to create my little 1b1 driver code.
Again, simple, I used others hard work. Specifically, Michael Hord with Sparkfun's MiniMoto library.
Really, all I did was tweak the code a little bit to fit JavaScript syntax.
The result
'use strict';
var i2c = require('i2c-bus');
var sleep = require('sleep');
// Commands
const FAULT_CMD = 0x01;
// Fault constants
const CLEAR_FAULT = 0x80;
const FAULT = 0x01;
const ILIMIT = 0x10;
const OTS = 0x08 ...