Wiki source code of 11 GPS

Last modified by Devin Chen on 2025/11/27 21:25

Show last authors
1 = 1.Network Configuration =
2
3 (% class="box infomessage" %)
4 (((
5 GPS function only supported by H-SG
6 )))
7
8 (% style="text-align:center" %)
9 [[image:4G网络.png]]
10
11 4G antenna(right) with GPS antenna(left)
12
13 (% style="text-align:center" %)
14 [[image:天线.png||height="673" width="872"]]
15
16 Make sure the box is online using a 4G signal
17
18 (% style="text-align:center" %)
19 [[image:4G信号.png||height="671" width="1106"]]
20
21 = 2.GPS positioning =
22
23 When the 4G signal is normal, select Use device base station positionning.
24
25 (% style="text-align:center" %)
26 [[image:BOX GPS定位.png||height="798" width="1099"]]
27
28 (% style="text-align:center" %)
29 [[image:地图显示结果.png||height="461" width="1102"]]
30
31 = 3.Create an address =
32
33 Use a lua script to copy the latitude and longitude to the HDW address.
34
35 * Address format is chosen as 64 bit float.
36 * 4 bits between addresses
37
38 (% style="text-align:center" %)
39 [[image:创建地址承接.png||height="601" width="1200"]]
40
41 (% style="text-align:center" %)
42 [[image:地址间隔.png||height="348" width="1192"]]
43
44 = 4.Lua script =
45
46 (% class="box infomessage" %)
47 (((
48 * Longitude: addr_getdouble("@W_HSW187") (read only)
49 * Latitude: addr_getdouble("@W_HSW183") (read only)
50 )))
51
52 (% style="text-align:center" %)
53 [[image:创建脚本.png||height="597" width="1224"]]
54
55
56 (% style="text-align:center" %)
57 [[image:脚本程序.png||height="360" width="1260"]]
58
59 {{code language="lua"}}
60 function GPS.main()
61
62 local Longitude1 = addr_getdouble("@W_HSW187")
63 local Latitude1 = addr_getdouble("@W_HSW183")
64
65 addr_setdouble("@longitude",Longitude1)
66 addr_setdouble("@latitude",Latitude1)
67
68 print(Longitude1)
69 print(Latitude1)
70 end
71 {{/code}}
72
73 Debug
74
75 (% style="text-align:center" %)
76 [[image:结果显示.png]]