diff --git a/docs/en/api/button.md b/docs/en/api/button.md index ff52da19..ee10e50f 100644 --- a/docs/en/api/button.md +++ b/docs/en/api/button.md @@ -209,7 +209,7 @@ void loop() { M5.Lcd.setCursor(0, 0); M5.Lcd.print("release Button A, 3 seconds will clear screen"); } - if (M5.BtnA.releasedFor(3000)) { + if (M5.BtnA.wasReleasefor(3000)) { M5.Lcd.clear(BLACK); } } diff --git a/docs/en/api/eeprom.md b/docs/en/api/eeprom.md index 3c3cba21..e77a10c7 100644 --- a/docs/en/api/eeprom.md +++ b/docs/en/api/eeprom.md @@ -24,8 +24,6 @@ Open EEPROM,Size is the maximum address + 1 of the data bytes to be read and wri **Description:** -Load before use - Write data to storage space. **Function argument** @@ -43,8 +41,6 @@ Write data to storage space. **Description:** -Load before use - This function needs to be called every time an address is written. **Function argument** @@ -59,8 +55,6 @@ None **Description:** -Load before use - Reading data from storage space. **Function argument** diff --git a/docs/en/api/gpio.md b/docs/en/api/gpio.md index b930ed63..fb88f247 100644 --- a/docs/en/api/gpio.md +++ b/docs/en/api/gpio.md @@ -258,7 +258,6 @@ Specify the port to output. None. - ## ledcWrite() **Syntax:** @@ -286,7 +285,6 @@ The unit of duty depends on the bit scale set at initialization. When specifying with 8 bits, specifying 0xFF results in 100% output. - ## ledcDetachPin() **Syntax:** @@ -388,8 +386,6 @@ Set the actual sampling times of single sampling, take the value of 1 ~ 255, def None - - ## analogSetAttenuation() **Syntax:** @@ -410,7 +406,6 @@ Set the global input attenuation of ADC to ADC_0db, ADC_2_5db, ADC_6db, ADC_11db None - ## analogSetPinAttenuation() **Syntax:** @@ -449,8 +444,7 @@ None **Function return value:** -None. - +int. ## attachInterrupt() diff --git a/docs/en/api/lcd.md b/docs/en/api/lcd.md index aa6e9a60..a24f2ba9 100644 --- a/docs/en/api/lcd.md +++ b/docs/en/api/lcd.md @@ -689,6 +689,34 @@ Draws a straight line of the specified color from the specified start point to t M5.Lcd.drawChar(0,0,'A',TFT_GREEN,TFT_BLACK,3); ``` +## drawChar() + +**Description:** + +Draws a straight line of the specified start point to the end point. + +**Syntax:** + +drawChar(int16_t uniCode, int32_t x, uint16_t y, uint8_t font); + +**Function argument:** + +| argument | type | Description | +| --- | --- | -- | +| uniCode | int32_t | char | +| x | int32_t | Coordinate X | +| y | uint16_t | coordinate Y | +| font | uint32_t | font | + +**Example of use:** + +```arduino +#include + + M5.begin(); + M5.Lcd.drawChar('A', 160, 120, 2); +``` + ## drawNumber() **Description:** diff --git a/docs/en/api/rtc.md b/docs/en/api/rtc.md index 0e060533..d9a972ea 100644 --- a/docs/en/api/rtc.md +++ b/docs/en/api/rtc.md @@ -25,7 +25,6 @@ void setup() { void loop(){}; ``` - ## GetTime() **Syntax:** @@ -97,7 +96,6 @@ void loop(){}; ``` - ## GetData() **Syntax:** diff --git a/docs/en/api/wifi.md b/docs/en/api/wifi.md index f552645d..422ec1d9 100644 --- a/docs/en/api/wifi.md +++ b/docs/en/api/wifi.md @@ -27,7 +27,6 @@ Use this method to open AP mode and return true after successful opening **Description:** -Load before use set AP IP address **Function argument** @@ -46,8 +45,6 @@ set AP IP address **Description:** -Load before use - Turn off the current AP and restore the network settings if wifioff is true **Function argument** @@ -64,8 +61,6 @@ Turn off the current AP and restore the network settings if wifioff is true **Description:** -Load before use - Returns the number of clients connected to AP **Function argument** @@ -80,8 +75,6 @@ None **Description:** -Load before use - Returns current IP of AP **Function argument** @@ -96,8 +89,6 @@ None **Description:** -Load before use - Set Hostname if success return true **Function argument** @@ -114,15 +105,12 @@ Set Hostname if success return true **Description:** -Load before use - Get Hostname if success return true **Function argument** None - ## WiFi.softAPmacAddress() **Syntax:** @@ -131,8 +119,6 @@ None **Description:** -Load before use - return MAC address **Function argument** @@ -147,16 +133,14 @@ None **Description:** -Load before use - This method is used to access the network .If connect equals true, it will connect to ssid's WiFi hotspot,If connect equals false, WiFi hotspots that are not connected to SSID will be created to save the above parameters. **Function argument** | Argument | Description | Type | | --- | --- | -- | -| ssid |The name of an AP network 0-32 bytes | const char* | -| passphrase | password NULL or 8-63 bytes | const char* | +| ssid | WiFi hospot name | const char* | +| passphrase | password | const char* | | channel | channel number | int32_t | | bssid | MAC address of WiFi hotspot, optional parameters | const uint8_t* | | connect | Establish a connection | bool | @@ -169,16 +153,15 @@ This method is used to access the network .If connect equals true, it will conne **Description:** -Load before use set network addresses. **Function argument** | Argument | Description | Type | | --- | --- | -- | -| local_ip | local_ip defult 192.168.4.1 | IPAddress | -| gateway | gateway defult 192.168.4.1 | IPAddress | -| subnet | subnet mask defult 255.255.255.0 | IPAddress | +| local_ip | local_ip address | IPAddress | +| gateway | gateway address | IPAddress | +| subnet | subnet mask address | IPAddress | | dns1 | DNS address | IPAddress | | dns2 | DNS address | IPAddress | @@ -191,8 +174,6 @@ set network addresses. **Description:** -Load before use - If wifioff is true, the network settings will be restored. If eraseap is true, the network parameters saved in flash will be cleared. **Function argument** @@ -210,8 +191,6 @@ If wifioff is true, the network settings will be restored. If eraseap is true, t **Description:** -Load before use - Returns whether the network has been accessed or not. **Function argument** @@ -226,15 +205,13 @@ None **Description:** -Load before use - Setting up automatic reconnection after disconnection. **Function argument** None -## WiFi.setAutoReconnect() +## WiFi.getAutoReconnect() **Syntax:** @@ -242,9 +219,7 @@ None **Description:** -Load before use - -Setting up automatic reconnection after disconnection. +Returns whether automatic reconnection occurs. **Function argument** @@ -258,8 +233,6 @@ None **Description:** -Load before use - Return local IP address. **Function argument** @@ -274,8 +247,6 @@ None **Description:** -Load before use - Return subnet mask. **Function argument** @@ -290,8 +261,6 @@ None **Description:** -Load before use - Return gateway IP address. **Function argument** @@ -306,8 +275,6 @@ None **Description:** -Load before use - Return DNS address. **Function argument** @@ -322,8 +289,6 @@ None **Description:** -Load before use - Return MAC address. **Function argument** @@ -338,8 +303,6 @@ None **Description:** -Load before use - Return Hostname. **Function argument** @@ -354,8 +317,6 @@ None **Description:** -Load before use - Return WIFI status. **Function return value** @@ -380,18 +341,11 @@ Return WIFI status. **Description:** -Load before use - scan wifi networks. **Function argument** -| Function argument |Type |Description | -| --- | --- | --- | -| async | false | Asynchronous scanning,the value is true, will not block | -| show_hidden | false | Whether to scan non-broadcast networks | -| passive | bool | boost scan | -| max_ms_per_chan | uint32_t | Scanning time per channel | +None ## WiFi.scanComplete() @@ -401,8 +355,6 @@ scan wifi networks. **Description:** -Load before use - Asynchronous mode is used to obtain the number of scanned networks. If the return value is - 1, it means that the scan is still in progress. If the return value is - 2, it means that the scan has not been done or failed. **Function argument** @@ -422,8 +374,6 @@ Asynchronous mode is used to obtain the number of scanned networks. If the retur **Description:** -Load before use - Delete scan results in memory. **Function argument** @@ -438,8 +388,6 @@ None **Description:** -Load before use - Returns the scanned network name. **Function argument** @@ -457,8 +405,6 @@ Returns the scanned network name. **Description:** -Load before use - Returns the type of network encryption scanned. **Function argument** @@ -475,8 +421,6 @@ Returns the type of network encryption scanned. **Description:** -Load before use - Return the scanned network signal strength. **Function argument** @@ -493,8 +437,6 @@ Return the scanned network signal strength. **Description:** -Load before use - Return the scanned network channel number. **Function argument** diff --git a/docs/zh_CN/api.md b/docs/zh_CN/api.md index 57d4eedd..18cdf6a2 100644 --- a/docs/zh_CN/api.md +++ b/docs/zh_CN/api.md @@ -8,8 +8,8 @@ |**[LCD 屏](zh_CN/api/lcd)** | **[按键](zh_CN/api/button)** | |**[MPU9250](zh_CN/api/mpu9250)** | **[TF 卡](zh_CN/api/tf)** | |**[电源管理](zh_CN/api/power)** |**[I/O](zh_CN/api/gpio)** | -|**[I2C](zh_CN/api/commutil)** | | - +|**[I2C](zh_CN/api/commutil)** | |**[EEPROM](zh_CN/api/eeprom)**| +|**[WIFI](zh_CN/api/wifi)**| \ No newline at end of file diff --git a/docs/zh_CN/api/button.md b/docs/zh_CN/api/button.md index 0fd28a59..5847bc7e 100644 --- a/docs/zh_CN/api/button.md +++ b/docs/zh_CN/api/button.md @@ -50,6 +50,33 @@ void loop() { } ``` +## lastChange() + +**函数原型:** + +uint32_t lastChange(void); + +**功能:** + +返回最后一次状态发生变化的时间 . + +**例程:** + +```arduino +#include + +void setup() { + M5.begin(); +} + +void loop() { + M5.update(); + int current_time = M5.BtnB.lastChange(); + M5.Lcd.setCursor(0, 0); + M5.Lcd.printf("The last change at No. %d ms",current_time); +} +``` + ## wasPressed() **函数原型:** @@ -107,3 +134,97 @@ void loop() { } } ``` + +## releasedFor() + +**函数原型:** + +uint8_t releasedFor(uint32_t ms) + +**功能:** + +如果按键松开超过设定的时间则总是返回真 + +**例程:** + +```arduino +#include + +void setup() { + M5.begin(); +} + +void loop() { + M5.update(); + M5.Lcd.clear(); + M5.Lcd.setCursor(0, 0); + if (M5.BtnA.wasPressed()) { + M5.Lcd.printf("Button A was pressed."); + delay(1000); + } +} +``` + +## wasReleased() + +**函数原型:** + +uint8_t wasReleased(void) + +**功能:** + +按键按下松开一次则返回一次真 + +**例程:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.print("Press Button A and release, you will see the message"); +} + +void loop() { + M5.update(); + if (M5.BtnA.wasReleased()){ + M5.Lcd.clear(); + M5.Lcd.setCursor(0, 0); + M5.Lcd.print("Button A was Released"); + } +} +``` + +## wasReleasefor() + +**函数原型:** + +uint8_t wasReleasefor(uint32_t ms); + +**功能:** + +按键按下,在超过指定时间后松开则返回真 . + +**例程:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.setCursor(0, 0); + M5.Lcd.print("press Button A to display message"); + delay(3000); +} + +void loop() { + M5.update(); + if (M5.BtnA.isPressed()){ + M5.Lcd.setCursor(0, 0); + M5.Lcd.print("release Button A, 3 seconds will clear screen"); + } + if (M5.BtnA.wasReleasefor(3000)) { + M5.Lcd.clear(BLACK); + } +} +``` \ No newline at end of file diff --git a/docs/zh_CN/api/eeprom.md b/docs/zh_CN/api/eeprom.md new file mode 100644 index 00000000..fd24affc --- /dev/null +++ b/docs/zh_CN/api/eeprom.md @@ -0,0 +1,64 @@ +## EEPROM.begin() + +**函数原型:** + +EEPROM.begin(size) + +**功能:** + +使用前加载 + +开启EEPROM,大小为最大地址+1个字节,范围1-4096. + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| size | int | EEPROM size | + +## EEPROM.write() + +**函数原型:** + +EEPROM.write(addr, data) + +**功能:** + +向地址写入数据. + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| addr | int | 空间存储地址 | +| data | int | 数据 | + +## EEPROM.commit() + +**函数原型:** + +EEPROM.commit() + +**功能:** + +每次向地址写入数据后都需要调用,保存数据. + +**函数参数** + +None + +## EEPROM.read() + +**函数原型:** + +EEPROM.read(addr) + +**功能:** + +读取地址内存储的数据. + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| addr | int | 读取地址内的数据 | \ No newline at end of file diff --git a/docs/zh_CN/api/gpio.md b/docs/zh_CN/api/gpio.md index 9185f86c..f128569f 100644 --- a/docs/zh_CN/api/gpio.md +++ b/docs/zh_CN/api/gpio.md @@ -46,7 +46,7 @@ ## digitalRead() -**構文:** +**函数原型:** int digitalRead(uint8_t pin); @@ -56,7 +56,7 @@ **参数** -| 参数 |型 |功能 | +| 参数 | 类型 | 描述 | | --- | --- | --- | | pin | uint8 |Pin No | @@ -79,7 +79,7 @@ pin21_data = digitalRead(21); ## digitalWrite() -**構文:** +**函数原型:** void digitalWrite(uint8_t pin, uint8_t val); @@ -89,7 +89,7 @@ pin21_data = digitalRead(21); **参数** -| 参数 |型 |功能 | +| 参数 | 类型 | 描述 | | --- | --- | --- | | pin | uint8 |pin No | | val | uint8 |输出状态(0/1) | @@ -112,7 +112,7 @@ digitalWrite(2,1); ## pinMode() -**構文:** +**函数原型:** void pinMode(uint8_t pin, uint8_t mode); @@ -122,7 +122,7 @@ digitalWrite(2,1); **参数** -| 参数 |型 |功能 | +| 参数 | 类型 | 描述 | | --- | --- | --- | | pin | uint8 |pin No | | mode | uint8 |INPUT,OUTPUT,INPUT_PULLUP 的任何一个| @@ -147,7 +147,7 @@ pinMode(2,INPUT); ## analogRead() -**構文:** +**函数原型:** uint16_t analogRead(uint8_t pin); **功能:** @@ -156,7 +156,7 @@ pinMode(2,INPUT); **参数** -| 参数 |型 |功能 | +| 参数 | 类型 | 描述 | | --- | --- | --- | | pin | uint8 |pin No | @@ -177,7 +177,7 @@ ret=analogRead(35); ## dacWrite() -**構文:** +**函数原型:** void dacWrite(uint8_t pin, uint8_t value); @@ -187,7 +187,7 @@ ret=analogRead(35); **参数** -| 参数 |型 |功能 | +| 参数 | 类型 | 描述 | | --- | --- | --- | | pin | uint8 |pin No | | value | uint8 |设定输出电压 | @@ -208,7 +208,7 @@ dacWrite(25,0x40); ## ledcSetup() -**構文:** +**函数原型:** double ledcSetup(uint8_t channel, double freq, uint8_t resolution_bits); @@ -218,7 +218,7 @@ dacWrite(25,0x40); **参数** -| 参数 |型 |功能 | +| 参数 | 类型 | 描述 | | --- | --- | --- | | channel | uint8 |channel (0~15) | | freq | double |frequency (Hz) | @@ -237,17 +237,17 @@ Actual output frequency. ## ledcAttachPin() -**構文:** +**函数原型:** void ledcAttachPin(uint8_t pin, uint8_t chan); **功能:** -Specify the port to output. +指定引脚. **参数** -| 参数 |型 |功能 | +| 参数 | 类型 | 描述 | | --- | --- | --- | | pin | uint8_t |pin No) | | chan | uint8_t |渠道(0~15) | @@ -259,7 +259,7 @@ Specify the port to output. ## ledcWrite() -**構文:** +**函数原型:** void ledcWrite(uint8_t chan, uint32_t duty); @@ -269,7 +269,7 @@ Specify the port to output. **参数** -| 参数 |型 |功能 | +| 参数 | 类型 | 描述 | | --- | --- | --- | | chan | uint8_t |渠道(0~15) | | duty | uint32_t |比 | @@ -287,7 +287,7 @@ Specify the port to output. ## ledcDetachPin() -**構文:** +**函数原型:** void ledcDetachPin(uint8_t pin); @@ -297,7 +297,7 @@ Specify the port to output. **参数** -| 参数 |型 |功能 | +| 参数 | 类型 | 描述 | | --- | --- | --- | | pin | uint8_t |pin No | @@ -305,3 +305,305 @@ Specify the port to output. **返回值:** 无。 + +## adcAttachPin() + +**函数原型:** + +bool adcAttachPin(uint8_t pin) + +**功能:** + +非阻塞模式.连接设定引脚到ADC . + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| pin | uint8_t | 指定引脚 | + +**函数返回值:** + +设置成功返回1 + +## adcBusy() + +**函数原型:** + +bool adcBusy(uint8_t pin) + +**功能:** + +非阻塞模式,检查adc转换是否进行中. + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| pin | uint8_t | 指定引脚 | + +**函数返回值:** + +转换中返回1 + +## adcEnd() + +**函数原型:** + +uint16_t adcEnd(uint8_t pin) + +**功能:** + +非阻塞模式,返回转换结果,如果未转换完成等待完成. + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| pin | uint8_t | 指定引脚 | + +**函数返回值:** + +返回转换结果 + +## adcStart() + +**函数原型:** + +bool adcStart(uint8_t pin) + +**功能:** + +非阻塞模式,开启adc转换. + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| pin | uint8_t | 指定引脚 | + +**函数返回值:** + +成功开启返回1 + + +## analogReadResolution() + +**函数原型:** + +void analogReadResolution(uint8_t bits) + +**功能:** + +设置模拟数据读取分辨率,取值1~16,默认为12。如果介于9和12之间,它将等于设置的硬件分辨率,否则值将被移动. + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| bits | uint8_t | 采样分辨率 | + +**函数返回值:** + +None + +## analogSetAttenuation() + +**函数原型:** + +void analogSetAttenuation(adc_attenuation_t attenuation) + +**功能:** + +设置ADC全局输入衰减,取值ADC_0db, ADC_2_5db, ADC_6db, ADC_11db,默认为11db + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| attenuation | adc_attenuation_t | 衰减值 | + +**函数返回值:** + +None + +## analogSetCycles() + +**函数原型:** + +void analogSetCycles(uint8_t cycles) + +**功能:** + +设置采样周期1-255,默认为8. + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| cycles | uint8_t | sampling period | + +**函数返回值:** + +None + +## analogSetPinAttenuation() + +**函数原型:** + +void analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation) + +**功能:** + +设置某个单独引脚衰减 + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| pin | uint8_t | specified pin | +| attenuation | adc_attenuation_t | 衰减值 | + +**函数返回值:** + +None + +## analogSetSamples() + +**函数原型:** + +void analogSetSamples(uint8_t samples) + +**功能:** + +设置单次采样的实际采样倍数,取值1-255,默认为1,实际效果为提高adc灵敏度,采样次数扩大N倍; + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| samples | uint8_t | 采样倍数 | + +**函数返回值:** + +None + +## analogSetWidth() + +**函数原型:** + +void analogSetWidth(uint8_t bits) + +**功能:** + +设置adc采样分辨率9-12,默认为12. + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| bits | uint8_t | 采样分辨率 | + +**函数返回值:** + +None + +## attachInterrupt() + +**函数原型:** + +void attachInterrupt(pin, ISR(callback function), interrupt type/mode) + +**功能:** + +设置引脚中断. + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| pin | uint8_t | 引脚 | +| ISR | callcack function | 回调函数 | +| interrupt | mode | 触发类型 | + +**函数返回值:** + +None. + +## detachInterrupt() + +**函数原型:** + +void detachInterrupt(pin) + +**功能:** + +Prohibit specified pin interruptio. + +**函数参数** + +| 函数参数 |类型 |功能 | +| --- | --- | --- | +| pin | uint8_t | pin No. | + +**函数返回值:** + +None. + +## hallRead() + +**函数原型:** + +int hallRead(void)); + +**功能:** + +读取霍尔传感器. + +**函数参数** + +None + +**函数返回值:** + +int. + +## ledcRead() + +**函数原型:** + +uint32_t ledcRead(uint8_t channel) + +**功能:** + +返回指定通道的占空比. + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| channel | uint8_t | 指定通道 | + +**函数返回值:** + +占空比 + +## ledcReadFreq() + +**函数原型:** + +double ledcReadFreq(uint8_t channel) + +**功能:** + +返回当前通道频率. + +**函数参数** + +| 函数参数 |类型 | 描述 | +| --- | --- | --- | +| channel | uint8_t | 指定通道 | + +**函数返回值:** + +通道频率 \ No newline at end of file diff --git a/docs/zh_CN/api/lcd.md b/docs/zh_CN/api/lcd.md index 74510cbb..1bbee3f9 100644 --- a/docs/zh_CN/api/lcd.md +++ b/docs/zh_CN/api/lcd.md @@ -82,6 +82,39 @@ M5.Lcd.sleep(); M5.Lcd.setBrightness(0); ``` +## alphaBlend() + +**函数原型:** + +设置透明度,混合前景和背景色. + +**Syntax:** + +uint16_t alphaBlend(uint8_t alpha, uint16_t fgc, uint16_t bgc); + +**Function argument:** + +| 参数 | 描述 | 类型 | +| --- | --- | -- | +| alpha | 透明度 | uint8_t | +| fgc | 前景色 | uint16_t | +| bgc | 背景色 | uint16_t | + +**使用示例:** + +```arduino +#include + +M5.begin(); + +int val = M5.Lcd.alphaBlend(128, 0X00FF00, 0XFF0000); + +M5.Lcd.fillRect(0, 0, 320, 240, val); + +M5.Lcd.print(val); +``` + + ## wakeup() **功能:** @@ -126,7 +159,7 @@ M5.Lcd.setBrightness(200); **参数:** -| 值 | 型 | 功能 | +| 参数 | 类型 | 描述 | | --- | --- | -- | | brightness | uint8_t | 亮度 (0: Off - 255:Full) | @@ -161,7 +194,7 @@ M5.Lcd.setBrightness(200); **参数:** -| 值 | 型 | 功能 | +| 参数 | 类型 | 描述 | | --- | --- | -- | | x | int | 坐标 X(左上角) | | y | int | 坐标 Y(左上角) | @@ -204,7 +237,7 @@ Generate a QR code. **参数:** -| 值 | 型 | 功能 | +| 参数 | 类型 | 描述 | | --- | --- | -- | | val | string / String& | 要嵌入QR的字符串 | | x | uint16_t | 坐标 X(左上角) | @@ -251,7 +284,7 @@ Generate a QR code. **参数:** -| 值 | 型 | 功能 | +| 参数 | 类型 | 描述 | | --- | --- | -- | | x0 | uint16_t | 坐标 X(左上角) | | y0 | uint16_t | 坐标 Y(左上角) | @@ -272,6 +305,33 @@ Generate a QR code. 见样品 sketch:M5Stack->Advanced->drawXBitmap +## drawChar() + +**功能:** + +显示字符 + +**函数原型:** + +drawChar(int16_t uniCode, int32_t x, uint16_t y, uint8_t font); + +**函数参数:** + +| 参数 | 类型 | 描述 | +| --- | --- | -- | +| uniCode | int32_t | 字符 | +| x | int32_t | X坐标 | +| y | uint16_t | Y坐标 | +| font | uint32_t | 字体 | + +**使用示例:** + +```arduino +#include + + M5.begin(); + M5.Lcd.drawChar('A', 160, 120, 2); +``` ## drawBmpFile() @@ -287,7 +347,7 @@ Generate a QR code. **参数:** -| 值 | 型 | 功能 | +| 参数 | 类型 | 描述 | | --- | --- | -- | | fs | fs::FS | 文件流 | | path | const char * | 文件路径 | @@ -327,7 +387,7 @@ Generate a QR code. **参数:** -| 值 | 型 | 功能 | +| 参数 | 类型 | 描述 | | --- | --- | -- | | jpg_data |uint8_t * | 数据顶部 | | jpg_len | size_t | 数据长度 | @@ -375,7 +435,7 @@ Generate a QR code. **参数:** -| 值 | 型 | 功能 | +| 参数 | 类型 | 描述 | | --- | --- | -- | | fs | fs::FS | 文件流 | | path | const char * | 文件路径 | @@ -644,6 +704,31 @@ M5.Lcd.drawFastHLine(0, 0, 12, TFT_GREEN); M5.Lcd.drawFastHLine(0, 0, 12, TFT_GREEN); ``` +## drawNumber() + +**功能:** + +显示整数. + +**函数原型:** + +drawNumber(long long_num, int32_t poX, int32_t poY); + +**Function argument:** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| long_num | long | 数字 | +| poX | int32_t | X坐标 | +| poY | int32_t | Y坐标Y | + +**Example of use:** + +```arduino +#include + +M5.Lcd.drawNumber(12345, 160, 120); +``` ## drawLine() @@ -741,6 +826,116 @@ lcd.drawLine(0,0,12,12,lcd.WHITE) * * * +## fillCircle() + +**函数原型:** + +fillCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color); + +**功能: Draw a filled circle on point(x0, y0), Radis is r with color** + +| 参数 | 类型 | ,描述 | +| --- | --- | --- | +| x0 | int32_t | 中心点X坐标 | +| y0 | int32_t | 中心点y坐标 | +| r | int32_t | 半径 | +|color| uint32_t | 颜色 0~65535 | + +**例程:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.fillCircle(160, 120, 30, 0XFF00FF); +``` + +* * * + +## fillSprite() + +**功能:** + +将精灵填充指定颜色 + +**函数原型:** + +void fillSprite(uint32_t color) + +**函数参数:** + +| 参数 | 类型 | 描述 | +| --- | --- | -- | +| color | int32_t | filled color | + +**例程:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.createSprite(70, 80); + +img.fillSprite(WHITE); +``` + +* * * + +## getCursorX() + +**函数原型:** + +uint16_t getCursorX(void); + + + +**功能: 获取x坐标.** + +**例程:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.print("Hello "); + +int X = M5.Lcd.getCursorX(); + +M5.Lcd.print(X); +``` + +## getCursorY() + +**函数原型:** + +uint16_t getCursorY(void); + + + +**功能: 获取y坐标.** + +**Example:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.setCursor(0, 20); +M5.Lcd.print("Hello "); + +int Y = M5.Lcd.getCursorY(); + +M5.Lcd.print(Y); +``` + +* * * + ## drawRect() **函数原型:** @@ -808,6 +1003,280 @@ lcd.drawLine(0,0,12,12,lcd.WHITE) ``` --> +* * * + +## getRotation() + +**功能:** + +返回屏幕旋转方向 + +**函数原型:** + +uint8_t getRotation(void) + +**Function argument:** + +None + +**Example of use:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.print(M5.Lcd.getRotation()); +``` + +* * * +## textWidth() + +**功能:** + +返回文本所占像素宽度 + +**函数原型:** + +int16_t textWidth(const String& string) + +**函数参数:** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| string | const String& | text String | + +**例程:** + +```arduino +#include + +M5.begin(); + +String text = "hello "; + +M5.Lcd.print(text); + +M5.Lcd.print(M5.Lcd.textWidth(text)); +``` + +* * * + +## getTextDatum() + +**功能:** + +返回文字对齐方式 + +**函数原型:** + +uint8_t setRotation(void) + +**函数参数:** + +None + +**例程:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.setTextDatum(MC_DATUM); + +M5.Lcd.print(M5.Lcd.getTextDatum()); +``` + +* * * + +## setTextDatum() + +**功能:** + +设置文本对齐方式 + +**函数原型:** + +setTextDatum(uint8_t datum) + +**函数参数:** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| TL_DATUM | uint8_t | 左上角对齐 | +| TC_DATUM | uint8_t | 居中向上对齐 | +| TR_DATUM | uint8_t | 右上角对齐 | +| ML_DATUM | uint8_t | 中部左对齐 | +| MC_DATUM | uint8_t | 中心对齐 | +| MR_DATUM | uint8_t | 中部右对齐 | +| BL_DATUM | uint8_t | 左下角对齐 | +| BC_DATUM | uint8_t | 居中底部对齐 | +| BR_DATUM | uint8_t | 右下角对齐 | + +**例程:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.setTextDatum(MC_DATUM); + +M5.Lcd.drawString("hello", 160, 120, 2); +``` + +* * * + +## height() + +**功能:** + +返回精灵高度 + +**函数原型:** + +int16_t height(void) + +**函数参数:** + +None + +**例程:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.createSprite(70, 80); + +M5.Lcd.print(img.height()); +``` + +* * * + +## setTextPadding() + +**功能:** + +覆盖文本重新分配显示区域 + +**函数原型:** + +setTextPadding(uint16_t x_width) + +**Function argument:** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| x_width | uint16_t | 空白区域宽度 | + +**示例:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.drawString("Orbitron 32", 160, 60,2); + +delay(2000); + +M5.Lcd.setTextPadding(M5.Lcd.width() - 20); + +M5.Lcd.drawString("Orbitron 32 with padding", 160, 60, 2); +``` + +* * * + +## setTextWrap() + +**功能:** + +是否自动换行 + +**函数原型:** + +setTextWrap(boolean wrapX, boolean wrapY) + +**函数参数:** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| wrapX | boolean | X 方向 | +| wrapY | boolean | Y 方向 | + +**例程:** + +```arduino +#include + +M5.Lcd.setTextWrap(ture, true); +``` +* * * + +## hight() + +**功能:** + +返回屏幕高度 + +**函数原型:** + +int16_t height(void) + +**函数参数:** + +None + +**例程:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.print(M5.Lcd.height()); +``` + +* * * + +## pushSprite() + +**功能:** + +推送精灵到指定坐标 可以设置透明色 + +**函数原型:** + +void pushSprite(int32_t x, int32_t y, uint16_t transparent) + +**函数参数:** + +| 参数 | 类型 | 描述 | +| --- | --- | -- | +| x | int32_t | X坐标 | +| y | int32_t | Y坐标 | +| transparent | int16_t | 透明色 可选 | + + +**Example of use:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.createSprite(70, 80); + +img.pushSprite(35, 40, WHITE); +``` + * * * ## drawRoundRect() @@ -845,6 +1314,32 @@ lcd.drawLine(0,0,12,12,lcd.WHITE) * * * +## width() + +**功能:** + +返回屏幕像素宽度 + +**函数原型:** + +int16_t width(void) + +**函数参数:** + +None + +**例程:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.print(M5.Lcd.width()); +``` + +* * * + ## fillRoundRect() **功能:** @@ -874,7 +1369,62 @@ lcd.drawLine(0,0,12,12,lcd.WHITE) M5.begin(); M5.Lcd.fillRoundRect(180, 70, 122, 10, 4, BLUE); ``` +* * * +## width() + +**功能:** + +返回精灵宽度 + +**函数原型:** + +int16_t width(void) + +**函数参数:** + +None + +**例程:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.createSprite(70, 80); + +M5.Lcd.print(img.width()); +``` + +## drawFloat() + +**功能:** + +显示小数,最多小数点后7位 + +**函数原型:** + +int16_t drawFloat(float floatNumber, uint8_t dp, int32_t poX, int32_t poY); + +**函数参数:** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| floatNumber | float | number | +| dp | uint8_t | Within seven decimal places | +| poX | int32_t | coordinate of Y | +| poY | int32_t | coordinate of Y | + +**使用示例:** + +```arduino +#include + +M5.Lcd.drawFloat(12.345, 3, 160, 120); +``` ## drawEllipse() @@ -967,6 +1517,34 @@ M5.Lcd.drawEllipse(100,100,20,30, TFT_GREEN); ``` +## deleteSprite() + +**功能:** + + 从内存删除精灵 + +**函数原型:** + +deleteSprite(void) + +**函数参数:** + +None + +**使用示例:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.createSprite(70, 80); + +img.deleteSprite(); +``` + ## setRotation() **功能:** diff --git a/docs/zh_CN/api/mpu9250.md b/docs/zh_CN/api/mpu9250.md index e3590a54..b2654251 100644 --- a/docs/zh_CN/api/mpu9250.md +++ b/docs/zh_CN/api/mpu9250.md @@ -256,4 +256,43 @@ void loop(){ Serial.println(" mg "); } } +``` + +## readTempData() + +**函数原型:** + +int16_t readTempData(void); + +**功能:** + +读取温度. + +**例程:** + +```arduino +#include +#include "utility/MPU9250.h" + +MPU9250 IMU; // new a MPU9250 object + +void setup() +{ + M5.begin(); + Wire.begin(); + + IMU.calibrateMPU9250(IMU.gyroBias, IMU.accelBias); + IMU.initMPU9250(); + IMU.initAK8963(IMU.magCalibration); +} + +void loop() +{ + IMU.tempCount = IMU.readTempData(); + IMU.temperature = ((float) IMU.tempCount) / 333.87 + 21.0; + M5.Lcd.setCursor(0, 0); + M5.Lcd.print("MPU9250 Temperature is "); + M5.Lcd.print(IMU.temperature, 1); + delay(500); +} ``` \ No newline at end of file diff --git a/docs/zh_CN/api/rtc.md b/docs/zh_CN/api/rtc.md new file mode 100644 index 00000000..ec705dd0 --- /dev/null +++ b/docs/zh_CN/api/rtc.md @@ -0,0 +1,139 @@ +## SetTime() + +**函数原型:** + +void SetTime(RTC_TimeTypeDef* RTC_TimeStruct) + +**函数参数:** + +设置结构体变量时间 + +**示例:** + +```arduino +#include + +RTC_TimeTypeDef TimeStruct; +void setup() { + M5.begin(); + + TimeStruct.Hours = 18; + TimeStruct.Minutes = 56; + TimeStruct.Seconds = 10; + M5.Rtc.SetTime(&TimeStruct); +} +void loop(){}; +``` + + +## GetTime() + +**函数原型:** + +void GetTime(RTC_TimeTypeDef* RTC_TimeStruct) + +**函数参数:** + +获取结构体时间 + +**示例:** + +```arduino + +#include + +RTC_TimeTypeDef TimeStruct; +void setup() { + M5.begin(); + M5.Lcd.setRotation(3); + M5.Lcd.fillScreen(BLACK); + + M5.Lcd.setTextSize(1); + M5.Lcd.setCursor(40, 0, 2); + M5.Lcd.println("RTC TEST"); + + TimeStruct.Hours = 18; + TimeStruct.Minutes = 56; + TimeStruct.Seconds = 10; + M5.Rtc.SetTime(&TimeStruct); +} + +void loop() { + M5.Rtc.GetTime(&TimeStruct); + M5.Lcd.setCursor(0, 15); + M5.Lcd.printf("Time: %02d : %02d : %02d\n",TimeStruct.Hours, TimeStruct.Minutes, TimeStruct.Seconds); + delay(500); +} +``` + +## SetData() + +**函数原型:** + +void SetData(RTC_TimeTypeDef* RTC_DateStruct) + +**函数参数:** + +设置结构体变量日期 + +**示例:** + +```arduino + +#include + +RTC_TimeTypeDef TimeStruct; +RTC_DateTypeDef DateStruct; +void setup() { + M5.begin(); + + DateStruct.WeekDay = 3; + DateStruct.Month = 3; + DateStruct.Date = 22; + DateStruct.Year = 2019; + M5.Rtc.SetData(&DateStruct); +} +void loop(){}; + +``` + + +## GetData() + +**函数原型:** + +void GetData(RTC_TimeTypeDef* RTC_DateStruct) + +**函数参数:** + +获取结构体变量日期 + +**示例:** + +```arduino +#include + +RTC_DateTypeDef DateStruct; +void setup() { + M5.begin(); + M5.Lcd.setRotation(3); + M5.Lcd.fillScreen(BLACK); + + M5.Lcd.setTextSize(1); + M5.Lcd.setCursor(40, 0, 2); + M5.Lcd.println("RTC TEST"); + + DateStruct.WeekDay = 3; + DateStruct.Month = 3; + DateStruct.Date = 22; + DateStruct.Year = 2019; + M5.Rtc.SetData(&DateStruct); +} + +void loop() { + M5.Rtc.GetData(&DateStruct); + M5.Lcd.setCursor(0, 15); + M5.Lcd.printf("Data: %04d-%02d-%02d\n",DateStruct.Year, DateStruct.Month,DateStruct.Date); + M5.Lcd.printf("Week: %d\n",DateStruct.WeekDay); + delay(500); +} \ No newline at end of file diff --git a/docs/zh_CN/api/wifi.md b/docs/zh_CN/api/wifi.md new file mode 100644 index 00000000..85beca90 --- /dev/null +++ b/docs/zh_CN/api/wifi.md @@ -0,0 +1,447 @@ +## WiFi.softAP() + +**函数原型:** + +bool WiFi.softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden, int max_connection) + +**功能:** + +使用前加载 + +开启AP模式,开启成功返回真 + +**函数参数** + +| 参数 | 描述 | 类型 | +| --- | --- | -- | +| ssid | AP名称 0-32个字节 | const char* | +| passphrase | 密码8-63个字节或NULL| const char* | +| ssid_hidden | 是否隐藏SSID 1:隐藏 0:不隐藏 | int | +| max_conncetion | 最大连接数量1-4 | int | + +## WiFi.softAPConfig() + +**函数原型:** + +bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet) + +**功能:** + +设置AP的IP地址 + +**函数参数** + +| 参数 | 描述 | 类型 | +| --- | --- | -- | +| local_ip | 默认本地IP 192.168.4.1 | IPAddress | +| gateway | 默认网关 192.168.4.1 | IPAddress | +| subnet | 默认子网掩码 255.255.255.0 | IPAddress | + +## WiFi.softAPdisconnect() + +**函数原型:** + +bool softAPdisconnect(bool wifioff = false) + +**功能:** + +关闭当前AP,wifioff设置为true则还原网络设置 + +**函数参数** + +| 参数 | 描述 | 类型 | +| --- | --- | -- | +| wifioff | 还原设置 | bool | + +## WiFi.softAPgetStationNum() + +**函数原型:** + +uint8_t softAPgetStationNum() + +**功能:** + +返回连接到AP的客户端数量 + +**函数参数** + +None + +## WiFi.softAPIP() + +**函数原型:** + +IPAddress softAPIP() + +**功能:** + +返回当前AP的IP地址 + +**函数参数** + +None + +## WiFi.softAPsetHostname() + +**函数原型:** + +bool softAPsetHostname(const char * hostname) + +**功能:** + +设置主机名称,成功返回真 + +**函数参数** + +| 参数 | 描述 | 类型 | +| --- | --- | -- | +| hostname | 主机名称 | const char* | + +## WiFi.softAPgetHostname() + +**函数原型:** + +const char * softAPgetHostname() + +**功能:** + +获得主机名称 + +**函数参数** + +None + +## WiFi.softAPmacAddress() + +**函数原型:** + +String softAPmacAddress(void) + +**功能:** + +返回主机MAC + +**函数参数** + +None + +## WiFi.begin() + +**函数原型:** + +wl_status_t begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true) + +**功能:** + +使用这个方法来接入网络.如果connect参数为真则接入网络,如果参数为假则只保存设置,返回wifi状态 + +**函数参数** + +| 参数 | 描述 | 类型 | +| --- | --- | -- | +| ssid | 网络热点名称 | const char* | +| passphrase | 密码 | const char* | +| channel | 热点通道号 | int32_t | +| bssid | 热点的mac地址 可选 | const uint8_t* | +| connect | 建立连接 | bool | + +## WiFi.config() + +**函数原型:** + +bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000) + +**功能:** + +配置网络地址 + +**函数参数** + +| 参数 | 描述 | 类型 | +| --- | --- | -- | +| local_ip | 设置IP| IPAddress | +| gateway | 设置网关 | IPAddress | +| subnet | 设置子网掩码 | IPAddress | +| dns1 | 设置DNS1 | IPAddress | +| dns2 | 设置DNS2 | IPAddress | + + +## WiFi.disconnect() + +**函数原型:** + +bool disconnect(bool wifioff = false, bool eraseap = false) + +**功能:** + +断开网络连接,若wifioff为true则还将还原网络设置,若eraseap为true则将清除保存于flash中的网络参数. + +**函数参数** + +| 参数 | 描述 | 类型 | +| --- | --- | -- | +| wifioff | 还原设置 | bool | +| eraseap | flash清除AP设置 | bool | + +## WiFi.isConnected() + +**函数原型:** + +bool isConnected() + +**功能:** + +返回网络连接状态 + +**函数参数** + +None + +## WiFi.setAutoReconnect() + +**函数原型:** + +bool setAutoReconnect(bool autoReconnect) + +**功能:** + +设置自动重连. + +**函数参数** + +None + +## WiFi.getAutoReconnect() + +**函数原型:** + +bool getAutoReconnect() + +**功能:** + +返回是否重新连接 + +**函数参数** + +None + +## WiFi.localIP() + +**函数原型:** + +IPAddress localIP() + +**功能:** + +返回本地IP地址 + +**函数参数** + +None + +## WiFi.subnetMask() + +**函数原型:** + +IPAddress subnetMask() + +**功能:** + +返回子网掩码 + +**函数参数** + +None + +## WiFi.gatewayIP() + +**函数原型:** + +IPAddress gatewayIP() + +**功能:** + +返回网关地址 + +**函数参数** + +None + +## WiFi.dnsIP() + +**函数原型:** + +IPAddress dnsIP(uint8_t dns_no = 0) + +**功能:** + +返回DNS地址 + +**函数参数** + +None + +## WiFi.macAddress() + +**函数原型:** + +String macAddress() + +**功能:** + +返回mac地址 + +**函数参数** + +None + +## WiFi.getHostname() + +**函数原型:** + +const char * getHostname() + +**功能:** + +主机名称 + +**函数参数** + +None + +## WiFi.status() + +**函数原型:** + +wl_status_t status() + +**功能:** + +返回WiFi状态 + +**返回值** + +| 值 | 描述 | +| --- | --- | +| 255 | WL_NO_SHIELD 检查WiFi Shield | +| 0 | WL_IDLE_STATUS 正在WiFi工作模式间切换 | +| 1 | WL_NO_SSID_AVAIL 无法访问设置的SSID网络 | +| 2 | WL_SCAN_COMPLETED 扫描完成 | +| 3 | WL_CONNECTED 连接成功 | +| 4 | WL_CONNECT_FAILED 连接失败 | +| 5 | WL_CONNECTION_LOST 丢失连接 | +| 6 | WL_DISCONNECTED 断开连接 | + + +## WiFi.scanNetworks() + +**函数原型:** + +int16_t scanNetworks(bool async = false, bool show_hidden = false, bool passive = false, uint32_t max_ms_per_chan = 300) + +**功能:** + +异步扫描WiFi网络,非阻塞模式 + +**函数参数** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| async | false | 异步扫描,值为true时启动 | +| show_hidden | false | 是否扫描隐藏网络 | +| passive | bool | 快速扫描 | +| max_ms_per_chan | uint32_t | 通道扫描时间 | + +## WiFi.scanComplete() + +**函数原型:** + +int16_t scanComplete() + +**功能:** + +异步模式下获取扫描网络.返回值-1表示扫描未完成.返回值为-2表示扫描失败. + +**函数参数** + +None + +## WiFi.scanDelete() + +**函数原型:** + +void scanDelete() + +**功能:** + +从内存中删除扫描结果 + +**函数参数** + +None + +## WiFi.SSID() + +**函数原型:** + +String SSID(uint8_t networkItem) + +**功能:** + +返回扫描到的网络. + +**函数参数** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| networkItem | uint8_t | SSID名称 | + + +## WiFi.encryptionType() + +**函数原型:** + +wifi_auth_mode_t encryptionType(uint8_t networkItem) + +**功能:** + +返回扫描到的加密网络 + +**函数参数** + +| 函数参数 | 类型 | 描述 | +| --- | --- | --- | +| networkItem | uint8_t | SSID名称 | + +## WiFi.RSSI() + +**函数原型:** + +int32_t RSSI(uint8_t networkItem) + +**功能:** + +返回扫描到的RSSI强度 + +**函数参数** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| networkItem | uint8_t | RSSI item | + +## WiFi.channel() + +**函数原型:** + +int32_t channel(uint8_t networkItem) + +**功能:** + +返回扫描到的网络通道号 + +**函数参数** + +| 参数 | 类型 | 描述 | +| --- | --- | --- | +| networkItem | uint8_t | channel item | +