Skip to content

Commit 3a924af

Browse files
authored
Update array-gpio.js
1 parent d94421a commit 3a924af

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

lib/array-gpio.js

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -262,23 +262,23 @@ setInput () {
262262
*/
263263
if(!Number.isInteger(arguments[0]) && typeof arguments[0] === 'object' && arguments.length === 1) {
264264
for (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{
268268
rpi.gpio_open(arguments[0].pin[x], 0);
269-
}
270-
catch(e){
269+
}
270+
catch(e){
271271
inputPin.push(' *' + arguments[0].pin[x]);
272272
console.log('input pins [ ' + inputPin + ' ]');
273273
invalidPinError(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
*/
290290
if (Number.isInteger(arguments[0]) && arguments.length >= 1) {
291291
for (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{
295295
rpi.gpio_open(arguments[x], 0);
296-
}
297-
catch(e){
296+
}
297+
catch(e){
298298
inputPin.push(' *' + arguments[x]);
299299
console.log('input pins [ ' + inputPin + ' ]');
300300
invalidPinError(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
306306
else if(Number.isInteger(arguments[x]) && arguments[x] <= 0 || arguments[x] > 40){
307307
invalidPinError(arguments[x]);
@@ -338,16 +338,16 @@ setInput () {
338338
*/
339339
function createObject(inputPin, options, GpioInput){
340340
for (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){
344344
pinCheck = false;
345-
}
346-
if(options.index === 'PinAsIndex' || options.index === 'pin'){
345+
}
346+
if(options.index === 'PinAsIndex' || options.index === 'pin'){
347347
index = 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 () {
365365
arraySetup = 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
}
371371
else if(inputPin.length < 2 && options.array === true && (options.index === 'PinAsIndex' || options.index === 'pin')){
@@ -438,22 +438,22 @@ setOutput () {
438438
if(!Number.isInteger(arguments[0]) && typeof arguments[0] === 'object' && arguments.length === 1) {
439439
for (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{
443443
rpi.gpio_open(arguments[0].pin[x] , 1);
444-
}
445-
catch(e){
444+
}
445+
catch(e){
446446
outputPin.push(' *' + arguments[0].pin[x]);
447447
console.log('output pins [ ' + outputPin + ' ]');
448448
invalidPinError(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){
542542
arraySetup = 'array:true, index:pin';

0 commit comments

Comments
 (0)