Lua Script: Difference between revisions

From Smart LCD
mNo edit summary
Line 1: Line 1:
== 1 Basic ==
== Smart LCD Lua Script Support ==
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. (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.
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. (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.
== Lua Script Structure ==
==== Basic structure ====
-- define variable(s)
Script_Variable01 = 0x00
-- main loop
luamain = function(void)
return 0
end
Note:
* main loop run continually
* intensive loop in the main loop may affect the Smart LCD UI operations
==== Advance structure with hooks ====
-- define variable(s)
Script_Variable01 = 0x00
-- main loop
luamain = function(void)
return 0
end
-- touch key hook
tpkhook = function(page, id, state)
return 0
end
-- page hook
pagechangehook = function(pageid)
return 0
end
Note:
* main loop run continually
* intensive loop in the main loop may affect the Smart LCD UI operations
* hooks share the MCU time with the main loop.
* looping or long delay will affect the main loop
* “wait loop” is not allowed in the hooks.
== Smart LCD VP variables ==
{| class="wikitable"
|+
!Mnemonic
!Name
!Memory Limit
!Address Range
|-
|VP_STR
|String Variable
|1024(MAX)*(127+1)byte
|0x000000~0x01FF80
|-
|VP_N16
|16Bit Integer Variable
|32512(MAX)*(2)byte
|0x080000~0x08FDFE
|-
|VP_N32
|32Bit Integer Variable
|16128(MAX)*(4)byte
|0x020000~0x02FEFC
|-
|VP_N64
|64Bit Integer Variable
|7936(MAX)*(8)byte
|0x030000~0x03F7F8
|-
|VP_SYS
|System Register Variable
|256(MAX)*(1)byte
|0xFFFF00~0xFFFFFF
|}
Note. Please also refer to Smart LCD handbook for VP variables details

Revision as of 14:48, 24 February 2025

Smart LCD Lua Script Support

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. (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.

Lua Script Structure

Basic structure

-- define variable(s)
Script_Variable01 = 0x00

-- main loop
luamain = function(void)

return 0
end

Note:

  • main loop run continually
  • intensive loop in the main loop may affect the Smart LCD UI operations

Advance structure with hooks

-- define variable(s)
Script_Variable01 = 0x00

-- main loop
luamain = function(void)

return 0
end

-- touch key hook
tpkhook = function(page, id, state)
return 0
end

-- page hook
pagechangehook = function(pageid)

return 0
end

Note:

  • main loop run continually
  • intensive loop in the main loop may affect the Smart LCD UI operations
  • hooks share the MCU time with the main loop.
  • looping or long delay will affect the main loop
  • “wait loop” is not allowed in the hooks.

Smart LCD VP variables

Mnemonic Name Memory Limit Address Range
VP_STR String Variable 1024(MAX)*(127+1)byte 0x000000~0x01FF80
VP_N16 16Bit Integer Variable 32512(MAX)*(2)byte 0x080000~0x08FDFE
VP_N32 32Bit Integer Variable 16128(MAX)*(4)byte 0x020000~0x02FEFC
VP_N64 64Bit Integer Variable 7936(MAX)*(8)byte 0x030000~0x03F7F8
VP_SYS System Register Variable 256(MAX)*(1)byte 0xFFFF00~0xFFFFFF

Note. Please also refer to Smart LCD handbook for VP variables details