Skip to content

Instantly share code, notes, and snippets.

@korczis
Created March 1, 2014 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korczis/9295189 to your computer and use it in GitHub Desktop.
Save korczis/9295189 to your computer and use it in GitHub Desktop.
Strange error
var g = null;
var msg = "";
var scaleValue = function(v, vMax) {
return v * vMax;
};
var tick = function() {
console.log("tick()");
g.clear();
var light = analogRead(A1);
var val = scaleValue(1 - light, 40);
// Block 1 - mutually exclusive with Block 2
msg = "Raw: " + light.toFixed(4);
console.log(msg);
g.drawString(msg, 0, 10);
// Block 2 - mutually exclusive with Block 1
msg = "Light: " + val.toFixed(4);
console.log(msg);
g.drawString(msg, 0, 20);
g.flip();
};
var init = function() {
console.log("init()");
SPI1.setup({ baud: 1000000, sck:B3, mosi:B5 });
g = require("PCD8544").connect(SPI1,B6,B7,B8);
setInterval(function() { tick(); }, 500);
};
init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment