nodemcu-firmware/README.html

2292 lines
164 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html><head><meta charset="utf-8"><style>body {
width: 45em;
border: 1px solid #ddd;
outline: 1300px solid #fff;
margin: 16px auto;
}
body .markdown-body
{
padding: 30px;
}
@font-face {
font-family: fontawesome-mini;
src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAzUABAAAAAAFNgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABbAAAABwAAAAcZMzaOEdERUYAAAGIAAAAHQAAACAAOQAET1MvMgAAAagAAAA+AAAAYHqhde9jbWFwAAAB6AAAAFIAAAFa4azkLWN2dCAAAAI8AAAAKAAAACgFgwioZnBnbQAAAmQAAAGxAAACZVO0L6dnYXNwAAAEGAAAAAgAAAAIAAAAEGdseWYAAAQgAAAFDgAACMz7eroHaGVhZAAACTAAAAAwAAAANgWEOEloaGVhAAAJYAAAAB0AAAAkDGEGa2htdHgAAAmAAAAAEwAAADBEgAAQbG9jYQAACZQAAAAaAAAAGgsICJBtYXhwAAAJsAAAACAAAAAgASgBD25hbWUAAAnQAAACZwAABOD4no+3cG9zdAAADDgAAABsAAAAmF+yXM9wcmVwAAAMpAAAAC4AAAAusPIrFAAAAAEAAAAAyYlvMQAAAADLVHQgAAAAAM/u9uZ4nGNgZGBg4ANiCQYQYGJgBEJuIGYB8xgABMMAPgAAAHicY2Bm42OcwMDKwMLSw2LMwMDQBqGZihmiwHycoKCyqJjB4YPDh4NsDP+BfNb3DIuAFCOSEgUGRgAKDgt4AAB4nGNgYGBmgGAZBkYGEAgB8hjBfBYGCyDNxcDBwMTA9MHhQ9SHrA8H//9nYACyQyFs/sP86/kX8HtB9UIBIxsDXICRCUgwMaACRoZhDwA3fxKSAAAAAAHyAHABJQB/AIEAdAFGAOsBIwC/ALgAxACGAGYAugBNACcA/wCIeJxdUbtOW0EQ3Q0PA4HE2CA52hSzmZDGe6EFCcTVjWJkO4XlCGk3cpGLcQEfQIFEDdqvGaChpEibBiEXSHxCPiESM2uIojQ7O7NzzpkzS8qRqnfpa89T5ySQwt0GzTb9Tki1swD3pOvrjYy0gwdabGb0ynX7/gsGm9GUO2oA5T1vKQ8ZTTuBWrSn/tH8Cob7/B/zOxi0NNP01DoJ6SEE5ptxS4PvGc26yw/6gtXhYjAwpJim4i4/plL+tzTnasuwtZHRvIMzEfnJNEBTa20Emv7UIdXzcRRLkMumsTaYmLL+JBPBhcl0VVO1zPjawV2ys+hggyrNgQfYw1Z5DB4ODyYU0rckyiwNEfZiq8QIEZMcCjnl3Mn+pED5SBLGvElKO+OGtQbGkdfAoDZPs/88m01tbx3C+FkcwXe/GUs6+MiG2hgRYjtiKYAJREJGVfmGGs+9LAbkUvvPQJSA5fGPf50ItO7YRDyXtXUOMVYIen7b3PLLirtWuc6LQndvqmqo0inN+17OvscDnh4Lw0FjwZvP+/5Kgfo8LK40aA4EQ3o3ev+iteqIq7wXPrIn07+xWgAAAAABAAH//wAPeJyFlctvG1UUh+/12DPN1B7P3JnYjj2Ox4/MuDHxJH5N3UdaEUQLqBIkfQQioJWQ6AMEQkIqsPGCPwA1otuWSmTBhjtps2ADWbJg3EpIXbGouqSbCraJw7kzNo2dRN1cnXN1ZvT7zuuiMEI7ncizyA0URofRBJpCdbQuIFShYY+GZRrxMDVtih5TwQPHtXDFFSIKoWIbuREBjLH27Ny4MsbVx+uOJThavebgVrNRLAiYx06rXsvhxLgWx9xpfHdrs/ekc2Pl2cpPCVEITQpwbj8VQhfXSq2m+Wxqaq2D73Kne5e3NjHqQNj3CRYlJlgUl/jRNP+2Gs2pNYRQiOnmUaQDqm30KqKiTTWPWjboxnTWpvgxjXo0KrtZXAHt7hwIz0YVcj88JnKlJKi3NPAwLyDwZudSmJSMMJFDYaOkaol6XtESx3Gt1VTytdZJ3DCLeaVhVnCBH1fycHTxFXwPX+l2e3d6H/TufGGmMTLTnbSJUdo00zuBswMO/nl3YLeL/wnu9/limCuD3vC54h5NBVz6Li414AI8Vx3iiosKcQXUbrvhFFiYb++HN4DaF4XzFW0fIN4XDWJ3a3XQoq9V8WiyRmdsatV9xUcHims1JloH0YUa090G3Tro3mC6c01f+YwCPquINr1PTaCP6rVTOOmf0GE2dBc7zWIhji3/5MchSuBHgDbU99RMWt3YUNMZMJmx92YP6NsHx/5/M1yvInpnkIOM3Z8fA3JQ2lW1RFC1KaBPDFXNAHYYvGy73aYZZZ3HifbeuiVZCpwA3oQBs0wGPYJbJfg60xrKEbKiNtTe1adwrpBRwlAuQ3q3VRaX0QmQ9a49BTSCuF1MLfQ6+tinOubRBZuWPNoMevGMT+V41KitO1is3D/tpMcq1JHZqDHGs8DoYGDkxJgKjHROeTCmhZvzPm9pod+ltKm4PN7Dyvvldlpsg8D+4AUJZ3F/JBstZz7cbFRxsaAGV6yX/dkcycWf8eS3QlQea+YLjdm3yrOnrhFpUyKVvFE4lpv4bO3Svx/6F/4xmiDu/RT5iI++lko18mY1oX+5UGKR6kmVjM/Zb76yfHtxy+h/SyQ0lLdpdKy/lWB6szatetQJ8nZ80A2Qt6ift6gJeavU3BO4gtxs/KCtNPVibCtYCWY3SIlSBPKXZALXiIR9oZeJ1AuMyxLpHIy/yO7vSiSE+kZvk0ihJ30HgHfzZtEMmvV58x6dtqns0XTAW7Vdm4HJ04OCp/crOO7rd9SGxQAE/mVA9xRN+kVSMRFF6S9JFGUtthkjBA5tFCWc2l4V43Ex9GmUP3SI37Jjmir9KqlaDJ4S4JB3vuM/jzyH1+8MuoZ+QGzfnvPoJb96cZlWjMcKLfgDwB7E634JTY+asjsPzS5CiVnEWY+KsrsIN5rn3mAPjqmQBxGjcGKB9f9ZxY3mYC2L85CJ2FXIxKKyHk+dg0FHbuEc7D5NzWUX32WxFcWNGRAbvwSx0RmIXVDuYySafluQBmzA/ssqJAMLnli+WIC90Gw4lm85wcp0qjArEDPJJV/sSx4P9ungTpgMw5gVC1XO4uULq0s3v1rqLi0vX/z65vlH50f8T/RHmSPTk5xxWBWOluMT6WiOy+tdvWxlV/XQb3o3c6Ssr+r6I708GsX9/nzp1tKFh0s3v7m4vAy/Hnb/KMOvc1wump6Il48K6mGDy02X9Yd65pa+nQIjk76lWxCkG8NBCP0HQS9IpAAAeJxjYGRgYGBhcCrq214Qz2/zlUGenQEEzr/77oug/zewFbB+AHI5GJhAogBwKQ0qeJxjYGRgYH3/P46BgZ0BBNgKGBgZUAEPAE/7At0AAAB4nGNngAB2IGYjhBsYBAAIYADVAAAAAAAAAAAAAFwAyAEeAaACCgKmAx4DggRmAAAAAQAAAAwAagAEAAAAAAACAAEAAgAWAAABAAChAAAAAHiclZI7bxQxFIWPd/JkUYQChEhIyAVKgdBMskm1QkKrRETpQiLRUczueB/K7HhlOxttg8LvoKPgP9DxFxANDR0tHRWi4NjrPIBEgh1p/dm+vufcawNYFWsQmP6e4jSyQB2fI9cwj++RE9wTjyPP4LYoI89iWbyLPIe6+Bh5Hs9rryMv4GbtW+RF3EhuRa7jbrIbeQkPkjdUETOLnL0Kip4FVvAhco1RXyMnSPEz8gzWxE7kWTwUp5HnsCLeR57HW/El8gJWa58iL+JO7UfkOh4l9yMv4UnyEtvQGGECgwF66MNBooF1bGCL1ELB/TYU+ZBRlvsKQ44Se6jQ4a7hef+fh72Crv25kp+8lNWGmeKoOI5jJLb1aGIGvb6TjfWNLdkqdFvJw4l1amjlXtXRZqRN7lSRylZZyhBqpVFWmTEXgWfUrpi/hZOQXdOd4rKuXOtEWT3k5IArPRzTUU5tHKjecZkTpnVbNOnt6jzN8240GD4xtikvZW56043rPMg/dS+dlOceXoR+WPbJ55Dsekq1lJpnypsMUsYOdCW30o103Ytu/lvh+5RWFLfBjm9/N8hJntPhvx92rnoE/kyHdGasGy754kw36vsVf/lFeBi+0COu+cfgQr42G3CRpeLoZ53gmfe3X6rcKt5oVxnptHR9JS8ehVUd5wvvahN2uqxOOpMXapibI5k7Zwbt4xBSaTfoKBufhAnO/uqNcfK8OTs0OQ6l7JIqFjDhYj5WcjevCnI/1DDiI8j4ndWb/5YzDZWh79yomWXeXj7Nnw70/2TIeFPTrlSh89k1ObOSRVZWZfgF0r/zJQB4nG2JUQuCQBCEd07TTg36fb2IyBaLd3vWaUh/vmSJnvpgmG8YcmS8X3Shf3R7QA4OBUocUKHGER5NNbOOEvwc1txnuWkTRb/aPjimJ5vXabI+3VfOiyS15UWvyezM2xiGOPyuMohOH8O8JiO4Af+FsAGNAEuwCFBYsQEBjlmxRgYrWCGwEFlLsBRSWCGwgFkdsAYrXFhZsBQrAAA=) format('woff');
}
@font-face {
font-family: octicons-anchor;
src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAYcAA0AAAAACjQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABMAAAABwAAAAca8vGTk9TLzIAAAFMAAAARAAAAFZG1VHVY21hcAAAAZAAAAA+AAABQgAP9AdjdnQgAAAB0AAAAAQAAAAEACICiGdhc3AAAAHUAAAACAAAAAj//wADZ2x5ZgAAAdwAAADRAAABEKyikaNoZWFkAAACsAAAAC0AAAA2AtXoA2hoZWEAAALgAAAAHAAAACQHngNFaG10eAAAAvwAAAAQAAAAEAwAACJsb2NhAAADDAAAAAoAAAAKALIAVG1heHAAAAMYAAAAHwAAACABEAB2bmFtZQAAAzgAAALBAAAFu3I9x/Nwb3N0AAAF/AAAAB0AAAAvaoFvbwAAAAEAAAAAzBdyYwAAAADP2IQvAAAAAM/bz7t4nGNgZGFgnMDAysDB1Ml0hoGBoR9CM75mMGLkYGBgYmBlZsAKAtJcUxgcPsR8iGF2+O/AEMPsznAYKMwIkgMA5REMOXicY2BgYGaAYBkGRgYQsAHyGMF8FgYFIM0ChED+h5j//yEk/3KoSgZGNgYYk4GRCUgwMaACRoZhDwCs7QgGAAAAIgKIAAAAAf//AAJ4nHWMMQrCQBBF/0zWrCCIKUQsTDCL2EXMohYGSSmorScInsRGL2DOYJe0Ntp7BK+gJ1BxF1stZvjz/v8DRghQzEc4kIgKwiAppcA9LtzKLSkdNhKFY3HF4lK69ExKslx7Xa+vPRVS43G98vG1DnkDMIBUgFN0MDXflU8tbaZOUkXUH0+U27RoRpOIyCKjbMCVejwypzJJG4jIwb43rfl6wbwanocrJm9XFYfskuVC5K/TPyczNU7b84CXcbxks1Un6H6tLH9vf2LRnn8Ax7A5WQAAAHicY2BkYGAA4teL1+yI57f5ysDNwgAC529f0kOmWRiYVgEpDgYmEA8AUzEKsQAAAHicY2BkYGB2+O/AEMPCAAJAkpEBFbAAADgKAe0EAAAiAAAAAAQAAAAEAAAAAAAAKgAqACoAiAAAeJxjYGRgYGBhsGFgYgABEMkFhAwM/xn0QAIAD6YBhwB4nI1Ty07cMBS9QwKlQapQW3VXySvEqDCZGbGaHULiIQ1FKgjWMxknMfLEke2A+IJu+wntrt/QbVf9gG75jK577Lg8K1qQPCfnnnt8fX1NRC/pmjrk/zprC+8D7tBy9DHgBXoWfQ44Av8t4Bj4Z8CLtBL9CniJluPXASf0Lm4CXqFX8Q84dOLnMB17N4c7tBo1AS/Qi+hTwBH4rwHHwN8DXqQ30XXAS7QaLwSc0Gn8NuAVWou/gFmnjLrEaEh9GmDdDGgL3B4JsrRPDU2hTOiMSuJUIdKQQayiAth69r6akSSFqIJuA19TrzCIaY8sIoxyrNIrL//pw7A2iMygkX5vDj+G+kuoLdX4GlGK/8Lnlz6/h9MpmoO9rafrz7ILXEHHaAx95s9lsI7AHNMBWEZHULnfAXwG9/ZqdzLI08iuwRloXE8kfhXYAvE23+23DU3t626rbs8/8adv+9DWknsHp3E17oCf+Z48rvEQNZ78paYM38qfk3v/u3l3u3GXN2Dmvmvpf1Srwk3pB/VSsp512bA/GG5i2WJ7wu430yQ5K3nFGiOqgtmSB5pJVSizwaacmUZzZhXLlZTq8qGGFY2YcSkqbth6aW1tRmlaCFs2016m5qn36SbJrqosG4uMV4aP2PHBmB3tjtmgN2izkGQyLWprekbIntJFing32a5rKWCN/SdSoga45EJykyQ7asZvHQ8PTm6cslIpwyeyjbVltNikc2HTR7YKh9LBl9DADC0U/jLcBZDKrMhUBfQBvXRzLtFtjU9eNHKin0x5InTqb8lNpfKv1s1xHzTXRqgKzek/mb7nB8RZTCDhGEX3kK/8Q75AmUM/eLkfA+0Hi908Kx4eNsMgudg5GLdRD7a84npi+YxNr5i5KIbW5izXas7cHXIMAau1OueZhfj+cOcP3P8MNIWLyYOBuxL6DRylJ4cAAAB4nGNgYoAALjDJyIAOWMCiTIxMLDmZedkABtIBygAAAA==) format('woff');
}
.markdown-body {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
color: #333333;
overflow: hidden;
font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif;
font-size: 16px;
line-height: 1.6;
word-wrap: break-word;
}
.markdown-body a {
background: transparent;
}
.markdown-body a:active,
.markdown-body a:hover {
outline: 0;
}
.markdown-body b,
.markdown-body strong {
font-weight: bold;
}
.markdown-body mark {
background: #ff0;
color: #000;
font-style: italic;
font-weight: bold;
}
.markdown-body sub,
.markdown-body sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
.markdown-body sup {
top: -0.5em;
}
.markdown-body sub {
bottom: -0.25em;
}
.markdown-body h1 {
font-size: 2em;
margin: 0.67em 0;
}
.markdown-body img {
border: 0;
}
.markdown-body hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
.markdown-body pre {
overflow: auto;
}
.markdown-body code,
.markdown-body kbd,
.markdown-body pre,
.markdown-body samp {
font-family: monospace, monospace;
font-size: 1em;
}
.markdown-body input {
color: inherit;
font: inherit;
margin: 0;
}
.markdown-body html input[disabled] {
cursor: default;
}
.markdown-body input {
line-height: normal;
}
.markdown-body input[type="checkbox"] {
box-sizing: border-box;
padding: 0;
}
.markdown-body table {
border-collapse: collapse;
border-spacing: 0;
}
.markdown-body td,
.markdown-body th {
padding: 0;
}
.markdown-body .codehilitetable {
border: 0;
border-spacing: 0;
}
.markdown-body .codehilitetable tr {
border: 0;
}
.markdown-body .codehilitetable pre,
.markdown-body div.codehilite {
margin: 0;
}
.markdown-body .linenos,
.markdown-body .code,
.markdown-body .codehilitetable td {
border: 0;
padding: 0;
}
.markdown-body td:not(.linenos) .linenodiv {
padding: 0 !important;
}
.markdown-body .code {
width: 100%;
}
.markdown-body .linenos div pre,
.markdown-body .linenodiv pre,
.markdown-body .linenodiv {
border: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
-webkit-border-top-left-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
-moz-border-radius-topleft: 3px;
-moz-border-radius-bottomleft: 3px;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}
.markdown-body .code div pre,
.markdown-body .code div {
border: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
-webkit-border-top-right-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
-moz-border-radius-topright: 3px;
-moz-border-radius-bottomright: 3px;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}
.markdown-body * {
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.markdown-body input {
font: 13px Helvetica, arial, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
line-height: 1.4;
}
.markdown-body a {
color: #4183c4;
text-decoration: none;
}
.markdown-body a:hover,
.markdown-body a:focus,
.markdown-body a:active {
text-decoration: underline;
}
.markdown-body hr {
height: 0;
margin: 15px 0;
overflow: hidden;
background: transparent;
border: 0;
border-bottom: 1px solid #ddd;
}
.markdown-body hr:before,
.markdown-body hr:after {
display: table;
content: " ";
}
.markdown-body hr:after {
clear: both;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
margin-top: 15px;
margin-bottom: 15px;
line-height: 1.1;
}
.markdown-body h1 {
font-size: 30px;
}
.markdown-body h2 {
font-size: 21px;
}
.markdown-body h3 {
font-size: 16px;
}
.markdown-body h4 {
font-size: 14px;
}
.markdown-body h5 {
font-size: 12px;
}
.markdown-body h6 {
font-size: 11px;
}
.markdown-body blockquote {
margin: 0;
}
.markdown-body ul,
.markdown-body ol {
padding: 0;
margin-top: 0;
margin-bottom: 0;
}
.markdown-body ol ol,
.markdown-body ul ol {
list-style-type: lower-roman;
}
.markdown-body ul ul ol,
.markdown-body ul ol ol,
.markdown-body ol ul ol,
.markdown-body ol ol ol {
list-style-type: lower-alpha;
}
.markdown-body dd {
margin-left: 0;
}
.markdown-body code,
.markdown-body pre,
.markdown-body samp {
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
font-size: 12px;
}
.markdown-body pre {
margin-top: 0;
margin-bottom: 0;
}
.markdown-body kbd {
background-color: #e7e7e7;
background-image: -moz-linear-gradient(#fefefe, #e7e7e7);
background-image: -webkit-linear-gradient(#fefefe, #e7e7e7);
background-image: linear-gradient(#fefefe, #e7e7e7);
background-repeat: repeat-x;
border-radius: 2px;
border: 1px solid #cfcfcf;
color: #000;
padding: 3px 5px;
line-height: 10px;
font: 11px Consolas, "Liberation Mono", Menlo, Courier, monospace;
display: inline-block;
}
.markdown-body>*:first-child {
margin-top: 0 !important;
}
.markdown-body>*:last-child {
margin-bottom: 0 !important;
}
.markdown-body .headeranchor-link {
position: absolute;
top: 0;
bottom: 0;
left: 0;
display: block;
padding-right: 6px;
padding-left: 30px;
margin-left: -30px;
}
.markdown-body .headeranchor-link:focus {
outline: none;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
position: relative;
margin-top: 1em;
margin-bottom: 16px;
font-weight: bold;
line-height: 1.4;
}
.markdown-body h1 .headeranchor,
.markdown-body h2 .headeranchor,
.markdown-body h3 .headeranchor,
.markdown-body h4 .headeranchor,
.markdown-body h5 .headeranchor,
.markdown-body h6 .headeranchor {
display: none;
color: #000;
vertical-align: middle;
}
.markdown-body h1:hover .headeranchor-link,
.markdown-body h2:hover .headeranchor-link,
.markdown-body h3:hover .headeranchor-link,
.markdown-body h4:hover .headeranchor-link,
.markdown-body h5:hover .headeranchor-link,
.markdown-body h6:hover .headeranchor-link {
height: 1em;
padding-left: 8px;
margin-left: -30px;
line-height: 1;
text-decoration: none;
}
.markdown-body h1:hover .headeranchor-link .headeranchor,
.markdown-body h2:hover .headeranchor-link .headeranchor,
.markdown-body h3:hover .headeranchor-link .headeranchor,
.markdown-body h4:hover .headeranchor-link .headeranchor,
.markdown-body h5:hover .headeranchor-link .headeranchor,
.markdown-body h6:hover .headeranchor-link .headeranchor {
display: inline-block;
}
.markdown-body h1 {
padding-bottom: 0.3em;
font-size: 2.25em;
line-height: 1.2;
border-bottom: 1px solid #eee;
}
.markdown-body h2 {
padding-bottom: 0.3em;
font-size: 1.75em;
line-height: 1.225;
border-bottom: 1px solid #eee;
}
.markdown-body h3 {
font-size: 1.5em;
line-height: 1.43;
}
.markdown-body h4 {
font-size: 1.25em;
}
.markdown-body h5 {
font-size: 1em;
}
.markdown-body h6 {
font-size: 1em;
color: #777;
}
.markdown-body p,
.markdown-body blockquote,
.markdown-body ul,
.markdown-body ol,
.markdown-body dl,
.markdown-body table,
.markdown-body pre,
.markdown-body .admonition {
margin-top: 0;
margin-bottom: 16px;
}
.markdown-body hr {
height: 4px;
padding: 0;
margin: 16px 0;
background-color: #e7e7e7;
border: 0 none;
}
.markdown-body ul,
.markdown-body ol {
padding-left: 2em;
}
.markdown-body ul ul,
.markdown-body ul ol,
.markdown-body ol ol,
.markdown-body ol ul {
margin-top: 0;
margin-bottom: 0;
}
.markdown-body li>p {
margin-top: 16px;
}
.markdown-body dl {
padding: 0;
}
.markdown-body dl dt {
padding: 0;
margin-top: 16px;
font-size: 1em;
font-style: italic;
font-weight: bold;
}
.markdown-body dl dd {
padding: 0 16px;
margin-bottom: 16px;
}
.markdown-body blockquote {
padding: 0 15px;
color: #777;
border-left: 4px solid #ddd;
}
.markdown-body blockquote>:first-child {
margin-top: 0;
}
.markdown-body blockquote>:last-child {
margin-bottom: 0;
}
.markdown-body table {
display: block;
width: 100%;
overflow: auto;
word-break: normal;
word-break: keep-all;
}
.markdown-body table th {
font-weight: bold;
}
.markdown-body table th,
.markdown-body table td {
padding: 6px 13px;
border: 1px solid #ddd;
}
.markdown-body table tr {
background-color: #fff;
border-top: 1px solid #ccc;
}
.markdown-body table tr:nth-child(2n) {
background-color: #f8f8f8;
}
.markdown-body img {
max-width: 100%;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.markdown-body code,
.markdown-body samp {
padding: 0;
padding-top: 0.2em;
padding-bottom: 0.2em;
margin: 0;
font-size: 85%;
background-color: rgba(0,0,0,0.04);
border-radius: 3px;
}
.markdown-body code:before,
.markdown-body code:after {
letter-spacing: -0.2em;
content: "\00a0";
}
.markdown-body pre>code {
padding: 0;
margin: 0;
font-size: 100%;
word-break: normal;
white-space: pre;
background: transparent;
border: 0;
}
.markdown-body .codehilite {
margin-bottom: 16px;
}
.markdown-body .codehilite pre,
.markdown-body pre {
padding: 16px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
background-color: #f7f7f7;
border-radius: 3px;
}
.markdown-body .codehilite pre {
margin-bottom: 0;
word-break: normal;
}
.markdown-body pre {
word-wrap: normal;
}
.markdown-body pre code {
display: inline;
max-width: initial;
padding: 0;
margin: 0;
overflow: initial;
line-height: inherit;
word-wrap: normal;
background-color: transparent;
border: 0;
}
.markdown-body pre code:before,
.markdown-body pre code:after {
content: normal;
}
/* Admonition */
.markdown-body .admonition {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
padding: 0.5em 1em 0.5em 1em;
color: #888888;
background-color: #F7F7F7;
border: 1px solid #888888;
}
.markdown-body .admonition blockquote {
color: rgba(136, 136, 136, 0.5);
border-left: 4px solid rgba(136, 136, 136, 0.5);
}
.markdown-body .admonition table {
color: #333;
}
.markdown-body .admonition p {
padding: 0;
margin: 0;
}
.markdown-body .admonition-title {
font-weight: bold;
margin: 0;
}
.markdown-body .admonition-icon {
font: normal normal 16px fontawesome-mini;
line-height: 1.5;
-moz-osx-font-smoothing: grayscale;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
float: left;
}
.markdown-body .attention {
color: #4F8A10;
background-color: #DFF2BF;
border: 1px solid #4F8A10;
}
.markdown-body .caution {
color: #D63301;
background-color: #FFCCBA;
border: 1px solid #D63301;
}
.markdown-body .hint {
color: #00529B;
background-color: #BDE5F8;
border: 1px solid #00529B;
}
.markdown-body .danger {
color: #D8000C;
background-color: #FFBABA;
border: 1px solid #D8000C;
}
.markdown-body .question {
color: #00049b;
background-color: #BDC8F8;
border: 1px solid #00049b;
}
.markdown-body .note {
color: #9F6000;
background-color: #FEEFB3;
border: 1px solid #9F6000;
}
.markdown-body .attention {
color: #4F8A10;
background-color: #DFF2BF;
border: 1px solid #4F8A10;
}
.markdown-body .caution blockquote {
color: rgba(214, 51, 1, .5);
border-left: 4px solid rgba(214, 51, 1, .5);
}
.markdown-body .hint blockquote {
color: rgba(0, 82, 155, .5);
border-left: 4px solid rgba(0, 82, 155, .5);
}
.markdown-body .danger blockquote {
color: rgba(216, 0, 12, .5);
border-left: 4px solid rgba(216, 0, 12, .5);
}
.markdown-body .question blockquote {
color: rgba(0, 4, 155, .5);
border-left: 4px solid rgba(0, 4, 155, .5);;
}
.markdown-body .note blockquote {
color: rgba(159, 96, 0, .5);
border-left: 4px solid rgba(159, 96, 0, .5);
}
.markdown-body .admonition-icon:before {
content: "\f040\00a0";
}
.markdown-body .attention > .admonition-icon:before {
content: "\f058\00a0";
}
.markdown-body .caution > .admonition-icon:before {
content: "\f06a\00a0";
}
.markdown-body .hint > .admonition-icon:before {
content: "\f05a\00a0";
}
.markdown-body .danger > .admonition-icon:before {
content: "\f056\00a0";
}
.markdown-body .question > .admonition-icon:before {
content: "\f059\00a0";
}
.markdown-body .note > .admonition-icon:before {
content: "\f040\00a0";
}
/* progress bar*/
.markdown-body .progress {
display: block;
width: 300px;
margin: 10px 0;
height: 24px;
border: 1px solid #ccc;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
background-color: #F8F8F8;
position: relative;
box-shadow: inset -1px 1px 3px rgba(0, 0, 0, .1);
}
.markdown-body .progress-label {
position: absolute;
text-align: center;
font-weight: bold;
width: 100%; margin: 0;
line-height: 24px;
color: #333;
text-shadow: 1px 1px 0 #fefefe, -1px -1px 0 #fefefe, -1px 1px 0 #fefefe, 1px -1px 0 #fefefe, 0 1px 0 #fefefe, 0 -1px 0 #fefefe, 1px 0 0 #fefefe, -1px 0 0 #fefefe, 1px 1px 2px #000;
-webkit-font-smoothing: antialiased !important;
white-space: nowrap;
overflow: hidden;
}
.markdown-body .progress-bar {
height: 24px;
float: left;
border-right: 1px solid #ccc;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
background-color: #34c2e3;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5);
background-size: 30px 30px;
background-image: -webkit-linear-gradient(
135deg, rgba(255, 255, 255, .4) 27%,
transparent 27%,
transparent 53%, rgba(255, 255, 255, .4) 53%,
rgba(255, 255, 255, .4) 77%,
transparent 77%, transparent
);
background-image: -moz-linear-gradient(
135deg,
rgba(255, 255, 255, .4) 27%, transparent 27%,
transparent 53%, rgba(255, 255, 255, .4) 53%,
rgba(255, 255, 255, .4) 77%, transparent 77%,
transparent
);
background-image: -ms-linear-gradient(
135deg,
rgba(255, 255, 255, .4) 27%, transparent 27%,
transparent 53%, rgba(255, 255, 255, .4) 53%,
rgba(255, 255, 255, .4) 77%, transparent 77%,
transparent
);
background-image: -o-linear-gradient(
135deg,
rgba(255, 255, 255, .4) 27%, transparent 27%,
transparent 53%, rgba(255, 255, 255, .4) 53%,
rgba(255, 255, 255, .4) 77%, transparent 77%,
transparent
);
background-image: linear-gradient(
135deg,
rgba(255, 255, 255, .4) 27%, transparent 27%,
transparent 53%, rgba(255, 255, 255, .4) 53%,
rgba(255, 255, 255, .4) 77%, transparent 77%,
transparent
);
}
.markdown-body .progress-100plus .progress-bar {
background-color: #1ee038;
}
.markdown-body .progress-80plus .progress-bar {
background-color: #86e01e;
}
.markdown-body .progress-60plus .progress-bar {
background-color: #f2d31b;
}
.markdown-body .progress-40plus .progress-bar {
background-color: #f2b01e;
}
.markdown-body .progress-20plus .progress-bar {
background-color: #f27011;
}
.markdown-body .progress-0plus .progress-bar {
background-color: #f63a0f;
}
.markdown-body .gloss .progress-bar {
box-shadow:
inset -1px 1px 0 rgba(255, 255, 255, .5),
inset 0 -4px 12px rgba(255, 255, 255, .7),
inset 0 4px 12px rgba(255, 255, 255, .7),
inset 0 -12px 0 rgba(0, 0, 0, .05),
inset 1px -1px 0 rgba(255, 255, 255, .2);
}
.markdown-body .candystripe-animate .progress-bar{
-webkit-animation: animate-stripes 3s linear infinite;
-moz-animation: animate-stripes 3s linear infinite;
animation: animate-stripes 3s linear infinite;
}
@-webkit-keyframes animate-stripes {
0% {
background-position: 0 0;
}
100% {
background-position: 60px 0;
}
}
@-moz-keyframes animate-stripes {
0% {
background-position: 0 0;
}
100% {
background-position: 60px 0;
}
}
@keyframes animate-stripes {
0% {
background-position: 0 0;
}
100% {
background-position: 60px 0;
}
}
/* Multimarkdown Critic Blocks */
.markdown-body .critic_mark {
background: #ff0;
}
.markdown-body .critic_delete {
color: #c82829;
text-decoration: line-through;
}
.markdown-body .critic_insert {
color: #718c00 ;
text-decoration: underline;
}
.markdown-body .critic_comment {
color: #8e908c;
font-style: italic;
}
.markdown-body .headeranchor {
font: normal normal 16px octicons-anchor;
line-height: 1;
display: inline-block;
text-decoration: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.headeranchor:before {
content: '\f05c';
}
.markdown-body .task-list-item {
list-style-type: none;
}
.markdown-body .task-list-item+.task-list-item {
margin-top: 3px;
}
.markdown-body .task-list-item input {
margin: 0 4px 0.25em -20px;
vertical-align: middle;
}
/* Media */
@media only screen and (min-width: 480px) {
.markdown-body {
font-size:14px;
}
}
@media only screen and (min-width: 768px) {
.markdown-body {
font-size:16px;
}
}
@media print {
.markdown-body * {
background: transparent !important;
color: black !important;
filter:none !important;
-ms-filter: none !important;
}
.markdown-body {
font-size:12pt;
max-width:100%;
outline:none;
border: 0;
}
.markdown-body a,
.markdown-body a:visited {
text-decoration: underline;
}
.markdown-body .headeranchor-link {
display: none;
}
.markdown-body a[href]:after {
content: " (" attr(href) ")";
}
.markdown-body abbr[title]:after {
content: " (" attr(title) ")";
}
.markdown-body .ir a:after,
.markdown-body a[href^="javascript:"]:after,
.markdown-body a[href^="#"]:after {
content: "";
}
.markdown-body pre {
white-space: pre;
white-space: pre-wrap;
word-wrap: break-word;
}
.markdown-body pre,
.markdown-body blockquote {
border: 1px solid #999;
padding-right: 1em;
page-break-inside: avoid;
}
.markdown-body .progress,
.markdown-body .progress-bar {
box-shadow: none;
}
.markdown-body tr,
.markdown-body img {
page-break-inside: avoid;
}
.markdown-body img {
max-width: 100% !important;
}
.markdown-body p,
.markdown-body h2,
.markdown-body h3 {
orphans: 3;
widows: 3;
}
.markdown-body h2,
.markdown-body h3 {
page-break-after: avoid;
}
}
</style><style>.codehilite pre .hll { background-color: #ffffcc }
.codehilite pre { background: #f8f8f8; color: #333333 }
.codehilite pre .c { color: #999988; font-style: italic } /* Comment */
.codehilite pre .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.codehilite pre .k { font-weight: bold } /* Keyword */
.codehilite pre .n { color: #333333 } /* Name */
.codehilite pre .o { font-weight: bold } /* Operator */
.codehilite pre .cm { color: #999988; font-style: italic } /* Comment.Multiline */
.codehilite pre .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
.codehilite pre .c1 { color: #999988; font-style: italic } /* Comment.Single */
.codehilite pre .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
.codehilite pre .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.codehilite pre .ge { font-style: italic } /* Generic.Emph */
.codehilite pre .gr { color: #aa0000 } /* Generic.Error */
.codehilite pre .gh { color: #999999 } /* Generic.Heading */
.codehilite pre .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.codehilite pre .go { color: #888888 } /* Generic.Output */
.codehilite pre .gp { color: #555555 } /* Generic.Prompt */
.codehilite pre .gs { font-weight: bold } /* Generic.Strong */
.codehilite pre .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.codehilite pre .gt { color: #aa0000 } /* Generic.Traceback */
.codehilite pre .kc { font-weight: bold } /* Keyword.Constant */
.codehilite pre .kd { font-weight: bold } /* Keyword.Declaration */
.codehilite pre .kn { font-weight: bold } /* Keyword.Namespace */
.codehilite pre .kp { font-weight: bold } /* Keyword.Pseudo */
.codehilite pre .kr { font-weight: bold } /* Keyword.Reserved */
.codehilite pre .kt { color: #445588; font-weight: bold } /* Keyword.Type */
.codehilite pre .m { color: #009999 } /* Literal.Number */
.codehilite pre .s { color: #dd1144 } /* Literal.String */
.codehilite pre .na { color: #008080 } /* Name.Attribute */
.codehilite pre .nb { color: #0086b3 } /* Name.Builtin */
.codehilite pre .nc { color: #445588; font-weight: bold } /* Name.Class */
.codehilite pre .no { color: #008080 } /* Name.Constant */
.codehilite pre .nd { color: #333333 } /* Name.Decorator */
.codehilite pre .ni { color: #800080 } /* Name.Entity */
.codehilite pre .ne { color: #990000; font-weight: bold } /* Name.Exception */
.codehilite pre .nf { color: #990000; font-weight: bold } /* Name.Function */
.codehilite pre .nl { color: #333333 } /* Name.Label */
.codehilite pre .nn { color: #555555 } /* Name.Namespace */
.codehilite pre .nx { color: #333333 } /* Name.Other */
.codehilite pre .py { color: #333333 } /* Name.Property */
.codehilite pre .nt { color: #000080 } /* Name.Tag */
.codehilite pre .nv { color: #008080 } /* Name.Variable */
.codehilite pre .ow { font-weight: bold } /* Operator.Word */
.codehilite pre .w { color: #bbbbbb } /* Text.Whitespace */
.codehilite pre .mb { color: #009999 } /* Literal.Number.Bin */
.codehilite pre .mf { color: #009999 } /* Literal.Number.Float */
.codehilite pre .mh { color: #009999 } /* Literal.Number.Hex */
.codehilite pre .mi { color: #009999 } /* Literal.Number.Integer */
.codehilite pre .mo { color: #009999 } /* Literal.Number.Oct */
.codehilite pre .sb { color: #dd1144 } /* Literal.String.Backtick */
.codehilite pre .sc { color: #dd1144 } /* Literal.String.Char */
.codehilite pre .sd { color: #dd1144 } /* Literal.String.Doc */
.codehilite pre .s2 { color: #dd1144 } /* Literal.String.Double */
.codehilite pre .se { color: #dd1144 } /* Literal.String.Escape */
.codehilite pre .sh { color: #dd1144 } /* Literal.String.Heredoc */
.codehilite pre .si { color: #dd1144 } /* Literal.String.Interpol */
.codehilite pre .sx { color: #dd1144 } /* Literal.String.Other */
.codehilite pre .sr { color: #009926 } /* Literal.String.Regex */
.codehilite pre .s1 { color: #dd1144 } /* Literal.String.Single */
.codehilite pre .ss { color: #990073 } /* Literal.String.Symbol */
.codehilite pre .bp { color: #999999 } /* Name.Builtin.Pseudo */
.codehilite pre .vc { color: #008080 } /* Name.Variable.Class */
.codehilite pre .vg { color: #008080 } /* Name.Variable.Global */
.codehilite pre .vi { color: #008080 } /* Name.Variable.Instance */
.codehilite pre .il { color: #009999 } /* Literal.Number.Integer.Long */</style><title>README</title></head><body><article class="markdown-body"><h1 id="nodemcu-api-instruction"><strong>nodeMcu API Instruction</strong></h1>
<h3 id="version-02-2014-11-10"><a name="user-content-version-02-2014-11-10" href="#version-02-2014-11-10" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>version 0.2 2014-11-10</h3>
<h3 id="change-log"><a name="user-content-change-log" href="#change-log" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>change log:</h3>
<p>2014-11-11<br /><br />
add file.seek() api to file module<br /><br />
now max 6 pwm channel is supported<br /></p>
<p>2014-11-10<br /><br />
change log module to file module<br /><br />
now file operation support multiple read/write<br /><br />
for now file module only allowed one file opened<br /></p>
<p>2014-11-5<br /><br />
delete log operation api from node module<br /><br />
add log module<br /><br />
modify wifi module api<br /><br />
modify node.key long_press and short_press default function<br /><br />
key is triged only when key is released<br /></p>
<h1 id="summary"><a name="user-content-summary" href="#summary" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Summary</h1>
<ul>
<li>Easy to access wireless router</li>
<li>Based on Lua 5.1.4, Developers are supposed to have experience with Lua Program language.</li>
<li>Event-Drive programming modal.</li>
<li>Build-in file, timer, pwm, i2c, net, gpio, wifi module.</li>
<li>Serial Port BaudRate:9600</li>
<li>Re-mapped GPIO pin, use the index to program gpio, i2c, pwm.</li>
<li>GPIO Map Table:</li>
</ul>
<table>
<tr>
<th scope="col">IO index</th><th scope="col">ESP8266 pin</th><th scope="col">IO index</th><th scope="col">ESP8266 pin</th>
</tr>
<tr>
<td>0</td><td>GPIO12</td><td>8</td><td>GPIO0</td>
</tr>
<tr>
<td>1</td><td>GPIO13</td><td>9</td><td>GPIO2</td>
</tr>
<tr>
<td>2</td><td>GPIO14</td><td>10</td><td>GPIO4</td>
</tr>
<tr>
<td>3</td><td>GPIO15</td><td>11</td><td>GPIO5</td>
</tr>
<tr>
<td>4</td><td>GPIO3</td><td></td><td></td>
</tr>
<tr>
<td>5</td><td>GPIO1</td><td></td><td></td>
</tr>
<tr>
<td>6</td><td>GPIO9</td><td></td><td></td>
</tr>
<tr>
<td>7</td><td>GPIO10</td<td></td><td></td>
</tr>
</table>
<h1 id="firmware-program"><a name="user-content-firmware-program" href="#firmware-program" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Firmware Program</h1>
<h3 id="address"><a name="user-content-address" href="#address" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Address</h3>
<p>eagle.app.v6.flash.bin: 0x00000<br /><br />
eagle.app.v6.irom0text.bin: 0x10000<br /><br />
esp_init_data_default.bin: 0x7c000<br /><br />
blank.bin: 0x7e000</p>
<h1 id="node-module"><a name="user-content-node-module" href="#node-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>node module</h1>
<p><a id="nm_restart"></a></p>
<h2 id="noderestart"><a name="user-content-noderestart" href="#noderestart" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>node.restart()</h2>
<h4 id="description"><a name="user-content-description" href="#description" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>restart the chip.</p>
<h4 id="syntax"><a name="user-content-syntax" href="#syntax" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>node.restart()</p>
<h4 id="parameters"><a name="user-content-parameters" href="#parameters" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns"><a name="user-content-returns" href="#returns" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example"><a name="user-content-example" href="#example" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">node</span><span class="o">.</span><span class="vg">restart</span><span class="p">();</span>
</pre></div>
<h4 id="see-also"><a name="user-content-see-also" href="#see-also" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href=""></a></p>
<p><a id="nm_dsleep"></a></p>
<h2 id="nodedsleep"><a name="user-content-nodedsleep" href="#nodedsleep" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>node.dsleep()</h2>
<h4 id="description_1"><a name="user-content-description_1" href="#description_1" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>Enter deep sleep mode, wake up when timed out<br /></p>
<h4 id="syntax_1"><a name="user-content-syntax_1" href="#syntax_1" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>node.dsleep(us)<br /><br />
<strong>-Note:</strong> This function can only be used in the condition that esp8266 PIN32(RST) and PIN8(XPD_DCDC) are connected together.</p>
<h4 id="parameters_1"><a name="user-content-parameters_1" href="#parameters_1" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>us: sleep time in micro second</p>
<h4 id="returns_1"><a name="user-content-returns_1" href="#returns_1" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_1"><a name="user-content-example_1" href="#example_1" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">node</span><span class="o">.</span><span class="vg">dsleep</span><span class="p">(</span><span class="vg">us</span><span class="p">);</span>
</pre></div>
<h4 id="see-also_1"><a name="user-content-see-also_1" href="#see-also_1" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href=""></a></p>
<p><a id="nm_chipid"></a></p>
<h2 id="nodechipid"><a name="user-content-nodechipid" href="#nodechipid" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>node.chipid()</h2>
<h4 id="description_2"><a name="user-content-description_2" href="#description_2" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>return chip ID</p>
<h4 id="syntax_2"><a name="user-content-syntax_2" href="#syntax_2" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>node.chipid()</p>
<h4 id="parameters_2"><a name="user-content-parameters_2" href="#parameters_2" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_2"><a name="user-content-returns_2" href="#returns_2" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>number:chip ID</p>
<h4 id="example_2"><a name="user-content-example_2" href="#example_2" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="vg">node</span><span class="o">.</span><span class="vg">chipid</span><span class="p">();</span>
</pre></div>
<h4 id="see-also_2"><a name="user-content-see-also_2" href="#see-also_2" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href=""></a></p>
<p><a id="nm_heap"></a></p>
<h2 id="nodeheap"><a name="user-content-nodeheap" href="#nodeheap" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>node.heap()</h2>
<h4 id="description_3"><a name="user-content-description_3" href="#description_3" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>return the remain HEAP size in bytes</p>
<h4 id="syntax_3"><a name="user-content-syntax_3" href="#syntax_3" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>node.heap()</p>
<h4 id="parameters_3"><a name="user-content-parameters_3" href="#parameters_3" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_3"><a name="user-content-returns_3" href="#returns_3" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>number: system heap size left in bytes</p>
<h4 id="example_3"><a name="user-content-example_3" href="#example_3" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">heap_size</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="vg">node</span><span class="o">.</span><span class="vg">heap</span><span class="p">();</span>
</pre></div>
<h4 id="see-also_3"><a name="user-content-see-also_3" href="#see-also_3" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href=""></a></p>
<p><a id="nm_key"></a></p>
<h2 id="nodekey"><a name="user-content-nodekey" href="#nodekey" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>node.key()</h2>
<h4 id="description_4"><a name="user-content-description_4" href="#description_4" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>define button function.</p>
<h4 id="syntax_4"><a name="user-content-syntax_4" href="#syntax_4" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>node.key(type, function())</p>
<h4 id="parameters_4"><a name="user-content-parameters_4" href="#parameters_4" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>type: type is either string &ldquo;long&rdquo; or &ldquo;short&rdquo;. long: press the key for 3 seconds, short: press shortly(less than 3 seconds)<br /><br />
function(): user defined function which is called when key is pressed. If nil, cancling the user defined function.<br /><br />
Default function: long: change LED blinking rate, short: reset chip</p>
<h4 id="returns_4"><a name="user-content-returns_4" href="#returns_4" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_4"><a name="user-content-example_4" href="#example_4" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">node</span><span class="o">.</span><span class="vg">key</span><span class="p">(</span><span class="s2">&quot;long&quot;</span><span class="p">,</span><span class="w"> </span><span class="vg">function</span><span class="p">(){</span><span class="vg">print</span><span class="p">(</span><span class="c1">&#39;hello world&#39;)})</span>
</pre></div>
<h4 id="see-also_4"><a name="user-content-see-also_4" href="#see-also_4" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href=""></a></p>
<p><a id="nm_led"></a></p>
<h2 id="nodeled"><a name="user-content-nodeled" href="#nodeled" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>node.led()</h2>
<h4 id="description_5"><a name="user-content-description_5" href="#description_5" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>setup the on/off time for led</p>
<h4 id="syntax_5"><a name="user-content-syntax_5" href="#syntax_5" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>node.led(low, high)</p>
<h4 id="parameters_5"><a name="user-content-parameters_5" href="#parameters_5" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>Low: LED off time, LED keeps on when low=0. Unit: milliseconds, time resolution: 80~100ms<br /><br />
High: LED off time. Unit: milliseconds, time resolution: 80~100ms</p>
<h4 id="returns_5"><a name="user-content-returns_5" href="#returns_5" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_5"><a name="user-content-example_5" href="#example_5" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">turn</span><span class="w"> </span><span class="vg">led</span><span class="w"> </span><span class="vg">on</span><span class="w"> </span><span class="vg">forever</span><span class="o">.</span>
<span class="w"> </span><span class="vg">node</span><span class="o">.</span><span class="vg">led</span><span class="p">(</span><span class="il">0</span><span class="p">);</span>
</pre></div>
<h4 id="see-also_5"><a name="user-content-see-also_5" href="#see-also_5" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href=""></a></p>
<h1 id="file-module"><a name="user-content-file-module" href="#file-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>file module</h1>
<p><a id="fl_remove"></a></p>
<h2 id="fileremove"><a name="user-content-fileremove" href="#fileremove" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>file.remove()</h2>
<h4 id="description_6"><a name="user-content-description_6" href="#description_6" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>remove file from file system.</p>
<h4 id="syntax_6"><a name="user-content-syntax_6" href="#syntax_6" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>file.remove(filename)</p>
<h4 id="parameters_6"><a name="user-content-parameters_6" href="#parameters_6" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>filename: file to remove</p>
<h4 id="returns_6"><a name="user-content-returns_6" href="#returns_6" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_6"><a name="user-content-example_6" href="#example_6" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">remove</span><span class="w"> </span><span class="s2">&quot;foo.lua&quot;</span><span class="w"> </span><span class="vg">from</span><span class="w"> </span><span class="vg">file</span><span class="w"> </span><span class="vg">system</span><span class="o">.</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">remove</span><span class="p">(</span><span class="s2">&quot;foo.lua&quot;</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_6"><a name="user-content-see-also_6" href="#see-also_6" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#fl_open">file.open()</a><br /><br />
<strong>-</strong> <a href="#fl_close">file.close()</a></p>
<p><a id="fl_open"></a></p>
<h2 id="fileopen"><a name="user-content-fileopen" href="#fileopen" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>file.open()</h2>
<h4 id="description_7"><a name="user-content-description_7" href="#description_7" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>open file.</p>
<h4 id="syntax_7"><a name="user-content-syntax_7" href="#syntax_7" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>file.open(filename, mode)</p>
<h4 id="parameters_7"><a name="user-content-parameters_7" href="#parameters_7" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>filename: file to be opened, directories are not supported<br /><br />
mode:<br /><br />
&ldquo;r&rdquo;: read mode (the default)<br /><br />
&ldquo;w&rdquo;: write mode<br /><br />
&ldquo;a&rdquo;: append mode<br /><br />
&ldquo;r+&rdquo;: update mode, all previous data is preserved<br /><br />
&ldquo;w+&rdquo;: update mode, all previous data is erased<br /><br />
&ldquo;a+&rdquo;: append update mode, previous data is preserved, writing is only allowed at the end of file</p>
<h4 id="returns_7"><a name="user-content-returns_7" href="#returns_7" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_7"><a name="user-content-example_7" href="#example_7" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">open</span><span class="w"> </span><span class="c1">&#39;init.lua&#39;, print the first line.</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">open</span><span class="p">(</span><span class="s2">&quot;init.lua&quot;</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;r&quot;</span><span class="p">)</span>
<span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">file</span><span class="o">.</span><span class="vg">readline</span><span class="p">())</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">close</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_7"><a name="user-content-see-also_7" href="#see-also_7" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#fl_close">file.close()</a><br /><br />
<strong>-</strong> <a href="#fl_readline">file.readline()</a></p>
<p><a id="fl_close"></a></p>
<h2 id="fileclose"><a name="user-content-fileclose" href="#fileclose" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>file.close()</h2>
<h4 id="description_8"><a name="user-content-description_8" href="#description_8" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>close the file.</p>
<h4 id="syntax_8"><a name="user-content-syntax_8" href="#syntax_8" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>file.close()</p>
<h4 id="parameters_8"><a name="user-content-parameters_8" href="#parameters_8" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_8"><a name="user-content-returns_8" href="#returns_8" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_8"><a name="user-content-example_8" href="#example_8" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">open</span><span class="w"> </span><span class="c1">&#39;init.lua&#39;, print the first line.</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">open</span><span class="p">(</span><span class="s2">&quot;init.lua&quot;</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;r&quot;</span><span class="p">)</span>
<span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">file</span><span class="o">.</span><span class="vg">readline</span><span class="p">())</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">close</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_8"><a name="user-content-see-also_8" href="#see-also_8" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#fl_open">file.open()</a><br /><br />
<strong>-</strong> <a href="#fl_readline">file.readline()</a></p>
<p><a id="fl_readline"></a></p>
<h2 id="filereadline"><a name="user-content-filereadline" href="#filereadline" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>file.readline()</h2>
<h4 id="description_9"><a name="user-content-description_9" href="#description_9" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>read one line of file which is opened before.</p>
<h4 id="syntax_9"><a name="user-content-syntax_9" href="#syntax_9" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>file.readline()</p>
<h4 id="parameters_9"><a name="user-content-parameters_9" href="#parameters_9" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_9"><a name="user-content-returns_9" href="#returns_9" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>file content in string, line by line</p>
<h4 id="example_9"><a name="user-content-example_9" href="#example_9" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">print</span><span class="w"> </span><span class="vg">the</span><span class="w"> </span><span class="vg">first</span><span class="w"> </span><span class="vg">line</span><span class="w"> </span><span class="vg">of</span><span class="w"> </span><span class="c1">&#39;init.lua&#39;</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">open</span><span class="p">(</span><span class="s2">&quot;init.lua&quot;</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;r&quot;</span><span class="p">)</span>
<span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">file</span><span class="o">.</span><span class="vg">readline</span><span class="p">())</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">close</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_9"><a name="user-content-see-also_9" href="#see-also_9" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#fl_open">file.open()</a><br /><br />
<strong>-</strong> <a href="#fl_close">file.close()</a></p>
<p><a id="fl_writeline"></a></p>
<h2 id="filewriteline"><a name="user-content-filewriteline" href="#filewriteline" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>file.writeline()</h2>
<h4 id="description_10"><a name="user-content-description_10" href="#description_10" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>write string to file and add a &lsquo;\n&rsquo; at the end.</p>
<h4 id="syntax_10"><a name="user-content-syntax_10" href="#syntax_10" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>file.writeline(string)</p>
<h4 id="parameters_10"><a name="user-content-parameters_10" href="#parameters_10" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>string: content to be write to file</p>
<h4 id="returns_10"><a name="user-content-returns_10" href="#returns_10" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>true: write ok.<br />
nil: there is error</p>
<h4 id="example_10"><a name="user-content-example_10" href="#example_10" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">open</span><span class="w"> </span><span class="c1">&#39;init.lua&#39; in &#39;a+&#39; mode</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">open</span><span class="p">(</span><span class="s2">&quot;init.lua&quot;</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;a+&quot;</span><span class="p">)</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">write</span><span class="w"> </span><span class="c1">&#39;foo bar&#39; to the end of the file</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">writeline</span><span class="p">(</span><span class="c1">&#39;foo bar&#39;)</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">close</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_10"><a name="user-content-see-also_10" href="#see-also_10" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#fl_open">file.open()</a><br /><br />
<strong>-</strong> <a href="#fl_write">file.write()</a></p>
<p><a id="fl_write"></a></p>
<h2 id="filewrite"><a name="user-content-filewrite" href="#filewrite" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>file.write()</h2>
<h4 id="description_11"><a name="user-content-description_11" href="#description_11" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>write string to file.</p>
<h4 id="syntax_11"><a name="user-content-syntax_11" href="#syntax_11" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>file.write(string)</p>
<h4 id="parameters_11"><a name="user-content-parameters_11" href="#parameters_11" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>string: content to be write to file.</p>
<h4 id="returns_11"><a name="user-content-returns_11" href="#returns_11" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>true: write ok.<br />
nil: there is error</p>
<h4 id="example_11"><a name="user-content-example_11" href="#example_11" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">open</span><span class="w"> </span><span class="c1">&#39;init.lua&#39; in &#39;a+&#39; mode</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">open</span><span class="p">(</span><span class="s2">&quot;init.lua&quot;</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;a+&quot;</span><span class="p">)</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">write</span><span class="w"> </span><span class="c1">&#39;foo bar&#39; to the end of the file</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">write</span><span class="p">(</span><span class="c1">&#39;foo bar&#39;)</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">close</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_11"><a name="user-content-see-also_11" href="#see-also_11" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#fl_open">file.open()</a><br /><br />
<strong>-</strong> <a href="#fl_writeline">file.writeline()</a></p>
<p><a id="fl_flush"></a></p>
<h2 id="fileflush"><a name="user-content-fileflush" href="#fileflush" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>file.flush()</h2>
<h4 id="description_12"><a name="user-content-description_12" href="#description_12" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>flush to file.</p>
<h4 id="syntax_12"><a name="user-content-syntax_12" href="#syntax_12" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>file.flush()</p>
<h4 id="parameters_12"><a name="user-content-parameters_12" href="#parameters_12" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_12"><a name="user-content-returns_12" href="#returns_12" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_12"><a name="user-content-example_12" href="#example_12" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">open</span><span class="w"> </span><span class="c1">&#39;init.lua&#39; in &#39;a+&#39; mode</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">open</span><span class="p">(</span><span class="s2">&quot;init.lua&quot;</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;a+&quot;</span><span class="p">)</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">write</span><span class="w"> </span><span class="c1">&#39;foo bar&#39; to the end of the file</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">write</span><span class="p">(</span><span class="c1">&#39;foo bar&#39;)</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">flush</span><span class="p">()</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">close</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_12"><a name="user-content-see-also_12" href="#see-also_12" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#fl_open">file.open()</a><br /><br />
<strong>-</strong> <a href="#fl_writeline">file.writeline()</a></p>
<p><a id="fl_seek"></a></p>
<h2 id="fileseek"><a name="user-content-fileseek" href="#fileseek" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>file.seek()</h2>
<h4 id="description_13"><a name="user-content-description_13" href="#description_13" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>Sets and gets the file position, measured from the beginning of the file, to the position given by offset plus a base specified by the string whence.</p>
<h4 id="syntax_13"><a name="user-content-syntax_13" href="#syntax_13" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>file.seek(whence, offset)</p>
<h4 id="parameters_13"><a name="user-content-parameters_13" href="#parameters_13" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>whence:<br /><br />
&ldquo;set&rdquo;: base is position 0 (beginning of the file);<br /><br />
&ldquo;cur&rdquo;: base is current position;(default value)<br /><br />
&ldquo;end&rdquo;: base is end of file;<br /><br />
offset: default 0</p>
<h4 id="returns_13"><a name="user-content-returns_13" href="#returns_13" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>success: returns the final file position<br /><br />
fail: returns nil</p>
<h4 id="example_13"><a name="user-content-example_13" href="#example_13" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">open</span><span class="w"> </span><span class="c1">&#39;init.lua&#39; in &#39;a+&#39; mode</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">open</span><span class="p">(</span><span class="s2">&quot;init.lua&quot;</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;a+&quot;</span><span class="p">)</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">write</span><span class="w"> </span><span class="c1">&#39;foo bar&#39; to the end of the file</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">write</span><span class="p">(</span><span class="c1">&#39;foo bar&#39;)</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">flush</span><span class="p">()</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">seek</span><span class="p">(</span><span class="s2">&quot;set&quot;</span><span class="p">)</span>
<span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">file</span><span class="o">.</span><span class="vg">readline</span><span class="p">())</span>
<span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">close</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_13"><a name="user-content-see-also_13" href="#see-also_13" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#fl_open">file.open()</a><br /><br />
<strong>-</strong> <a href="#fl_writeline">file.writeline()</a></p>
<p><a id="fl_list"></a></p>
<h2 id="filelist"><a name="user-content-filelist" href="#filelist" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>file.list()</h2>
<h4 id="description_14"><a name="user-content-description_14" href="#description_14" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>list all files.</p>
<h4 id="syntax_14"><a name="user-content-syntax_14" href="#syntax_14" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>file.list()</p>
<h4 id="parameters_14"><a name="user-content-parameters_14" href="#parameters_14" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_14"><a name="user-content-returns_14" href="#returns_14" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>a lua table which contains the {file name: file size} pairs</p>
<h4 id="example_14"><a name="user-content-example_14" href="#example_14" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">l</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="vg">file</span><span class="o">.</span><span class="vg">list</span><span class="p">();</span>
<span class="w"> </span><span class="vg">for</span><span class="w"> </span><span class="vg">k</span><span class="p">,</span><span class="vg">v</span><span class="w"> </span><span class="vg">in</span><span class="w"> </span><span class="vg">l</span><span class="w"> </span><span class="vg">do</span>
<span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="s2">&quot;name:&quot;</span><span class="o">..</span><span class="vg">k</span><span class="o">..</span><span class="s2">&quot;, size:&quot;</span><span class="o">..</span><span class="vg">v</span><span class="p">)</span>
<span class="w"> </span><span class="vg">end</span>
</pre></div>
<h4 id="see-also_14"><a name="user-content-see-also_14" href="#see-also_14" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#fl_remove">file.remove()</a></p>
<h1 id="wifi-module"><a name="user-content-wifi-module" href="#wifi-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi module</h1>
<h2 id="constant"><a name="user-content-constant" href="#constant" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>CONSTANT</h2>
<p>wifi.STATION, wifi.SOFTAP, wifi.STATIONAP</p>
<p><a id="wf_setmode"></a></p>
<h2 id="wifisetmodemode"><a name="user-content-wifisetmodemode" href="#wifisetmodemode" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.setmode(mode)</h2>
<h4 id="description_15"><a name="user-content-description_15" href="#description_15" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>setup wifi operation mode.</p>
<h4 id="syntax_15"><a name="user-content-syntax_15" href="#syntax_15" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.setmode(mode)</p>
<h4 id="parameters_15"><a name="user-content-parameters_15" href="#parameters_15" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>mode: value should be: wifi.STATION, wifi.SOFTAP or wifi.STATIONAP</p>
<h4 id="returns_15"><a name="user-content-returns_15" href="#returns_15" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>current mode after setup</p>
<h4 id="example_15"><a name="user-content-example_15" href="#example_15" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">wifi</span><span class="o">.</span><span class="vg">setmode</span><span class="p">(</span><span class="vg">wifi</span><span class="o">.</span><span class="vg">STATION</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_15"><a name="user-content-see-also_15" href="#see-also_15" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#wf_getmode">wifi.getmode()</a></p>
<p><a id="wf_getmode"></a></p>
<h2 id="wifigetmodemode"><a name="user-content-wifigetmodemode" href="#wifigetmodemode" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.getmode(mode)</h2>
<h4 id="description_16"><a name="user-content-description_16" href="#description_16" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>get wifi operation mode.</p>
<h4 id="syntax_16"><a name="user-content-syntax_16" href="#syntax_16" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.getmode()</p>
<h4 id="parameters_16"><a name="user-content-parameters_16" href="#parameters_16" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_16"><a name="user-content-returns_16" href="#returns_16" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>wifi operation mode</p>
<h4 id="example_16"><a name="user-content-example_16" href="#example_16" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">wifi</span><span class="o">.</span><span class="vg">getmode</span><span class="p">())</span>
</pre></div>
<h4 id="see-also_16"><a name="user-content-see-also_16" href="#see-also_16" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#wf_setmode">wifi.setmode()</a></p>
<p><a id="wf_startsmart"></a></p>
<h2 id="wifistartsmart"><a name="user-content-wifistartsmart" href="#wifistartsmart" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.startsmart()</h2>
<h4 id="description_17"><a name="user-content-description_17" href="#description_17" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>starts to auto configuration, if success set up ssid and pwd automatically .</p>
<h4 id="syntax_17"><a name="user-content-syntax_17" href="#syntax_17" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.startsmart(channel, function succeed_callback())</p>
<h4 id="parameters_17"><a name="user-content-parameters_17" href="#parameters_17" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>channel: 1~13, startup channel for searching, if nil, default to 6. 20 seconds for each channel.<br /><br />
succeed_callback: callback function called after configuration, which is called when got password and connected to AP.</p>
<h4 id="returns_17"><a name="user-content-returns_17" href="#returns_17" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_17"><a name="user-content-example_17" href="#example_17" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">wifi</span><span class="o">.</span><span class="vg">startsmart</span><span class="p">(</span><span class="il">6</span><span class="p">,</span><span class="w"> </span><span class="vg">cb</span><span class="p">())</span>
</pre></div>
<h4 id="see-also_17"><a name="user-content-see-also_17" href="#see-also_17" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#wf_stopsmart">wifi.stopsmart()</a></p>
<p><a id="wf_stopsmart"></a></p>
<h2 id="wifistopsmart"><a name="user-content-wifistopsmart" href="#wifistopsmart" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.stopsmart()</h2>
<h4 id="description_18"><a name="user-content-description_18" href="#description_18" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>stop the configuring process.</p>
<h4 id="syntax_18"><a name="user-content-syntax_18" href="#syntax_18" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.stopsmart()</p>
<h4 id="parameters_18"><a name="user-content-parameters_18" href="#parameters_18" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_18"><a name="user-content-returns_18" href="#returns_18" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_18"><a name="user-content-example_18" href="#example_18" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">wifi</span><span class="o">.</span><span class="vg">stopsmart</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_18"><a name="user-content-see-also_18" href="#see-also_18" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#wf_startsmart">wifi.startsmart()</a></p>
<h1 id="wifista-module"><a name="user-content-wifista-module" href="#wifista-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.sta module</h1>
<p><a id="ws_config"></a></p>
<h2 id="wifistaconfig"><a name="user-content-wifistaconfig" href="#wifistaconfig" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.sta.config()</h2>
<h4 id="description_19"><a name="user-content-description_19" href="#description_19" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>set ssid and password in station mode.</p>
<h4 id="syntax_19"><a name="user-content-syntax_19" href="#syntax_19" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.sta.config(ssid, password)</p>
<h4 id="parameters_19"><a name="user-content-parameters_19" href="#parameters_19" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>ssid: string which is less than 32 bytes.<br /><br />
password: string which is less than 64 bytes.</p>
<h4 id="returns_19"><a name="user-content-returns_19" href="#returns_19" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_19"><a name="user-content-example_19" href="#example_19" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">wifi</span><span class="o">.</span><span class="vg">sta</span><span class="o">.</span><span class="vg">config</span><span class="p">(</span><span class="s2">&quot;myssid&quot;</span><span class="p">,</span><span class="s2">&quot;mypassword&quot;</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_19"><a name="user-content-see-also_19" href="#see-also_19" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ws_connect">wifi.sta.connect()</a><br /><br />
<strong>-</strong> <a href="#ws_disconnect">wifi.sta.disconnect()</a></p>
<p><a id="ws_connect"></a></p>
<h2 id="wifistaconnect"><a name="user-content-wifistaconnect" href="#wifistaconnect" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.sta.connect()</h2>
<h4 id="description_20"><a name="user-content-description_20" href="#description_20" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>connect to AP in station mode.</p>
<h4 id="syntax_20"><a name="user-content-syntax_20" href="#syntax_20" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.sta.connect()</p>
<h4 id="parameters_20"><a name="user-content-parameters_20" href="#parameters_20" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_20"><a name="user-content-returns_20" href="#returns_20" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_20"><a name="user-content-example_20" href="#example_20" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">wifi</span><span class="o">.</span><span class="vg">sta</span><span class="o">.</span><span class="vg">connect</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_20"><a name="user-content-see-also_20" href="#see-also_20" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ws_disconnect">wifi.sta.disconnect()</a><br /><br />
<strong>-</strong> <a href="#ws_config">wifi.sta.config()</a></p>
<p><a id="ws_disconnect"></a></p>
<h2 id="wifistadisconnect"><a name="user-content-wifistadisconnect" href="#wifistadisconnect" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.sta.disconnect()</h2>
<h4 id="description_21"><a name="user-content-description_21" href="#description_21" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>disconnect from AP in station mode.</p>
<h4 id="syntax_21"><a name="user-content-syntax_21" href="#syntax_21" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.sta.disconnect()</p>
<h4 id="parameters_21"><a name="user-content-parameters_21" href="#parameters_21" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_21"><a name="user-content-returns_21" href="#returns_21" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_21"><a name="user-content-example_21" href="#example_21" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">wifi</span><span class="o">.</span><span class="vg">sta</span><span class="o">.</span><span class="vg">disconnect</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_21"><a name="user-content-see-also_21" href="#see-also_21" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ws_config">wifi.sta.config()</a><br /><br />
<strong>-</strong> <a href="#ws_connect">wifi.sta.connect()</a></p>
<p><a id="ws_autoconnect"></a></p>
<h2 id="wifistaautoconnect"><a name="user-content-wifistaautoconnect" href="#wifistaautoconnect" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.sta.autoconnect()</h2>
<h4 id="description_22"><a name="user-content-description_22" href="#description_22" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>auto connect to AP in station mode.</p>
<h4 id="syntax_22"><a name="user-content-syntax_22" href="#syntax_22" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.sta.autoconnect(auto)</p>
<h4 id="parameters_22"><a name="user-content-parameters_22" href="#parameters_22" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>auto: 0 to disable auto connecting. 1 to enable auto connecting</p>
<h4 id="returns_22"><a name="user-content-returns_22" href="#returns_22" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_22"><a name="user-content-example_22" href="#example_22" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">wifi</span><span class="o">.</span><span class="vg">sta</span><span class="o">.</span><span class="vg">autoconnect</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_22"><a name="user-content-see-also_22" href="#see-also_22" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ws_config">wifi.sta.config()</a><br /><br />
<strong>-</strong> <a href="#ws_connect">wifi.sta.connect()</a><br /><br />
<strong>-</strong> <a href="#ws_disconnect">wifi.sta.disconnect()</a></p>
<p><a id="ws_getip"></a></p>
<h2 id="wifistagetip"><a name="user-content-wifistagetip" href="#wifistagetip" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.sta.getip()</h2>
<h4 id="description_23"><a name="user-content-description_23" href="#description_23" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>get ip address in station mode.</p>
<h4 id="syntax_23"><a name="user-content-syntax_23" href="#syntax_23" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.sta.getip()</p>
<h4 id="parameters_23"><a name="user-content-parameters_23" href="#parameters_23" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_23"><a name="user-content-returns_23" href="#returns_23" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>ip address in string, for example:&rdquo;192.168.0.111&rdquo;</p>
<h4 id="example_23"><a name="user-content-example_23" href="#example_23" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">print</span><span class="w"> </span><span class="vg">current</span><span class="w"> </span><span class="vg">ip</span>
<span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">wifi</span><span class="o">.</span><span class="vg">sta</span><span class="o">.</span><span class="vg">getip</span><span class="p">())</span>
</pre></div>
<h4 id="see-also_23"><a name="user-content-see-also_23" href="#see-also_23" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ws_getmac">wifi.sta.getmac()</a></p>
<p><a id="ws_getmac"></a></p>
<h2 id="wifistagetmac"><a name="user-content-wifistagetmac" href="#wifistagetmac" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.sta.getmac()</h2>
<h4 id="description_24"><a name="user-content-description_24" href="#description_24" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>get mac address in station mode.</p>
<h4 id="syntax_24"><a name="user-content-syntax_24" href="#syntax_24" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.sta.getmac()</p>
<h4 id="parameters_24"><a name="user-content-parameters_24" href="#parameters_24" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_24"><a name="user-content-returns_24" href="#returns_24" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>mac address in string, for example:&rdquo;18-33-44-FE-55-BB&rdquo;</p>
<h4 id="example_24"><a name="user-content-example_24" href="#example_24" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">print</span><span class="w"> </span><span class="vg">current</span><span class="w"> </span><span class="vg">mac</span><span class="w"> </span><span class="vg">address</span>
<span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">wifi</span><span class="o">.</span><span class="vg">sta</span><span class="o">.</span><span class="vg">getmac</span><span class="p">())</span>
</pre></div>
<h4 id="see-also_24"><a name="user-content-see-also_24" href="#see-also_24" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ws_getip">wifi.sta.getip()</a></p>
<h1 id="wifiap-module"><a name="user-content-wifiap-module" href="#wifiap-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.ap module</h1>
<p><a id="wa_config"></a></p>
<h2 id="wifiapconfig"><a name="user-content-wifiapconfig" href="#wifiapconfig" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.ap.config()</h2>
<h4 id="description_25"><a name="user-content-description_25" href="#description_25" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>set ssid and password in ap mode.</p>
<h4 id="syntax_25"><a name="user-content-syntax_25" href="#syntax_25" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.ap.config(cfg)</p>
<h4 id="parameters_25"><a name="user-content-parameters_25" href="#parameters_25" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>cfg: lua table to setup ap.</p>
<h4 id="example_25"><a name="user-content-example_25" href="#example_25" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example:</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">cfg</span><span class="o">=</span><span class="p">{}</span>
<span class="w"> </span><span class="vg">cfg</span><span class="o">.</span><span class="vg">ssid</span><span class="o">=</span><span class="s2">&quot;myssid&quot;</span>
<span class="w"> </span><span class="vg">cfg</span><span class="o">.</span><span class="vg">pwd</span><span class="o">=</span><span class="s2">&quot;mypwd&quot;</span>
<span class="w"> </span><span class="vg">wifi</span><span class="o">.</span><span class="vg">ap</span><span class="o">.</span><span class="vg">setconfig</span><span class="p">(</span><span class="vg">cfg</span><span class="p">)</span>
</pre></div>
<h4 id="returns_25"><a name="user-content-returns_25" href="#returns_25" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_26"><a name="user-content-example_26" href="#example_26" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">wifi</span><span class="o">.</span><span class="vg">ap</span><span class="o">.</span><span class="vg">config</span><span class="p">(</span><span class="vg">ssid</span><span class="p">,</span><span class="w"> </span><span class="c1">&#39;password&#39;)</span>
</pre></div>
<h4 id="see-also_25"><a name="user-content-see-also_25" href="#see-also_25" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href=""></a></p>
<p><a id="wa_getip"></a></p>
<h2 id="wifiapgetip"><a name="user-content-wifiapgetip" href="#wifiapgetip" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.ap.getip()</h2>
<h4 id="description_26"><a name="user-content-description_26" href="#description_26" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>get ip in ap mode.</p>
<h4 id="syntax_26"><a name="user-content-syntax_26" href="#syntax_26" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.ap.getip()</p>
<h4 id="parameters_26"><a name="user-content-parameters_26" href="#parameters_26" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_26"><a name="user-content-returns_26" href="#returns_26" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>ip address in string, for example:&rdquo;192.168.0.111&rdquo;</p>
<h4 id="example_27"><a name="user-content-example_27" href="#example_27" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">wifi</span><span class="o">.</span><span class="vg">ap</span><span class="o">.</span><span class="vg">getip</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_26"><a name="user-content-see-also_26" href="#see-also_26" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#wa_getmac">wifi.ap.getmac()</a></p>
<p><a id="wa_getmac"></a></p>
<h2 id="wifiapgetmac"><a name="user-content-wifiapgetmac" href="#wifiapgetmac" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>wifi.ap.getmac()</h2>
<h4 id="description_27"><a name="user-content-description_27" href="#description_27" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>get mac address in ap mode.</p>
<h4 id="syntax_27"><a name="user-content-syntax_27" href="#syntax_27" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>wifi.ap.getmac()</p>
<h4 id="parameters_27"><a name="user-content-parameters_27" href="#parameters_27" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_27"><a name="user-content-returns_27" href="#returns_27" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>mac address in string, for example:&rdquo;1A-33-44-FE-55-BB&rdquo;</p>
<h4 id="example_28"><a name="user-content-example_28" href="#example_28" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">wifi</span><span class="o">.</span><span class="vg">ap</span><span class="o">.</span><span class="vg">getmac</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_27"><a name="user-content-see-also_27" href="#see-also_27" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#wa_getip">wifi.ap.getip()</a></p>
<h1 id="timer-module"><a name="user-content-timer-module" href="#timer-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>timer module</h1>
<p><a id="tm_delay"></a></p>
<h2 id="tmrdelay"><a name="user-content-tmrdelay" href="#tmrdelay" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>tmr.delay()</h2>
<h4 id="description_28"><a name="user-content-description_28" href="#description_28" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>delay us micro seconds.</p>
<h4 id="syntax_28"><a name="user-content-syntax_28" href="#syntax_28" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>tmr.dealy(us)</p>
<h4 id="parameters_28"><a name="user-content-parameters_28" href="#parameters_28" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>us: delay time in micro second</p>
<h4 id="returns_28"><a name="user-content-returns_28" href="#returns_28" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_29"><a name="user-content-example_29" href="#example_29" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">delay</span><span class="w"> </span><span class="il">100</span><span class="vg">us</span>
<span class="w"> </span><span class="vg">tmr</span><span class="o">.</span><span class="vg">delay</span><span class="p">(</span><span class="il">100</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_28"><a name="user-content-see-also_28" href="#see-also_28" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#tm_now">tmr.now()</a></p>
<p><a id="tm_now"></a></p>
<h2 id="tmrnow"><a name="user-content-tmrnow" href="#tmrnow" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>tmr.now()</h2>
<h4 id="description_29"><a name="user-content-description_29" href="#description_29" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>return the current value of system counter: uint32, us.</p>
<h4 id="syntax_29"><a name="user-content-syntax_29" href="#syntax_29" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>tmr.now()</p>
<h4 id="parameters_29"><a name="user-content-parameters_29" href="#parameters_29" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_29"><a name="user-content-returns_29" href="#returns_29" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>uint32: value of counter</p>
<h4 id="example_30"><a name="user-content-example_30" href="#example_30" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">print</span><span class="w"> </span><span class="vg">current</span><span class="w"> </span><span class="vg">value</span><span class="w"> </span><span class="vg">of</span><span class="w"> </span><span class="vg">counter</span>
<span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">tmr</span><span class="o">.</span><span class="vg">now</span><span class="p">())</span>
</pre></div>
<h4 id="see-also_29"><a name="user-content-see-also_29" href="#see-also_29" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#tm_delay">tmr.delay()</a></p>
<p><a id="tm_alarm"></a></p>
<h2 id="tmralarm"><a name="user-content-tmralarm" href="#tmralarm" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>tmr.alarm()</h2>
<h4 id="description_30"><a name="user-content-description_30" href="#description_30" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>alarm time.</p>
<h4 id="syntax_30"><a name="user-content-syntax_30" href="#syntax_30" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>tmr.alarm(interval, repeat, function do())</p>
<h4 id="parameters_30"><a name="user-content-parameters_30" href="#parameters_30" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>Interval: alarm time, unit: millisecond<br /><br />
repeat: 0 - one time alarm, 1 - repeat<br /><br />
function do(): callback function for alarm timed out</p>
<h4 id="returns_30"><a name="user-content-returns_30" href="#returns_30" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_31"><a name="user-content-example_31" href="#example_31" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">print</span><span class="w"> </span><span class="s2">&quot;hello world&quot;</span><span class="w"> </span><span class="vg">every</span><span class="w"> </span><span class="il">1000</span><span class="vg">ms</span>
<span class="w"> </span><span class="vg">tmr</span><span class="o">.</span><span class="vg">alarm</span><span class="p">(</span><span class="il">1000</span><span class="p">,</span><span class="w"> </span><span class="il">1</span><span class="p">,</span><span class="w"> </span><span class="vg">function</span><span class="p">()</span><span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="s2">&quot;hello world&quot;</span><span class="p">)</span><span class="w"> </span><span class="vg">end</span><span class="w"> </span><span class="p">)</span>
</pre></div>
<h4 id="see-also_30"><a name="user-content-see-also_30" href="#see-also_30" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#tm_now">tmr.now()</a></p>
<p><a id="tm_stop"></a></p>
<h2 id="tmrstop"><a name="user-content-tmrstop" href="#tmrstop" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>tmr.stop()</h2>
<h4 id="description_31"><a name="user-content-description_31" href="#description_31" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>stop alarm.<br /><br />
<strong>-Note:</strong> only one alarm is allowed, the previous one would be replaced if tmr.alarm() called again before tmr.stop().</p>
<h4 id="syntax_31"><a name="user-content-syntax_31" href="#syntax_31" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>tmr.stop()</p>
<h4 id="parameters_31"><a name="user-content-parameters_31" href="#parameters_31" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil.</p>
<h4 id="returns_31"><a name="user-content-returns_31" href="#returns_31" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_32"><a name="user-content-example_32" href="#example_32" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">print</span><span class="w"> </span><span class="s2">&quot;hello world&quot;</span><span class="w"> </span><span class="vg">every</span><span class="w"> </span><span class="il">1000</span><span class="vg">ms</span>
<span class="w"> </span><span class="vg">tmr</span><span class="o">.</span><span class="vg">alarm</span><span class="p">(</span><span class="il">1000</span><span class="p">,</span><span class="w"> </span><span class="il">1</span><span class="p">,</span><span class="w"> </span><span class="vg">function</span><span class="p">()</span><span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="s2">&quot;hello world&quot;</span><span class="p">)</span><span class="w"> </span><span class="vg">end</span><span class="w"> </span><span class="p">)</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">something</span><span class="w"> </span><span class="vg">else</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">stop</span><span class="w"> </span><span class="vg">alarm</span>
<span class="w"> </span><span class="vg">tmr</span><span class="o">.</span><span class="vg">stop</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_31"><a name="user-content-see-also_31" href="#see-also_31" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#tm_now">tmr.now()</a></p>
<h1 id="gpio-module"><a name="user-content-gpio-module" href="#gpio-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>GPIO module</h1>
<h2 id="constant_1"><a name="user-content-constant_1" href="#constant_1" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>CONSTANT</h2>
<p>gpio.OUTPUT, gpio.INPUT, gpio.INT, gpio.HIGH, gpio.LOW</p>
<p><a id="io_mode"></a></p>
<h2 id="gpiomode"><a name="user-content-gpiomode" href="#gpiomode" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>gpio.mode()</h2>
<h4 id="description_32"><a name="user-content-description_32" href="#description_32" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>initialize pin to GPIO mode, set the pin in/out mode.</p>
<h4 id="syntax_32"><a name="user-content-syntax_32" href="#syntax_32" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>gpio.mode(pin, mode)</p>
<h4 id="parameters_32"><a name="user-content-parameters_32" href="#parameters_32" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index<br /><br />
mode: gpio.OUTPUT or gpio.INPUT, or gpio.INT(interrupt mode)</p>
<h4 id="returns_32"><a name="user-content-returns_32" href="#returns_32" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_33"><a name="user-content-example_33" href="#example_33" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">set</span><span class="w"> </span><span class="vg">gpio</span><span class="w"> </span><span class="il">0</span><span class="w"> </span><span class="vg">as</span><span class="w"> </span><span class="vg">output</span><span class="o">.</span>
<span class="w"> </span><span class="vg">gpio</span><span class="o">.</span><span class="vg">mode</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="w"> </span><span class="vg">gpio</span><span class="o">.</span><span class="k">OUTPUT</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_32"><a name="user-content-see-also_32" href="#see-also_32" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#io_read">gpio.read()</a></p>
<p><a id="io_read"></a></p>
<h2 id="gpioread"><a name="user-content-gpioread" href="#gpioread" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>gpio.read()</h2>
<h4 id="description_33"><a name="user-content-description_33" href="#description_33" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>read pin value.</p>
<h4 id="syntax_33"><a name="user-content-syntax_33" href="#syntax_33" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>gpio.read(pin)</p>
<h4 id="parameters_33"><a name="user-content-parameters_33" href="#parameters_33" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index</p>
<h4 id="returns_33"><a name="user-content-returns_33" href="#returns_33" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>number:0 - low, 1 - high</p>
<h4 id="example_34"><a name="user-content-example_34" href="#example_34" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">read</span><span class="w"> </span><span class="vg">value</span><span class="w"> </span><span class="vg">of</span><span class="w"> </span><span class="vg">gpio</span><span class="w"> </span><span class="il">0</span><span class="o">.</span>
<span class="w"> </span><span class="vg">gpio</span><span class="o">.</span><span class="vg">read</span><span class="p">(</span><span class="il">0</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_33"><a name="user-content-see-also_33" href="#see-also_33" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#io_mode">gpio.mode()</a></p>
<p><a id="io_write"></a></p>
<h2 id="gpiowrite"><a name="user-content-gpiowrite" href="#gpiowrite" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>gpio.write()</h2>
<h4 id="description_34"><a name="user-content-description_34" href="#description_34" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>set pin value.</p>
<h4 id="syntax_34"><a name="user-content-syntax_34" href="#syntax_34" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>gpio.write(pin)</p>
<h4 id="parameters_34"><a name="user-content-parameters_34" href="#parameters_34" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index<br /><br />
level: gpio.HIGH or gpio.LOW</p>
<h4 id="returns_34"><a name="user-content-returns_34" href="#returns_34" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_35"><a name="user-content-example_35" href="#example_35" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">set</span><span class="w"> </span><span class="vg">pin</span><span class="w"> </span><span class="vg">index</span><span class="w"> </span><span class="il">1</span><span class="w"> </span><span class="vg">to</span><span class="w"> </span><span class="vg">GPIO</span><span class="w"> </span><span class="vg">mode</span><span class="p">,</span><span class="w"> </span><span class="vg">and</span><span class="w"> </span><span class="vg">set</span><span class="w"> </span><span class="vg">the</span><span class="w"> </span><span class="vg">pin</span><span class="w"> </span><span class="vg">to</span><span class="w"> </span><span class="vg">high</span><span class="o">.</span>
<span class="w"> </span><span class="vg">pin</span><span class="o">=</span><span class="il">1</span>
<span class="w"> </span><span class="vg">gpio</span><span class="o">.</span><span class="vg">mode</span><span class="p">(</span><span class="vg">pin</span><span class="p">,</span><span class="w"> </span><span class="vg">gpio</span><span class="o">.</span><span class="k">OUTPUT</span><span class="p">)</span>
<span class="w"> </span><span class="vg">gpio</span><span class="o">.</span><span class="vg">write</span><span class="p">(</span><span class="vg">pin</span><span class="p">,</span><span class="w"> </span><span class="vg">gpio</span><span class="o">.</span><span class="vg">HIGH</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_34"><a name="user-content-see-also_34" href="#see-also_34" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#io_mode">gpio.mode()</a><br /><br />
<strong>-</strong> <a href="#io_read">gpio.read()</a></p>
<p><a id="io_trig"></a></p>
<h2 id="gpiotrig"><a name="user-content-gpiotrig" href="#gpiotrig" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>gpio.trig()</h2>
<h4 id="description_35"><a name="user-content-description_35" href="#description_35" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>set the interrupt callback function for pin.</p>
<h4 id="syntax_35"><a name="user-content-syntax_35" href="#syntax_35" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>gpio.trig(pin, type, function(level))</p>
<h4 id="parameters_35"><a name="user-content-parameters_35" href="#parameters_35" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index<br /><br />
type: &ldquo;up&rdquo;, &ldquo;down&rdquo;, &ldquo;both&rdquo;, &ldquo;low&rdquo;, &ldquo;high&rdquo;, which represent rising edge, falling edge, both edge, low level, high level trig mode separately.<br /><br />
function(level): callback function when triggered. The gpio level is the param. Use previous callback function if undefined here.</p>
<h4 id="returns_35"><a name="user-content-returns_35" href="#returns_35" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_36"><a name="user-content-example_36" href="#example_36" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">use</span><span class="w"> </span><span class="vg">pin</span><span class="w"> </span><span class="il">0</span><span class="w"> </span><span class="vg">as</span><span class="w"> </span><span class="vg">the</span><span class="w"> </span><span class="vg">input</span><span class="w"> </span><span class="vg">pulse</span><span class="w"> </span><span class="vg">width</span><span class="w"> </span><span class="vg">counter</span>
<span class="w"> </span><span class="vg">pulse0</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="il">0</span>
<span class="w"> </span><span class="vg">du</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="il">0</span>
<span class="w"> </span><span class="vg">gpio</span><span class="o">.</span><span class="vg">mode</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="vg">gpio</span><span class="o">.</span><span class="kr">INT</span><span class="p">)</span>
<span class="w"> </span><span class="vg">function</span><span class="w"> </span><span class="vg">pin0cb</span><span class="p">(</span><span class="vg">level</span><span class="p">)</span>
<span class="w"> </span><span class="vg">du</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="vg">tmr</span><span class="o">.</span><span class="vg">now</span><span class="p">()</span><span class="w"> </span><span class="err"></span><span class="w"> </span><span class="vg">pulse0</span>
<span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">du</span><span class="p">)</span>
<span class="w"> </span><span class="vg">pulse0</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="vg">tmr</span><span class="o">.</span><span class="vg">now</span><span class="p">()</span>
<span class="w"> </span><span class="vg">if</span><span class="w"> </span><span class="vg">level</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="il">1</span><span class="w"> </span><span class="vg">then</span><span class="w"> </span><span class="vg">gpio</span><span class="o">.</span><span class="vg">trig</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;down &quot;</span><span class="p">)</span><span class="w"> </span><span class="vg">else</span><span class="w"> </span><span class="vg">gpio</span><span class="o">.</span><span class="vg">trig</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;up &quot;</span><span class="p">)</span><span class="w"> </span><span class="vg">end</span>
<span class="w"> </span><span class="vg">end</span>
<span class="w"> </span><span class="vg">gpio</span><span class="o">.</span><span class="vg">trig</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;down &quot;</span><span class="p">,</span><span class="vg">pin0cb</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_35"><a name="user-content-see-also_35" href="#see-also_35" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#io_mode">gpio.mode()</a><br /><br />
<strong>-</strong> <a href="#io_write">gpio.write()</a></p>
<h1 id="pwm-module"><a name="user-content-pwm-module" href="#pwm-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>PWM module</h1>
<p><a id="pw_setup"></a></p>
<h2 id="pwmsetup"><a name="user-content-pwmsetup" href="#pwmsetup" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>pwm.setup()</h2>
<h4 id="description_36"><a name="user-content-description_36" href="#description_36" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>set pin to PWM mode. Only 3 pins can be set to PWM mode at the most.</p>
<h4 id="syntax_36"><a name="user-content-syntax_36" href="#syntax_36" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>pwm.setup(pin, clock, duty)</p>
<h4 id="parameters_36"><a name="user-content-parameters_36" href="#parameters_36" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index<br /><br />
clock: 1~500, pwm frequency<br /><br />
duty: 0~100, pwm duty cycle in percentage</p>
<h4 id="returns_36"><a name="user-content-returns_36" href="#returns_36" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_37"><a name="user-content-example_37" href="#example_37" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">set</span><span class="w"> </span><span class="vg">pin</span><span class="w"> </span><span class="vg">index</span><span class="w"> </span><span class="il">0</span><span class="w"> </span><span class="vg">as</span><span class="w"> </span><span class="vg">pwm</span><span class="w"> </span><span class="vg">output</span><span class="p">,</span><span class="w"> </span><span class="vg">frequency</span><span class="w"> </span><span class="vg">is</span><span class="w"> </span><span class="il">100</span><span class="vg">Hz</span><span class="p">,</span><span class="w"> </span><span class="vg">duty</span><span class="w"> </span><span class="vg">cycle</span><span class="w"> </span><span class="vg">is</span><span class="w"> </span><span class="il">50-50</span><span class="o">.</span>
<span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">setup</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="w"> </span><span class="il">100</span><span class="p">,</span><span class="w"> </span><span class="il">50</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_36"><a name="user-content-see-also_36" href="#see-also_36" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#pw_start">pwm.start()</a></p>
<p><a id="pw_close"></a></p>
<h2 id="pwmclose"><a name="user-content-pwmclose" href="#pwmclose" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>pwm.close()</h2>
<h4 id="description_37"><a name="user-content-description_37" href="#description_37" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>quit PWM mode for specified pin.</p>
<h4 id="syntax_37"><a name="user-content-syntax_37" href="#syntax_37" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>pwm.close(pin)</p>
<h4 id="parameters_37"><a name="user-content-parameters_37" href="#parameters_37" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index</p>
<h4 id="returns_37"><a name="user-content-returns_37" href="#returns_37" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_38"><a name="user-content-example_38" href="#example_38" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">close</span><span class="p">(</span><span class="il">0</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_37"><a name="user-content-see-also_37" href="#see-also_37" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#pw_start">pwm.start()</a></p>
<p><a id="pw_start"></a></p>
<h2 id="pwmstart"><a name="user-content-pwmstart" href="#pwmstart" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>pwm.start()</h2>
<h4 id="description_38"><a name="user-content-description_38" href="#description_38" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>pwm starts, you can detect the waveform on the gpio.</p>
<h4 id="syntax_38"><a name="user-content-syntax_38" href="#syntax_38" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>pwm.start(pin)</p>
<h4 id="parameters_38"><a name="user-content-parameters_38" href="#parameters_38" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index</p>
<h4 id="returns_38"><a name="user-content-returns_38" href="#returns_38" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_39"><a name="user-content-example_39" href="#example_39" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">start</span><span class="p">(</span><span class="il">0</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_38"><a name="user-content-see-also_38" href="#see-also_38" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#pw_stop">pwm.stop()</a></p>
<p><a id="pw_stop"></a></p>
<h2 id="pwmstop"><a name="user-content-pwmstop" href="#pwmstop" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>pwm.stop()</h2>
<h4 id="description_39"><a name="user-content-description_39" href="#description_39" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>pause the output of PWM waveform.</p>
<h4 id="syntax_39"><a name="user-content-syntax_39" href="#syntax_39" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>pwm.stop(pin)</p>
<h4 id="parameters_39"><a name="user-content-parameters_39" href="#parameters_39" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index</p>
<h4 id="returns_39"><a name="user-content-returns_39" href="#returns_39" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_40"><a name="user-content-example_40" href="#example_40" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">stop</span><span class="p">(</span><span class="il">0</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_39"><a name="user-content-see-also_39" href="#see-also_39" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#pw_start">pwm.start()</a></p>
<p><a id="pw_setclock"></a></p>
<h2 id="pwmsetclock"><a name="user-content-pwmsetclock" href="#pwmsetclock" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>pwm.setclock()</h2>
<h4 id="description_40"><a name="user-content-description_40" href="#description_40" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>set pwm frequency for pin.<br /><br />
<strong>-Note:</strong> setup pwm frequency will synchronously change others if there are any. Only one PWM frequency can be allowed for the system.</p>
<h4 id="syntax_40"><a name="user-content-syntax_40" href="#syntax_40" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>pwm.setclock(pin, clock)</p>
<h4 id="parameters_40"><a name="user-content-parameters_40" href="#parameters_40" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index.<br /><br />
clock: 1~500, pwm frequency.</p>
<h4 id="returns_40"><a name="user-content-returns_40" href="#returns_40" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_41"><a name="user-content-example_41" href="#example_41" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">setclock</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="w"> </span><span class="il">100</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_40"><a name="user-content-see-also_40" href="#see-also_40" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#pw_getclock">pwm.getclock()</a></p>
<p><a id="pw_getclock"></a></p>
<h2 id="pwmgetclock"><a name="user-content-pwmgetclock" href="#pwmgetclock" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>pwm.getclock()</h2>
<h4 id="description_41"><a name="user-content-description_41" href="#description_41" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>get pwm frequency of pin.</p>
<h4 id="syntax_41"><a name="user-content-syntax_41" href="#syntax_41" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>pwm.getclock(pin)</p>
<h4 id="parameters_41"><a name="user-content-parameters_41" href="#parameters_41" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index.</p>
<h4 id="returns_41"><a name="user-content-returns_41" href="#returns_41" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>number:pwm frequency of pin</p>
<h4 id="example_42"><a name="user-content-example_42" href="#example_42" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">pwm</span><span class="o">.</span><span class="vg">getclock</span><span class="p">(</span><span class="il">0</span><span class="p">))</span>
</pre></div>
<h4 id="see-also_41"><a name="user-content-see-also_41" href="#see-also_41" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#pw_setclock">pwm.setclock()</a></p>
<p><a id="pw_setduty"></a></p>
<h2 id="pwmsetduty"><a name="user-content-pwmsetduty" href="#pwmsetduty" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>pwm.setduty()</h2>
<h4 id="description_42"><a name="user-content-description_42" href="#description_42" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>set duty clycle for pin.</p>
<h4 id="syntax_42"><a name="user-content-syntax_42" href="#syntax_42" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>pwm.setduty(pin, duty)</p>
<h4 id="parameters_42"><a name="user-content-parameters_42" href="#parameters_42" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index<br /><br />
duty: 0~100, pwm duty cycle in percentage</p>
<h4 id="returns_42"><a name="user-content-returns_42" href="#returns_42" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_43"><a name="user-content-example_43" href="#example_43" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">setduty</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="w"> </span><span class="il">50</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_42"><a name="user-content-see-also_42" href="#see-also_42" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#pw_getduty">pwm.getduty()</a></p>
<p><a id="pw_getduty"></a></p>
<h2 id="pwmgetduty"><a name="user-content-pwmgetduty" href="#pwmgetduty" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>pwm.getduty()</h2>
<h4 id="description_43"><a name="user-content-description_43" href="#description_43" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>get duty clycle for pin.</p>
<h4 id="syntax_43"><a name="user-content-syntax_43" href="#syntax_43" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>pwm.getduty(pin)</p>
<h4 id="parameters_43"><a name="user-content-parameters_43" href="#parameters_43" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>pin: 0~11, IO index</p>
<h4 id="returns_43"><a name="user-content-returns_43" href="#returns_43" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_44"><a name="user-content-example_44" href="#example_44" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">D0</span><span class="w"> </span><span class="vg">is</span><span class="w"> </span><span class="vg">connected</span><span class="w"> </span><span class="vg">to</span><span class="w"> </span><span class="vg">green</span><span class="w"> </span><span class="vg">led</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">D1</span><span class="w"> </span><span class="vg">is</span><span class="w"> </span><span class="vg">connected</span><span class="w"> </span><span class="vg">to</span><span class="w"> </span><span class="vg">blue</span><span class="w"> </span><span class="vg">led</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">D2</span><span class="w"> </span><span class="vg">is</span><span class="w"> </span><span class="vg">connected</span><span class="w"> </span><span class="vg">to</span><span class="w"> </span><span class="vg">red</span><span class="w"> </span><span class="vg">led</span>
<span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">setup</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="il">500</span><span class="p">,</span><span class="il">50</span><span class="p">)</span>
<span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">setup</span><span class="p">(</span><span class="il">1</span><span class="p">,</span><span class="il">500</span><span class="p">,</span><span class="il">50</span><span class="p">)</span>
<span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">setup</span><span class="p">(</span><span class="il">2</span><span class="p">,</span><span class="il">500</span><span class="p">,</span><span class="il">50</span><span class="p">)</span>
<span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">start</span><span class="p">(</span><span class="il">0</span><span class="p">)</span>
<span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">start</span><span class="p">(</span><span class="il">1</span><span class="p">)</span>
<span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">start</span><span class="p">(</span><span class="il">2</span><span class="p">)</span>
<span class="w"> </span><span class="vg">function</span><span class="w"> </span><span class="vg">led</span><span class="p">(</span><span class="vg">r</span><span class="p">,</span><span class="vg">g</span><span class="p">,</span><span class="vg">b</span><span class="p">)</span>
<span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">setduty</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="vg">g</span><span class="p">)</span>
<span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">setduty</span><span class="p">(</span><span class="il">1</span><span class="p">,</span><span class="vg">b</span><span class="p">)</span>
<span class="w"> </span><span class="vg">pwm</span><span class="o">.</span><span class="vg">setduty</span><span class="p">(</span><span class="il">2</span><span class="p">,</span><span class="vg">r</span><span class="p">)</span>
<span class="w"> </span><span class="vg">end</span>
<span class="w"> </span><span class="vg">led</span><span class="p">(</span><span class="il">50</span><span class="p">,</span><span class="il">0</span><span class="p">,</span><span class="il">0</span><span class="p">)</span><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">set</span><span class="w"> </span><span class="vg">led</span><span class="w"> </span><span class="vg">to</span><span class="w"> </span><span class="vg">red</span>
<span class="w"> </span><span class="vg">led</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="il">0</span><span class="p">,</span><span class="il">50</span><span class="p">)</span><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">set</span><span class="w"> </span><span class="vg">led</span><span class="w"> </span><span class="vg">to</span><span class="w"> </span><span class="vg">blue</span><span class="o">.</span>
</pre></div>
<h4 id="see-also_43"><a name="user-content-see-also_43" href="#see-also_43" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#pw_setduty">pwm.setduty()</a></p>
<h1 id="net-module"><a name="user-content-net-module" href="#net-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>net module</h1>
<h2 id="constant_2"><a name="user-content-constant_2" href="#constant_2" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>CONSTANT</h2>
<p>net.TCP, net.UDP</p>
<p><a id="nt_createServer"></a></p>
<h2 id="netcreateserver"><a name="user-content-netcreateserver" href="#netcreateserver" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>net.createServer()</h2>
<h4 id="description_44"><a name="user-content-description_44" href="#description_44" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>create a server.</p>
<h4 id="syntax_44"><a name="user-content-syntax_44" href="#syntax_44" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>net.createServer(type, secure)</p>
<h4 id="parameters_44"><a name="user-content-parameters_44" href="#parameters_44" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>type: net.TCP or net.UDP<br /><br />
secure: true or false, true for safe link, false for ordinary link</p>
<h4 id="returns_44"><a name="user-content-returns_44" href="#returns_44" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>net.server sub module</p>
<h4 id="example_45"><a name="user-content-example_45" href="#example_45" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">net</span><span class="o">.</span><span class="vg">createServer</span><span class="p">(</span><span class="vg">net</span><span class="o">.</span><span class="vg">TCP</span><span class="p">,</span><span class="w"> </span><span class="vg">true</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_44"><a name="user-content-see-also_44" href="#see-also_44" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#nt_createConnection">net.createConnection()</a></p>
<p><a id="nt_createConnection"></a></p>
<h2 id="netcreateconnection"><a name="user-content-netcreateconnection" href="#netcreateconnection" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>net.createConnection()</h2>
<h4 id="description_45"><a name="user-content-description_45" href="#description_45" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>create a client.</p>
<h4 id="syntax_45"><a name="user-content-syntax_45" href="#syntax_45" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>net.createConnection(type, secure)</p>
<h4 id="parameters_45"><a name="user-content-parameters_45" href="#parameters_45" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>type: net.TCP or net.UDP<br /><br />
secure: true or false, true for safe link, false for ordinary link</p>
<h4 id="returns_45"><a name="user-content-returns_45" href="#returns_45" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>net.server sub module</p>
<h4 id="example_46"><a name="user-content-example_46" href="#example_46" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">net</span><span class="o">.</span><span class="vg">createConnection</span><span class="p">(</span><span class="vg">net</span><span class="o">.</span><span class="vg">UDP</span><span class="p">,</span><span class="w"> </span><span class="vg">false</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_45"><a name="user-content-see-also_45" href="#see-also_45" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#nt_createServer">net.createServer()</a></p>
<h1 id="netserver-module"><a name="user-content-netserver-module" href="#netserver-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>net.server module</h1>
<p><a id="ns_listen"></a></p>
<h2 id="listen"><a name="user-content-listen" href="#listen" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>listen()</h2>
<h4 id="description_46"><a name="user-content-description_46" href="#description_46" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>listen on port from [ip] address.</p>
<h4 id="syntax_46"><a name="user-content-syntax_46" href="#syntax_46" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>net.server.listen(port,[ip],function(net.socket))</p>
<h4 id="parameters_46"><a name="user-content-parameters_46" href="#parameters_46" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>port: port number<br /><br />
ip:ip address string, can be omitted<br /><br />
function(net.socket): callback function, pass to Caller function as param if a connection is created successfully</p>
<h4 id="returns_46"><a name="user-content-returns_46" href="#returns_46" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_47"><a name="user-content-example_47" href="#example_47" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">create</span><span class="w"> </span><span class="vg">a</span><span class="w"> </span><span class="vg">server</span>
<span class="w"> </span><span class="vg">sv</span><span class="o">=</span><span class="vg">net</span><span class="o">.</span><span class="vg">createServer</span><span class="p">(</span><span class="vg">net</span><span class="o">.</span><span class="vg">TCP</span><span class="p">,</span><span class="w"> </span><span class="vg">false</span><span class="p">)</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">server</span><span class="w"> </span><span class="vg">listen</span><span class="w"> </span><span class="vg">on</span><span class="w"> </span><span class="il">80</span><span class="p">,</span><span class="w"> </span><span class="vg">if</span><span class="w"> </span><span class="vg">data</span><span class="w"> </span><span class="vg">received</span><span class="p">,</span><span class="w"> </span><span class="vg">print</span><span class="w"> </span><span class="vg">data</span><span class="w"> </span><span class="vg">to</span><span class="w"> </span><span class="vg">console</span><span class="p">,</span><span class="w"> </span><span class="vg">and</span><span class="w"> </span><span class="vg">send</span><span class="w"> </span><span class="s2">&quot;hello world&quot;</span><span class="w"> </span><span class="vg">to</span><span class="w"> </span><span class="vg">remote</span><span class="o">.</span>
<span class="w"> </span><span class="nl">sv:</span><span class="vg">listen</span><span class="p">(</span><span class="il">80</span><span class="p">,</span><span class="vg">function</span><span class="p">(</span><span class="vg">c</span><span class="p">)</span>
<span class="w"> </span><span class="nl">c:</span><span class="vg">on</span><span class="p">(</span><span class="s2">&quot;receive&quot;</span><span class="p">,</span><span class="w"> </span><span class="vg">function</span><span class="p">(</span><span class="vg">sck</span><span class="p">,</span><span class="w"> </span><span class="vg">pl</span><span class="p">)</span><span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">pl</span><span class="p">)</span><span class="w"> </span><span class="vg">end</span><span class="p">)</span>
<span class="w"> </span><span class="nl">c:</span><span class="vg">send</span><span class="p">(</span><span class="s2">&quot;hello world&quot;</span><span class="p">)</span>
<span class="w"> </span><span class="vg">end</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_46"><a name="user-content-see-also_46" href="#see-also_46" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#nt_createServer">net.createServer()</a></p>
<p><a id="ns_close"></a></p>
<h2 id="close"><a name="user-content-close" href="#close" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>close()</h2>
<h4 id="description_47"><a name="user-content-description_47" href="#description_47" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>close server.</p>
<h4 id="syntax_47"><a name="user-content-syntax_47" href="#syntax_47" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>net.server.close()</p>
<h4 id="parameters_47"><a name="user-content-parameters_47" href="#parameters_47" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_47"><a name="user-content-returns_47" href="#returns_47" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_48"><a name="user-content-example_48" href="#example_48" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">create</span><span class="w"> </span><span class="vg">a</span><span class="w"> </span><span class="vg">server</span>
<span class="w"> </span><span class="vg">sv</span><span class="o">=</span><span class="vg">net</span><span class="o">.</span><span class="vg">createServer</span><span class="p">(</span><span class="vg">net</span><span class="o">.</span><span class="vg">TCP</span><span class="p">,</span><span class="w"> </span><span class="vg">false</span><span class="p">)</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">close</span><span class="w"> </span><span class="vg">server</span>
<span class="w"> </span><span class="nl">sv:</span><span class="vg">close</span><span class="p">()</span>
</pre></div>
<h4 id="see-also_47"><a name="user-content-see-also_47" href="#see-also_47" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#nt_createServer">net.createServer()</a></p>
<h1 id="netsocket-module"><a name="user-content-netsocket-module" href="#netsocket-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>net.socket module</h1>
<p><a id="nk_connect"></a></p>
<h2 id="connect"><a name="user-content-connect" href="#connect" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>connect()</h2>
<h4 id="description_48"><a name="user-content-description_48" href="#description_48" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>connect to remote.</p>
<h4 id="syntax_48"><a name="user-content-syntax_48" href="#syntax_48" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>connect(port, ip)</p>
<h4 id="parameters_48"><a name="user-content-parameters_48" href="#parameters_48" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>port: port number<br /><br />
ip: ip address in string</p>
<h4 id="returns_48"><a name="user-content-returns_48" href="#returns_48" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="see-also_48"><a name="user-content-see-also_48" href="#see-also_48" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#nk_on">net.socket:on()</a></p>
<p><a id="nk_send"></a></p>
<h2 id="send"><a name="user-content-send" href="#send" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>send()</h2>
<h4 id="description_49"><a name="user-content-description_49" href="#description_49" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>send data to remote via connection.</p>
<h4 id="syntax_49"><a name="user-content-syntax_49" href="#syntax_49" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>send(string, function(sent))</p>
<h4 id="parameters_49"><a name="user-content-parameters_49" href="#parameters_49" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>string: data in string which will be sent to remote<br /><br />
function(sent): callback function for sending string</p>
<h4 id="returns_49"><a name="user-content-returns_49" href="#returns_49" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="see-also_49"><a name="user-content-see-also_49" href="#see-also_49" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#nk_on">net.socket:on()</a></p>
<p><a id="nk_on"></a></p>
<h2 id="on"><a name="user-content-on" href="#on" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>on()</h2>
<h4 id="description_50"><a name="user-content-description_50" href="#description_50" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>register callback function for event.</p>
<h4 id="syntax_50"><a name="user-content-syntax_50" href="#syntax_50" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>on(event, function cb())</p>
<h4 id="parameters_50"><a name="user-content-parameters_50" href="#parameters_50" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>event: string, which can be: &ldquo;connection&rdquo;, &ldquo;reconnection&rdquo;, &ldquo;disconnection&rdquo;, &ldquo;receive&rdquo;, &ldquo;sent&rdquo;<br /><br />
function cb(net.socket, [string]): callback function. The first param is the socket.<br /><br />
If event is&rdquo;receive&rdquo;, the second param is received data in string.</p>
<h4 id="returns_50"><a name="user-content-returns_50" href="#returns_50" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_49"><a name="user-content-example_49" href="#example_49" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">sk</span><span class="o">=</span><span class="vg">net</span><span class="o">.</span><span class="vg">createConnection</span><span class="p">(</span><span class="vg">net</span><span class="o">.</span><span class="vg">TCP</span><span class="p">,</span><span class="w"> </span><span class="vg">false</span><span class="p">)</span>
<span class="w"> </span><span class="nl">sk:</span><span class="vg">on</span><span class="p">(</span><span class="s2">&quot;receive&quot;</span><span class="p">,</span><span class="w"> </span><span class="vg">function</span><span class="p">(</span><span class="vg">sck</span><span class="p">,</span><span class="w"> </span><span class="vg">c</span><span class="p">)</span><span class="w"> </span><span class="vg">print</span><span class="p">(</span><span class="vg">c</span><span class="p">)</span><span class="w"> </span><span class="vg">end</span><span class="w"> </span><span class="p">)</span>
<span class="w"> </span><span class="nl">sk:</span><span class="vg">connect</span><span class="p">(</span><span class="il">80</span><span class="p">,</span><span class="s2">&quot;192.168.0.66&quot;</span><span class="p">)</span>
<span class="w"> </span><span class="nl">sk:</span><span class="vg">send</span><span class="p">(</span><span class="s2">&quot;GET / HTTP/1.1\r\nHost: 192.168.0.66\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n&quot;</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_50"><a name="user-content-see-also_50" href="#see-also_50" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#nt_createServer">net.createServer()</a></p>
<p><a id="nk_close"></a></p>
<h2 id="close_1"><a name="user-content-close_1" href="#close_1" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>close()</h2>
<h4 id="description_51"><a name="user-content-description_51" href="#description_51" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>close socket.</p>
<h4 id="syntax_51"><a name="user-content-syntax_51" href="#syntax_51" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>close()</p>
<h4 id="parameters_51"><a name="user-content-parameters_51" href="#parameters_51" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>nil</p>
<h4 id="returns_51"><a name="user-content-returns_51" href="#returns_51" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="see-also_51"><a name="user-content-see-also_51" href="#see-also_51" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#nt_createServer">net.createServer()</a></p>
<p><a id="nk_dns"></a></p>
<h2 id="dns"><a name="user-content-dns" href="#dns" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>dns()</h2>
<h4 id="description_52"><a name="user-content-description_52" href="#description_52" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>get domain ip</p>
<h4 id="syntax_52"><a name="user-content-syntax_52" href="#syntax_52" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>dns(domain, function(net.socket, ip))</p>
<h4 id="parameters_52"><a name="user-content-parameters_52" href="#parameters_52" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>domain: domain name.<br /><br />
function (net.socket, ip): callback function. The first param is the socket, the second param is the ip address in string.</p>
<h4 id="returns_52"><a name="user-content-returns_52" href="#returns_52" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="see-also_52"><a name="user-content-see-also_52" href="#see-also_52" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#nt_createServer">net.createServer()</a></p>
<h1 id="i2c-module"><a name="user-content-i2c-module" href="#i2c-module" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>i2c module</h1>
<h2 id="constant_3"><a name="user-content-constant_3" href="#constant_3" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>CONSTANT</h2>
<p>i2c.SLOW, i2c.TRANSMITTER, i2c. RECEIVER. FAST400kis not supported for now.</p>
<p><a id="ic_setup"></a></p>
<h2 id="i2csetup"><a name="user-content-i2csetup" href="#i2csetup" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>i2c.setup()</h2>
<h4 id="description_53"><a name="user-content-description_53" href="#description_53" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>initialize i2c.</p>
<h4 id="syntax_53"><a name="user-content-syntax_53" href="#syntax_53" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>i2c.setup(id, pinSDA, pinSCL, speed)</p>
<h4 id="parameters_53"><a name="user-content-parameters_53" href="#parameters_53" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>id = 0<br /><br />
pinSDA: 0~11, IO index<br /><br />
pinSCL: 0~11, IO index<br /><br />
speed: i2c.SLOW</p>
<h4 id="returns_53"><a name="user-content-returns_53" href="#returns_53" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="see-also_53"><a name="user-content-see-also_53" href="#see-also_53" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ic_read">i2c.read()</a></p>
<p><a id="ic_start"></a></p>
<h2 id="i2cstart"><a name="user-content-i2cstart" href="#i2cstart" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>i2c.start()</h2>
<h4 id="description_54"><a name="user-content-description_54" href="#description_54" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>start i2c transporting.</p>
<h4 id="syntax_54"><a name="user-content-syntax_54" href="#syntax_54" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>i2c.start(id)</p>
<h4 id="parameters_54"><a name="user-content-parameters_54" href="#parameters_54" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>id = 0</p>
<h4 id="returns_54"><a name="user-content-returns_54" href="#returns_54" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="see-also_54"><a name="user-content-see-also_54" href="#see-also_54" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ic_read">i2c.read()</a></p>
<p><a id="ic_stop"></a></p>
<h2 id="i2cstop"><a name="user-content-i2cstop" href="#i2cstop" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>i2c.stop()</h2>
<h4 id="description_55"><a name="user-content-description_55" href="#description_55" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>stop i2c transporting.</p>
<h4 id="syntax_55"><a name="user-content-syntax_55" href="#syntax_55" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>i2c.stop(id)</p>
<h4 id="parameters_55"><a name="user-content-parameters_55" href="#parameters_55" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>id = 0</p>
<h4 id="returns_55"><a name="user-content-returns_55" href="#returns_55" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="see-also_55"><a name="user-content-see-also_55" href="#see-also_55" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ic_read">i2c.read()</a></p>
<p><a id="ic_address"></a></p>
<h2 id="i2caddress"><a name="user-content-i2caddress" href="#i2caddress" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>i2c.address()</h2>
<h4 id="description_56"><a name="user-content-description_56" href="#description_56" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>setup i2c address and read/write mode.</p>
<h4 id="syntax_56"><a name="user-content-syntax_56" href="#syntax_56" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>i2c.address(id, device_addr, direction)</p>
<h4 id="parameters_56"><a name="user-content-parameters_56" href="#parameters_56" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>id=0<br /><br />
device_addr: device address.<br /><br />
direction: i2c.TRANSMITTER for writing mode , i2c. RECEIVER for reading mode</p>
<h4 id="returns_56"><a name="user-content-returns_56" href="#returns_56" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="see-also_56"><a name="user-content-see-also_56" href="#see-also_56" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ic_read">i2c.read()</a></p>
<p><a id="ic_write"></a></p>
<h2 id="i2cwrite"><a name="user-content-i2cwrite" href="#i2cwrite" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>i2c.write()</h2>
<h4 id="description_57"><a name="user-content-description_57" href="#description_57" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>write data to i2c, data can be multi numbers, string or lua table.</p>
<h4 id="syntax_57"><a name="user-content-syntax_57" href="#syntax_57" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>i2c.write(id, data1, data2,&hellip;)</p>
<h4 id="parameters_57"><a name="user-content-parameters_57" href="#parameters_57" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>id=0<br /><br />
data: data can be numbers, string or lua table.</p>
<h4 id="returns_57"><a name="user-content-returns_57" href="#returns_57" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>nil</p>
<h4 id="example_50"><a name="user-content-example_50" href="#example_50" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">i2c</span><span class="o">.</span><span class="vg">write</span><span class="p">(</span><span class="il">0</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;hello&quot;</span><span class="p">,</span><span class="w"> </span><span class="s2">&quot;world&quot;</span><span class="p">)</span>
</pre></div>
<h4 id="see-also_57"><a name="user-content-see-also_57" href="#see-also_57" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ic_read">i2c.read()</a></p>
<p><a id="ic_read"></a></p>
<h2 id="i2cread"><a name="user-content-i2cread" href="#i2cread" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>i2c.read()</h2>
<h4 id="description_58"><a name="user-content-description_58" href="#description_58" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Description</h4>
<p>read data for len bytes.</p>
<h4 id="syntax_58"><a name="user-content-syntax_58" href="#syntax_58" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Syntax</h4>
<p>i2c.read(id, len)</p>
<h4 id="parameters_58"><a name="user-content-parameters_58" href="#parameters_58" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Parameters</h4>
<p>id=0<br /><br />
len: data length</p>
<h4 id="returns_58"><a name="user-content-returns_58" href="#returns_58" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Returns</h4>
<p>string:data received.</p>
<h4 id="example_51"><a name="user-content-example_51" href="#example_51" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>Example</h4>
<div class="codehilite"><pre><span class="w"> </span><span class="vg">id</span><span class="o">=</span><span class="il">0</span>
<span class="w"> </span><span class="vg">sda</span><span class="o">=</span><span class="il">1</span>
<span class="w"> </span><span class="vg">scl</span><span class="o">=</span><span class="il">0</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">initialize</span><span class="w"> </span><span class="vg">i2c</span><span class="p">,</span><span class="w"> </span><span class="vg">set</span><span class="w"> </span><span class="vg">pin1</span><span class="w"> </span><span class="vg">as</span><span class="w"> </span><span class="vg">sda</span><span class="p">,</span><span class="w"> </span><span class="vg">set</span><span class="w"> </span><span class="vg">pin0</span><span class="w"> </span><span class="vg">as</span><span class="w"> </span><span class="vg">scl</span>
<span class="w"> </span><span class="vg">i2c</span><span class="o">.</span><span class="vg">setup</span><span class="p">(</span><span class="vg">id</span><span class="p">,</span><span class="vg">sda</span><span class="p">,</span><span class="vg">scl</span><span class="p">,</span><span class="vg">i2c</span><span class="o">.</span><span class="vg">SLOW</span><span class="p">)</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">user</span><span class="w"> </span><span class="vg">defined</span><span class="w"> </span><span class="nl">function:</span><span class="w"> </span><span class="vg">read</span><span class="w"> </span><span class="vg">from</span><span class="w"> </span><span class="vg">reg_addr</span><span class="w"> </span><span class="vg">content</span><span class="w"> </span><span class="vg">of</span><span class="w"> </span><span class="vg">dev_addr</span>
<span class="w"> </span><span class="vg">function</span><span class="w"> </span><span class="vg">read_reg</span><span class="p">(</span><span class="vg">dev_addr</span><span class="p">,</span><span class="w"> </span><span class="vg">reg_addr</span><span class="p">)</span>
<span class="w"> </span><span class="vg">i2c</span><span class="o">.</span><span class="vg">start</span><span class="p">(</span><span class="vg">id</span><span class="p">)</span>
<span class="w"> </span><span class="vg">i2c</span><span class="o">.</span><span class="vg">address</span><span class="p">(</span><span class="vg">id</span><span class="p">,</span><span class="w"> </span><span class="vg">dev_addr</span><span class="w"> </span><span class="p">,</span><span class="vg">i2c</span><span class="o">.</span><span class="vg">TRANSMITTER</span><span class="p">)</span>
<span class="w"> </span><span class="vg">i2c</span><span class="o">.</span><span class="vg">write</span><span class="p">(</span><span class="vg">id</span><span class="p">,</span><span class="vg">reg_addr</span><span class="p">)</span>
<span class="w"> </span><span class="vg">i2c</span><span class="o">.</span><span class="vg">stop</span><span class="p">(</span><span class="vg">id</span><span class="p">)</span>
<span class="w"> </span><span class="vg">i2c</span><span class="o">.</span><span class="vg">start</span><span class="p">(</span><span class="vg">id</span><span class="p">)</span>
<span class="w"> </span><span class="vg">i2c</span><span class="o">.</span><span class="vg">address</span><span class="p">(</span><span class="vg">id</span><span class="p">,</span><span class="w"> </span><span class="vg">dev_addr</span><span class="p">,</span><span class="vg">i2c</span><span class="o">.</span><span class="vg">RECEIVER</span><span class="p">)</span>
<span class="w"> </span><span class="vg">c</span><span class="o">=</span><span class="vg">i2c</span><span class="o">.</span><span class="vg">read</span><span class="p">(</span><span class="vg">id</span><span class="p">,</span><span class="il">1</span><span class="p">)</span>
<span class="w"> </span><span class="vg">i2c</span><span class="o">.</span><span class="vg">stop</span><span class="p">(</span><span class="vg">id</span><span class="p">)</span>
<span class="w"> </span><span class="vg">return</span><span class="w"> </span><span class="vg">c</span>
<span class="w"> </span><span class="vg">end</span>
<span class="w"> </span><span class="o">--</span><span class="w"> </span><span class="vg">get</span><span class="w"> </span><span class="vg">content</span><span class="w"> </span><span class="vg">of</span><span class="w"> </span><span class="vg">register</span><span class="w"> </span><span class="il">0</span><span class="vg">xAA</span><span class="w"> </span><span class="vg">of</span><span class="w"> </span><span class="vg">device</span><span class="w"> </span><span class="il">0</span><span class="vg">x77</span>
<span class="w"> </span><span class="vg">reg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="vg">read_reg</span><span class="p">(</span><span class="il">0</span><span class="vg">x77</span><span class="p">,</span><span class="w"> </span><span class="il">0</span><span class="vg">xAA</span><span class="p">)</span>
<span class="w"> </span><span class="vg">pirnt</span><span class="p">(</span><span class="vg">string</span><span class="o">.</span><span class="vg">byte</span><span class="p">(</span><span class="vg">reg</span><span class="p">))</span>
</pre></div>
<h4 id="see-also_58"><a name="user-content-see-also_58" href="#see-also_58" class="headeranchor-link" aria-hidden="true"><span class="headeranchor"></span></a>See also</h4>
<p><strong>-</strong> <a href="#ic_write">i2c.write()</a></p></article></body></html>