Skip to content

Commit cb4f90a

Browse files
Tinyu-Zhaolbuque
authored andcommitted
lib/driver: Add ATGM336H driver.
Signed-off-by: Tinyu-Zhao <[email protected]>
1 parent d34466a commit cb4f90a

File tree

14 files changed

+769
-330
lines changed

14 files changed

+769
-330
lines changed

docs/en/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ MicroPython documentation and references
1111
widgets/index.rst
1212
software/index.rst
1313
hardware/index.rst
14-
advanced/index.rst
1514
module/index.rst
1615
units/index.rst
1716
hats/index.rst

docs/en/module/gpsv2.rst

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
2+
GPS V2.0 Module
3+
==================
4+
5+
.. include:: ../refs/module.gpsv2.ref
6+
7+
Module GPS v2.0 is a high-performance GNSS global positioning module, integrated with the high-performance AT6668 chip to provide precise and reliable satellite positioning services. This module supports multi-frequency, multi-mode GNSS signal reception and is compatible with various satellite navigation systems, including GPS, BD2, BD3, GLONASS, GALILEO, and QZSS, enabling high-precision, multi-system joint positioning or single-system independent positioning, and offering excellent anti-jamming capabilities. In weak signal areas, it can quickly acquire higher precision positioning information.
8+
The module comes equipped with an external SMA antenna, and also features a dip switch to allow users to flexibly switch TX/RX communication pins, with PPS signal output for precise timing adjustments. It supports multi-stack usage, offering more customization and flexibility, making it suitable for high-precision positioning applications such as in-vehicle navigation, IoT positioning devices, remote monitoring, smart cities, and home and industrial automation.
9+
10+
Support the following products:
11+
12+
|GPSV2Module|
13+
14+
Micropython Example:
15+
16+
.. literalinclude:: ../../../examples/module/gpsv2/gpsv2_core2_example.py
17+
:language: python
18+
:linenos:
19+
20+
21+
UIFLOW2 Example:
22+
23+
|example.png|
24+
25+
.. only:: builder_html
26+
27+
|gpsv2_core2_example.m5f2|
28+
29+
class GPSV2Module
30+
----------------
31+
32+
Constructors
33+
------------
34+
35+
.. class:: GPSV2Module(id, rx, tx)
36+
37+
Initialize the GPSV2Module with a specific UART id and port for communication.
38+
39+
:param int id: The UART ID for communication with the GPS module. It can be 0, 1, or 2.
40+
:param rx: The RX pin of the UART.
41+
:param tx: The TX pin of the UART.
42+
43+
UIFLOW2:
44+
45+
|init.png|
46+
47+
48+
Methods
49+
-------
50+
51+
.. method:: GPSV2Module.set_work_mode(mode)
52+
53+
Set the working mode of the GPS module.
54+
55+
:param int mode: The mode to set, defined by the GPS module.
56+
57+
UIFLOW2:
58+
59+
|set_work_mode.png|
60+
61+
.. method:: GPSV2Module.get_work_mode()
62+
63+
Get the current working mode of the GPS module.
64+
65+
:return: The current working mode of the GPS module.
66+
67+
UIFLOW2:
68+
69+
|get_work_mode.png|
70+
71+
.. method:: GPSV2Module.get_antenna_state()
72+
73+
Get the state of the antenna.
74+
75+
:return: The antenna state.
76+
77+
UIFLOW2:
78+
79+
|get_antenna_state.png|
80+
81+
.. method:: GPSV2Module.get_gps_time()
82+
83+
Get the current GPS time.
84+
85+
:return: The GPS time as a list of strings [hour, minute, second].
86+
87+
UIFLOW2:
88+
89+
|get_gps_time.png|
90+
91+
.. method:: GPSV2Module.get_gps_date()
92+
93+
Get the current GPS date.
94+
95+
:return: The GPS date as a list of strings [day, month, year].
96+
97+
UIFLOW2:
98+
99+
|get_gps_date.png|
100+
101+
.. method:: GPSV2Module.get_gps_date_time()
102+
103+
Get the current GPS date and time combined.
104+
105+
:return: The GPS date and time as a list of strings [year, month, day, hour, minute, second].
106+
107+
UIFLOW2:
108+
109+
|get_gps_date_time.png|
110+
111+
.. method:: GPSV2Module.get_timestamp()
112+
113+
Get the timestamp of the current GPS time.
114+
115+
:return: The timestamp representing the current GPS time.
116+
117+
UIFLOW2:
118+
119+
|get_timestamp.png|
120+
121+
.. method:: GPSV2Module.get_latitude()
122+
123+
Get the current latitude.
124+
125+
:return: The current latitude in string format.
126+
127+
UIFLOW2:
128+
129+
|get_latitude.png|
130+
131+
.. method:: GPSV2Module.get_longitude()
132+
133+
Get the current longitude.
134+
135+
:return: The current longitude in string format.
136+
137+
UIFLOW2:
138+
139+
|get_longitude.png|
140+
141+
.. method:: GPSV2Module.get_altitude()
142+
143+
Get the current altitude.
144+
145+
:return: The current altitude in string format.
146+
147+
UIFLOW2:
148+
149+
|get_altitude.png|
150+
151+
.. method:: GPSV2Module.get_satellite_num()
152+
153+
Get the number of satellites used for positioning.
154+
155+
:return: The number of satellites.
156+
157+
UIFLOW2:
158+
159+
|get_satellite_num.png|
160+
161+
.. method:: GPSV2Module.get_pos_quality()
162+
163+
Get the quality of the GPS position.
164+
165+
:return: The position quality indicator.
166+
167+
UIFLOW2:
168+
169+
|get_pos_quality.png|
170+
171+
.. method:: GPSV2Module.get_corse_over_ground()
172+
173+
Get the course over ground (COG).
174+
175+
:return: The course over ground in degrees.
176+
177+
UIFLOW2:
178+
179+
|get_corse_over_ground.png|
180+
181+
.. method:: GPSV2Module.get_speed_over_ground()
182+
183+
Get the speed over ground (SOG).
184+
185+
:return: The speed over ground in knots.
186+
187+
UIFLOW2:
188+
189+
|get_speed_over_ground.png|
190+
191+
.. method:: GPSV2Module.set_time_zone(value)
192+
193+
Set the time zone offset for the GPS time.
194+
195+
:param value: The time zone offset value to set.
196+
197+
UIFLOW2:
198+
199+
|set_time_zone.png|
200+
201+
.. method:: GPSV2Module.get_time_zone()
202+
203+
Get the current time zone offset.
204+
205+
:return: The current time zone offset.
206+
207+
UIFLOW2:
208+
209+
|get_time_zone.png|
210+
211+
.. method:: GPSV2Module.deinit()
212+
213+
Deinitialize the GPS unit, stopping any running tasks and releasing resources.
214+
215+
UIFLOW2:
216+
217+
|deinit.png|
218+
219+
220+
.. method:: GPSV2Module._add_checksum(message)
221+
222+
Add checksum to the message for communication with the GPS module.
223+
224+
:param str message: The message to which the checksum will be added.
225+
226+
:return: The message with added checksum.
227+
228+
229+
.. method:: GPSV2Module._decode_gga(data)
230+
231+
Decode the GGA sentence to extract GPS quality, number of satellites, and altitude.
232+
233+
:param str data: The GGA sentence to decode.
234+
235+
236+
.. method:: GPSV2Module._decode_rmc(data)
237+
238+
Decode the RMC sentence to extract GPS time, latitude, longitude, speed, course, and date.
239+
240+
:param str data: The RMC sentence to decode.
241+
242+
243+
.. method:: GPSV2Module._decode_txt(data)
244+
245+
Decode the TXT sentence to extract antenna state.
246+
247+
:param str data: The TXT sentence to decode.
248+
249+
250+
.. method:: GPSV2Module._monitor()
251+
252+
Monitor the GPS data and decode incoming sentences.

docs/en/module/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Module
1111
dualkmeter.rst
1212
gnss.rst
1313
gps.rst
14+
gpsv2.rst
1415
grbl.rst
1516
goplus2.rst
1617
hmi.rst

docs/en/refs/module.gpsv2.ref

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
.. |GPSV2Module| image:: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/products/module/Module%20GPS%20v2.0/4.webp
3+
:target: https://docs.m5stack.com/en/module/Module%20GPS%20v2.0
4+
:height: 200px
5+
:width: 200px
6+
7+
.. |init.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/init.png
8+
.. |example.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/example.png
9+
.. |set_work_mode.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/set_work_mode.png
10+
.. |get_work_mode.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_work_mode.png
11+
.. |get_antenna_state.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_antenna_state.png
12+
.. |get_gps_time.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_gps_time.png
13+
.. |get_gps_date.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_gps_date.png
14+
.. |get_gps_date_time.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_gps_date_time.png
15+
.. |get_timestamp.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_timestamp.png
16+
.. |get_latitude.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_latitude.png
17+
.. |get_longitude.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_longitude.png
18+
.. |get_altitude.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_altitude.png
19+
.. |get_satellite_num.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_satellite_num.png
20+
.. |get_pos_quality.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_pos_quality.png
21+
.. |get_corse_over_ground.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_corse_over_ground.png
22+
.. |get_speed_over_ground.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_speed_over_ground.png
23+
.. |set_time_zone.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/set_time_zone.png
24+
.. |get_time_zone.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/get_time_zone.png
25+
.. |deinit.png| image:: https://static-cdn.m5stack.com/mpy_docs/module/gps_v2/deinit.png
26+
27+
28+
.. |gpsv2_core2_example.m5f2| raw:: html
29+
30+
<a
31+
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/module/gps_v2/gpsv2_core2_example.m5f2"
32+
target="_blank"
33+
>
34+
gpsv2_core2_example.m5f2
35+
</a>
36+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"V2.0","versionNumber":"V2.2.0","type":"core2","components":[{"name":"screen","type":"screen","layer":0,"screenId":"builtin","screenName":"","id":"__core2_screen","createTime":1731899117494,"x":0,"y":0,"width":320,"height":240,"backgroundColor":"#222222","size":0,"isSelected":true},{"name":"label0","type":"label","layer":1,"screenId":"builtin","screenName":"","id":"aV=hlRypz%`gCw6!","createTime":1731979364656,"x":1,"y":33,"color":"#ffffff","backgroundColor":"#222222","text":"Power On:","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false},{"name":"title0","type":"title","layer":2,"screenId":"builtin","screenName":"","id":"h&ax5VjJc5PS`x!w","createTime":1731982291747,"x":0,"y":0,"color":"#ffffff","backgroundColor":"#0000FF","text":"GPSV2Module Core2 Example","textOffset":3,"font":"Widgets.FONTS.DejaVu18","isSelected":false},{"name":"label1","type":"label","layer":3,"screenId":"builtin","screenName":"","id":"th_hP9V`=`Oc3Hne","createTime":1731982384061,"x":1,"y":66,"color":"#ffffff","backgroundColor":"#222222","text":"Satellite Num:","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false},{"name":"label2","type":"label","layer":4,"screenId":"builtin","screenName":"","id":"bFKKt&NFFQVsKRCz","createTime":1731982412771,"x":1,"y":202,"color":"#ffffff","backgroundColor":"#222222","text":"Timestamp:","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false},{"name":"label3","type":"label","layer":5,"screenId":"builtin","screenName":"","id":"fS+h`CcxnJPOUamC","createTime":1731982437766,"x":-6,"y":526,"color":"#ffffff","backgroundColor":"#222222","text":"GPS Data:","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false},{"name":"label4","type":"label","layer":6,"screenId":"builtin","screenName":"","id":"qhfaI_MwZgf-Z&4C","createTime":1731982459346,"x":1,"y":104,"color":"#ffffff","backgroundColor":"#222222","text":"Latitude:","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false},{"name":"label5","type":"label","layer":7,"screenId":"builtin","screenName":"","id":"isvW8fc2@_m+G&R2","createTime":1731982478637,"x":1,"y":140,"color":"#ffffff","backgroundColor":"#222222","text":"Longitude:","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false},{"name":"label6","type":"label","layer":8,"screenId":"builtin","screenName":"","id":"kaRu88vcg1v$uy3G","createTime":1731982491347,"x":1,"y":170,"color":"#ffffff","backgroundColor":"#222222","text":"Altitude:","engine":"gfx","font":"Widgets.FONTS.DejaVu18","rotation":0,"isSelected":false}],"resources":[{"hardware":["hardware_button","hardware_pin_button","imu","speaker","touch","mic"]},{"module":["module_gpsv2"]}],"units":[],"hats":[],"bases":[],"i2cs":[],"blockly":"<variables><variable id=\",2q]l?*B@B^ATa)BXHu%\">power_on_time</variable></variables><block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"370\" y=\"250\"><mutation isBegin=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_begin\" id=\"system_m5_begin\"><next><block type=\"module_gpsv2_init\" id=\"|Hq*!1D~+Co!QLAq#NmO\"><field name=\"NAME\">module_gpsv2_0</field><value name=\"UART\"><shadow type=\"module_gpsv2_id_option\" id=\"=MT2M`})oJMPL.Rc/Jfr\"><field name=\"VALUE\">2</field></shadow></value><value name=\"TX\"><shadow type=\"module_gpsv2_tx_option\" id=\"nIusE0Ahnm[Sm9xwZyhG\"><field name=\"VALUE\">14</field></shadow></value><value name=\"RX\"><shadow type=\"module_gpsv2_rx_option\" id=\",rH(mR).5|.?fXI^F,iG\"><field name=\"VALUE\">13</field></shadow></value><value name=\"PPS\"><shadow type=\"module_gpsv2_pps_option\" id=\",d[KRE2(/Cle(D7~F`5o\"><field name=\"VALUE\">25</field></shadow></value><next><block type=\"variables_set\" id=\":tFTNu0_#[_^t3/#$2,,\"><field name=\"VAR\" id=\",2q]l?*B@B^ATa)BXHu%\">power_on_time</field><value name=\"VALUE\"><block type=\"time_get_system_time\" id=\"jR?8bP[MIU#nAa$46?9A\"></block></value><next><block type=\"module_gpsv2_set_work_mode\" id=\"gu6`GjPXS]ZmFOgMuWE`\"><field name=\"NAME\">module_gpsv2_0</field><value name=\"VALUE\"><shadow type=\"module_gpsv2_work_mode_option\" id=\"~Erdadsb4n/)AiDlbH*f\"><field name=\"VALUE\">7</field></shadow></value></block></next></block></next></block></next></block></statement></block><block type=\"basic_on_loop\" id=\"loop_block\" deletable=\"false\" x=\"370\" y=\"590\"><mutation isUpdate=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_update\" id=\"system_m5_update\"><next><block type=\"label_set_text\" id=\",5^v[rvO^A@=rh0GFr]K\"><field name=\"NAME\">label0</field><value name=\"TEXT\"><shadow type=\"text\" id=\"-bXAGK2$*?)QH:pO#[Y1\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\";5QG;t13G)wu:gu0uYZN\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"X2~2dOJgl6Jlq=X?dtpA\"><field name=\"TEXT\">Power On:</field></shadow></value><value name=\"VALUE2\"><block type=\"math_arithmetic\" id=\"7S6J7TSLEMk8F,[!u)2i\"><field name=\"OP\">MINUS</field><value name=\"A\"><shadow type=\"math_number\" id=\"vf-POpo9Kbt#IE|i.$*5\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">1</field></shadow><block type=\"time_get_system_time\" id=\"rG4L3s`|=gKn(~K$(xj.\"></block></value><value name=\"B\"><shadow type=\"math_number\" id=\"[}Z03iEacM:?4/[YDSYr\"><mutation max=\"Infinity\" min=\"-Infinity\" precision=\"0\"></mutation><field name=\"NUM\">1</field></shadow><block type=\"variables_get\" id=\"[EP7::[YI^pp)X25tI(m\"><field name=\"VAR\" id=\",2q]l?*B@B^ATa)BXHu%\">power_on_time</field></block></value></block></value></block></value><next><block type=\"label_set_text\" id=\"!$HZ8Gg^dyG8LD$)}_7y\"><field name=\"NAME\">label1</field><value name=\"TEXT\"><shadow type=\"text\" id=\"-bXAGK2$*?)QH:pO#[Y1\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\"t.~IJB;1R?BFZKs;)3[d\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"!t}K$r;lh0}(xoE.o`nk\"><field name=\"TEXT\">Satellite Num:</field></shadow></value><value name=\"VALUE2\"><block type=\"module_gpsv2_get_satellite_num\" id=\"TwB(Gz}V(UN`seZI!QiD\"><field name=\"NAME\">module_gpsv2_0</field></block></value></block></value><next><block type=\"label_set_text\" id=\"(XB[G~]xii!:?a~k!N{s\"><field name=\"NAME\">label2</field><value name=\"TEXT\"><shadow type=\"text\" id=\"-bXAGK2$*?)QH:pO#[Y1\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\"lfbv##D[+djT,9*tc8fR\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"-G.!O,zDoI0,ELO}A(c-\"><field name=\"TEXT\">Timestamp:</field></shadow></value><value name=\"VALUE2\"><block type=\"module_gpsv2_get_timestamp\" id=\"gaBWyR~mF^#(tB%eRT6F\"><field name=\"NAME\">module_gpsv2_0</field></block></value></block></value><next><block type=\"label_set_text\" id=\")pq;aofcT8glyHZsNAWM\"><field name=\"NAME\">label4</field><value name=\"TEXT\"><shadow type=\"text\" id=\"-bXAGK2$*?)QH:pO#[Y1\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\"^6}L7?E6:tw6l@$bhsH-\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"i)G@q}$A^b_FF_~X1B%`\"><field name=\"TEXT\">Latitude:</field></shadow></value><value name=\"VALUE2\"><block type=\"module_gpsv2_get_latitude\" id=\"Xy66?x#O*DJd|)g1pLG/\"><field name=\"NAME\">module_gpsv2_0</field></block></value></block></value><next><block type=\"label_set_text\" id=\"BCD?rxF`:R)g?PU7qBc6\"><field name=\"NAME\">label5</field><value name=\"TEXT\"><shadow type=\"text\" id=\"-bXAGK2$*?)QH:pO#[Y1\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\"K;!Jj#Blm|0Dk+Z^17eY\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"G}yMRXL6C{L)#)^UYUrc\"><field name=\"TEXT\">Longitude:</field></shadow></value><value name=\"VALUE2\"><block type=\"module_gpsv2_get_longitude\" id=\"zV;]Ra1,T(klb]9}@!Tg\"><field name=\"NAME\">module_gpsv2_0</field></block></value></block></value><next><block type=\"label_set_text\" id=\"vOf2eqTNks%GzO#,Fla$\"><field name=\"NAME\">label6</field><value name=\"TEXT\"><shadow type=\"text\" id=\"-bXAGK2$*?)QH:pO#[Y1\"><field name=\"TEXT\">Label</field></shadow><block type=\"text_add_str\" id=\"u]efIO,9x1{4VqR4T4.*\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"(ub!#l@I[%[z%??=G[(F\"><field name=\"TEXT\">Altitude:</field></shadow></value><value name=\"VALUE2\"><block type=\"module_gpsv2_get_altitude\" id=\"bC(fclghWlM,Zg@9UBQf\"><field name=\"NAME\">module_gpsv2_0</field></block></value></block></value><next><block type=\"time_sleep_second\" id=\"H8.9QuT-t0y46F`Jnx-H\"><value name=\"SECOND\"><shadow type=\"math_number\" id=\"fl)dYRD5OHW{S6z96J|s\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">1</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block>","screen":[{"simulationName":"Built-in","type":"builtin","width":320,"height":240,"scale":0.78,"screenName":"","blockId":"","screenColorType":0,"id":"builtin","createTime":1731899117492}],"logicWhenNum":0,"customList":[]}

0 commit comments

Comments
 (0)