From 5e57076f57a260b2abc1c7bd51dfdc850b568afa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20Nordstr=C3=B8m=20Rasmussen?=
 <au471373@uni.au.dk>
Date: Sun, 15 Sep 2019 14:44:54 +0200
Subject: [PATCH] first commit

---
 README.md         | 20 ++++++++++++++++++++
 public/index.html | 30 ++++++++++++++++++++++++++++--
 src/app.js        |  1 -
 src/pressure.js   | 18 ++++++++++++++++++
 4 files changed, 66 insertions(+), 3 deletions(-)
 create mode 100644 src/pressure.js

diff --git a/README.md b/README.md
index 5c3b30d..d52d046 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,23 @@
+Milestone 1: 
+Building the docker image: 
+docker build --tag=humid .
+
+Run build:
+docker run -p 8080:8080 --privileged humid
+
+Be aware: 
+We instantiate a socket in the public/readings.js file. 
+In order for the socket to work, you give the ip as parameter to the io.connect method. 
+You get the IP by using:
+hostname -I
+Then you are able to access the data through the browser on localhost:8080
+
+Also be aware: 
+The buttons do nothing yet Ż\_(?)_/Ż
+
+____________________________________________________________________________________________
+
+
 # IOT node.js project starting template
 
 This repository includes a simple template for a node.js/express application,
diff --git a/public/index.html b/public/index.html
index 64972aa..64739d4 100644
--- a/public/index.html
+++ b/public/index.html
@@ -3,15 +3,41 @@
   <head>
   <meta charset="utf-8">
   <title>Websockets 101</title>
-  <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>	
+  <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>
+  <style>
+    body {
+      background-color: #F0F3F5; 
+      padding: 20px 20px;
+    }
+
+    .btn {
+      padding: 8px 12px;
+      color: white; 
+      font-size: 16px;
+      font-weight: bold;
+      background-color: #f44336;
+      display: block; 
+      margin: 10px 10px;
+      border: none;
+    }
+     #btn-red {
+      background-color: #f44336;
+     }
+	
+     #btn-green {
+      background-color: #4caf50;
+     }
+  </style>	
   </head>
-  <body style="background-color: #F0F3F5; padding: 20px 20px">
+  <body>
   <div>
   <h1>RASPBERRY PI VALUES</h1>
     <div id="output">
 
     </div>
   </div>
+  <button id="btn-red" class="btn" type="button">Red light</button>
+  <button id="btn-green" class="btn" type="button">Green light</button>
 
   <script src="readings.js"></script>
   </body>
diff --git a/src/app.js b/src/app.js
index 32033ea..3b7a05f 100644
--- a/src/app.js
+++ b/src/app.js
@@ -63,7 +63,6 @@ io.on('connect', function(io){
   });
 
   io.on('update', function(data){
-    console.log("called");
     io.emit('update', {
       temp: temp,
       humidity: humidity, 
diff --git a/src/pressure.js b/src/pressure.js
new file mode 100644
index 0000000..edee532
--- /dev/null
+++ b/src/pressure.js
@@ -0,0 +1,18 @@
+import RPi.GPIO as GPIO
+import time
+
+GPIO.setmode(GPIO.BCM)
+GPIO.setup(4, GPIO.IN)
+
+prev_input = 0
+try:
+    while True:
+        input = GPIO.input(4)
+        if((not prev_input) and input):
+            print("under pressure")
+        prev_input = input
+        time.sleep(0.10)
+except KeyboardInterrupt:
+    pass
+finally:
+    GPIO.cleanup()
\ No newline at end of file
-- 
GitLab