@@ -262,23 +262,23 @@ setInput () {
262262 */
263263if ( ! Number . isInteger ( arguments [ 0 ] ) && typeof arguments [ 0 ] === 'object' && arguments . length === 1 ) {
264264for ( var x = 0 ; x < arguments [ 0 ] . pin . length ; x ++ ) {
265- // check if pins are from numbers 1 ~ 40 and validate for input use
266- if ( Number . isInteger ( arguments [ 0 ] . pin [ x ] ) && arguments [ 0 ] . pin [ x ] > 0 && arguments [ 0 ] . pin [ x ] < 41 ) {
267- try {
265+ // check if pins are from numbers 1 ~ 40 and validate for input use
266+ if ( Number . isInteger ( arguments [ 0 ] . pin [ x ] ) && arguments [ 0 ] . pin [ x ] > 0 && arguments [ 0 ] . pin [ x ] < 41 ) {
267+ try {
268268rpi . gpio_open ( arguments [ 0 ] . pin [ x ] , 0 ) ;
269- }
270- catch ( e ) {
269+ }
270+ catch ( e ) {
271271inputPin . push ( ' *' + arguments [ 0 ] . pin [ x ] ) ;
272272console . log ( 'input pins [ ' + inputPin + ' ]' ) ;
273273invalidPinError ( arguments [ 0 ] . pin [ x ] ) ;
274- }
275- inputPin . push ( arguments [ 0 ] . pin [ x ] ) ;
276- arrayPinCheck . push ( arguments [ 0 ] . pin [ x ] ) ;
277- }
278- // invalid pin number
279- else {
280- invalidPinError ( arguments [ 0 ] . pin [ x ] ) ;
281- }
274+ }
275+ inputPin . push ( arguments [ 0 ] . pin [ x ] ) ;
276+ arrayPinCheck . push ( arguments [ 0 ] . pin [ x ] ) ;
277+ }
278+ // invalid pin number
279+ else {
280+ invalidPinError ( arguments [ 0 ] . pin [ x ] ) ;
281+ }
282282 }
283283 options = arguments [ 0 ] ;
284284}
@@ -289,19 +289,19 @@ setInput () {
289289 */
290290if ( Number . isInteger ( arguments [ 0 ] ) && arguments . length >= 1 ) {
291291for ( var x = 0 ; x < arguments . length ; x ++ ) {
292- // check if pins are from numbers 1 ~ 40 and validate for input use
293- if ( Number . isInteger ( arguments [ x ] ) && arguments [ x ] > 0 && arguments [ x ] < 41 ) {
294- try {
292+ // check if pins are from numbers 1 ~ 40 and validate for input use
293+ if ( Number . isInteger ( arguments [ x ] ) && arguments [ x ] > 0 && arguments [ x ] < 41 ) {
294+ try {
295295rpi . gpio_open ( arguments [ x ] , 0 ) ;
296- }
297- catch ( e ) {
296+ }
297+ catch ( e ) {
298298inputPin . push ( ' *' + arguments [ x ] ) ;
299299console . log ( 'input pins [ ' + inputPin + ' ]' ) ;
300300invalidPinError ( arguments [ x ] ) ;
301- }
302- inputPin . push ( arguments [ x ] ) ;
303- arrayPinCheck . push ( inputPin [ x ] ) ;
304- }
301+ }
302+ inputPin . push ( arguments [ x ] ) ;
303+ arrayPinCheck . push ( inputPin [ x ] ) ;
304+ }
305305// invalid pin number
306306else if ( Number . isInteger ( arguments [ x ] ) && arguments [ x ] <= 0 || arguments [ x ] > 40 ) {
307307invalidPinError ( arguments [ x ] ) ;
@@ -338,16 +338,16 @@ setInput () {
338338 */
339339function createObject ( inputPin , options , GpioInput ) {
340340for ( var i = 0 ; i < inputPin . length ; i ++ ) {
341- var index = i , pin = inputPin [ i ] ;
342- if ( options ) {
343- if ( options . pinCheck === 'NoPinCheck' || options . pinCheck === false ) {
341+ var index = i , pin = inputPin [ i ] ;
342+ if ( options ) {
343+ if ( options . pinCheck === 'NoPinCheck' || options . pinCheck === false ) {
344344pinCheck = false ;
345- }
346- if ( options . index === 'PinAsIndex' || options . index === 'pin' ) {
345+ }
346+ if ( options . index === 'PinAsIndex' || options . index === 'pin' ) {
347347index = inputPin [ i ] ;
348- }
349- eventPin . push ( pin ) ;
350- input [ index ] = new GpioInput ( index , pin , options ) ;
348+ }
349+ eventPin . push ( pin ) ;
350+ input [ index ] = new GpioInput ( index , pin , options ) ;
351351 }
352352 }
353353}
@@ -365,7 +365,7 @@ setInput () {
365365arraySetup = options . index ;
366366 config = '{ pin:[' + inputPin + ']' + ', index:' + options . index + ' } ' + endTime ( 1 ) ;
367367 if ( options . array ) {
368- config = '{ pin:[' + inputPin + ']' + ', array:true, index:' + options . index + ' } ' + endTime ( 1 ) ;
368+ config = '{ pin:[' + inputPin + ']' + ', array:true, index:' + options . index + ' } ' + endTime ( 1 ) ;
369369 }
370370}
371371else if ( inputPin . length < 2 && options . array === true && ( options . index === 'PinAsIndex' || options . index === 'pin' ) ) {
@@ -438,22 +438,22 @@ setOutput () {
438438if ( ! Number . isInteger ( arguments [ 0 ] ) && typeof arguments [ 0 ] === 'object' && arguments . length === 1 ) {
439439for ( var x = 0 ; x < arguments [ 0 ] . pin . length ; x ++ ) {
440440// check if pins are from numbers 1 ~ 40 and validate for output use
441- if ( Number . isInteger ( arguments [ 0 ] . pin [ x ] ) && arguments [ 0 ] . pin [ x ] > 0 && arguments [ 0 ] . pin [ x ] < 41 ) {
442- try {
441+ if ( Number . isInteger ( arguments [ 0 ] . pin [ x ] ) && arguments [ 0 ] . pin [ x ] > 0 && arguments [ 0 ] . pin [ x ] < 41 ) {
442+ try {
443443rpi . gpio_open ( arguments [ 0 ] . pin [ x ] , 1 ) ;
444- }
445- catch ( e ) {
444+ }
445+ catch ( e ) {
446446outputPin . push ( ' *' + arguments [ 0 ] . pin [ x ] ) ;
447447console . log ( 'output pins [ ' + outputPin + ' ]' ) ;
448448invalidPinError ( arguments [ 0 ] . pin [ x ] ) ;
449- }
450- outputPin . push ( arguments [ 0 ] . pin [ x ] ) ;
451- arrayPinCheck . push ( arguments [ 0 ] . pin [ x ] ) ;
452- }
449+ }
450+ outputPin . push ( arguments [ 0 ] . pin [ x ] ) ;
451+ arrayPinCheck . push ( arguments [ 0 ] . pin [ x ] ) ;
452+ }
453453// invalid pin number
454- else {
455- invalidPinError ( arguments [ 0 ] . pin [ x ] ) ;
456- }
454+ else {
455+ invalidPinError ( arguments [ 0 ] . pin [ x ] ) ;
456+ }
457457 }
458458 options = arguments [ 0 ] ;
459459}
@@ -533,10 +533,10 @@ setOutput () {
533533 arraySetup = 'index:0~n' ;
534534 }
535535 else if ( options . index && ! options . array ) {
536- arraySetup = 'index:pin' ;
536+ arraySetup = 'index:pin' ;
537537 }
538538 else if ( options . array && ! options . index ) {
539- arraySetup = 'array:true, index:0~n' ;
539+ arraySetup = 'array:true, index:0~n' ;
540540 }
541541 else if ( options . array && options . index ) {
542542arraySetup = 'array:true, index:pin' ;
0 commit comments