@hypericon/revpi-lib
v0.1.2
Published
Library to interact with Kunbus RevPi hardware from Nodejs applications
Downloads
4
Readme
RevPi Lib
Library to interact with Kunbus RevPi hardware from Nodejs applications.
Installation
$ npm i @hypericon/revpi-lib
Usage
Simple example:
// The `model` parameter helps catch errors when attempting to interact with non-existent hardware
const revpi = new RevPiLib({ model: "Core" });
// The last value written to the LEDs is tracked, allowing LEDs to have their colours individually
// controlled by the application
await revpi.ledSetA1("green");
await wait(1000);
await revpi.ledSetA2("red");
await wait(1000);
await revpi.ledSetA1("orange");
await wait(1000);
await revpi.ledSetA2("off");
await wait(1000);
await revpi.ledsAllOff();
/** Simple wait function for example code */
async function wait(ms) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(), ms);
});
}
Optionally override the default logger by passing another as a parameter to the RevPiLib
constructor options:
import { RevPiLogger } from "@hypericon/revpi-lib";
const myLogger: RevPiLogger = {
// etc.
};
const revpi = new RevPiLib({
model: "Core",
logger: myLogger,
});
Details
The library executes commands using piTest
which comes pre-installed on RevPi units.
More info here: https://revolutionpi.com/tutorials/overview-revpi-core/on-revpi-core/
Development
$ npm run dev