Skip to content

Instantly share code, notes, and snippets.

@Antoinebr
Created March 10, 2018 19:53
Show Gist options
  • Save Antoinebr/bb8ec8fb557d73ff0548317a3c2fad84 to your computer and use it in GitHub Desktop.
Save Antoinebr/bb8ec8fb557d73ff0548317a3c2fad84 to your computer and use it in GitHub Desktop.
var SPI2 = new SPI();
SPI2.setup({mosi: NodeMCU.D7 , sck: NodeMCU.D8 });
var disp = require("MAX7219").connect(SPI2, NodeMCU.D5, 4 /* 4 chained devices */);
disp.intensity(0);
var g = Graphics.createArrayBuffer(32, 8, 1);
require("Font6x8").add(Graphics);
g.setFont6x8();
g.flip = function() { disp.raw(g.buffer); }; // To send to the display
g.drawString("Hello");
g.flip(); // update what's on the display
function clearAll(){
g.clear();
g.flip();
}
function write(string){
g.clear();
g.drawString(string , (g.getWidth()-g.stringWidth( string )) / 2 );
g.flip();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment