You are reading a single comment by @Kalus and its replies. Click here to read the full conversation.
  • @JumJum yes, for sure (sorry i had been at the hospital for some days). It's runcode but it could be easily converted to a Driver like the SSD1351 :

    SPI1.setup({ mosi:A7, sck:A5, baud:2000000 });
    
    function connect (/*=SPI*/spi, /*=PIN*/dc, /*=PIN*/cs, /*=PIN*/rst, callback) {
      cs.write(1); // disable
      dc.write(0); // command
      rst.write(0); // reset
      var cd = function (c,d) {
        dc.write(0); // command
        spi.send(c);
        if (d!==undefined) {
          dc.write(1); // data
          spi.send(d);
        }
      };
      setTimeout(function() { // 20ms delay
        rst.write(1); // un-reset
        setTimeout(function() { // 120ms delay
          cs.write(0); // enable
    
          // cd(0x01); // ST7735: Software reset
          // wait 120ms
          
          // cd(0x00); // ST7735: No Operation
          
          // cd(0x10); // ST7735: SLPIN Sleep in & booster off
          cd(0x11); // ST7735: SLPOUT Sleep out & booster on
          // cd(0x12); // ST7735: PTLON Partial mode on
          // cd(0x13); // ST7735: NORON Partial off (Normal)
          
          // cd(0x38); // ST7735: IDMOFF Idle mode off
          // cd(0x39); // ST7735: IDMON Idle mode on
          
          // cd(0x20); // ST7735: INVOFF Display inversion off
          // cd(0x21); // ST7735: INVON Display inversion on
          cd(0x26,8);  // ST7735: GAMSET Gamma curve select
          // cd(0x28); // ST7735: DISPOFF Display off
                
          // cd(0x30,[psl15_8, psl7_0, pel15_8, pel7_0]); // ST7735: PTLAR Partial start/End address set
          // cd(0x34); // ST7735: TEOFF tearing effect line off
          // cd(0x35, telom); // ST7735: TEON Tearing effect mode set & on
          
          // ST7735: MADCTL Memory data access control (rotation, mirror, rgb/bgr, refresh order)
          cd(0x36, 0xC0); // horizontal128, vertical160, connector at bottom, no mirror
          // cd(0x36, 0x00); // horizontal128, vertical160, connector at top, no mirror
          
          // ST7735: COLMOD Interface pixel format 
          cd(0x3a, 5); // 5 =  16bit/pixel
          
          // ST7735: Panel function Command List
          // cd(0xB1,[rtna3_0, fpa5_0, bpa5_0]); // ST7735: FRMCTR1 In normal mode (Full colors)
          // cd(0xB2,[rtnb3_0, fpb5_0, bpb5_0]); // ST7735: FRMCTR2 In Idle mode (8-colors)
          // cd(0xB3,[rtnc3_0, fpc5_0, bpc5_0, rtnd3_0, fpd5_0, bpd5_0]); // ST7735: FRMCTR3 In partial mode + Full colors
          // cd(0xB4, nla_c); // ST7735: INVCTR Display inversion control
          // cd(0xB6, [no1_0_sdt1_0_eq1_0, ptg1_0_pt1_0]); // ST7735: DISSET5 Display function setting
                
          cd(0x29); // ST7735: DISPON Display on
    
          cs.write(1); // disable
          if (callback!==undefined) callback();
        }, 120);
      }, 20);
    
      return Graphics.createCallback(128,160,16,{ setPixel : function(x,y,col) {
        cs.write(0); 
        dc.write(0);spi.send(0x2a);     // ST7735: CASET Column address set
        dc.write(1);spi.send([0,x,0,127]);
        dc.write(0);spi.send(0x2b);     // ST7735: RASET Row address set
        dc.write(1);spi.send([0,y,0,159]);
        dc.write(0);spi.send(0x2c);     // ST7735: RAMWR Memory write
        dc.write(1);spi.send([col>>8,col]);
        cs.write(1);
      }, fillRect : function(x1,y1,x2,y2,col) {
        cs.write(0); 
        dc.write(0);spi.send(0x2a);     // ST7735: CASET Column address set
        dc.write(1);spi.send([0,x1,0,x2]);
        dc.write(0);spi.send(0x2b);     // ST7735: RASET Row address set
        dc.write(1);spi.send([0,y1,0,y2]);
        dc.write(0);spi.send(0x2c);     // ST7735: RAMWR Memory write
        dc.write(1);
        var p = [col>>8,col, col>>8,col, col>>8,col, col>>8,col,
                 col>>8,col, col>>8,col, col>>8,col, col>>8,col];
        var i=(1+x2-x1)*(1+y2-y1)+8;
        while ((i-=8)>8) spi.send(p);
        p = [col>>8,col];
        while (i-->0) spi.send(p);
        cs.write(1);
      }});
    }
    
    var g = connect(SPI1, A3, B10, B11, function() {
      g.clear();
      g.drawString("Hello",0,0);
      g.setFontVector(20);
      g.setColor(0,0.5,1);
      g.drawString("Espruino",0,10);
    });
    
About

Avatar for Kalus @Kalus started