You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kevin Cheung edited this page Jun 29, 2020
·
2 revisions
Starting with version 2.x, you can use node-canvas to write to framebuffer devices, such as the Adafruit PiTFT:
const{createCanvas}=require("canvas");constcanvas=createCanvas(480,320);// Draw to your canvas:constctx=canvas.getContext("2d",{pixelFormat: "RGB16_565"});// important: RGB16_565ctx.font="30px impact";ctx.fillStyle="red";ctx.fillText("Hello!",50,100);// Write to the framebuffer device:constfs=require("fs");constfb=fs.openSync("/dev/fb1","w");// where /dev/fb1 is the path to your fb deviceconstbuff=canvas.toBuffer("raw");console.log(buff.byteLength);// should be equal to width*height*2fs.writeSync(fb,buff,0,buff.byteLength,0);