@@ -13,12 +13,26 @@ var factoryFlashMemory;
1313// Log of messages from app
1414var appLog = "" ;
1515var lastOutputLine = "" ;
16+ var consoleOutputCallback ;
1617
1718function onConsoleOutput ( txt ) {
1819 appLog += txt + "\n" ;
1920 lastOutputLine = txt ;
21+ if ( consoleOutputCallback )
22+ consoleOutputCallback ( txt ) ;
23+ else
24+ console . log ( "EMSCRIPTEN:" , txt ) ;
2025}
2126
27+ /* Initialise the emulator,
28+
29+ options = {
30+ EMULATOR : "banglejs"/"banglejs2"
31+ DEVICEID : "BANGLEJS"/"BANGLEJS2"
32+ rxCallback : function(int) - called every time a character received
33+ consoleOutputCallback : function(str) - called when a while line is received
34+ }
35+ */
2236exports . init = function ( options ) {
2337 if ( options . EMULATOR )
2438 EMULATOR = options . EMULATOR ;
@@ -29,8 +43,10 @@ exports.init = function(options) {
2943 eval ( require ( "fs" ) . readFileSync ( DIR_IDE + "/emu/emu_" + EMULATOR + ".js" ) . toString ( ) ) ;
3044 eval ( require ( "fs" ) . readFileSync ( DIR_IDE + "/emu/common.js" ) . toString ( ) /*.replace('console.log("EMSCRIPTEN:"', '//console.log("EMSCRIPTEN:"')*/ ) ;
3145
32- jsRXCallback = function ( ) { } ;
46+ jsRXCallback = options . rxCallback ? options . rxCallback : function ( ) { } ;
3347 jsUpdateGfx = function ( ) { } ;
48+ if ( options . consoleOutputCallback )
49+ consoleOutputCallback = options . consoleOutputCallback ;
3450
3551 factoryFlashMemory = new Uint8Array ( FLASH_SIZE ) ;
3652 factoryFlashMemory . fill ( 255 ) ;
0 commit comments