Last active
August 29, 2015 14:07
-
-
Save maggocnx/3209898123c0d9acfc06 to your computer and use it in GitHub Desktop.
Customer Lcd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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