Skip to content

Commit 677f21b

Browse files
committed
Allow more callbacks for incoming data from the emulator
1 parent dc682af commit 677f21b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/emulator.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ var factoryFlashMemory;
1313
// Log of messages from app
1414
var appLog = "";
1515
var lastOutputLine = "";
16+
var consoleOutputCallback;
1617

1718
function onConsoleOutput(txt) {
1819
appLog += txt + "\n";
1920
lastOutputLine = txt;
21+
if (consoleOutputCallback)
22+
consoleOutputCallback(txt);
23+
else
24+
console.log("EMSCRIPTEN:", txt);
2025
}
2126

2227
exports.init = function(options) {
@@ -29,8 +34,10 @@ exports.init = function(options) {
2934
eval(require("fs").readFileSync(DIR_IDE + "/emu/emu_"+EMULATOR+".js").toString());
3035
eval(require("fs").readFileSync(DIR_IDE + "/emu/common.js").toString()/*.replace('console.log("EMSCRIPTEN:"', '//console.log("EMSCRIPTEN:"')*/);
3136

32-
jsRXCallback = function() {};
37+
jsRXCallback = options.rxCallback ? options.rxCallback : function() {};
3338
jsUpdateGfx = function() {};
39+
if (options.consoleOutputCallback)
40+
consoleOutputCallback = options.consoleOutputCallback;
3441

3542
factoryFlashMemory = new Uint8Array(FLASH_SIZE);
3643
factoryFlashMemory.fill(255);

0 commit comments

Comments
 (0)