Merge branch 'master' of github.com:m5stack/m5-docs

This commit is contained in:
Gitshaoxiang
2020-05-13 17:08:00 +08:00
17 changed files with 376 additions and 5 deletions

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

+39 -1
View File
@@ -296,4 +296,42 @@ read encoder button
> display encoder status
><img src="/image/Modules/GoPlus_user.gif" width="70%">
><img src="/image/Modules/GoPlus_user.gif" width="70%">
# GPS
#### Feature Introduction
>Get GPS information
><img src="/image/Units/GPS.webp" width="30%">
* __get time__
Get local time
* __get latitude__
Get latitude
* __get longitude__
Get longitude
* __get satellite num__
Number of satellites acquired
* __get positioning quality__
Get positioning quality
* __get speed__
Obtain relative ground speed
* __get course__
Get geographic north pole location
* __set time zone__
Set local time zone
#### Usage
> Display GPS related information on the screen
><img src="/image/Units/GPS_user.webp" width="80%">
+39 -1
View File
@@ -681,4 +681,42 @@ Update the temperature inside the XY matrix and display the center temperature
> The screen displays the highest temperature minimum temperature and image center temperature
><img src="/image/Units/THERMAL_user.gif" width="50%">
><img src="/image/Units/THERMAL_user.gif" width="50%">
# GPS
#### Feature Introduction
>Get GPS information
><img src="/image/Units/GPS.webp" width="30%">
* __get time__
Get local time
* __get latitude__
Get latitude
* __get longitude__
Get longitude
* __get satellite num__
Number of satellites acquired
* __get positioning quality__
Get positioning quality
* __get speed__
Obtain relative ground speed
* __get course__
Get geographic north pole location
* __set time zone__
Set local time zone
#### Usage
> Display GPS related information on the screen
><img src="/image/Units/GPS_user.webp" width="80%">
+110 -1
View File
@@ -518,7 +518,7 @@ Write a string to the serial port
><img src="/image/Advanced module/I2C.webp" width="50%">
* __Master slave addr__
Set the host interface and slave address
Set the Master interface and slave address
* __Set at sda scl slave addr__
Custom SDA SCL and slave address
@@ -668,3 +668,112 @@ Return request data
>Send a GET request to Baidu, return data and print
><img src="/image/Advanced module/Http_user.gif" width="50%">
# EEPROM
#### Function Description
>Save the important data in the form of key-value pairs to the NVS partition to prevent data loss after shutdown (to prevent program processing from being blocked, the data is actually written in 5 seconds later), please do not write the data to the NVS partition repeatedly, otherwise it will affect the flash life and cause damage
><img src="/image/Advanced module/EEPROM.webp" width="40%">
* __EEPROM write key value__
Create a key-value pair to save data to EEPROM.
* __EEPROM read key__
Read out the data content corresponding to the keyword.
* __EEPROM read key to int__
Read out the data content corresponding to the keyword and convert Str to the Int.
#### Instructions
>Create key-value to write to NVS partition and read data.
><img src="/image/Advanced module/EEPROM_user.webp" width="70%">
# Modbus Master
#### Function Description
>Create a Modbus Master, encapsulate the data with Modbus protocol, send the data to the Slave through serial communication, and the data value range is 0-65535.
><img src="/image/Advanced module/modbus_master.webp" width="40%">
* __Init baud tx rx in uart crc__
Initialize the communication interface, and specify the Baudrate, TX, RX, Serial-port and CRC check with BIG or LITTLE mode
* __Send addr function reg addr value__
Send the packet to the specified Slave address. addr is the Slave address, function is the function number, reg_addr is the register address, and value is the user data.
* __Rx buffer cache number__
Number of bytes read from buffer
* __Read rx data__
Read the received packets, suitable for custom processing
* __Get rx addr function data__
Receive packets by callback, receive parameters by variables, and update parameters automatically
#### Instructions
>Main functions: (used together with the following Slave code) connect two M5Stack Fire, establish the Master and Slave through Modbus, the Master press the A / B button to send data, and receive the data packet returned from the Slave (receive function code 2). There are two ways to process the data packet:
>1.The data package returned from the Slave is processed by loop-cycle and displayed on the screen.
According to the definition of Modbus protocol, the data package returned from the Slave contains at least 3 valid data (address, function code, data), so more than 3 bytes is regarded as valid data, and the data is parsed through the List-block.
><img src="/image/Advanced module/modbus_loop_master_user.webp" width="100%">
>2. Handle the returned packets through the callback. When using the callback function, do not use loop-cycle, otherwise the callback will be blocked.
Set three variables to receive the address, function number and data returned from the Slave.
><img src="/image/Advanced module/modbus_callback_master_user.webp" width="100%">
# Modbus Slave
#### Function Description
>Create a Modbus Slave, receive the data package encapsulated by Modbus, communicate with the Master through the serial interface, and the data value range is 0-65535.
><img src="/image/Advanced module/modbus_slave.webp" width="40%">
* __Init addr baud tx rx in uart__
Initialize the communication interface, specify the Slave address, Baudrate, TX, RX and Serial-port,CRC is verified as BIG mode.
* __Init function reg addr value method__
Define Modbus data operation format, function is function number, reg_addr is register address, value is initial default value, method is read or write operation mode
* __Update function reg addr value__
Update the data in the specified register address according to the function number.
* __Get rx buffer data__
Read buffer data
* __Get reg write function reg addr value__
Obtain the data packets (function number, register address, data) sent by the Master by callback, and receive them by variables.
* __Get function reg addr value__
Get the content of the specified Master data package, and specify it by function number and register address.
* __send addr function reg addr value__
Respond to the content of the packet sent to the Master after receiving the Master packet.
#### Instructions
>Main functions: (used together with the Master code above) connect two M5Stack Fire, and establish the Master and Slave through Modbus. The Slave receives the data package of address code 1, function number 1 and register address 1, and then parses the data. if the data is 1 to light the LED bar, and if the data is 2 to turn off the LED Bar, at the same time, the Slave updates its own corresponding data in real time and responds to the Master (through function code 2). The Slave will also report the data to theMaster in real time through pressed A / B button. There are two ways to achieve this:
>1.Process the data package returned from the Slave through loop-cycle, update the data on the screen in time and respond.
Receive the specified packet and analyze the data, judge the data to respond and report to the Master (via function number 2), press A / B button to respond to itself, and send the packet report status to the Master (via function number 2)
><img src="/image/Advanced module/modbus_loop_slave_user.webp" width="100%">
>2. Through the callback to process the returned data, specify that the packet should add judgment processing to "fun" and "reg_addr". When using the callback function, loop should not be used, otherwise the callback will be blocked.
Set three variables to receive the address, function number and data sent by the Master, use the List-block to obtain data, judge and process the data, and report the status to the Master through (function number 2). Press the A / B button manually to report to the Master (via function number 2) while responding.
><img src="/image/Advanced module/modbus_callback_slave_user.webp" width="100%">
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

+37
View File
@@ -303,3 +303,40 @@ Module的I2C地址
><img src="/image/Modules/GoPlus_user.gif" width="70%">
# GPS
#### 功能说明
> 获取GPS信息
><img src="/image/Units/GPS.webp" width="50%">
* __get time__
获取本地时间
* __get latitude__
获取纬度
* __get longitude__
获取经度
* __get satellite num__
获取搜星数量
* __get positioning quality__
获取定位精度
* __get speed__
获取对地速度
* __get course__
获取地理北极位置
* __set time zone__
设置本地时区
#### 使用方法
> 在屏幕上显示GPS相关信息
><img src="/image/Units/GPS_user.webp" width="80%">
+39 -1
View File
@@ -680,4 +680,42 @@ id及权限匹配则执行以下操作
> 屏幕显示最高温度最低温度和图像中心温度
><img src="/image/Units/THERMAL_user.gif" width="50%">
><img src="/image/Units/THERMAL_user.gif" width="50%">
# GPS
#### 功能说明
> 获取GPS信息
><img src="/image/Units/GPS.webp" width="50%">
* __get time__
获取本地时间
* __get latitude__
获取纬度
* __get longitude__
获取经度
* __get satellite num__
获取搜星数量
* __get positioning quality__
获取定位精度
* __get speed__
获取对地速度
* __get course__
获取地理北极位置
* __set time zone__
设置本地时区
#### 使用方法
> 在屏幕上显示GPS相关信息
><img src="/image/Units/GPS_user.webp" width="80%">
+112 -1
View File
@@ -26,6 +26,8 @@
**[Http](#Http)**
**[EEPROM](#EEPROM)**
# 远程控制
#### 功能说明
@@ -697,7 +699,6 @@ wifi重新连接
><img src="/image/Advanced module/SDCard_user.gif" width="50%">
# Http
#### 功能说明
@@ -722,3 +723,113 @@ wifi重新连接
><img src="/image/Advanced module/Http_user.gif" width="50%">
# EEPROM
#### 功能说明
>将重要数据以键值对的形式保存至NVS分区,防止关机后数据丢失(为防止程序处理被阻塞,5秒后数据被真正写入),请不要将数据随意反复写入NVS分区,否则将影响Flash寿命导致损坏。
><img src="/image/Advanced module/EEPROM.webp" width="40%">
* __EEPROM write key value__
创建一个键值对将数据保存到EEPROM中
* __EEPROM read key__
读出关键字对应的数据内容
* __EEPROM read key to int__
读出关键字对应的数据内容并转为整形数据
#### 使用说明
>创建键值对写入到NVS分区,并读取数据
><img src="/image/Advanced module/EEPROM_user.webp" width="70%">
# Modbus Master
#### 功能说明
>创建一个Modbus主机,利用ModBus协议封装数据,通过串行通讯将数据下发至从机,数据取值范围0-65535。
><img src="/image/Advanced module/modbus_master.webp" width="40%">
* __Init baud tx rx in uart crc__
对通讯接口进行初始化操作,可指定波特率、发送引脚、接收引脚、串口号及CRC校验大小端模式
* __Send addr function reg addr value__
向指定的从机地址发送数据包,addr为从机地址,function为功能码,reg addr为寄存器地址,value为用户数据
* __Rx buffer cache number__
从缓冲区读取的字节数
* __Rx buffer cache number__
从缓冲区读取的字节数
* __Read rx data__
读取接收的数据包,适用于自定义处理
* __Get rx addr function data__
用回调的方式接收数据包,通过变量接收参数,参数自动更新
#### 使用说明
>主要功能:(从机代码见下方说明)连接两台M5Stack,通过Modbus建立主机和从机,主机按下A/B按键下发数据,并接收从机返回的数据包(接收功能码2),数据包处理方式有以下两种:
>1.通过LOOP处理从机返回的数据包,在屏幕上显示。
根据Modbus协议定义,从机返回数据包至少包含3个有效数据(地址、功能码、数据),因此大于3字节视为有效数据,通过列表对数据进行解析处理
><img src="/image/Advanced module/modbus_loop_master_user.webp" width="100%">
>2. 通过回调函数处理返回的数据包,当使用回调函数时不得使用LOOP否则会阻塞回调。
设置三个变量分别接收从机返回的地址、功能码、数据
><img src="/image/Advanced module/modbus_callback_master_user.webp" width="100%">
# Modbus Slave
#### 功能说明
>创建一个Modbus从机,接收ModBus封装的数据包,通过串行接口与主机通讯,数据取值范围0-65535。
><img src="/image/Advanced module/modbus_slave.webp" width="40%">
* __Init addr baud tx rx in uart__
对通讯接口进行初始化操作,可指定从机地址、波特率、发送引脚、接收引脚、串口号,CRC校验为大端模式
* __Init function reg addr value method__
定义Modbus数据操作格式,function为功能码,reg addr为寄存器地址, value为初始默认值, method为读或写操作模式
* __Update function reg addr value__
按功能码对指定的寄存器地址内数据进行更新
* __Get rx buffer data__
读取缓冲区数据
* __Get reg write function reg addr value__
用回调的方式获取主机发来的数据包(功能码、寄存器地址、数据),通过变量进行接收,需要自行处理
* __Get function reg addr value__
获取指定的主机数据包内容,通过功能码、寄存器地址进行指定
* __send addr function reg addr value__
接收到主机数据包后向主机回应发送的数据包内容
#### 使用说明
>主要功能:(主机代码见上方说明)连接两台M5Stack,通过Modbus建立主机和从机,从机接收到地址码1,功能码1,寄存器地址1的数据包后解析数据,数据为1点亮LED Bar,数据为2熄灭LED Bar,同时从机实时更新自身相应数据,并对主机做出回应(通过功能码2),从机自身通过A/B按键操作也会实时将数据上报给主机。实现方式有以下两种:
>1.通过LOOP处理从机返回的数据包,及时更新数据在屏幕上显示,并进行响应。
接收指定的数据包并解析数据,判断数据做出响应并上报主机(通过功能码2),按A/B键对自身响应,并向主机发送数据包报告状态(通过功能码2)
><img src="/image/Advanced module/modbus_loop_slave_user.webp" width="100%">
>2. 通过回调函数处理返回的数据,指定数据包要对fun和reg_addr加入判断处理,当使用回调函数时不得使用LOOP否则会阻塞回调。
设置三个变量分别接收主机发送的地址、功能码、数据,使用列表获取数据,对数据进行判断处理,同时将状态通过(功能码2)上报主机。手动按A/B键在自身响应的同时也会上报主机(通过功能码2).
><img src="/image/Advanced module/modbus_callback_slave_user.webp" width="100%">