Skip to content

Instantly share code, notes, and snippets.

@hinzundcode
Created October 3, 2018 18:43
Show Gist options
  • Save hinzundcode/1c094a630af627b8a8171eeb731aa973 to your computer and use it in GitHub Desktop.
Save hinzundcode/1c094a630af627b8a8171eeb731aa973 to your computer and use it in GitHub Desktop.
puck js clock
function update() {
var now = new Date();
var minutes = now.getMinutes();
if (minutes < 10)
minutes = "0"+minutes;
var seconds = now.getSeconds();
if (seconds < 10)
seconds = "0"+seconds;
var time = now.getHours()+":"+minutes+":"+seconds;
g.clear();
g.drawString(time, 0, 0);
g.flip();
}
I2C1.setup({ scl: D1, sda: D2 });
var g = require("SSD1306").connect(I2C1, function () {
g.setFontVector(20);
update();
setInterval(update, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment