Skip to content

Commit 672bf41

Browse files
committed
Merge branch 'master' of https://github.com/rikkuness/EspruinoTools into packetsend
2 parents a7d40c9 + 65b2e0e commit 672bf41

19 files changed

+393
-130
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ module.exports = {
2323
"no-var": "off",
2424
"no-unused-vars": ["warn", { args: "none" }],
2525
"no-control-regex": "off",
26+
"brace-style": ["warn", "1tbs", { "allowSingleLine": true }]
2627
},
2728
};

bin/espruino-cli.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,7 @@ function terminal(devicePath, exitCallback) {
756756
if (args.watchFile) sendOnFileChanged();
757757
});
758758
});
759-
}
760-
else {
759+
} else {
761760
// figure out what code we need to send (if any)
762761
sendCode(function() {
763762
if (args.watchFile) sendOnFileChanged();

core/codeWriter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@
7474
});
7575
}
7676

77-
/// Parse and fix issues like `if (false)\n foo` in the root scope
77+
/**
78+
* Parse and fix issues like `if (false)\n foo` in the root scope
79+
* @param {string} code
80+
* @returns {string | undefined}
81+
*/
7882
function reformatCode(code) {
7983
var APPLY_LINE_NUMBERS = false;
8084
var lineNumberOffset = 0;

core/config.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@
108108
Espruino.Config[name] = options.defaultValue;
109109
}
110110

111-
/** Add a section (or information on the page).
112-
* options = {
113-
* sortOrder : int, // a number used for sorting
114-
* description : "",
115-
* getHTML : function(callback(html)) // optional
116-
* };
111+
/**
112+
* Add a section (or information on the page).
113+
* @param {string} name
114+
* @param {Object} options
115+
* @param {number} options.sortOrder a number used for sorting
116+
* @param {string} options.description
117+
* @param {() => void | undefined} options.getHTML
117118
*/
118119
function addSection(name, options) {
119120
options.name = name;
@@ -176,7 +177,8 @@
176177
}
177178
};
178179

179-
function clearAll() { // clear all settings
180+
/** Clear all settings */
181+
function clearAll() {
180182
_set({});
181183
for (var name in Espruino.Core.Config.data) {
182184
var options = Espruino.Core.Config.data[name];
@@ -185,7 +187,8 @@
185187
}
186188

187189
Espruino.Core.Config = {
188-
loadConfiguration : loadConfiguration, // special - called before init
190+
/** special - called before init */
191+
loadConfiguration : loadConfiguration,
189192

190193
init : init,
191194
add : add,
@@ -196,7 +199,8 @@
196199
getSection : getSection,
197200
getSections : getSections,
198201

199-
clearAll : clearAll, // clear all settings
202+
/** Clear all settings */
203+
clearAll : clearAll,
200204
};
201205

202206
})();

core/flasher.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@
392392
Espruino.Core.Terminal.setInputDataHandler(oldHandler);
393393
callback(err);
394394
};
395+
395396
// initialise
396397
initialiseChip(function (err) {
397398
if (err) return finish(err);

core/flasherESP8266.js

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,33 @@
2121
function init() {
2222
}
2323

24+
/**
25+
* @typedef {Object} FlasherOptions
26+
* @property {ArrayBuffer} binary
27+
* @property {(status: string) => void} cbStatus
28+
* @property {(err: Error) => void} cbDone
29+
* @property {string} serialDevice Serial2
30+
* @property {string} serialRx A3
31+
* @property {string} serialTx A2
32+
* @property {string} chBoot A14
33+
* @property {string} chPD A13
34+
*/
35+
36+
/**
37+
* @param {FlasherOptions} options
38+
* @returns {FlasherOptions}
39+
*/
2440
function defaultOptions(options) {
2541
options.serialDevice = options.serialDevice||"Serial2";
2642
options.serialRx = options.serialRx||"A3";
2743
options.serialTx = options.serialTx||"A2";
2844
}
2945

30-
/* options = {
31-
binary : ArrayBuffer,
32-
cbStatus,
33-
cbDone,
34-
serialDevice, // Serial2
35-
serialRx, // A3
36-
serialTx, // A2
37-
chBoot, // A14
38-
chPD, // A13
39-
*/
46+
/** @param {FlasherOptions} options */
4047
function flashDevice(options) {
4148
if (!options.binary) throw new Error("Needs binary");
4249
defaultOptions(options);
43-
50+
4451
var prevReader = Espruino.Core.Serial.startListening(function (buffer) {
4552
var bufView = new Uint8Array(buffer);
4653
for (var i=0;i<bufView.length;i++)
@@ -84,7 +91,11 @@
8491
});
8592
}
8693

87-
94+
/**
95+
* @param {FlasherOptions} options
96+
* @param {number} cmd
97+
* @param {ArrayBuffer} data
98+
*/
8899
function wr(options,cmd,data) {
89100
//console.log("Write",cmd,data.length,data);
90101
if (typeof data !== "string")
@@ -112,6 +123,7 @@ function sendCmd(options, cmd, data) {
112123
});
113124
}
114125

126+
/** @param {FlasherOptions} options */
115127
function setupEspruino(options) {
116128
if (options.cbStatus) options.cbStatus("Configuring Espruino...");
117129
return new Promise((resolve,reject)=>{
@@ -152,6 +164,7 @@ function setupEspruino(options) {
152164
});
153165
}
154166

167+
/** @param {FlasherOptions} options */
155168
function unsetupEspruino(options) {
156169
if (options.cbStatus) options.cbStatus("Resetting Espruino...");
157170
return new Promise((resolve,reject)=>{
@@ -163,6 +176,7 @@ function unsetupEspruino(options) {
163176
});
164177
}
165178

179+
/** @param {FlasherOptions} options */
166180
function cmdSync(options) {
167181
console.log("Syncing...");
168182
return new Promise((resolve,reject)=>{
@@ -197,8 +211,7 @@ function cmdSync(options) {
197211
});
198212
}
199213

200-
201-
214+
/** @param {FlasherOptions} options */
202215
function cmdFlash(options) {
203216
var binary = new Uint8Array(options.binary);
204217
var blockCount = Math.floor((binary.length + (BLOCK_SIZE-1)) / BLOCK_SIZE);
@@ -227,6 +240,10 @@ function cmdFlash(options) {
227240
});
228241
}
229242

243+
/**
244+
* @param {FlasherOptions} options
245+
* @param {(version: string) => void} callback
246+
*/
230247
function getFirmwareVersion(options, callback) {
231248
defaultOptions(options);
232249
Espruino.Core.Serial.write('\x03\x10reset()\n', false, function() {

core/notifications.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,20 @@
1313

1414
(function() {
1515

16-
function init()
17-
{
18-
}
16+
function init() { }
1917

2018
Espruino.Core.Notifications = {
2119
init : init,
22-
success: function(msg, setStatus)
23-
{
20+
success: function(msg, setStatus) {
2421
toastr.success(msg);
2522
},
26-
error: function(msg, setStatus)
27-
{
23+
error: function(msg, setStatus) {
2824
toastr.error(msg);
2925
},
30-
warning: function(msg, setStatus)
31-
{
26+
warning: function(msg, setStatus) {
3227
Espruino.callProcessor("notification",{type:"warning",msg:msg},function(){});
3328
},
34-
info: function(msg, setStatus)
35-
{
29+
info: function(msg, setStatus) {
3630
Espruino.callProcessor("notification",{type:"info",msg:msg},function(){});
3731
}
3832
};

core/serial_noble.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
try {
6161
process.on('uncaughtException', nobleExceptionHandler);
6262
if (Espruino.Core.Utils.isWindows()) { // ONLY try on windows - this breaks other OSes
63-
try { noble = require('noble-winrt'); // for windows 10+ compat. noble-uwp should work too
63+
try {
64+
noble = require('noble-winrt'); // for windows 10+ compat. noble-uwp should work too
6465
} catch (e) {
6566
console.log("Noble: noble-winrt not available",e);
6667
}
@@ -240,7 +241,7 @@
240241
}
241242
};
242243

243-
// Throttled serial write
244+
/** Throttled serial write */
244245
var writeSerial = function (data, callback) {
245246
if (txCharacteristic === undefined) return;
246247

core/serial_node_ble.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
});
195195
};
196196

197-
// Throttled serial write
197+
/** Throttled serial write */
198198
var writeSerial = function (data, callback) {
199199
if (txCharacteristic === undefined) return;
200200

core/serial_web_audio.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
var BAUD = 9600;
44

5+
/**
6+
* @param {boolean} ignoreSettings
7+
* @returns {{warning?: string, error?: string} | boolean}
8+
*/
59
function getStatus(ignoreSettings) {
610
if (typeof navigator == "undefined" || typeof window == "undefined") {
711
return {warning:"Not running in a browser"};

core/serial_web_bluetooth.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
isSupportedByBrowser=true;
1010
}
1111

12+
/**
13+
* @param {boolean} ignoreSettings
14+
* @returns {{warning?: string, error?: string} | boolean}
15+
*/
1216
function getStatus(ignoreSettings) {
1317
/* If BLE is handled some other way (eg noble), then it can be disabled here */
1418
if (Espruino.Core.Serial.NO_WEB_BLUETOOTH) {

core/terminal.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
// maximum lines on the terminal
5050
var MAX_LINES = 2048;
5151

52-
function init()
53-
{
52+
function init() {
5453
// Add stuff we need
5554
document.querySelector(".editor--terminal .editor__canvas").innerHTML = '<textarea id="terminalfocus" class="terminal__focus" rows="1" cols="1" style="z-index:-100;position:absolute;left:0px;top:0px;"></textarea><div id="terminal" class="terminal"></div>';
5655

@@ -647,8 +646,7 @@
647646
Espruino.callProcessor("getWatched",receivedData,function(){});
648647
receivedData = "";
649648
}
650-
}
651-
else{ receivedData = ""; }
649+
} else{ receivedData = ""; }
652650
}
653651

654652
/// Claim input and output of the Serial port

0 commit comments

Comments
 (0)