You are reading a single comment by @DrAzzy and its replies. Click here to read the full conversation.
  • this is the code

        function i2c1(c){I2C1.writeTo(0x3C, [0,c]);}
            function dispoff(){i2c1(0xae);}
            function dispon(){i2c1(0xaf);}
    
    function OLED(){
    pinMode(A7,'output');
    digitalWrite(A7,1);
    
    I2C1.setup({scl:B6,sda:B7});
    var g = require("SSD1306").connect(I2C1);
    g.clear();
    g.flip();
    
      g.setFontVector(15);
      g.drawString("OLED",25,20);
      g.flip();
    
    }
               
    OLED();
    

    but this only change the position of string displayed on the OLED,
    when I type 'i2c1(dispoff)' or 'i2c1(dispon)'

  • function i2c1(c){I2C1.writeTo(0x3C, [0,c]);}
    function dispoff(){i2c1(0xae);}
    function dispon(){i2c1(0xaf);}
    
    i2c1(dispoff)
    
    

    What do you expect that to do? Probably not what it's doing.

    You create a function called i2c1 which takes an argument, and sends that to the display.

    You also create a function called dispoff which calls that first function with the appropriate argument to turn off the display.

    But when you do i2c1(dispoff) you're telling it to send the function dispoff to the display (I have no idea what Espruino actually sends here, but I guarantee it's not what you want).

    Instead, you want to just call dispoff, eg dispoff();

    (which is pretty much what MaBe has posted)

About

Avatar for DrAzzy @DrAzzy started