SMART LCD Lua Functions Reference Note
Open the catalog to page 1Reference Note
Open the catalog to page 2Reference Note 1 Basic Lua script is supported in some of the TOPWAY Smart LCD to enhance the flexibility. Engineer may refine the Smart LCD functionality with script. The provided Lua functionality support most of the features of Lua 5.3 except OS operation and file I/O. (please refer to lua.net for Lua 5.3 details) It also extended with hmt library for Smart LCD variables access, function control and value return etc. 2 TOPWAY Smart LCD script and variable 2.1 Lua Scrip structure Basic structure -- define variable(s) Script_Variable01 = 0x00 Advance structure with hooks -- define variable(s)...
Open the catalog to page 3Reference Note 3 hmt library 3.1 hmt functions Summary Category VP read/write Function Name hmt.readvpstr(addr) hmt.writevpstr(addr, string) hmt.readvp16(addr) hmt.writevp16(addr, value) hmt.readvp32(addr) hmt.readvp32f(addr) hmt.writevp32(addr, value) hmt.readvp64(addr) hmt.readvp64f(addr) hmt.writevp64(addr, value) hmt.readvpreg(addr) hmt.writevpreg(addr, value) hmt.changepage(pageid) hmt.readpage() hmt.gettick() hmt.delayms(time) hmt.runcmd(table, num) hmt.bypass(is) hmt.uartclearbuf() hmt.getchar() hmt.putchar(char) hmt.uartsendbytes(table, num) hmt.uartlock() hmt.uartunlock() hmt.uart1isempty()...
Open the catalog to page 4Reference Note 3.2.1 hmt.readvpstr Function hmt.readvpstr(addr) Description Read VP_STR value Parameter addr is the VP_STR address (*1) Return Value String Example Lua script local strvalue = ““ strvalue = hmt.readvpstr(0x000080) print(“strvalue=”, strvalue) Descriptions Put “TOPWAY” into VP_STR 0x000080 via SmartLCD UI define a local variable strvalue and put ““ inside copy value in VP_STR at 0x000080 to strvalue print to UART0 it should find the following at the UART0 strvalue=TOPWAY 3.2.2 hmt.writevpstr Function hmt.writevpstr(addr, string) Description Write a value to VP_STR Parameter addr...
Open the catalog to page 5Reference Note 3.2.5 hmt.readvp32 Function hmt.readvp32(addr) Description Read VP_N32 value Parameter addr is the VP_N32 address (*1) Return Value Integer Example Lua script local N32value = 0 N32value = hmt.readvp32(0x020004) print(“N32value:”, N32value) Descriptions Put 1108410368 into VP_N32 0x020004 via SmartLCD UI define a local variable N32value and put 0 inside copy value in VP_N32 at 0x020004 to N32value print to UART0 it should find the following at the UART0 N32value:1108410368 3.2.6 hmt.readvp32f Function hmt.readvp32f(addr) Description Read VP_N32 value with floating value inside...
Open the catalog to page 6Reference Note 3.2.9 hmt.readvp64f Function hmt.readvp64f(addr) Description Read VP_N64 value with floating value inside Parameter addr is the VP_N64 address (*1) Return Value Floating point Example Lua script local N64value = 0.0 N64value = hmt.readvp64f(0x030000) print(“N64value:”, N64value) Descriptions Put a floating point value 118.37 into VP_N64 0x030000 via SmartLCD UI define a local variable N64value and put 0.0 inside copy floating point value in VP_N64 at 0x030000 to N64value print to UART0 it should find the following at the UART0 N64value:118.37 3.2.10 hmt.writevp64 Function hmt.writevp64(addr,...
Open the catalog to page 7Reference Note 3.3 System Functions 3.3.1 hmt.changepage Function hmt.changepage(pageid) Description Change the Smart LCD UI display PAGE Parameter pageid is the target display PAGE to be shown Return Value Nil Example Lua script hmt.changepage(0x02) Descriptions UI show up the PAGE 2 3.3.2 hmt.readpage Function hmt.readpage() Description Read the current display page id Parameter Nil Return Value Integer Example Lua script local pageid = 0 pageid = hmt.readpage() print(“pageid:”, pageid) Descriptions SmartLCD UI is showing PAGE 3 define a local variable pageid and put 0 inside copy the current...
Open the catalog to page 8Reference Note 3.3.5 hmt.runcmd Function hmt.runcmd(table, num) Description Send a command directly as sending command to the Smart LCD terminal (no command head and command tail) Parameter table is the command byte array to be send num is the number of byte to be send Return Value Nil Example Lua script local cmdtab = {0x5F, 0x04} hmt.runcmd(cmdtab, 2) Descriptions define a local variable array and put 0x5F, 0x04 inside use hmt.runcmd to send 2 byte of local variable array to Smart LCD it will adjust the backlight of the display to dim down Note. 0xF5 is backlight control command; please also...
Open the catalog to page 9Reference Note UART0 functions UART0 is the default command terminal of the Smart LCD. It may be RS-232C or UART(3.3V) depends on model. Lua print function also using UART0 for default output. Some of the Smart LCD equipped with a second terminal UART1. It may be RS-232C or UART(3.3V) depends on model. 3.4.1 hmt.uartisempty Function hmt.uartisempty() Description Check the UART0 buffer status Parameter Nil Return Value Integer Return 1 for buffer empty; 0 for data in buffer Example Lua script local Uart0state = 0 Uart0state = hmt.uartisempty() print(“Uart0state:”, Uart0state) Descriptions define...
Open the catalog to page 10Reference Note 3.4.4 hmt.putchar Function hmt.putchar(char) Description Send one byte of data to UART0 Parameter char is the byte of data to be sent (it should be a byte value, not string char) Return Value Integer Example Lua script hmt.putchar(0x41) hmt.putchar(66) Descriptions it should find the following at the UART0 0x41 0x42 (in hex) or AB (in ASCII) 3.4.5 hmt.uartsendbytes Function hmt.uartsendbytes(table, num) Description Send bytes of data to UART0 Parameter table is the data byte array to be send num is the number of byte to be send Return Value Nil Example Lua script local sendbuff...
Open the catalog to page 11Reference Note UART1 functions UART1 is the extend terminal of some of the Smart LCD. It may be RS-232C or UART(3.3V) depends on model. 3.5.1 hmt.uart1isempty Function hmt.uart1isempty() Description Check the UART1 buffer status Parameter Nil Return Value Integer Return 1 for buffer empty; 0 for data in buffer Example Lua script local Uart1state = 0 Uart1state = hmt.uart1isempty() print(“Uart1state:”, Uart1state) Descriptions define a local variable Uart1state and put 0 inside copy the current UART is empty result to Uart1state print to UART0 it should find the following at the UART0 Uart1state:1...
Open the catalog to page 12108 Pages
1 Page
2 Pages
15 Pages
16 Pages
36 Pages
17 Pages
31 Pages
42 Pages
31 Pages
28 Pages
14 Pages
17 Pages
13 Pages
12 Pages
12 Pages
18 Pages
14 Pages
11 Pages
36 Pages
1 Page
1 Page
11 Pages
1 Page
19 Pages
31 Pages
34 Pages
1 Page
31 Pages
1 Page
1 Page
32 Pages
37 Pages
17 Pages
11 Pages
1 Page
11 Pages
1 Page
12 Pages
13 Pages
12 Pages
31 Pages
33 Pages
32 Pages
33 Pages
30 Pages
33 Pages
31 Pages
32 Pages
42 Pages
118 Pages
133 Pages
192 Pages
23 Pages
37 Pages
34 Pages
95 Pages
23 Pages
42 Pages
174 Pages
93 Pages
8 Pages
1 Page
14 Pages
14 Pages
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
1 Page
4 Pages
1 Page
1 Page
1 Page
1 Page
1 Page