Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 |
[Project]
Web-based Internet Signboard
[Items]
- PHPoC Black
- RS232 Board
- LED Signboard
[How it works]
- Codes work with web interface
- Once you click the [Send] button on the webpage, it sends the text with optional effects to the signboard
[Video clip]
<?php
include_once "/lib/sd_340.php";
include_once "func.php";
header("Content-Type: text/html; charset=euc-kr");
$str_send = "";
$read_data = 0;
$str_send = _POST("str_send");
$repetition = (int)_POST("repetition");
$animation = (int)_POST("animation");
$color = (int)_POST("color");
$position = (int)_POST("position");
//$repeat = strlen(_POST("repeat"));
$repeat = _POST("repeat");
uart_setup(0, 115200, "N81N");
uart_write(0, "[TMODE]\r");
if($repeat == "init")
{
uart_write(0, "[COMON][FINE][COMOFF]");
usleep(100000);
uart_write(0, "[COMON][PX0 PY0][ACT0][COMOFF]");
}
else
{
if(strlen($str_send))
{
uart_write(0, "[COMON]");
if($repetition != 0)
uart_write(0, f_repetition($repetition));
uart_write(0, f_position($position));
uart_write(0, f_color($color));
uart_write(0, $str_send);
uart_write(0, f_animation($animation));
uart_write(0, "[COMOFF]");
$str_send = "";
}
else
uart_write(0, "[COMON][PX0 PY0][ACT0][COMOFF]");
}
?>
<!DOCTYPE html>
<html>
<head>
<!-- Include meta tag to ensure proper rendering and touch zooming -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Include jQuery Mobile stylesheets -->
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<!-- Include the jQuery library -->
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<!-- Include the jQuery Mobile library -->
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript">
function init() {
if(confirm("Do you want to initialize signboard?") ){
document.form.repeat.value = "init";
document.form.submit();
}
}
function refresh() {
window.location.href = "index_m.php";
}
function send_message() {
if(confirm("Do you want to send message?") ){
document.form.submit();
}
}
</script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Internet Signboard</h1>
</div>
<div data-role="main" class="ui-content">
<p style="color:red;">Notice: Please check the [Initialize] button before you test this Signboard.</p>
<div class="ui-grid-b">
<div class="ui-block-c"><input type="button" value="Initialize" onclick="init();"></div>
<div class="ui-block-c"><input type="button" value="Refresh" onclick="refresh();"></div>
<div class="ui-block-c"><input type="button" value="Send" onclick="send_message();"></div>
</div>
<form name="form" method="post" action="index_m.php">
<fieldset class="ui-field-contain">
<label for="message">Message</label>
<textarea name="str_send" id="str_send"></textarea>
</fieldset>
<fieldset class="ui-field-contain">
<label for="position">Position</label>
<select name="position" id="position">
<option value="0">Top</option>
<option value="1" selected>Middle</option>
<option value="2">Bottom</option>
</select>
</fieldset>
<fieldset class="ui-field-contain">
<label for="repetition">Repetition</label>
<select name="repetition" id="repetition">
<option value="0" selected>None</option>
<option value="1">1</option>
<option value="2">10</option>
<option value="3">Infinite</option>
</select>
</fieldset>
<fieldset class="ui-field-contain">
<label for="color">Color</label>
<select name="color" id="color">
<option value="0" selected>Orange</option>
<option value="1">Red</option>
<option value="2">Green</option>
</select>
</fieldset>
<fieldset class="ui-field-contain">
<label for="animation">Animation</label>
<select name="animation" id="animation">
<option value="0" selected>None</option>
<option value="1">Flow Left</option>
<option value="2">Flow Right</option>
<option value="3">Flow Up</option>
<option value="4">Flow Down</option>
<option value="5">Random</option>
</select>
</fieldset>
<input type="hidden" name="repeat" id="repeat" value=""/>
</form>
</div>
<div data-role="footer" data-position="fixed">
<h1>Sollae Systems Co., Ltd.</h1>
</div>
</div>
</body>
</html>
<?php
function f_position($val)
{
$ret = "";
switch($val)
{
case 0:
$ret .= "[PX0 PY0]";
break;
case 1:
$ret .= "[PX0 PY7]";
break;
case 2:
$ret .= "[PX0 PY16]";
break;
default:
$ret .= "[PX0 PY0]";
break;
}
return $ret;
}
function f_repetition($val)
{
$ret = "";
switch($val)
{
case 1:
$ret .= "[REPEAT3]";
break;
case 2:
$ret .= "[REPEAT10]";
break;
case 3:
$ret .= "[REPEAT255]";
break;
}
return $ret;
}
function f_color($val)
{
$ret = "";
switch($val)
{
case 0:
$ret .= "[CR3]";
break;
case 1:
$ret .= "[CR1]";
break;
case 2:
$ret .= "[CR2]";
break;
default:
$ret .= "[CR3]";
break;
}
return $ret;
}
function f_animation($val)
{
$ret = "";
switch($val)
{
case 0:
$ret .= "[ACT0]";
break;
case 1:
$ret .= "[ACT1]";
break;
case 2:
$ret .= "[ACT2]";
break;
case 3:
$ret .= "[ACT3]";
break;
case 4:
$ret .= "[ACT4]";
break;
case 5:
$ret .= "[ACT8]";
break;
case 6:
$ret .= "[ACT22]";
break;
case 7:
$ret .= "[ACT";
$temp = rand(1, 5) * 100;
$temp += rand(1, 20);
$ret .= (string)$temp;
$ret .= "]";
break;
default:
$ret .= "[ACT0]";
break;
}
return $ret;
}
Comments