Skip to content

Commit 07a12d2

Browse files
committed
Add the beforeReady event
1 parent 7e92060 commit 07a12d2

File tree

10 files changed

+57
-15
lines changed

10 files changed

+57
-15
lines changed

dist/webduino-all.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,14 +2554,14 @@ if (typeof exports !== 'undefined') {
25542554
if (hasProcess()) {
25552555
debugStr = process.env[DEBUG_STR];
25562556
}
2557-
2557+
25582558
if (debugStr) {
25592559
debugKeys = debugStr.split(',').map(function (val) {
25602560
return val.trim();
25612561
});
25622562
}
25632563

2564-
if (debugKeys.indexOf('*') !== -1 || debugKeys.indexOf(this._key) !== -1) {
2564+
if (debugStr && (debugKeys.indexOf('*') !== -1 || debugKeys.indexOf(this._key) !== -1)) {
25652565
return true;
25662566
}
25672567

@@ -4036,6 +4036,7 @@ if (typeof exports !== 'undefined') {
40364036
STRING_MESSAGE: 'stringMessage',
40374037
SYSEX_MESSAGE: 'sysexMessage',
40384038
PIN_STATE_RESPONSE: 'pinStateResponse',
4039+
BEFOREREADY: 'beforeReady',
40394040
READY: 'ready',
40404041
ERROR: 'error',
40414042
BEFOREDISCONNECT: 'beforeDisconnect',
@@ -4133,6 +4134,7 @@ if (typeof exports !== 'undefined') {
41334134
}
41344135

41354136
function onOpen() {
4137+
this._logger.info('onOpen', 'Device online');
41364138
this.begin();
41374139
}
41384140

@@ -4367,6 +4369,7 @@ if (typeof exports !== 'undefined') {
43674369
break;
43684370
case ANALOG_MAPPING_RESPONSE:
43694371
this.processAnalogMappingResponse(sysexData);
4372+
this.emit(BoardEvent.BEFOREREADY);
43704373
break;
43714374
default:
43724375
this.emit(BoardEvent.SYSEX_MESSAGE, {
@@ -4477,6 +4480,7 @@ if (typeof exports !== 'undefined') {
44774480
};
44784481

44794482
proto.startup = function () {
4483+
this._logger.info('startup', 'Board Ready');
44804484
this._isReady = true;
44814485
this.emit(BoardEvent.READY, this);
44824486
};
@@ -4589,10 +4593,12 @@ if (typeof exports !== 'undefined') {
45894593
};
45904594

45914595
proto.queryCapabilities = function () {
4596+
this._logger.info('queryCapabilities');
45924597
this.send([START_SYSEX, CAPABILITY_QUERY, END_SYSEX]);
45934598
};
45944599

45954600
proto.queryAnalogMapping = function () {
4601+
this._logger.info('queryAnalogMapping');
45964602
this.send([START_SYSEX, ANALOG_MAPPING_QUERY, END_SYSEX]);
45974603
};
45984604

@@ -4625,10 +4631,12 @@ if (typeof exports !== 'undefined') {
46254631
};
46264632

46274633
proto.reportFirmware = function () {
4634+
this._logger.info('reportFirmware');
46284635
this.send([START_SYSEX, REPORT_FIRMWARE, END_SYSEX]);
46294636
};
46304637

46314638
proto.enableDigitalPins = function () {
4639+
this._logger.info('enableDigitalPins');
46324640
for (var i = 0; i < this._numPorts; i++) {
46334641
this.sendDigitalPortReporting(i, Pin.ON);
46344642
}

dist/webduino-all.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/webduino-base.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,14 +2554,14 @@ if (typeof exports !== 'undefined') {
25542554
if (hasProcess()) {
25552555
debugStr = process.env[DEBUG_STR];
25562556
}
2557-
2557+
25582558
if (debugStr) {
25592559
debugKeys = debugStr.split(',').map(function (val) {
25602560
return val.trim();
25612561
});
25622562
}
25632563

2564-
if (debugKeys.indexOf('*') !== -1 || debugKeys.indexOf(this._key) !== -1) {
2564+
if (debugStr && (debugKeys.indexOf('*') !== -1 || debugKeys.indexOf(this._key) !== -1)) {
25652565
return true;
25662566
}
25672567

@@ -4036,6 +4036,7 @@ if (typeof exports !== 'undefined') {
40364036
STRING_MESSAGE: 'stringMessage',
40374037
SYSEX_MESSAGE: 'sysexMessage',
40384038
PIN_STATE_RESPONSE: 'pinStateResponse',
4039+
BEFOREREADY: 'beforeReady',
40394040
READY: 'ready',
40404041
ERROR: 'error',
40414042
BEFOREDISCONNECT: 'beforeDisconnect',
@@ -4133,6 +4134,7 @@ if (typeof exports !== 'undefined') {
41334134
}
41344135

41354136
function onOpen() {
4137+
this._logger.info('onOpen', 'Device online');
41364138
this.begin();
41374139
}
41384140

@@ -4367,6 +4369,7 @@ if (typeof exports !== 'undefined') {
43674369
break;
43684370
case ANALOG_MAPPING_RESPONSE:
43694371
this.processAnalogMappingResponse(sysexData);
4372+
this.emit(BoardEvent.BEFOREREADY);
43704373
break;
43714374
default:
43724375
this.emit(BoardEvent.SYSEX_MESSAGE, {
@@ -4477,6 +4480,7 @@ if (typeof exports !== 'undefined') {
44774480
};
44784481

44794482
proto.startup = function () {
4483+
this._logger.info('startup', 'Board Ready');
44804484
this._isReady = true;
44814485
this.emit(BoardEvent.READY, this);
44824486
};
@@ -4589,10 +4593,12 @@ if (typeof exports !== 'undefined') {
45894593
};
45904594

45914595
proto.queryCapabilities = function () {
4596+
this._logger.info('queryCapabilities');
45924597
this.send([START_SYSEX, CAPABILITY_QUERY, END_SYSEX]);
45934598
};
45944599

45954600
proto.queryAnalogMapping = function () {
4601+
this._logger.info('queryAnalogMapping');
45964602
this.send([START_SYSEX, ANALOG_MAPPING_QUERY, END_SYSEX]);
45974603
};
45984604

@@ -4625,10 +4631,12 @@ if (typeof exports !== 'undefined') {
46254631
};
46264632

46274633
proto.reportFirmware = function () {
4634+
this._logger.info('reportFirmware');
46284635
this.send([START_SYSEX, REPORT_FIRMWARE, END_SYSEX]);
46294636
};
46304637

46314638
proto.enableDigitalPins = function () {
4639+
this._logger.info('enableDigitalPins');
46324640
for (var i = 0; i < this._numPorts; i++) {
46334641
this.sendDigitalPortReporting(i, Pin.ON);
46344642
}

dist/webduino-base.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/classes/webduino.Board.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ <h2>Constructor</h2>
159159
<div class="meta">
160160
<p>
161161
Defined in
162-
<a href="../files/src_core_Board.js.html#l66"><code>src&#x2F;core&#x2F;Board.js:66</code></a>
162+
<a href="../files/src_core_Board.js.html#l67"><code>src&#x2F;core&#x2F;Board.js:67</code></a>
163163
</p>
164164

165165

docs/data.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
"extension_for": [],
251251
"namespace": "webduino",
252252
"file": "src/core/Board.js",
253-
"line": 66,
253+
"line": 67,
254254
"description": "An abstract development board.",
255255
"is_constructor": 1,
256256
"params": [
@@ -816,7 +816,7 @@
816816
"classitems": [
817817
{
818818
"file": "src/core/Board.js",
819-
"line": 33,
819+
"line": 34,
820820
"description": "Message command bytes (128-255/0x80-0xFF)\nhttps://github.com/firmata/protocol/blob/master/protocol.md",
821821
"class": "webduino.Board"
822822
},
@@ -2345,7 +2345,7 @@
23452345
"warnings": [
23462346
{
23472347
"message": "Missing item type\nMessage command bytes (128-255/0x80-0xFF)\nhttps://github.com/firmata/protocol/blob/master/protocol.md",
2348-
"line": " src/core/Board.js:33"
2348+
"line": " src/core/Board.js:34"
23492349
}
23502350
]
23512351
}

docs/files/src_core_Board.js.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ <h1>src/core/Board.js <small>File</small></h1>
122122
STRING_MESSAGE: &#x27;stringMessage&#x27;,
123123
SYSEX_MESSAGE: &#x27;sysexMessage&#x27;,
124124
PIN_STATE_RESPONSE: &#x27;pinStateResponse&#x27;,
125+
BEFOREREADY: &#x27;beforeReady&#x27;,
125126
READY: &#x27;ready&#x27;,
126127
ERROR: &#x27;error&#x27;,
127128
BEFOREDISCONNECT: &#x27;beforeDisconnect&#x27;,
@@ -219,6 +220,7 @@ <h1>src/core/Board.js <small>File</small></h1>
219220
}
220221

221222
function onOpen() {
223+
this._logger.info(&#x27;onOpen&#x27;, &#x27;Device online&#x27;);
222224
this.begin();
223225
}
224226

@@ -453,6 +455,7 @@ <h1>src/core/Board.js <small>File</small></h1>
453455
break;
454456
case ANALOG_MAPPING_RESPONSE:
455457
this.processAnalogMappingResponse(sysexData);
458+
this.emit(BoardEvent.BEFOREREADY);
456459
break;
457460
default:
458461
this.emit(BoardEvent.SYSEX_MESSAGE, {
@@ -563,6 +566,7 @@ <h1>src/core/Board.js <small>File</small></h1>
563566
};
564567

565568
proto.startup = function () {
569+
this._logger.info(&#x27;startup&#x27;, &#x27;Board Ready&#x27;);
566570
this._isReady = true;
567571
this.emit(BoardEvent.READY, this);
568572
};
@@ -675,10 +679,12 @@ <h1>src/core/Board.js <small>File</small></h1>
675679
};
676680

677681
proto.queryCapabilities = function () {
682+
this._logger.info(&#x27;queryCapabilities&#x27;);
678683
this.send([START_SYSEX, CAPABILITY_QUERY, END_SYSEX]);
679684
};
680685

681686
proto.queryAnalogMapping = function () {
687+
this._logger.info(&#x27;queryAnalogMapping&#x27;);
682688
this.send([START_SYSEX, ANALOG_MAPPING_QUERY, END_SYSEX]);
683689
};
684690

@@ -711,10 +717,12 @@ <h1>src/core/Board.js <small>File</small></h1>
711717
};
712718

713719
proto.reportFirmware = function () {
720+
this._logger.info(&#x27;reportFirmware&#x27;);
714721
this.send([START_SYSEX, REPORT_FIRMWARE, END_SYSEX]);
715722
};
716723

717724
proto.enableDigitalPins = function () {
725+
this._logger.info(&#x27;enableDigitalPins&#x27;);
718726
for (var i = 0; i &lt; this._numPorts; i++) {
719727
this.sendDigitalPortReporting(i, Pin.ON);
720728
}

examples/basic.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@
3636
// 'url': 'wa1501.local'
3737
// });
3838

39+
board.on(webduino.BoardEvent.BEFOREREADY, function () {
40+
console.log('board beforeReady');
41+
});
42+
3943
board.on(webduino.BoardEvent.READY, function() {
40-
led = new webduino.module.Led(board, board.getDigitalPin(10));
44+
console.log('board ready');
45+
led = new webduino.module.Led(board, board.getDigitalPin(13));
4146
led.blink(500);
4247

4348
setTimeout(function() {

examples/node/basic.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ board = new webduino.WebArduino('device_id');
3535
// 'url': 'wa1501.local'
3636
// });
3737

38+
board.on(webduino.BoardEvent.BEFOREREADY, function () {
39+
console.log('board beforeReady');
40+
});
41+
3842
board.on(webduino.BoardEvent.READY, function () {
39-
led = new webduino.module.Led(board, board.getDigitalPin(10));
43+
console.log('board ready');
44+
led = new webduino.module.Led(board, board.getDigitalPin(13));
4045
led.blink(500);
4146

4247
setTimeout(function () {

src/core/Board.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
STRING_MESSAGE: 'stringMessage',
2525
SYSEX_MESSAGE: 'sysexMessage',
2626
PIN_STATE_RESPONSE: 'pinStateResponse',
27+
BEFOREREADY: 'beforeReady',
2728
READY: 'ready',
2829
ERROR: 'error',
2930
BEFOREDISCONNECT: 'beforeDisconnect',
@@ -121,6 +122,7 @@
121122
}
122123

123124
function onOpen() {
125+
this._logger.info('onOpen', 'Device online');
124126
this.begin();
125127
}
126128

@@ -355,6 +357,7 @@
355357
break;
356358
case ANALOG_MAPPING_RESPONSE:
357359
this.processAnalogMappingResponse(sysexData);
360+
this.emit(BoardEvent.BEFOREREADY);
358361
break;
359362
default:
360363
this.emit(BoardEvent.SYSEX_MESSAGE, {
@@ -465,6 +468,7 @@
465468
};
466469

467470
proto.startup = function () {
471+
this._logger.info('startup', 'Board Ready');
468472
this._isReady = true;
469473
this.emit(BoardEvent.READY, this);
470474
};
@@ -577,10 +581,12 @@
577581
};
578582

579583
proto.queryCapabilities = function () {
584+
this._logger.info('queryCapabilities');
580585
this.send([START_SYSEX, CAPABILITY_QUERY, END_SYSEX]);
581586
};
582587

583588
proto.queryAnalogMapping = function () {
589+
this._logger.info('queryAnalogMapping');
584590
this.send([START_SYSEX, ANALOG_MAPPING_QUERY, END_SYSEX]);
585591
};
586592

@@ -613,10 +619,12 @@
613619
};
614620

615621
proto.reportFirmware = function () {
622+
this._logger.info('reportFirmware');
616623
this.send([START_SYSEX, REPORT_FIRMWARE, END_SYSEX]);
617624
};
618625

619626
proto.enableDigitalPins = function () {
627+
this._logger.info('enableDigitalPins');
620628
for (var i = 0; i < this._numPorts; i++) {
621629
this.sendDigitalPortReporting(i, Pin.ON);
622630
}

0 commit comments

Comments
 (0)