<!--
-
-
- Copyright (C) 2019 Xilinx, Inc.  All rights reserved.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of
- this software and associated documentation files (the "Software"), to deal in
- the Software without restriction, including without limitation the rights to
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- of the Software, and to permit persons to whom the Software is furnished to do
- so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
-
- Author: Michael Chyziak <chyziak@xilinx.com>
-
-->


{% extends "Default/default.html" %}
{% block content %}

<div class="page-header">
  <h1 class="display-4"><b>{% block title %}Temperature and Humidity Display{% endblock %}</b></h1>
</div>

<h2>Description</h2>
<div class="well">
  <p>Build a temperature and humidity display. We will read the data stream from the Digital Humidity and Temperature (DHT) sensor and it passes the raw data to linux via the serial port. The program display the temperature and humidity readings on the LCD display. For more information on the Grove Sensor Kit please visit <a href="grove_starter_kit.html">Grover Starter Kit</a>.</p>
</div>

<h2>Hardware Setup</h2>
<div class="well">
  <ul class="features" style="list-style-position:inside">  
    <li>Attach the RGB LCD to I2C0</li>
    <li>Attach the temperature and humidity sensor to A0</li>
  </ul>
  <img class="img-responsive center-block" src="{{url_for('static', filename='images/96boards_images/Example_Temperature_Humidity_LCD.png')}}" onclick="showImageModal(this)"/>
  <br>
  <form id="run_project_form" action="temp_display.html" method="post">
    <center><button type="submit" id="start" name="submit" value="start" class="btn btn-primary btn-lg" onclick="onRunProject()">Run Project</button>
     Timeout: <select id="timeout" name="timeout">
                    <option value="5">5</option>
                    <option value="10">10</option>
                    <option value="15">15</option>
                    <option value="20">20</option>
                    <option value="25">25</option>
                    <option value="30">30</option>
                    <option value="35">35</option>
                    <option value="40">40</option>
                    <option value="45">45</option>
                    <option value="50">50</option>
                    <option value="55">55</option>
                    <option value="60">60</option>
    </select>
    </center>
    <br>
    <center><button type="submit" id="stop" name="submit" value="stop" class="btn btn-primary btn-lg" onclick="onRunProject()">Stop Project</button>
    </center>	  
  </form>
</div>

<h2>Source Code</h2>
<div class="well">
  <form action="viewer.html" method="get">
    <button type="submit" class="btn btn-primary" name="filename" value="humid_temp/read_dht.ino">read_dht.ino</button>
  </form>
  <br>
  <form action="viewer.html" method="get">
    <button type="submit" class="btn btn-primary" name="filename" value="humid_temp/humid_temp.py">humid_temp.py</button>
  </form>
</div>
<script>
  document.getElementById("timeout").value = "{{timeout}}";
  var timeleft = "{{remaining_time}}";
  var runbutton = document.getElementById("start");
  var timer_status = "{{timer_status}}";
  if (timer_status == "timer_enabled") {
    runbutton.disabled = true;
    var timer = setInterval(function() {
      timeleft--;
      runbutton.textContent = "Project Running " + timeleft + " s";
      if (timeleft <= 0) {
        clearInterval(timer);
	runbutton.disabled = false;
	runbutton.textContent = "Run Project";
	timer_status = "timer_disabled";
      }
    }, 1000);
  }
  function onRunProject(){
    var form = document.getElementById("run_project_form");
    form.submit();
  }
</script>

{% endblock %}
