Gyusik Song
Published © GPL3+

Web-Based Internet Signboard

Build a web-based Internet Signboard with PHPoC.

BeginnerFull instructions provided3 hours997
Web-Based Internet Signboard

Things used in this project

Hardware components

PHPoC Black
PHPoC Black
×1
PHPoC RS232 Expansion Board
PHPoC RS232 Expansion Board
×1
LED Signboard
×1

Story

Read more

Code

index.php

PHP
<?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>

func.php

PHP
<?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;
}

task0.php

PHP
<?php

include "/lib/sd_340.php";

uart_setup(0, 115200, "N81N");

uart_write(0, "[TMODE]\r[COMON][PX0 PY0]Waiting Messages..[ACT0][COMOFF]");

for(;;)
	;

?>

Credits

Gyusik Song

Gyusik Song

5 projects • 9 followers

Comments