forked from node-hid/node-hid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-bigredbutton.js
More file actions
35 lines (29 loc) · 853 Bytes
/
test-bigredbutton.js
File metadata and controls
35 lines (29 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Interface with the Dream Cheeky Big Red button
* http://dreamcheeky.com/big-red-button
*
* Uses info gleened from:
* http://ddurdle.blogspot.com/2013/12/using-usb-big-red-button-panic-button.html
*
* @author Tod Kurt (https://github.com/todbot)
*/
/*jslint node: true */
"use strict";
var HID = require('..');
var device = new HID.HID(7476, 13);
var buttonGetDataCmd = [ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 ];
device.on('data', function(data) {
var msg = '';
var buttonState = data[0];
if( buttonState === 0x17 ) {
msg = "Lid opened!";
} else if( buttonState === 0x16 ) {
msg = "Button pushed!";
} else if( buttonState === 0x15 ) {
msg = "waiting...";
}
console.log('button data', data, msg);
});
setInterval( function() {
device.write( buttonGetDataCmd );
}, 100);