Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 234aca5

Browse files
update README and add Simplified Chinese README
1 parent c812fb6 commit 234aca5

File tree

2 files changed

+113
-5
lines changed

2 files changed

+113
-5
lines changed

‎README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# ESP Arduino Lua
1+
*[中文版本](README_cn.md)
22

3-
This Arduino library provides the [lua](https://www.lua.org/) 5.3.5 ( [release](https://www.lua.org/ftp/lua-5.3.5.tar.gz) ) scripting engine for ESP8266/ESP32 sketches. This allows dynamic execution of Lua code on the Arduino without having to compile and flash a new firmware.
3+
# Arduino Lua
44

5-
Along with the Lua 5.3.5 Core the following Lua standard libraries are included:
5+
This Arduino library provides the [lua](https://www.lua.org/) 5.3.6 ( [release](https://www.lua.org/ftp/lua-5.3.6.tar.gz) ) scripting engine for ESP8266/ESP32/ArduinoUnoR4 sketches. This allows dynamic execution of Lua code on the Arduino without having to compile and flash a new firmware.
6+
7+
Along with the Lua 5.3.6 Core the following Lua standard libraries are included:
68

79
- base (print(), tostring(), tonumber(), etc.)
810
- math
@@ -11,7 +13,7 @@ Along with the Lua 5.3.5 Core the following Lua standard libraries are included:
1113

1214
## Sample sketch example: ExecuteScriptFromSerial.ino
1315

14-
After installing the library, some sketch examples are available from the *File* menu, then *Examples* and finally under *ESP-Arduino-Lua*. The examples include **ExecuteScriptFromSerial** which takes a lua script from the serial line and executes it. As an example, the following standard Arduino functions are available in lua scripts as bindings:
16+
After installing the library, some sketch examples are available from the *File* menu, then *Examples* and finally under *Arduino-Lua*. The examples include **ExecuteScriptFromSerial** which takes a lua script from the serial line and executes it. As an example, the following standard Arduino functions are available in lua scripts as bindings:
1517

1618
- pinMode()
1719
- digitalWrite()
@@ -65,8 +67,12 @@ Global variables use 31276 bytes (38%) of dynamic memory, leaving 50644 bytes fo
6567
Sketch uses 310749 bytes (23%) of program storage space. Maximum is 1310720 bytes.
6668
Global variables use 15388 bytes (4%) of dynamic memory, leaving 312292 bytes for local variables. Maximum is 327680 bytes.
6769

70+
**Arduino Uno R4:**
71+
Sketch uses 133756 bytes (51%) of program storage space. Maximum is 262144 bytes.
72+
Global variables use 2836 bytes (8%) of dynamic memory, leaving 29932 bytes for local variables. Maximum is 32768 bytes.
73+
6874
## Arduino IDE Library example: HelloWorld.ino
69-
```
75+
```
7076
#include <LuaWrapper.h>
7177
7278
LuaWrapper lua;

‎README_CN.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Arduino Lua
2+
3+
本Arduino扩展库为ESP8266/ESP32/ArduinoUnoR4提供 [lua](https://www.lua.org/) 5.3.6 ([正式版](https://www.lua.org/ftp/lua-5.3.6.tar.gz)) 的脚本运行引擎。 使用该扩展库,可以在Arduino上动态运行Lua代码,而不必重新编译和烧录固件。
4+
5+
除了 Lua 5.3.6 核心功能以外,还包含了如下的 Lua 标准库:
6+
7+
- base (print(), tostring(), tonumber(), etc.)
8+
- math
9+
- table (insert(), sort(), remove(), ...)
10+
- string (len(), match(), ...)
11+
12+
## 示例: ExecuteScriptFromSerial.ino
13+
14+
安装本扩展后,在 *File* 菜单中的 *Examples* 下的 *Arduino-Lua* 中 会提供部分示例。示例中包含 **ExecuteScriptFromSerial** ,可以通过串口输入 Lua 脚本并执行。例如,如下的标准 Arduino 函数,可以被绑定从而在 lua 脚本中使用:
15+
16+
- pinMode()
17+
- digitalWrite()
18+
- delay()
19+
- millis()
20+
- print() *(only builtin binding)*
21+
22+
```
23+
# Enter the lua script and press Control-D when finished:
24+
# 输入如下的 lua脚本,然后按 Ctrl+D 运行:
25+
print("My first test!")
26+
# Executing script:
27+
# 运行脚本:
28+
My first test!
29+
30+
31+
# Enter the lua script and press Control-D when finished-
32+
print("Current uptime: " .. millis())
33+
# Executing script:
34+
Current uptime: 159926.0
35+
36+
37+
# Enter the lua script and press Control-D when finished:
38+
print("Hello world!")
39+
# Executing script:
40+
Hello world!
41+
42+
43+
# Enter the lua script and press Control-D when finished:
44+
pinLED = 2
45+
period = 500
46+
pinMode(pinLED, OUTPUT)
47+
while(true)
48+
do
49+
print("LED on")
50+
digitalWrite(pinLED, LOW)
51+
delay(period)
52+
print("LED off")
53+
digitalWrite(pinLED, HIGH)
54+
delay(period)
55+
end
56+
# Executing script:
57+
LED on
58+
LED off
59+
```
60+
## 资源使用 (ExecuteScriptFromSerial.ino)
61+
62+
**ESP8266:**
63+
Sketch uses 327776 bytes (31%) of program storage space. Maximum is 1044464 bytes.
64+
Global variables use 31276 bytes (38%) of dynamic memory, leaving 50644 bytes for local variables. Maximum is 81920 bytes.
65+
66+
**ESP32:**
67+
Sketch uses 310749 bytes (23%) of program storage space. Maximum is 1310720 bytes.
68+
Global variables use 15388 bytes (4%) of dynamic memory, leaving 312292 bytes for local variables. Maximum is 327680 bytes.
69+
70+
**Arduino Uno R4:**
71+
Sketch uses 133756 bytes (51%) of program storage space. Maximum is 262144 bytes.
72+
Global variables use 2836 bytes (8%) of dynamic memory, leaving 29932 bytes for local variables. Maximum is 32768 bytes.
73+
74+
## 示例: HelloWorld.ino
75+
```
76+
#include <LuaWrapper.h>
77+
78+
LuaWrapper lua;
79+
80+
void setup() {
81+
Serial.begin(115200);
82+
String script = String("print('Hello world!')");
83+
Serial.println(lua.Lua_dostring(&script));
84+
}
85+
86+
void loop() {
87+
88+
}
89+
```
90+
## 资源使用 (HelloWorld.ino)
91+
92+
**ESP8266:**
93+
Sketch uses 365276 bytes (34%) of program storage space. Maximum is 1044464 bytes.
94+
Global variables use 34712 bytes (42%) of dynamic memory, leaving 47208 bytes for local variables. Maximum is 81920 bytes.
95+
96+
**ESP32:**
97+
Sketch uses 309913 bytes (23%) of program storage space. Maximum is 1310720 bytes.
98+
Global variables use 15388 bytes (4%) of dynamic memory, leaving 312292 bytes for local variables. Maximum is 327680 bytes.
99+
100+
## Lua 语言:
101+
[Lua 5.3 参考手册](https://www.lua.org/manual/5.3/)
102+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /