Lua sleep function in milliseconds
Lua Socekt must be use in order to call sleep function in milliseconds.
An example to install Lua Socket to OpenWRT
opkg update
opkg install luasocket
|
An example to sleep 10 milliseconds
require "socket"
socket.sleep(0.010)
|
Lua can only sleep/wait in seconds (not milliseconds) without install Lua Socket. Code below shows the sleep funciton.
function delay_s(delay)
delay = delay or 1
local time_to = os.time() + delay while os.time() < time_to do end end
|
Example to sleep 5 seconds
delay_s(5) |
Port Forward - Control Device Over Internet
- TL-WR1043 router IP address: 192.168.1.1
- Device to be control (IP address) : 192.168.1.49
- Device to be control (Port) : 455
Control Serial via PHP
<?php |
HTML Onclick Image Button with CSS
This is a tutorial to show image button on webpage, it use CSS.
See http://www.w3schools.com/css/default.asp for more information.
Below is an example to show two image buttons. <div class="img"> is the CSS, it is not define in this example, but it is working without any CSS style.
</html> <div > |
HTML Onclick Button Image
There is few ways to show image button on the webpage. Here I use <a.
<a target="_parent" href="/newWebPage.php"><img src="/images/light_on.png" alt="Light" /></a> |
Above example shows an image with event. newWebPage.php will open if user click on the image.
- target="_parent" means open a new page when user click on the image. See http://www.w3schools.com/tags/att_a_target.asp for more information
- href= is the action. It will open newWebPage.php when user click on the image.
- img src= show the image on the page. It support many formats such as png, jpg, gif, bmp & others. I often use png & gif (animation) format since both support transparent.
- alt= will show the text if the associated image is not exist.
Note: IE8 and Google Chrome show output differently. There is a rectangular frame around the image if loaded with IE8, while Google Chrome did not show any frame.
Below example execute a javascript function called runCmd with two parameters:
<a href="javascript:runCmd(1,'a')"><img src="/images/fan_on.png" alt="Fan" /></a> |
See http://www.w3schools.com/tags/tag_a.asp for more information on how to use <a
Below example shows four images aligned in horizontally:
<a target="_parent" href="/newWebPage.php"><img src="/images/light_on.png" alt="Light" /></a> |