File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ board.on('ready', function() {
10
10
led = new five . Led ( 13 ) ;
11
11
ws . on ( 'message' , function ( data , flags ) {
12
12
frame = JSON . parse ( data ) ;
13
- if ( frame . hands && frame . hands . length > 1 ) {
13
+ if ( frame . hands && frame . hands . length >= 1 ) {
14
14
led . on ( ) ;
15
15
} else {
16
16
led . off ( ) ;
Original file line number Diff line number Diff line change
1
+ // Leap motion enables a websocket with all frame data
2
+ var webSocket = require ( 'ws' ) ,
3
+ ws = new webSocket ( 'ws://127.0.0.1:6437' ) ;
4
+
5
+ // On successful connection
6
+ ws . onopen = function ( event ) {
7
+ var enableMessage = JSON . stringify ( { enableGestures : true } ) ;
8
+ ws . send ( enableMessage ) ; // Enable gestures
9
+ } ;
10
+
11
+ // We can parse this
12
+ ws . on ( 'message' , function ( data , flags ) {
13
+ frame = JSON . parse ( data ) ;
14
+ if ( frame . gestures && frame . gestures . length > 0 ) {
15
+ frame . gestures . forEach ( function ( gesture ) {
16
+ switch ( gesture . type ) {
17
+ case "circle" :
18
+ console . log ( "Circle Gesture" ) ;
19
+ break ;
20
+ case "keyTap" :
21
+ console . log ( "Key Tap Gesture" ) ;
22
+ break ;
23
+ case "screenTap" :
24
+ console . log ( "Screen Tap Gesture" ) ;
25
+ break ;
26
+ case "swipe" :
27
+ console . log ( "Swipe Gesture" ) ;
28
+ break ;
29
+ }
30
+ } ) ;
31
+ }
32
+ } ) ;
You can’t perform that action at this time.
0 commit comments