Skip to content

Commit c42b6ad

Browse files
Tinyu-Zhaolbuque
authored andcommitted
lib/units: Add GPS_V1.1 Unit Example.
Signed-off-by: Tinyu <[email protected]>
1 parent dcb5cdc commit c42b6ad

File tree

8 files changed

+116
-93
lines changed

8 files changed

+116
-93
lines changed

docs/en/refs/unit.gps_v11.ref

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,33 @@
44
:height: 200px
55
:width: 200px
66

7-
.. |init.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/init.png
8-
.. |set_work_mode.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/set_work_mode.png
9-
.. |get_work_mode.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_work_mode.png
10-
.. |get_antenna_state.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_antenna_state.png
11-
.. |get_gps_time.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_gps_time.png
12-
.. |get_gps_date.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_gps_date.png
13-
.. |get_gps_date_time.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_gps_date_time.png
14-
.. |get_timestamp.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_timestamp.png
15-
.. |get_latitude.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_latitude.png
16-
.. |get_longitude.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_longitude.png
17-
.. |get_altitude.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_altitude.png
18-
.. |get_satellite_num.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_satellite_num.png
19-
.. |get_pos_quality.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_pos_quality.png
20-
.. |get_corse_over_ground.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_corse_over_ground.png
21-
.. |get_speed_over_ground.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_speed_over_ground.png
22-
.. |set_time_zone.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/set_time_zone.png
23-
.. |get_time_zone.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/get_time_zone.png
24-
.. |deinit.png| image:: https://static-cdn.m5stack.com/mpy_docs//gps_v11/deinit.png
7+
.. |init.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/init.png
8+
.. |example.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/example.png
9+
.. |set_work_mode.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/set_work_mode.png
10+
.. |get_work_mode.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_work_mode.png
11+
.. |get_antenna_state.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_antenna_state.png
12+
.. |get_gps_time.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_gps_time.png
13+
.. |get_gps_date.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_gps_date.png
14+
.. |get_gps_date_time.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_gps_date_time.png
15+
.. |get_timestamp.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_timestamp.png
16+
.. |get_latitude.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_latitude.png
17+
.. |get_longitude.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_longitude.png
18+
.. |get_altitude.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_altitude.png
19+
.. |get_satellite_num.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_satellite_num.png
20+
.. |get_pos_quality.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_pos_quality.png
21+
.. |get_corse_over_ground.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_corse_over_ground.png
22+
.. |get_speed_over_ground.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_speed_over_ground.png
23+
.. |set_time_zone.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/set_time_zone.png
24+
.. |get_time_zone.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/get_time_zone.png
25+
.. |deinit.png| image:: https://static-cdn.m5stack.com/mpy_docs/unit/gps_v11/deinit.png
2526

2627

27-
.. |gps_example.m5f2| raw:: html
28+
.. |gpsv11_core2_example.m5f2| raw:: html
2829

2930
<a
30-
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/unit/gps_v11/gps_example.m5f2"
31+
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/unit/gps_v11/gpsv11_core2_example.m5f2"
3132
target="_blank"
3233
>
33-
gps_example.m5f2
34+
gpsv11_core2_example.m5f2
3435
</a>
3536

docs/en/units/gps_v11.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11

2-
GPSUnit V1.1
3-
============
2+
GPSV1.1(SMA) Unit
3+
=================
44

5-
.. include:: ../refs/.gpsunit.ref
5+
.. include:: ../refs/unit.gps_v11.ref
66

77
GPS Unit v1.1 is a GNSS global positioning navigation unit, integrating the high-performance CASIC navigation chip AT6668 and signal amplifier chip MAX2659, with a built-in ceramic antenna, providing more precise and reliable satellite positioning services.
88

9+
GPS SMA Unit is a GNSS global positioning navigation unit that integrates the high-performance CASIC navigation chip AT6668 and the signal amplifier chip MAX2659. It uses an external antenna to provide more accurate and reliable satellite positioning services.
10+
911
Support the following products:
1012

11-
|GPSV11Unit|
13+
|GPSV11Unit|
1214

1315
Micropython Example:
1416

15-
.. literalinclude:: ../../../examples/unit/gps_example.py
17+
.. literalinclude:: ../../../examples/unit/gps_v11/gpsv11_core2_example.py
1618
:language: python
1719
:linenos:
1820

@@ -23,10 +25,10 @@ UIFLOW2 Example:
2325

2426
.. only:: builder_html
2527

26-
|gps_example.m5f2|
28+
|gpsv11_core2_example.m5f2|
2729

2830
class GPSV11Unit
29-
-------------
31+
----------------
3032

3133
Constructors
3234
------------

docs/en/units/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Unit
3131
flash_light.rst
3232
glass.rst
3333
glass2.rst
34+
gps_v11.rst
3435
grove2grove.rst
3536
hall_effect.rst
3637
heart.rst
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"V2.0","versionNumber":"V2.1.7","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,"width":91,"height":20},{"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":"GPSV11Unit 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,"width":127,"height":20},{"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,"width":106,"height":20},{"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,"width":90,"height":20},{"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,"width":79,"height":20},{"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,"width":95,"height":20},{"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,"width":76,"height":20}],"resources":[{"hardware":["hardware_button","hardware_pin_button","imu","speaker","touch","mic"]},{"unit":["unit_gpsv11"]}],"units":[{"type":"unit_gpsv11","name":"gpsv11_0","portList":["A","B","C","Custom"],"portType":"A","userPort":[22,21],"id":"rCfd_BWx3VS`vUzk","createTime":1731979349754}],"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=\"270\"><mutation isBegin=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_begin\" id=\"system_m5_begin\"><next><block type=\"unit_gpsv11_init\" id=\"[email protected]~W-#Jei;ja7:;D:\"><field name=\"NAME\">gpsv11_0</field><value name=\"UART\"><shadow type=\"unit_gpsv11_id_option\" id=\"CkR~qbO]u!I_F~4,7Q_U\"><field name=\"VALUE\">2</field></shadow></value><next><block type=\"unit_gpsv11_set_work_mode\" id=\"E.7uMZqhqYPvI;q94o1+\"><field name=\"NAME\">gpsv11_0</field><value name=\"VALUE\"><shadow type=\"unit_gpsv11_work_mode_option\" id=\":j2X_Y9?7Qqu*PVfV7l4\"><field name=\"VALUE\">7</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></block></next></block></next></block></next></block></statement></block><block type=\"basic_on_loop\" id=\"loop_block\" deletable=\"false\" x=\"370\" y=\"490\"><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=\"unit_gpsv11_get_satellite_num\" id=\"$aTh)A*S9Q3E3wEYg9cO\"><field name=\"NAME\">gpsv11_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=\"unit_gpsv11_get_timestamp\" id=\"hHRjUa0T.dkO!ylQRtCL\"><field name=\"NAME\">gpsv11_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=\"unit_gpsv11_get_latitude\" id=\"*WqZWYms%J|D2}92tZdj\"><field name=\"NAME\">gpsv11_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=\"unit_gpsv11_get_longitude\" id=\"w|(?6lC(w@Err8T|Kl4C\"><field name=\"NAME\">gpsv11_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=\"unit_gpsv11_get_altitude\" id=\"$RYQ`m:~ivxLcEAe67+z\"><field name=\"NAME\">gpsv11_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":[]}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import os, sys, io
6+
import M5
7+
from M5 import *
8+
from unit import GPSV11Unit
9+
import time
10+
11+
12+
label0 = None
13+
title0 = None
14+
label1 = None
15+
label2 = None
16+
label3 = None
17+
label4 = None
18+
label5 = None
19+
label6 = None
20+
gpsv11_0 = None
21+
22+
23+
power_on_time = None
24+
25+
26+
def setup():
27+
global label0, title0, label1, label2, label3, label4, label5, label6, gpsv11_0, power_on_time
28+
29+
M5.begin()
30+
Widgets.fillScreen(0x222222)
31+
label0 = Widgets.Label("Power On:", 1, 33, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
32+
title0 = Widgets.Title(
33+
"GPSV11Unit Core2 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18
34+
)
35+
label1 = Widgets.Label(
36+
"Satellite Num:", 1, 66, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18
37+
)
38+
label2 = Widgets.Label("Timestamp:", 1, 202, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
39+
label3 = Widgets.Label("GPS Data:", -6, 526, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
40+
label4 = Widgets.Label("Latitude:", 1, 104, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
41+
label5 = Widgets.Label("Longitude:", 1, 140, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
42+
label6 = Widgets.Label("Altitude:", 1, 170, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
43+
44+
gpsv11_0 = GPSV11Unit(2, port=(33, 32))
45+
gpsv11_0.set_work_mode(7)
46+
power_on_time = time.time()
47+
48+
49+
def loop():
50+
global label0, title0, label1, label2, label3, label4, label5, label6, gpsv11_0, power_on_time
51+
M5.update()
52+
label0.setText(str((str("Power On:") + str(((time.time()) - power_on_time)))))
53+
label1.setText(str((str("Satellite Num:") + str((gpsv11_0.get_satellite_num())))))
54+
label2.setText(str((str("Timestamp:") + str((gpsv11_0.get_timestamp())))))
55+
label4.setText(str((str("Latitude:") + str((gpsv11_0.get_latitude())))))
56+
label5.setText(str((str("Longitude:") + str((gpsv11_0.get_longitude())))))
57+
label6.setText(str((str("Altitude:") + str((gpsv11_0.get_altitude())))))
58+
time.sleep(1)
59+
60+
61+
if __name__ == "__main__":
62+
try:
63+
setup()
64+
while True:
65+
loop()
66+
except (Exception, KeyboardInterrupt) as e:
67+
try:
68+
from utility import print_error_msg
69+
70+
print_error_msg(e)
71+
except ImportError:
72+
print("please update to latest firmware")

m5stack/libs/unit/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"GlassUnit": "glass",
5151
"Glass2Unit": "glass2",
5252
"GPSUnit": "gps",
53+
"GPSV11Unit": "gps_v11",
5354
"Grove2GroveUnit": "grove2grove",
5455
"HallEffectUnit": "hall_effect",
5556
"HbridgeUnit": "hbridge",

0 commit comments

Comments
 (0)