Wiki source code of 11 GPS

Version 1.1 by Wecon on 2025/09/03 21:04

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 * Convert base station to latitude and longitude via API
49 ** Longitude: addr_getdouble("@W_HSW187") (read only)
50 ** Latitude: addr_getdouble("@W_HSW183") (read only)
51 )))
52
53 (% style="text-align:center" %)
54 [[image:创建脚本.png||height="597" width="1224"]]
55
56
57 (% style="text-align:center" %)
58 [[image:脚本程序.png||height="360" width="1260"]]
59
60 {{code language="lua"}}
61 function GPS.main()
62
63 local Longitude1 = addr_getdouble("@W_HSW187")
64 local Latitude1 = addr_getdouble("@W_HSW183")
65
66 addr_setdouble("@longitude",Longitude1)
67 addr_setdouble("@latitude",Latitude1)
68
69 print(Longitude1)
70 print(Latitude1)
71 end
72 {{/code}}
73
74 Debug
75
76 (% style="text-align:center" %)
77 [[image:结果显示.png]]