Re: ESP8266 als Brücke ins wlan mit AT gedöns
Verfasst: Di 20. Nov 2018, 21:05
Es tut sich was im Getriebe.
Retro Style Eigenbau Computer mit Parallax Propeller
https://hive-project.de/board/
Code: Alles auswählen
PUB Init( pRow, pCol, pTextPtr, pVgaPtr, pVgaWidth ) | strIdx
varVgaCols := pVgaWidth
varRow := pRow
varCol := pCol
varScreenPtr := pVgaPtr
varStatus := 0
varWidth := strsize( pTextPtr ) + 2
varCol2 := varCol + varWidth - 1
varTextN[0] := 32
bytemove( @varTextN[1], pTextPtr, varWidth - 2 ) 'copy menu item text string
varTextN[varWidth - 1] := 32
varTextN[varWidth] := 0
strIdx := 0
repeat varWidth
varTextI[strIdx] := varTextN[strIdx]+128 'invert the string
strIdx++
varTextI[strIdx] := 0
varVgaPos := varRow * varVgaCols + varCol 'now draw the menu item
bytemove( @byte[varScreenPtr][varVgaPos], @varTextI, varWidth )
Code: Alles auswählen
VAR
word varGdx 'GUI control variable
long varScreenPtr 'screen buffer pointer
long varVgaPos 'starting position of the menu item
byte varTextN[16] 'normal text, 15 chars MAX, with room for terminating Null and bracketing spaces
byte varTextI[16] 'inverted text, 15 chars MAX, with room for terminating Null and bracketing spaces
byte varRow 'top row location
byte varCol 'left col location
byte varCol2 'right col location
byte varWidth 'width of text
byte varStatus '0=normal else user defined value
byte varVgaCols 'width of screen in columns
PUB Init( pRow, pCol, pTextPtr, pVgaPtr, pVgaWidth ) | strIdx
varVgaCols := pVgaWidth
varRow := pRow
varCol := pCol
varScreenPtr := pVgaPtr
varStatus := 0
varWidth := strsize( pTextPtr )
varCol2 := varCol + varWidth
varTextN[0] := 32
bytemove( @varTextN[0], pTextPtr, varWidth ) 'copy menu item text string
varTextN[varWidth] := 0
strIdx := 0
repeat varWidth
varTextI[strIdx] := varTextN[strIdx]+128 'invert the string
strIdx++
varTextI[strIdx] := 0
varVgaPos := varRow * varVgaCols + varCol 'now draw the menu item
bytemove( @byte[varScreenPtr][varVgaPos], @varTextI, varWidth )
Code: Alles auswählen
PUB SetText( pPtr ) | strIdx
bytefill( @varTextN[1], 32, varWidth - 2 ) 'clear it first
bytemove( @varTextN[1], pPtr, strsize(pPtr) ) 'copy menu item text string
strIdx := 0
repeat varWidth
varTextI[strIdx] := varTextN[strIdx]+128 'invert the string
strIdx++
bytemove( @byte[varScreenPtr][varVgaPos], varTextI, varWidth )
Code: Alles auswählen
PUB SetText( pPtr ) | strIdx
bytefill( @varTextN[0], 32, varWidth ) 'clear it first
bytemove( @varTextN[0], pPtr, strsize(pPtr) ) 'copy menu item text string
strIdx := 0
repeat varWidth
varTextI[strIdx] := varTextN[strIdx]+128 'invert the string
strIdx++
bytemove( @byte[varScreenPtr][varVgaPos], varTextI, varWidth )
Code: Alles auswählen
<?php
$ipaddress = $_SERVER['REMOTE_ADDR'];
echo $ipaddress ;
?>
Code: Alles auswählen
<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors", 1);
date_default_timezone_set("America/Argentina/Buenos_Aires");
function query_time_server ($timeserver, $socket)
{
$fp = fsockopen($timeserver,$socket,$err,$errstr,5);
# parameters: server, socket, error code, error text, timeout
if($fp)
{
fputs($fp, "\n");
$timevalue = fread($fp, 49);
fclose($fp); # close the connection
}
else
{
$timevalue = " ";
}
$ret = array();
$ret[] = $timevalue;
$ret[] = $err; # error code
$ret[] = $errstr; # error text
return($ret);
} # function query_time_server
$timeserver = "ntp.pads.ufrj.br";
$timercvd = query_time_server($timeserver, 37);
//if no error from query_time_server
if(!$timercvd[1])
{
$timevalue = bin2hex($timercvd[0]);
$timevalue = abs(HexDec('7fffffff') - HexDec($timevalue) - HexDec('7fffffff'));
$tmestamp = $timevalue - 2208988800; # convert to UNIX epoch time stamp
$datum = date("Y-m-d (D) H:i:s",$tmestamp - date("Z",$tmestamp)); /* incl time zone offset */
$doy = (date("z",$tmestamp)+1);
echo "Time check from time server ",$timeserver," : [<font color=\"red\">",$timevalue,"</font>]";
echo " (seconds since 1900-01-01 00:00.00).<br>\n";
echo "The current date and universal time is ",$datum," UTC. ";
echo "It is day ",$doy," of this year.<br>\n";
echo "The unix epoch time stamp is $tmestamp.<br>\n";
echo date("d/m/Y H:i:s", $tmestamp);
}
else
{
echo "Unfortunately, the time server $timeserver could not be reached at this time. ";
echo "$timercvd[1] $timercvd[2].<br>\n";
}
?>
Code: Alles auswählen
query_time_server($timeserver, 37);
Code: Alles auswählen
fputs($fp, "\n");
Code: Alles auswählen
fread($fp, 49);
Code: Alles auswählen
<?php
error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors", 1);
date_default_timezone_set("America/Argentina/Buenos_Aires");
function query_time_server ($timeserver, $socket)
{
$fp = fsockopen($timeserver,$socket,$err,$errstr,5);
# parameters: server, socket, error code, error text, timeout
if($fp)
{
fputs($fp, "\n");
$timevalue = fread($fp, 49);
fclose($fp); # close the connection
}
else
{
$timevalue = " ";
}
$ret = array();
$ret[] = $timevalue;
$ret[] = $err; # error code
$ret[] = $errstr; # error text
return($ret);
} # function query_time_server
$timeserver = "192.168.1.102";
$timercvd = query_time_server($timeserver, 37);
//if no error from query_time_server
if(!$timercvd[1])
{
$timevalue = bin2hex($timercvd[0]);
$timevalue = abs(HexDec('7fffffff') - HexDec($timevalue) - HexDec('7fffffff'));
$tmestamp = $timevalue - 2208988800; # convert to UNIX epoch time stamp
$datum = date("Y-m-d (D) H:i:s",$tmestamp - date("Z",$tmestamp)); /* incl time zone offset */
$doy = (date("z",$tmestamp)+1);
// echo "Time check from time server ",$timeserver," : [<font color=\"red\">",$timevalue,"</font>]";
// echo " (seconds since 1900-01-01 00:00.00).<br>\n";
// echo "The current date and universal time is ",$datum," UTC. ";
// echo "It is day ",$doy," of this year.<br>\n";
// echo "The unix epoch time stamp is $tmestamp.<br>\n";
// echo date("d/m/Y H:i:s", $tmestamp);
}
else
{
echo "Unfortunately, the time server $timeserver could not be reached at this time. ";
echo "$timercvd[1] $timercvd[2].<br>\n";
}
?>
Code: Alles auswählen
$array = query_time_server('ntps1-1.cs.tu-berlin.de',13);
echo '<pre>';
print_r($array);
echo '</pre>';
Code: Alles auswählen
Array
(
[0] => Fri Sep 5 03:07:16 2003
[1] => 0
[2] =>
)
Code: Alles auswählen
VAR
' Antwort auf Kommandos
word ComIdx[1] ' 0 = Leer >0 = Datengröße in Byte
byte ComBuf[2048] ' Puffer
' Empfangsdaten
word BinIdx[1] ' 0 = Leer >0 = Datengröße in Byte
byte BinBuf[2048] ' Puffer