mirror of
https://github.com/zyphlar/easy-usb-relay.git
synced 2024-03-08 07:57:47 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df4fa8fb5b | ||
|
|
4a6720e525 | ||
|
|
b0da1b68e6 | ||
|
|
8bb1eed8a0 | ||
|
|
916f75c86e | ||
|
|
2cf4893252 |
@@ -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
2462
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user