Avatar for StefanB

StefanB

Member since Dec 2023 • Last active Dec 2023
  • 1 conversations
  • 6 comments

Most recent activity

    • 13 comments
    • 1,119 views
  • in Interfacing
    Avatar for StefanB

    I just created a pull request to add this module :)

  • in Interfacing
    Avatar for StefanB

    Thanks for looking into it, that indeed solved it! :D

  • in Interfacing
    Avatar for StefanB

    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
    
  • in Interfacing
    Avatar for StefanB

    Thanks for your replies. I tried the above but the only readable I got back was something about cal sector 1019 and freq trace enable 0.

    Below code seems to work pretty consistant without resets. Start gets called and I can send additional graphics commands to the screen via the left side of the IDE and they work :

    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); 
    

    However if I modify just a bit on this code things get weird. Trying to minify this code gives errors. For example, just commenting the print on line 70 breaks it. When I upload that it returns:

    this runs
    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
    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
    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
    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 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    F 17
    >F 17
    F 0
    Uncaught SyntaxError: Got '@' expected EOF
     at line 68 col 12
            i2c@(addr, chunk);
               ^
    in function called from system
    

    So, it's really confusing to me what's going on exactly...

  • in Interfacing
    Avatar for StefanB

    Thanks for the quick reply!
    That actually seemed to be thé problem! I still had to adjust line 37 to 0, 127 to fix the height
    of the display which also fixed the screen turning off.

    I'm only now getting sometimes issues with my board kinda randomly resetting or giving seemingly random errors when trying to upload the code. Perhaps I've already used up all the RAM or something?

    Hi! When you get this working it'd be great to turn it into a module for Espruino!

    Yes, I plan to (at least with i2c support) once I'm sure it's working fine.

  • in Interfacing
    Avatar for StefanB

    Hey everyone!

    For a project I'm working on I decided I'd like to use Espruino so I flashed it on an ESP8266.
    I have a GME128128-02 1.5" OLED display that is powered by a SSD1327 that I'd like to use. For my purposes I don't need any grayscale usage, only monochrome and only I2C is relevant for this specific screen.

    There doesn't seem to be a module for this specific screen model, and none of the ones I tried worked so I decided to try and modify the SSD1306 module. I've already looked at some Arduino/C libraries for the SSD1327 driver and had a peek at the datasheet but after some evenings experimenting I have to admit I'm quite stuck. When I flash the current code I have, I get a bunch of vertical lines for a few seconds, before the screen seemingly turns off.

    I feel like I'm probably not too far off but perhaps anyone here can immediately spot my mistakes and help me out. Thank you in advance!

    My code:

    var exports={};
    
    var C = {
     OLED_WIDTH                 : 128,
     OLED_CHAR                  : 0x40,//0x20,//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
                 // greyscale table?
                 //0xB8, 0x01, 0x11, // 10 Set greyscale table
                 //0x22, 0x32, 0x43, // .. cont
                 //0x54, 0x65, 0x76, // .. cont
                 0xB3, 0x00, // 19 Front clock divider: 0, Fosc: 0
                 0xAB, 0x01, // 21 Enable internal Vdd
                 0xB1, 0xF1, // 23 Set phase periods - 1: 1 clk, 2: 15 clks
                 0xBC, 0x08, // 25 Pre-charge voltage: Vcomh
                 0xBE, 0x07, // 27 COM deselect voltage level: 0.86 x Vcc
                 0xD5, 0x62, // 29 Enable 2nd pre-charge
                 0xB6, 0x0F, // 31 2nd Pre-charge period: 15 clks
                 0xA4, // 33 normal display
                 0xAF, // 34 display on 
                ]);
    
    // commands sent when sending data to the display
    var flipCmds = [
         0x15,//0x21, // columns
         0, 127, // 
         0x75,//0x22, // rows
         0, 31//127//15 /* (height>>3)-1 */
    ];
    
    function update(options) {
    }
    
    exports.connect = function(i2c, callback, options) {
      update(options);
      var oled = Graphics.createArrayBuffer(128,128,4,{ve­rtical_byte : false});
    
      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);
    
      // if there is a callback, call it now(ish)
      if (callback !== undefined) setTimeout(callback, 100);
    
      // write to the screen
      oled.flip = function() { 
        // set how the data is to be sent (whole screen)
        flipCmds.forEach(function(d) {i2c.writeTo(addr, [0,d]);});
        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,C.OLED_CHUNK), 1);
          i2c.writeTo(addr, chunk);
        } 
      };
        
      // 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); };
    
      // return graphics
      return oled;
    };
    
    
    function start(){
      print("this runs");
      g.on();
      g.clear();
      g.setContrast(128);
      g.setColor(1);
      // write some text
      //g.setFontVector(20);
      //g.drawString("Hello world!",0,0);
      g.drawString("Hello world!",32,32);
      g.fillRect(0, 0, 4, 4);
      // write to the screen
      g.flip(); 
    }
    
    // I2C
    I2C1.setup({scl:D5,sda:D4,bitrate:100000­});
    var g = exports.connect(I2C1, start);
    
Actions