You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • I think your problem is partially that you're re-initialising the display each time. setFontVector definitely works - I was using it just today, and just tested again.

    Try:

      var g = require("SSD1306").connect(I2C1);
        if (!g) {
        console.log("g failed to init");
        return null;
      }
    
    
    function showTemp()
    {
      g.clear();
      g.setColor(255,255,255);
      g.setFontVector(20);
      g.drawString("Temperature: ",0,0);
      g.drawString(text,0,20);
      g.flip(); 
    }
    

    There is however some regression issue when re-initialising the graphics multiple times, that I did notice recently and try to fix this morning (I fixed one problem, but haven't quite solved it yet).

  • Okay, it does work thanks for your help Gordon, it was indeed because i was initialising each time. The code that eventually worked properly was

    I2C1.setup({scl:B6,sda:B7});
    var g = require("SSD1306").connect(I2C1);
    var bmp = require("BMP085").connect(I2C1);
    //... more code here
    setInterval(function(){
    bmp.getPressure(function(d) {
        //console.log("Pressure: " + d.pressure + " Pa");
        console.log("Temperature: " + d.temperature + " C");
        g.clear();
      g.setFontVector(20);
       g.drawString("Temp: ",0,0);
      g.drawString(" "+ d.temperature + " C",0,25);
       // write to the screen
       g.flip(); 
      });
    },1000);
    
About

Avatar for Gordon @Gordon started