You are reading a single comment by @Aifer and its replies. Click here to read the full conversation.
  • In SSD1306.js, connectSPI() has some codes not work well on ESP32, such as digitalPulse(rst,0,10), cs.reset() and cs.set() .

    Just rewrite some lines:

    cs.reset() --> digitalWrite(cs,0)
    cs.set() --> digitalWrite(cs,1)
    digitalPulse(rst,0,10) --> for(var i = 0; i<10; i++){ digitalWrite(rst,0); digitalWrite(rst,1); }
    :-)

    The OLED module works well.

    But, the initial action of SPI and Graphics module must be in the onInit() function. why?
    And the RST pin must be connected! The cs option must be defined too.

    var g;
    
    function start(){
        // write some text
        g.drawString("Hello Espruino!", 2, 2);
        // write to the screen
        g.flip();
    }
    
    function onInit(){
      SPI2.setup({sck:18, mosi:23});
      g = require("mySSD1306").connectSPI(SPI2, 16 /*DC*/, 12 /*RST*/, start, {cs:17});
    }
    
    save();
    
About

Avatar for Aifer @Aifer started