Skip to content

Commit 0b1f73a

Browse files
author
Blaine Schmeisser
committed
Give all the variables a consistent casing.
Variables are lowerCamelCase Constants are UPPER_SNAKE_CASE.
1 parent d177b9a commit 0b1f73a

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

BigRedButton.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ var util = require('util');
66
var events = require('events');
77

88
var allDevices;
9-
var cmd_status=new Buffer([ 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 ]);
10-
var last_state;
9+
var cmdStatus=new Buffer([ 0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 ]);
10+
var lastState;
1111

1212
var LID_DOWN=0x15, LID_UP=0x17, BUTTON_DOWN=0x16;
1313

@@ -35,11 +35,11 @@ function BigRedButton(index)
3535
this.button = bigRedButton[index];
3636
this.hid = new HID.HID(bigRedButton[index].path);
3737

38-
this.hid.write(cmd_status);
38+
this.hid.write(cmdStatus);
3939

4040
var that=this;
4141
this.hid.read(function(error,data) {
42-
last_state=data[0];
42+
lastState=data[0];
4343
that.hid.read(that.interpretData.bind(that));
4444
});
4545
this.interval = setInterval(this.askForStatus.bind(this),100);
@@ -55,45 +55,45 @@ function BigRedButton(index)
5555
util.inherits(BigRedButton, events.EventEmitter);
5656

5757
BigRedButton.prototype.askForStatus = function() {
58-
this.hid.write(cmd_status);
58+
this.hid.write(cmdStatus);
5959
};
6060

6161
BigRedButton.prototype.interpretData = function(error, data) {
6262
if (!this.interval || error || !data) {
6363
this.close();
6464
return;
6565
}
66-
var n_state=data[0];
66+
var newState=data[0];
6767

68-
if (last_state!=n_state) {
69-
if (last_state==LID_DOWN && n_state==LID_UP) {
68+
if (lastState!=newState) {
69+
if (lastState==LID_DOWN && newState==LID_UP) {
7070
this.emit("lidRaised");
71-
} else if (last_state==LID_UP && n_state==BUTTON_DOWN) {
71+
} else if (lastState==LID_UP && newState==BUTTON_DOWN) {
7272
this.emit("buttonPressed");
73-
} else if (last_state==BUTTON_DOWN && n_state==LID_UP) {
73+
} else if (lastState==BUTTON_DOWN && newState==LID_UP) {
7474
this.emit("buttonReleased");
75-
} else if (last_state==BUTTON_DOWN && n_state==LID_DOWN) {
75+
} else if (lastState==BUTTON_DOWN && newState==LID_DOWN) {
7676
this.emit("buttonReleased");
7777
this.emit("lidClosed");
78-
} else if (last_state==LID_UP && n_state==LID_DOWN) {
78+
} else if (lastState==LID_UP && newState==LID_DOWN) {
7979
this.emit("lidClosed");
8080
}
81-
last_state=n_state;
81+
lastState=newState;
8282
}
8383

8484
this.hid.read(this.interpretData.bind(this));
8585
}
8686

8787
BigRedButton.prototype.isLidUp = function() {
88-
return last_state==LID_UP || last_state==BUTTON_DOWN;
88+
return lastState==LID_UP || lastState==BUTTON_DOWN;
8989
}
9090

9191
BigRedButton.prototype.isButtonPressed = function() {
92-
return last_state==BUTTON_DOWN;
92+
return lastState==BUTTON_DOWN;
9393
}
9494

9595
BigRedButton.prototype.isLidDown = function() {
96-
return last_state==LID_DOWN;
96+
return lastState==LID_DOWN;
9797
}
9898

9999
exports.BigRedButton = BigRedButton;

0 commit comments

Comments
 (0)