Changes for page 05 Lua Script

Last modified by Hunter on 2026/10/01 15:44

From version 6.1
edited by Hunter
on 2026/02/25 18:52
Change comment: There is no comment for this version
To version 21.1
edited by Hunter
on 2026/10/01 15:44
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -48,29 +48,32 @@
48 48  (% style="text-align:center" %)
49 49  [[image:dZyxVCtWDz.png]]
50 50  
51 -~1. About how to set up the FTP server in Windows PC: **[[Build an FTP Site on IIS>>https://docs.microsoft.com/en-us/iis/publish/using-the-ftp-service/scenario-build-an-ftp-site-on-iis]] **,** [[How to set up and manage an FTP server on Windows 10>>https://www.windowscentral.com/how-set-and-manage-ftp-server-windows-10]]**
51 +(% class="box infomessage" %)
52 +(((
53 +Note:About how to set up the FTP server in Windows PC: **[[How to set up and manage an FTP server on Windows 10>>https://www.windowscentral.com/how-set-and-manage-ftp-server-windows-10]]**
54 +)))
52 52  
53 -2. Enter PC (FTP Server) IP address and port number (Default 21).
56 +1.Enter PC (FTP Server) IP address and port number (Default 21).
54 54  
55 55  (% style="text-align:center" %)
56 56  [[image:LuaFTPDemoIP&Port.png]]
57 57  
58 -3. Change the filename of the file that needs to be uploaded. If run on as Offline Simulator, the simulate upload path of "udisk:1.png" will be "C:\WECON\USB\1.png" on the PC.
61 +2.Change the filename of the file that needs to be uploaded. If run on as Offline Simulator, the simulate upload path of "udisk:1.png" will be "C:\WECON\USB\1.png" on the PC.
59 59  
60 60  (% style="text-align:center" %)
61 61  [[image:LuaFTPDemoUpload.png]]
62 62  
63 -4. Change drive letter of file save path according to drop-down list (There are three option available: Flash, UDisk and SDCard).
66 +3.Change drive letter of file save path according to drop-down list (There are three option available: Flash, UDisk and SDCard).
64 64  
65 65  (% style="text-align:center" %)
66 66  [[image:LuaFTPDemoDropBox.png]]
67 67  
68 -5. Change the filename of the file that needs to be downloaded from PC(Server).
71 +4.Change the filename of the file that needs to be downloaded from PC(Server).
69 69  
70 70  (% style="text-align:center" %)
71 71  [[image:LuaFTPDemoDownload.png]]
72 72  
73 -6. Set the default configuration in file "Script_BG.lua"
76 +5.Set the default configuration in file "Script_BG.lua"
74 74  
75 75  (% style="text-align:center" %)
76 76  [[image:LuaFTPDemoInitial.png]]
... ... @@ -123,6 +123,9 @@
123 123  
124 124  [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Telegram.zip]]
125 125  
129 +
130 +[[URL Encode Table for Special Characters>>https://docs.we-con.com.cn/bin/view/PIStudio/FAQ/Why%20can't%20I%20receive%20HMI%20messages%20on%20Telegram]]
131 +
126 126  = 9** LINE Notify(Not available now)** =
127 127  
128 128  This example shows how to use the LINE Notify to send message into LINE group. When monitoring bit "@B_HDX0.0" changes, it will trigger and send the message. Please replace with your own Token.
... ... @@ -696,19 +696,21 @@
696 696  (% style="text-align:center" %)
697 697  [[image:xT8f08pfY0.png]]
698 698  
699 -= [[26. Send attachment picture with SMTP by Gmail>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/SMTP%20for%20Gmail%28with%20Attachment%20picture%20%29.zip]] =
705 += 26 Send attachment picture with SMTP by Gmail =
700 700  
701 701  The project is to send mail message with text and attachment picture called test.png.
702 702  
709 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/SMTP%20for%20Gmail%28with%20Attachment%20picture%20%29.zip]]
703 703  
704 -= [[27. TTS function>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Music%20player.pi2]] =
711 += 27 TTS function =
705 705  
706 706  The project is to show a Music Player and alarm sound with TTS function in Lua script. Please note that  use PI version 10.4 or higher to open the project.
707 707  
715 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Music%20player.pi2]]
708 708  
709 709  = 28 Google Sheets API =
710 710  
711 -The example shows how to send the data into the Google sheets API via Lua script. Jump to Video
719 +The example shows how to send the data into the Google sheets API via Lua script. [[Jump to Video>>https://youtu.be/VKjr3_MVNzc]]
712 712  
713 713  {{warning}}
714 714  since the HMI lacks a built-in library for cryptographic signatures (RS256/JWT), user can automate this by sending the token to the HMI via external communication. Token need to be manual input in this project.
... ... @@ -715,3 +715,67 @@
715 715  {{/warning}}
716 716  
717 717  [[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/GoogleSheet.zip]]
726 +
727 += 29 Graphics Drawing =
728 +
729 +The example shows drawing a snow and a star on the HMI screen with drawing function from Lua Script.Please note that  use PI version 10.6 or higher to open the project.
730 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Graphics%20Drawing.pi2]]
731 +
732 +
733 += 30 Timestamp =
734 +
735 +This example shows how to obtain second-level and millisecond-level timestamps.
736 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Timestamp.zip]]
737 +
738 +
739 += 31 Sending CSV file with Gmail =
740 +
741 +This example shows how to send CSV file transferred by DB file with Gmail. Please note that  use PI version 10.6 or higher to open the project.
742 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Sending%20CSV%20file%20with%20Gmail.zip]]
743 +
744 +
745 += 32 GPS Function =
746 +
747 +This example shows how to get the GPS data from device (Support RH-AG). Please note that  use PI version 11.4.64.26081301 or higher to open the project.
748 +
749 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/GPS%20function.zip]]
750 +
751 +
752 += **33 Data record query** =
753 +
754 +This example shows how to obtain data records for a certain time period and display them at an address. Please note that  use PI version 10.6.45.26070101 or higher to open the project.
755 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/Data%20record%20query.zip]]
756 +
757 +
758 += 34 Ethernet A4 Printer =
759 +
760 +This example shows how to print A4 report paper directly from an HMI via TCP/IP, which is not required any PC software tool. [[Jump to Video>>https://youtu.be/IZoOoRefJc8]]
761 +
762 +**Common PCL5 Commands**
763 +
764 +{{code language="lua"}}
765 +--Set text position and content
766 +local sample = "\x1B*p1000x1000YHelloWorld"
767 +{{/code}}
768 +
769 +{{code language="lua"}}
770 +-- Set font size to 12 pt
771 +local fontSize = "\x1B(s12V"
772 +{{/code}}
773 +
774 +{{code language="lua"}}
775 +-- Set print direction to 0 degrees
776 +local direction = "\x1B&a0P"
777 +{{/code}}
778 +
779 +{{code language="lua"}}
780 +--Restore default drawing logic
781 +local defaultLogic = "\x1B*l252O"
782 +{{/code}}
783 +
784 +{{code language="lua"}}
785 +--New page feed output
786 +local formFeed = "\x0C"
787 +{{/code}}
788 +
789 +[[Download link>>https://ftp.we-con.com.cn/Download/WIKI/PI%20HMI/Demo/Lua%20Script/PrinterTCPSocket.zip]]