diff options
Diffstat (limited to 'code/006-button.js')
-rw-r--r-- | code/006-button.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/code/006-button.js b/code/006-button.js new file mode 100644 index 0000000..4bd0c31 --- /dev/null +++ b/code/006-button.js @@ -0,0 +1,24 @@ +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); + +setWatch(function(e) { + dht.read(draw_screen); +}, BTN, { repeat: true, edge: 'rising' }); + +start();
\ No newline at end of file |