• I have defined two images in code. One is shown when wifi is connected/associated, the other is shown when wifi disconnects.

    var imgNetworkSignal = {
      width : 8, height : 8, bpp : 1,
      transparent : 0,
      buffer : new Uint8Array([
        0b00000000,
        0b00000011,
        0b00000011,
        0b00011011,
        0b00011011,
        0b00011011,
        0b11011011,
        0b11011011,
      ]).buffer
    };
    
    var imgNoNetworkSignal = {
      width : 8, height : 8, bpp : 1,
      transparent : 0,
      buffer : new Uint8Array([
        0b00000000,
        0b00000000,
        0b00000000,
        0b00000000,
        0b00000000,
        0b00000000,
        0b11111111,
        0b11111111,
      ]).buffer
    };
    

    The wifi connected image is correctly shown as soon as soon as the NodeMCU I am using connects to Wifi. When I disconnect from wifi I expect the other image to show, but I still see the wifi-connected image. I need to specifically use a clear-command to remove everything (there is only a wifi-signal image) before showing the wifi-disconnected image. Strangely enough, it works the other way around. This makes me think that the zero's in the wifi-disconnected icon are not correctly resetting the one's from the wifi-connected icon.

    var wifiDisconnectImage = function() {
      console.log("Disconnect icon should show");
      graph.clear();   // <- required to clear OLED
      graph.drawImage(imgNoNetworkSignal, graph.getWidth()-8, 0);
      graph.flip();
    };
    
    var wifiConnectImage = function() {
      console.log("Connect icon should show");
      // graph.clear(); <--- works without the clear
      graph.drawImage(imgNetworkSignal, graph.getWidth()-8, 0);
      graph.flip();
    };
    
  • I think it's because you've set transparent:0 - so you're telling Espruino that anything that is 0 should be treated as transparent. If you just don't set transparent then you should be ok.

  • Good catch @Gordon, that solved it!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Overwriting image on SSD1306 OLED without clearing display

Posted by Avatar for CrashingDutchman @CrashingDutchman

Actions