6 Commits

Author SHA1 Message Date
zyphlar
df4fa8fb5b Fix all_on and all_off error
sendFeatureReport always needs two arguments, even if one is null (0x00)

See C++ source here for future development reference: 87cf2d92c7/lib/usb_relay_lib.c
2018-08-31 13:26:59 -07:00
Dana Woodman
4a6720e525 0.0.4 2018-07-23 13:21:02 -07:00
Dana Woodman
b0da1b68e6 Fix package import 2018-07-23 13:18:46 -07:00
Dana Woodman
8bb1eed8a0 0.0.3 2018-07-23 13:11:55 -07:00
Dana Woodman
916f75c86e Change package name 2018-07-23 13:11:27 -07:00
Dana Woodman
2cf4893252 Update module name 2018-07-23 13:09:30 -07:00
5 changed files with 1247 additions and 1242 deletions

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
v10.3.0

View File

@@ -1,4 +1,4 @@
# usbrelay
# easy-usb-relay
**THIS IS CURRENTLY IN AN EXPERIMENTAL STATE:** It does not yet support multiple boards or other manufacturers. Coming soon...
@@ -7,13 +7,13 @@
## Setup
```bash
npm install --save usbrelay
npm install --save easy-usb-relay
```
## Usage
```js
const { Board } = require('usbrelay')
const { Board } = require('easy-usb-relay')
const numRelays = 2
const relays = new Board(numRelays)
@@ -31,7 +31,7 @@ relays.on(1)
relays.off(1)
```
Please see [examples directory](/examples) for more examples on using `usbrelay`
Please see [examples directory](/examples) for more examples on using `easy-usb-relay`
## API

2462
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,19 @@
{
"name": "usbrelay",
"version": "0.0.2",
"description": "A USB relay support library",
"main": "src/relay.js",
"name": "easy-usb-relay",
"version": "0.0.4",
"description": "A simple USB relay support library",
"main": "src/relays.js",
"scripts": {
"test": "jest"
},
"repository": {
"type": "git",
"url": "github.com/danawoodman/usbrelay"
"url": "github.com/danawoodman/easy-usb-relay"
},
"keywords": [
"usb",
"relay",
"sainsmart",
"arduino",
"rpi",
"raspberry",

View File

@@ -69,14 +69,17 @@ class Board {
}
allOn() {
this.trigger([ALL_ON])
this.trigger([ALL_ON, 0])
}
allOff() {
this.trigger([ALL_OFF])
this.trigger([ALL_OFF, 0])
}
trigger(state) {
if (state.length != 2) {
throw new Error('easy-usb-relay library error: exactly two arguments required for trigger function.')
}
this.logState()
this.board.sendFeatureReport(state)
}