<!--
-
-
- 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 %}Hello World with the RGB LCD{% endblock %}</b></h1>
</div>

<h2>Description</h2>
<div class="well">
  <p>This is an example of how to display text on the Grove RGB LCD module and change the color of the backlight. 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>Connect the Grove RGB LCD to either of the I2C0 Grove connectors</li>
  </ul>
  <img class="img-responsive center-block" src="{{url_for('static', filename='images/96boards_images/Example_RGB_LCD.png')}}" onclick="showImageModal(this)"/>
  <br>
    <form id="run_project_form" action="hello_world.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" name="filename" value="rgb_lcd_demo/rgb_lcd_demo.cpp" class="btn btn-primary">rgb_lcd_demo.cpp</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 %}
