You are reading a single comment by @StefanB and its replies. Click here to read the full conversation.
  • Thanks, it's great you got it working!

    However that F message is concerning. That's not a print in your code is it?

    If not I think it's called when an assertion fails inside Espruino, which is a sign that somehow the RAM has got corrupted. What version of Espruino are you running on the ESP8266? Maybe you could try and cutting edge build, or if that is broken the 2v19 build.

    It's a bit hard for me to track down here as I can't run it without having one of those displays, but if you could find a way of changing your code so it'll run without external hardware and still show the error then I can try and track it down here

  • No, I don't print it.
    I'm running 2v19 which I flashed on it using this command:

    python "../esptool/esptool.py" --port COM6 --baud 115200 write_flash --flash_freq 80m --flash_mode qio --flash_size detect 0x0000 espruino_2v19_esp8266_4mb_combined_4096.­bin
    

    I now downloaded a cutting edge build from here: https://www.espruino.com/binaries/travis­/master/espruino_2v19.99_esp8266_4mb.tgz­
    and installed it with the following command:

    python "../esptool/esptool.py" --port COM6 --baud 115200 write_flash --flash_freq 80m --flash_mode qio --flash_size 4MB-c1 0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin 0x3FC000 esp_init_data_default.bin 0x3FE000 blank.bin
    

    However I get the same problem.
    I modified my code a bit to "work" without the screen (just commenting all the writeTo calls):

    var exports={};
    var C = {
     OLED_WIDTH                 : 128,
     OLED_CHAR                  : 0x40,
     OLED_CHUNK                 : 128
    };
    // commands sent when initialising the display
    var initCmds = new Uint8Array([
                 0xAE,       // 0 Display off (all pixels off)
                 0xA0, 0x53, // 1 Segment remap (com split, com remap, nibble remap, column remap)
                 0xA1, 0x00, // 3 Display start line
                 0xA2, 0x00, // 5 Display offset
                 0xA4,       // 7 Regular display
                 0xA8, 0x7F, // 8 Set multiplex ratio: 127
                 0xB3, 0x00, // 10 Front clock divider: 0, Fosc: 0
                 0xAB, 0x01, // 12 Enable internal Vdd
                 0xB1, 0xF1, // 14 Set phase periods - 1: 1 clk, 2: 15 clks
                 0xBC, 0x08, // 16 Pre-charge voltage: Vcomh
                 0xBE, 0x07, // 18 COM deselect voltage level: 0.86 x Vcc
                 0xD5, 0x62, // 20 Enable 2nd pre-charge
                 0xB6, 0x0F, // 22 2nd Pre-charge period: 15 clks
                 0xA4, // 24 normal display
                 0xAF, // 25 display on 
                ]);
    
    // commands sent when sending data to the display
    var flipCmds = [
         0x15,// columns
         0, C.OLED_WIDTH - 1,
         0x75, // rows
         0, 127
    ];
    
    function update(options) {
      //TODO
    }
    
    exports.connect = function(i2c, callback, options) {
      update(options);
      var oled = Graphics.createArrayBuffer(C.OLED_WIDTH,­128,4);
    
      var addr = 0x3C;
      if(options) {
        if (options.address) addr = options.address;  
        // reset display if 'rst' is part of options 
        if (options.rst) digitalPulse(options.rst, 0, 10); 
      }
      
      setTimeout(function() {
        // configure the OLED
        //initCmds.forEach(function(d) {i2c.writeTo(addr, [0,d]);});
      }, 50);
    
      // write to the screen
      oled.flip = function() { 
        // set how the data is to be sent (whole screen)
        //i2c.writeTo(addr, [0].concat(flipCmds));
        setTimeout(function() {
          flipCmds.forEach(function(d) {/*i2c.writeTo(addr, [0,d]);*/});
        }, 50);
        
        setTimeout(function() {
          var chunk = new Uint8Array(C.OLED_CHUNK+1);
          chunk[0] = C.OLED_CHAR;
    
          for (var p=0; p<this.buffer.length; p+=C.OLED_CHUNK) {
            chunk.set(new Uint8Array(this.buffer,p,128), 1);
            //i2c.writeTo(addr, chunk);
          } 
          //print("flip runs");
        }.bind(this), 100); //wait for flipcmds to run
      };
        
      // set contrast, 0..255
      oled.setContrast = function(c) { /*i2c.writeTo(addr, 0, 0x81, c);*/ };
    
      // set off
      oled.off = function() { /*i2c.writeTo(addr, 0, 0xAE);*/ };
    
      // set on
      oled.on = function() { /*i2c.writeTo(addr, 0, 0xAF);*/ };
    
      // if there is a callback, call it now(ish)
      if (callback !== undefined) setTimeout(callback, 100); //TODO test
      
      // return graphics
      return oled;
    };
    
    
    function start(){
      print("this runs");
      g.clear();
      g.setContrast(128);
      g.setColor(1);
      g.drawString("Hello world 123!",32,32);
      g.drawRect(0,0, 127, 127);
      g.flip(); 
    }
    
    I2C1.setup({scl:D5,sda:D4,bitrate:400000­});
    var g = exports.connect(I2C1, start); 
    

    Flashing this returns "this runs", but if I then run start() manually from the left side, it returns the following:

    >start();
    this runs
    =undefined
    >F 15
    F 15
    F 15
    F 17
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    F 0
    
About

Avatar for StefanB @StefanB started