@@ -13,12 +13,26 @@ var factoryFlashMemory;
13
13
// Log of messages from app
14
14
var appLog = "" ;
15
15
var lastOutputLine = "" ;
16
+ var consoleOutputCallback ;
16
17
17
18
function onConsoleOutput ( txt ) {
18
19
appLog += txt + "\n" ;
19
20
lastOutputLine = txt ;
21
+ if ( consoleOutputCallback )
22
+ consoleOutputCallback ( txt ) ;
23
+ else
24
+ console . log ( "EMSCRIPTEN:" , txt ) ;
20
25
}
21
26
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
+ */
22
36
exports . init = function ( options ) {
23
37
if ( options . EMULATOR )
24
38
EMULATOR = options . EMULATOR ;
@@ -29,8 +43,10 @@ exports.init = function(options) {
29
43
eval ( require ( "fs" ) . readFileSync ( DIR_IDE + "/emu/emu_" + EMULATOR + ".js" ) . toString ( ) ) ;
30
44
eval ( require ( "fs" ) . readFileSync ( DIR_IDE + "/emu/common.js" ) . toString ( ) /*.replace('console.log("EMSCRIPTEN:"', '//console.log("EMSCRIPTEN:"')*/ ) ;
31
45
32
- jsRXCallback = function ( ) { } ;
46
+ jsRXCallback = options . rxCallback ? options . rxCallback : function ( ) { } ;
33
47
jsUpdateGfx = function ( ) { } ;
48
+ if ( options . consoleOutputCallback )
49
+ consoleOutputCallback = options . consoleOutputCallback ;
34
50
35
51
factoryFlashMemory = new Uint8Array ( FLASH_SIZE ) ;
36
52
factoryFlashMemory . fill ( 255 ) ;
0 commit comments