From 06b1851216e42923b0df70bb498df8cf106965cc Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Fri, 24 Feb 2017 18:56:53 +0100 Subject: Completed code project --- code/005-event.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 code/005-event.js (limited to 'code/005-event.js') diff --git a/code/005-event.js b/code/005-event.js new file mode 100644 index 0000000..94d6d77 --- /dev/null +++ b/code/005-event.js @@ -0,0 +1,20 @@ +function draw_screen(data) { + console.log("Drawing the screen with data"); + console.log(data); + g.drawString("Espruino demo", 2, 2); + if (data) { + g.drawString("Temp: "+data.temp.toString(),2,10); + g.drawString(" RH: "+data.rh.toString(),2,18); + } + g.flip(); +} + +function start() { + dht = require("DHT22").connect(C11); + I2C1.setup({scl:B6,sda:B7}); + g = require("SH1106").connect(I2C1, draw_screen); +} + +E.on('init', start); + +start(); \ No newline at end of file -- cgit v1.2.3