Skip to content

Commit

Permalink
Allow more callbacks for incoming data from the emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
halemmerich committed May 9, 2024
1 parent dc682af commit 677f21b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/emulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ var factoryFlashMemory;
// Log of messages from app
var appLog = "";
var lastOutputLine = "";
var consoleOutputCallback;

function onConsoleOutput(txt) {
appLog += txt + "\n";
lastOutputLine = txt;
if (consoleOutputCallback)
consoleOutputCallback(txt);
else
console.log("EMSCRIPTEN:", txt);
}

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

jsRXCallback = function() {};
jsRXCallback = options.rxCallback ? options.rxCallback : function() {};
jsUpdateGfx = function() {};
if (options.consoleOutputCallback)
consoleOutputCallback = options.consoleOutputCallback;

factoryFlashMemory = new Uint8Array(FLASH_SIZE);
factoryFlashMemory.fill(255);
Expand Down

0 comments on commit 677f21b

Please sign in to comment.