File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,19 @@ connectionPromise.then(cap1188 => {
1212 console . log ( evt ) ;
1313 } ) ;
1414
15- cap1188 . on ( "reset" , function ( evt ) {
15+ cap1188 . on ( "touch" , function ( pin ) {
16+ console . log ( "pin touched: " , pin ) ;
17+ } ) ;
18+
19+ cap1188 . on ( "release" , function ( pin ) {
20+ console . log ( "pin released: " , pin ) ;
21+ } ) ;
22+
23+ cap1188 . on ( 2 , function ( touched ) {
24+ console . log ( "pin 2 is: " , touched ? "touched" : "released" ) ;
25+ } ) ;
26+
27+ cap1188 . on ( "reset" , function ( ) {
1628 console . log ( "reset" ) ;
1729 } ) ;
1830
Original file line number Diff line number Diff line change @@ -86,6 +86,9 @@ class CAP1188 extends EventEmitter {
8686 for ( var i = 0 ; i < 8 ; i ++ ) {
8787 if ( currentTouches [ i ] !== lastTouches [ i ] ) {
8888 changes . push ( { id : i , touched : currentTouches [ i ] } ) ;
89+ // Emits touch/release event with pin number
90+ this . emit ( currentTouches [ i ] ? "touch" : "release" , i ) ;
91+ this . emit ( i , currentTouches [ i ] ) ;
8992 }
9093 }
9194
You can’t perform that action at this time.
0 commit comments