Skip to content

Instantly share code, notes, and snippets.

@maggocnx
Last active August 29, 2015 14:07
Show Gist options
  • Save maggocnx/3209898123c0d9acfc06 to your computer and use it in GitHub Desktop.
Save maggocnx/3209898123c0d9acfc06 to your computer and use it in GitHub Desktop.
Customer Lcd
isNodeWebkit = (typeof process !== "undefined") ;
$("body").append('<canvas id="lcdCanvas" width="128" height="64"></canvas>');
var canvas = document.getElementById('lcdCanvas');
this.drawCanvas(canvas, function(){
if(isNodeWebkit){
fs = require("fs");
var exec = require("child_process").exec;
var __dirname = process.cwd();
var imgData = canvas.toDataURL().replace(/^data:image\/\w+;base64,/, "");
var buf = new Buffer(imgData, 'base64');
var imgPath =__dirname + "/lcd.png";
fs.writeFile(imgPath , buf, function(err){
exec("convert lcd.png -flip -flatten -negate -monochrome -colors 2 bmp:- | tail -c+35 > /dev/backlcd", function(){
});
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment