Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

firmata

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firmata - npm Package Compare versions

Comparing version
0.19.1
to
0.21.0
+40
.eslint.json
{
"env": {
"es6": true,
"browser": true,
"mocha": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module"
},
"globals": {
"it": true,
"describe": true,
"beforeEach": true,
"afterEach": true,
"before": true
},
"rules": {
"curly": 2,
"eqeqeq": 0,
"wrap-iife": [
2,
"any"
],
"no-use-before-define": 0,
"no-caller": 2,
"no-console": 0,
"no-empty": 0,
"dot-notation": 0,
"no-undef": 2,
"no-cond-assign": [
2,
"except-parens"
],
"no-eq-null": 0,
"strict": 0
}
}
"use strict";
const com = require("./lib/com");
module.exports = require("firmata-core")(com.SerialPort);
+13
-13

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -9,3 +9,3 @@ console.log(error);

var register = {
const register = {
POWER: 0x2D,

@@ -16,3 +16,3 @@ RANGE: 0x31,

var board = new Board(port.comName);
const board = new Board(port.comName);

@@ -22,4 +22,4 @@ board.on("ready", function() {

var adxl345 = 0x53;
var sensitivity = 0.00390625;
const adxl345 = 0x53;
const sensitivity = 0.00390625;

@@ -37,11 +37,11 @@ // Enable I2C

// Set register to READ position and request 6 bytes
this.i2cRead(adxl345, register.READ, 6, function(data) {
var x = (data[1] << 8) | data[0];
var y = (data[3] << 8) | data[2];
var z = (data[5] << 8) | data[4];
this.i2cRead(adxl345, register.READ, 6, data => {
const x = (data[1] << 8) | data[0];
const y = (data[3] << 8) | data[2];
const z = (data[5] << 8) | data[4];
// Wrap and clamp 16 bits;
var X = (x >> 15 ? ((x ^ 0xFFFF) + 1) * -1 : x) * sensitivity;
var Y = (y >> 15 ? ((y ^ 0xFFFF) + 1) * -1 : y) * sensitivity;
var Z = (z >> 15 ? ((z ^ 0xFFFF) + 1) * -1 : z) * sensitivity;
const X = (x >> 15 ? ((x ^ 0xFFFF) + 1) * -1 : x) * sensitivity;
const Y = (y >> 15 ? ((y ^ 0xFFFF) + 1) * -1 : y) * sensitivity;
const Z = (z >> 15 ? ((z ^ 0xFFFF) + 1) * -1 : z) * sensitivity;

@@ -48,0 +48,0 @@ console.log("X: ", X);

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -9,11 +9,11 @@ console.log(error);

var board = new Board(port.comName);
const board = new Board(port.comName);
board.on("ready", function() {
var pin = 13;
var state = 1;
board.on("ready", () => {
const pin = 13;
let state = 1;
board.pinMode(pin, board.MODES.OUTPUT);
setInterval(function() {
setInterval(() => {
board.digitalWrite(pin, (state ^= 1));

@@ -20,0 +20,0 @@ }, 500);

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -9,5 +9,5 @@ console.log(error);

var board = new Board(port.comName);
const board = new Board(port.comName);
board.on("close", function() {
board.on("close", () => {
// Unplug the board to see this event!

@@ -14,0 +14,0 @@ console.log("Closed!");

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -9,9 +9,8 @@ console.log(error);

var board = new Board(port.comName);
const board = new Board(port.comName);
board.on("ready", function() {
board.on("ready", () => {
console.log("READY");
var HW_SERIAL1 = board.SERIAL_PORT_IDs.HW_SERIAL1;
var maxBytesToRead = 4;
const HW_SERIAL1 = board.SERIAL_PORT_IDs.HW_SERIAL1;

@@ -23,9 +22,7 @@ board.serialConfig({

// leave 2nd parameter (maxBytesToRead) to read all available bytes in buffer
// board.serialRead(HW_SERIAL1, maxBytesToRead, function(data) {
board.serialRead(HW_SERIAL1, function(data) {
board.serialRead(HW_SERIAL1, data => {
console.log(new Buffer(data).toString("ascii"));
});
board.on("string", function (message) {
board.on("string", message => {
console.log(message);

@@ -35,7 +32,7 @@ });

// log serial pin numbers
for (var pin in board.pins) {
var modes = board.pins[pin].supportedModes;
for (var mode in modes) {
for (const pin in board.pins) {
const modes = board.pins[pin].supportedModes;
for (const mode in modes) {
if (modes[mode] === board.MODES.SERIAL) {
console.log("serial pin: " + pin);
console.log(`serial pin: ${pin}`);
}

@@ -42,0 +39,0 @@ }

@@ -1,7 +0,7 @@

var SerialPort = require("serialport");
var five = require("johnny-five");
var Firmata = require("../");
const SerialPort = require("serialport");
const five = require("johnny-five");
const Firmata = require("../");
SerialPort.list(function(error, list) {
var device = list.reduce(function(accum, item) {
SerialPort.list((error, list) => {
const device = list.reduce((accum, item) => {
if (item.manufacturer.indexOf("Arduino") === 0) {

@@ -19,8 +19,8 @@ return item;

var board = new five.Board({
const board = new five.Board({
io: new Firmata(device.comName)
});
board.on("ready", function() {
var led = new five.Led(13);
board.on("ready", () => {
const led = new five.Led(13);
led.blink(500);

@@ -27,0 +27,0 @@ });

@@ -6,5 +6,5 @@ /**

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -14,17 +14,17 @@ console.log(error);

}
var board = new Board(port.comName);
const board = new Board(port.comName);
board.on("ready", function() {
var k22 = 0x68;
board.on("ready", () => {
const k22 = 0x68;
board.i2cConfig();
board.i2cWrite(k22, [0x22, 0x00, 0x08, 0x2A]);
board.i2cRead(k22, 4, function(data) {
var ppms = 0;
board.i2cRead(k22, 4, data => {
let ppms = 0;
ppms |= data[1] & 0xFF;
ppms = ppms << 8;
ppms |= data[2] & 0xFF;
var checksum = data[0] + data[1] + data[2];
const checksum = data[0] + data[1] + data[2];
if (checksum === data[3]) {
console.log("Current PPMs: " + ppms);
console.log(`Current PPMs: ${ppms}`);
} else {

@@ -31,0 +31,0 @@ console.log("Checksum failure");

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -9,3 +9,3 @@ console.log(error);

var register = {
const register = {
CTRL_REG1: 0x2A,

@@ -16,3 +16,3 @@ XYZ_DATA_CFG: 0x0E,

var board = new Board(port.comName);
const board = new Board(port.comName);
// var board = new Board("/dev/cu.usbmodem1411");

@@ -23,5 +23,5 @@

var mma8452 = 0x1D;
var scale = 2; // 2G
var options = {
const mma8452 = 0x1D;
const scale = 2; // 2G
const options = {
address: mma8452,

@@ -36,4 +36,4 @@ settings: {

function mode(which, callback) {
board.i2cReadOnce(mma8452, register.CTRL_REG1, 1, function(data) {
var value = data[0];
board.i2cReadOnce(mma8452, register.CTRL_REG1, 1, data => {
let value = data[0];
if (which === "standby") {

@@ -53,4 +53,4 @@ // Clear the first bit

new Promise(function(resolve) {
mode("standby", function() {
new Promise(resolve => {
mode("standby", () => {

@@ -60,3 +60,3 @@ // 00: 2G (0b00000000)

// 10: 8G (0b00000010)
var fsr = scale >> 2; // 2G (0b00000000)
const fsr = scale >> 2; // 2G (0b00000000)
board.i2cWrite(mma8452, register.XYZ_DATA_CFG, fsr);

@@ -72,3 +72,3 @@

// 7: 1.56 Hz
var ctrlreg1 = 0b00000101 << 3; // 5 0b00[101]000
const ctrlreg1 = 0b00000101 << 3; // 5 0b00[101]000
board.i2cWrite(mma8452, register.CTRL_REG1, ctrlreg1);

@@ -78,12 +78,12 @@

});
}).then(function() {
}).then(() => {
board.i2cRead(mma8452, 0x00, 1, function(data) {
var available = data[0];
board.i2cRead(mma8452, 0x00, 1, data => {
const available = data[0];
if ((available & 0x08) >> 3) {
board.i2cReadOnce(mma8452, register.READ_X_MSB, 6, function(data) {
var x = (data[0] << 8 | data[1]) >> 4;
var y = (data[2] << 8 | data[3]) >> 4;
var z = (data[4] << 8 | data[5]) >> 4;
board.i2cReadOnce(mma8452, register.READ_X_MSB, 6, data => {
let x = (data[0] << 8 | data[1]) >> 4;
let y = (data[2] << 8 | data[3]) >> 4;
let z = (data[4] << 8 | data[5]) >> 4;

@@ -90,0 +90,0 @@ if (data[0] > 0x7F) {

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -8,7 +8,7 @@ console.log(error);

}
var board = new Board(port.comName);
const board = new Board(port.comName);
board.on("ready", function() {
var a = 6;
var b = 7;
const a = 6;
const b = 7;

@@ -20,3 +20,3 @@ console.log("Ready.");

var states = {
const states = {
5: 0,

@@ -39,3 +39,3 @@ 8: 0

// var analogs = [0, 1, 2, 3, 4, 5];
var analogs = [3];
const analogs = [3];

@@ -42,0 +42,0 @@ analogs.forEach(function(pin) {

@@ -1,7 +0,7 @@

var Board = require("../lib/firmata").Board;
var board = new Board("/dev/tty.usbmodem1421");
const Board = require("../");
const board = new Board("/dev/tty.usbmodem1421");
board.on("ready", function() {
var degrees = 10;
var incrementer = 10;
board.on("ready", () => {
let degrees = 10;
let incrementer = 10;

@@ -12,3 +12,3 @@ // This will map 0-180 to 1000-1500

setInterval(function() {
setInterval(() => {
if (degrees >= 180 || degrees === 0) {

@@ -15,0 +15,0 @@ incrementer *= -1;

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -8,10 +8,10 @@ console.log(error);

}
var board = new Board(port.comName);
const board = new Board(port.comName);
board.on("ready", function() {
var degrees = 10;
var incrementer = 10;
board.on("ready", () => {
let degrees = 10;
let incrementer = 10;
board.pinMode(9, board.MODES.SERVO);
board.servoWrite(9, 0);
setInterval(function() {
setInterval(() => {
if (degrees >= 180 || degrees === 0) {

@@ -18,0 +18,0 @@ incrementer *= -1;

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -9,5 +9,5 @@ console.log(error);

var board = new Board(port.comName);
const board = new Board(port.comName);
board.on("ready", function() {
board.on("ready", () => {

@@ -26,6 +26,6 @@ board.accelStepperConfig({

board.accelStepperAcceleration(0, 100);
board.accelStepperStep(0, 2000, function(position) {
console.log("Current position: " + position);
board.accelStepperStep(0, 2000, position => {
console.log(`Current position: ${position}`);
});
});
});

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -9,5 +9,5 @@ console.log(error);

var board = new Board(port.comName);
const board = new Board(port.comName);
board.on("ready", function() {
board.on("ready", () => {

@@ -26,4 +26,4 @@ board.accelStepperConfig({

board.accelStepperEnable(0, true);
board.accelStepperStep(0, 200, function(position) {
console.log("Current position: " + position);
board.accelStepperStep(0, 200, position => {
console.log(`Current position: ${position}`);
});

@@ -30,0 +30,0 @@

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -9,5 +9,5 @@ console.log(error);

var board = new Board(port.comName);
const board = new Board(port.comName);
board.on("ready", function() {
board.on("ready", () => {

@@ -42,10 +42,10 @@ board.accelStepperConfig({

board.multiStepperTo(0, [2000, 3000], function() {
board.multiStepperTo(0, [2000, 3000], () => {
board.accelStepperReportPosition(0, function(value) {
console.log("Stepper 0 position: " + value);
board.accelStepperReportPosition(0, value => {
console.log(`Stepper 0 position: ${value}`);
});
board.accelStepperReportPosition(1, function(value) {
console.log("Stepper 1 position: " + value);
board.accelStepperReportPosition(1, value => {
console.log(`Stepper 1 position: ${value}`);
});

@@ -52,0 +52,0 @@

@@ -1,2 +0,2 @@

var Board = require("../");
const Board = require("../");

@@ -3,0 +3,0 @@ Board.requestPort(function(error, port) {

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -8,9 +8,9 @@ console.log(error);

}
var board = new Board(port.comName);
const board = new Board(port.comName);
board.on("ready", function() {
board.on("ready", () => {
console.log("READY");
var SW_SERIAL0 = board.SERIAL_PORT_IDs.SW_SERIAL0;
var maxBytesToRead = 4;
const SW_SERIAL0 = board.SERIAL_PORT_IDs.SW_SERIAL0;
const maxBytesToRead = 4;

@@ -24,3 +24,3 @@ board.serialConfig({

board.serialRead(SW_SERIAL0, maxBytesToRead, function(data) {
board.serialRead(SW_SERIAL0, maxBytesToRead, data => {
console.log(new Buffer(data).toString("ascii"));

@@ -27,0 +27,0 @@ });

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -9,3 +9,3 @@ console.log(error);

var board = new Board(port.comName);
const board = new Board(port.comName);

@@ -15,15 +15,15 @@ console.log(__filename);

board.on("open", function() {
board.on("open", () => {
console.log(" ✔ open");
});
board.on("reportversion", function() {
board.on("reportversion", () => {
console.log(" ✔ reportversion");
});
board.on("queryfirmware", function() {
board.on("queryfirmware", () => {
console.log(" ✔ queryfirmware");
});
board.on("capability-query", function() {
board.on("capability-query", () => {
console.log(" ✔ capability-query");

@@ -37,3 +37,3 @@ });

this.pinMode(0, 2);
this.analogRead(0, function() {
this.analogRead(0, () => {
console.log(" ✔ received data (exiting)");

@@ -45,3 +45,3 @@ console.log("------------------------------");

var timeout = setTimeout(function() {
var timeout = setTimeout(() => {
console.log(board.currentBuffer);

@@ -48,0 +48,0 @@ console.log(">>>>>>>>>>>>>>TIMEOUT<<<<<<<<<<<<<<");

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -9,3 +9,3 @@ console.log(error);

var board = new Board(port.comName);
const board = new Board(port.comName);

@@ -15,24 +15,24 @@ console.log(__filename);

board.on("open", function() {
board.on("open", () => {
console.log(" ✔ open");
});
board.on("reportversion", function() {
board.on("reportversion", () => {
console.log(" ✔ reportversion");
});
board.on("queryfirmware", function() {
board.on("queryfirmware", () => {
console.log(" ✔ queryfirmware");
});
board.on("capability-query", function() {
board.on("capability-query", () => {
console.log(" ✔ capability-query");
});
board.on("ready", function() {
board.on("ready", () => {
console.log(" ✔ ready");
clearTimeout(timeout);
this.i2cConfig();
this.i2cRead(0x0A, 1, function() {
board.i2cConfig();
board.i2cRead(0x0A, 1, () => {
console.log(" ✔ received data (exiting)");

@@ -44,3 +44,3 @@ console.log("------------------------------");

var timeout = setTimeout(function() {
var timeout = setTimeout(() => {
console.log(board.currentBuffer);

@@ -47,0 +47,0 @@ console.log(">>>>>>>>>>>>>>TIMEOUT<<<<<<<<<<<<<<");

@@ -1,4 +0,4 @@

var Board = require("../");
const Board = require("../");
Board.requestPort(function(error, port) {
Board.requestPort((error, port) => {
if (error) {

@@ -9,3 +9,3 @@ console.log(error);

var board = new Board(port.comName);
const board = new Board(port.comName);

@@ -15,25 +15,25 @@ console.log(__filename);

board.on("open", function() {
board.on("open", () => {
console.log(" ✔ open");
});
board.on("reportversion", function() {
board.on("reportversion", () => {
console.log(" ✔ reportversion");
});
board.on("queryfirmware", function() {
board.on("queryfirmware", () => {
console.log(" ✔ queryfirmware");
});
board.on("capability-query", function() {
board.on("capability-query", () => {
console.log(" ✔ capability-query");
});
board.on("ready", function() {
board.on("ready", () => {
console.log(" ✔ ready");
clearTimeout(timeout);
var SW_SERIAL0 = this.SERIAL_PORT_IDs.SW_SERIAL0;
const SW_SERIAL0 = board.SERIAL_PORT_IDs.SW_SERIAL0;
this.serialConfig({
board.serialConfig({
portId: SW_SERIAL0,

@@ -45,3 +45,3 @@ baud: 9600,

this.serialRead(SW_SERIAL0, function(data) {
board.serialRead(SW_SERIAL0, () => {
console.log(" ✔ received data (exiting)");

@@ -53,3 +53,3 @@ console.log("------------------------------");

var timeout = setTimeout(function() {
var timeout = setTimeout(() => {
console.log(board.currentBuffer);

@@ -56,0 +56,0 @@ console.log(">>>>>>>>>>>>>>TIMEOUT<<<<<<<<<<<<<<");

@@ -5,31 +5,30 @@ "use strict";

function Mock(path, options, openCallback) {
this.isOpen = true;
this.baudRate = 0;
this.path = path;
}
Mock.prototype = Object.create(Emitter.prototype, {
constructor: {
value: Mock
class SerialPort extends Emitter {
constructor(path/*, options, openCallback*/) {
super();
this.isOpen = true;
this.baudRate = 0;
this.path = path;
}
});
Mock.prototype.write = function (buffer) {
// Tests are written to work with arrays not buffers
// this shouldn't impact the data, just the container
// This also should be changed in future test rewrites
if (Buffer.isBuffer(buffer)) {
buffer = Array.from(buffer);
write(buffer) {
// Tests are written to work with arrays not buffers
// this shouldn't impact the data, just the container
// This also should be changed in future test rewrites
/* istanbul ignore else */
if (Buffer.isBuffer(buffer)) {
buffer = Array.from(buffer);
}
this.lastWrite = buffer;
this.emit("write", buffer);
}
}
this.lastWrite = buffer;
this.emit("write", buffer);
};
let com;
let sp;
let stub = {
SerialPort: Mock,
SerialPort,
list() {
/* istanbul ignore next */
return Promise.resolve([]);

@@ -36,0 +35,0 @@ },

@@ -29,2 +29,3 @@ "use strict";

/* istanbul ignore else */
if (shift > 0) {

@@ -31,0 +32,0 @@ output.push(previous);

{
"name": "firmata",
"description": "Firmata protocol implementation for programmatic interaction with Arduino and Arduino compatible development boards.",
"version": "0.19.1",
"version": "0.21.0",
"author": "Julian Gautier",

@@ -22,3 +22,3 @@ "license": "MIT",

"grunt-cli": "^1.2.0",
"grunt-contrib-jshint": "^1.1.0",
"grunt-eslint": "^21.0.0",
"grunt-jsbeautifier": "^0.2.13",

@@ -25,0 +25,0 @@ "grunt-jscs": "^3.0.1",

+27
-19

@@ -38,4 +38,4 @@ # Firmata.js

```js
var Board = require("firmata");
var board = new Board("system path or name");
const Board = require("firmata");
const board = new Board("system path or name");

@@ -50,5 +50,5 @@ board.on("ready", () => {

```js
var Serialport = require("serialport");
var Board = require("firmata");
var board = new Board(new Serialport(...));
const Serialport = require("serialport");
const Board = require("firmata");
const board = new Board(new Serialport(...));

@@ -66,5 +66,5 @@ board.on("ready", () => {

```js
var Etherport = require("etherport");
var Board = require("firmata");
var board = new Board(new Etherport(...));
const Etherport = require("etherport");
const Board = require("firmata");
const board = new Board(new Etherport(...));

@@ -79,4 +79,4 @@ board.on("ready", () => {

```js
var Board = require("firmata");
var board = new Board("system path or name", () => {
const Board = require("firmata");
const board = new Board("system path or name", () => {
// Arduino is ready to communicate

@@ -89,5 +89,5 @@ });

```js
var Serialport = require("serialport");
var Board = require("firmata");
var board = new Board(new Serialport(...), () => {
const Serialport = require("serialport");
const Board = require("firmata");
const board = new Board(new Serialport(...), () => {
// Arduino is ready to communicate

@@ -100,5 +100,5 @@ });

```js
var Etherport = require("etherport");
var Board = require("firmata");
var board = new Board(new Etherport(...), () => {
const Etherport = require("etherport");
const Board = require("firmata");
const board = new Board(new Etherport(...), () => {
// Arduino is ready to communicate

@@ -216,6 +216,10 @@ });

- `digitalWrite(pin,value)`
- `digitalWrite(pin,value,enqueue)`
Write an output to a digital pin. pin is the number of the pin and the value is either board.HIGH or board.LOW.
Write an output to a digital pin. pin is the number of the pin and the value is either board.HIGH or board.LOW. enqueue is optional and when true will update the local pin value but will not write the data until `writeQueuedDigitalPorts()` is called.
- `writeQueuedDigitalPorts()`
Directs firmata to update all ports whose values have been changed via digitalWrite with the `enqueue` parameter set to true.
- `digitalRead(pin,callback)`

@@ -265,3 +269,3 @@

// set sampling interval to 30 milliseconds
var board = new Board(serialPortName, {samplingInterval: 30});
const board = new Board(serialPortName, {samplingInterval: 30});
```

@@ -591,3 +595,7 @@

- `board.clearSysexResponse(commandByte)`
Allow user to remove sysex response handler such as one previously set through board.sysexResponse(commandByte, handler).
### Encode/Decode

@@ -594,0 +602,0 @@

Sorry, the diff of this file is not supported yet

var Board = require("../");
Board.requestPort(function(error, port) {
if (error) {
console.log(error);
return;
}
// var board = new Board(port.comName);
var board = new Board("/dev/cu.usbmodem1411");
var state = 1;
console.log(__filename);
console.log("------------------------------");
board.on("ready", function() {
console.log(" ✔ ready");
// this.pinMode(5, board.MODES.INPUT);
// this.digitalRead(5, (value) => {
// console.log(`digitalRead: ${value}`);
// console.log("------------------------------");
// });
this.pinMode(5, board.MODES.OUTPUT);
setInterval(function() {
board.digitalWrite(5, (state ^= 1));
}, 500);
this.pinMode(5, board.MODES.ANALOG);
this.analogRead(5, (value) => {
console.log(`analogRead: ${value}`);
console.log("------------------------------");
});
});
});
var Board = require("../");
var board = new Board("/dev/cu.uart-30FF518F41100A47", {
serialport: {
baudRate: 9600,
bufferSize: 256,
}
});
board.on("ready", function() {
console.log("READY");
var pin = 2;
var state = 1;
board.pinMode(pin, board.MODES.OUTPUT);
setInterval(function() {
board.digitalWrite(pin, (state ^= 1));
}, 500);
});
var Board = require("../");
Board.requestPort(function(error, port) {
if (error) {
console.log(error);
return;
}
var board = new Board(port.comName, {samplingInterval: 1000});
board.on("ready", function() {
this.i2cConfig();
this.i2cRead(8,4, function(data) {
console.log("received data");
console.log(data);
});
});
});
var Board = require("../");
Board.requestPort(function(error, port) {
if (error) {
console.log(error);
return;
}
var board = new Board(port.comName);
board.on("ready", function() {
console.log(board.RESOLUTION);
});
});
var Board = require("../");
var pin = Number(process.argv[2] || 0);
Board.requestPort(function(error, port) {
if (error) {
console.log(error);
return;
}
var board = new Board(port.comName);
board.on("ready", function() {
console.log(" ✔ ready");
console.log(pin);
this.pinMode(pin, 2);
this.analogRead(pin, function(value) {
console.log(`analogRead: ${pin} ${value}`);
});
board.on("string", function(data) {
console.log(`string: ${data}`);
});
});
});

Sorry, the diff of this file is too big to display