aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--code/004-display.js12
-rw-r--r--code/005-event.js20
-rw-r--r--code/006-button.js24
-rw-r--r--code/007-contrast.js28
-rw-r--r--code/008-logging.js42
-rw-r--r--slides/img/contast_with_button.pngbin0 -> 64189 bytes
-rw-r--r--slides/img/display.pngbin38825 -> 30060 bytes
-rw-r--r--slides/img/display_interrupt.pngbin0 -> 61462 bytes
-rw-r--r--slides/img/logging_data.pngbin0 -> 67675 bytes
-rw-r--r--slides/img/set_date.pngbin0 -> 64427 bytes
-rw-r--r--slides/img/temp_with_button.pngbin0 -> 54824 bytes
-rw-r--r--slides/presentazione_espruino.rst39
12 files changed, 157 insertions, 8 deletions
diff --git a/code/004-display.js b/code/004-display.js
index e7b4cd1..4815e14 100644
--- a/code/004-display.js
+++ b/code/004-display.js
@@ -1,11 +1,7 @@
-var dht = require("DHT22").connect(C11);
+function start() {
+ g.drawString("Hello World!",2,2);
+ g.flip();
+}
I2C1.setup({scl:B6,sda:B7});
var g = require("SH1106").connect(I2C1, start);
-
-dht.read(function (data) {
- console.log("Read DHT22");
- g.drawString("Temp: "+data.temp.toString(),2,2);
- g.drawString(" RH: "+data.rh.toString(),2,10);
- g.flip();
-}); \ No newline at end of file
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
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
diff --git a/code/007-contrast.js b/code/007-contrast.js
new file mode 100644
index 0000000..432eb00
--- /dev/null
+++ b/code/007-contrast.js
@@ -0,0 +1,28 @@
+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) {
+ g.setContrast(255);
+ dht.read(draw_screen);
+ setTimeout(function () {
+ g.setContrast(1);
+ }, 4000);
+}, BTN, { repeat: true, edge: 'rising' });
+
+start(); \ No newline at end of file
diff --git a/code/008-logging.js b/code/008-logging.js
new file mode 100644
index 0000000..d5cb2a3
--- /dev/null
+++ b/code/008-logging.js
@@ -0,0 +1,42 @@
+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);
+ fs = require("fs");
+}
+
+E.on('init', start);
+
+setWatch(function(e) {
+ g.setContrast(255);
+ dht.read(draw_screen);
+ setTimeout(function () {
+ g.setContrast(1);
+ }, 4000);
+}, BTN, { repeat: true, edge: 'rising' });
+
+setTimeout(function() {
+ dht.read(function(data) {
+ entry = "- {time: " +
+ Date.now() +
+ ", temp: " +
+ data.temp.toString() +
+ ", rh: " +
+ data.rh.toString();
+ console.log("saving: " + entry);
+ fs.appendFileSync("temp_rh.yaml", entry);
+ });
+}, 60000);
+
+start(); \ No newline at end of file
diff --git a/slides/img/contast_with_button.png b/slides/img/contast_with_button.png
new file mode 100644
index 0000000..6acb6fd
--- /dev/null
+++ b/slides/img/contast_with_button.png
Binary files differ
diff --git a/slides/img/display.png b/slides/img/display.png
index 8627e0c..75e94db 100644
--- a/slides/img/display.png
+++ b/slides/img/display.png
Binary files differ
diff --git a/slides/img/display_interrupt.png b/slides/img/display_interrupt.png
new file mode 100644
index 0000000..d9ac429
--- /dev/null
+++ b/slides/img/display_interrupt.png
Binary files differ
diff --git a/slides/img/logging_data.png b/slides/img/logging_data.png
new file mode 100644
index 0000000..e703f1a
--- /dev/null
+++ b/slides/img/logging_data.png
Binary files differ
diff --git a/slides/img/set_date.png b/slides/img/set_date.png
new file mode 100644
index 0000000..0c68883
--- /dev/null
+++ b/slides/img/set_date.png
Binary files differ
diff --git a/slides/img/temp_with_button.png b/slides/img/temp_with_button.png
new file mode 100644
index 0000000..0a6b7aa
--- /dev/null
+++ b/slides/img/temp_with_button.png
Binary files differ
diff --git a/slides/presentazione_espruino.rst b/slides/presentazione_espruino.rst
index ca5f429..042c73c 100644
--- a/slides/presentazione_espruino.rst
+++ b/slides/presentazione_espruino.rst
@@ -142,6 +142,45 @@ OLED
.. image:: img/display.png
:align: center
+Saving and loading
+------------------
+
+.. image:: img/display_interrupt.png
+ :align: center
+
+Reading with a button
+---------------------
+
+.. image:: img/temp_with_button.png
+ :align: center
+
+Lowering contrast
+-----------------
+
+.. image:: img/contast_with_button.png
+ :align: center
+
+Setting the date
+----------------
+
+.. image:: img/set_date.png
+ :align: center
+
+Logging data
+------------
+
+.. image:: img/logging_data.png
+ :align: center
+
+
+
+Ulteriore documentazione
+------------------------
+
+* http://www.espruino.com/Reference
+* http://www.espruino.com/Modules
+* Queste slide: http://git.trueelena.org/cgit.cgi/docs/presentazione_espruino/
+
Domande?
--------