From c371a80175d599d211a9c9df15dc8a663bd33e5d Mon Sep 17 00:00:00 2001 From: lin-zi-jun <857413240@qq.com> Date: Thu, 15 Aug 2019 19:29:40 +0800 Subject: [PATCH] add API Arduino --- docs/en/api/M5Timer.md | 250 +++++++++++ docs/en/api/axp192_m5stickc.md | 118 +++++ docs/en/api/button.md | 131 +++++- docs/en/api/eeprom.md | 66 +++ docs/en/api/gpio.md | 325 +++++++++++++- docs/en/api/lcd.md | 784 ++++++++++++++++++++++++++++++++- docs/en/api/mpu9250.md | 42 +- docs/en/api/rtc.md | 139 ++++++ docs/en/api/sh200q_m5stickc.md | 28 ++ docs/en/api/speaker.md | 20 + docs/en/api/ticker.md | 134 ++++++ docs/en/api/wifi.md | 479 ++++++++++++++++++++ 12 files changed, 2495 insertions(+), 21 deletions(-) create mode 100644 docs/en/api/M5Timer.md create mode 100644 docs/en/api/eeprom.md create mode 100644 docs/en/api/rtc.md create mode 100644 docs/en/api/ticker.md create mode 100644 docs/en/api/wifi.md diff --git a/docs/en/api/M5Timer.md b/docs/en/api/M5Timer.md new file mode 100644 index 00000000..d5ac2cf1 --- /dev/null +++ b/docs/en/api/M5Timer.md @@ -0,0 +1,250 @@ +## run() + +**Syntax:** + +run() + +**Description:** + +this function must be called inside loop() + + +## setInterval() + +**Syntax:** + +int setInterval(long d, timer_callback f) + +**Description:** + +call function f every d milliseconds + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| d | long | milliseconds | +| f | function | timer_callback function | + +**Example:** + +```arduino +#include +#include "utility/M5Timer.h" + +M5Timer M5timer; +void repeatMe(){ + M5.Lcd.setCursor(0,0); + M5.Lcd.clear(); + M5.Lcd.print("Uptime(s): "); + M5.Lcd.println(millis()/1000); +} +void setup() { + M5.begin(); + M5timer.setInterval(1000, repeatMe); +} +void loop() { + M5timer.run(); +} +``` + +## setTimeout() + +**Syntax:** + +int setTimeout(long d, timer_callback f) + +**Description:** + +call function f once after d milliseconds + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| d | long | milliseconds | +| f | function | timer_callback function | + + +**Example:** + +```arduino +#include +#include "utility/M5Timer.h" + +M5Timer M5timer; +void Timeout(){ + M5.Lcd.setCursor(0,0); + M5.Lcd.clear(); + M5.Lcd.print("Timeout(s): "); + M5.Lcd.println(millis()/1000); +} +void setup() { + M5.begin(); + M5timer.setTimeout(5000, Timeout); +} +void loop() { + M5timer.run(); +} +``` + +## setTimer() + +**Syntax:** + +int setTimer(long d, timer_callback f, int n); + +**Description:** + +call function f every d milliseconds for n times + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| d | long | milliseconds | +| f | function | timer_callback function | +| n | int | Number of executions | + +**Example:** + +```arduino +#include +#include "utility/M5Timer.h" + +M5Timer M5timer; + +void Timer(){ + M5.Lcd.print("Timeout(s): "); + M5.Lcd.println(millis()/1000); +} + +void setup() { + M5.begin(); + M5timer.setTimer(2000, Timer, 3); +} + +void loop() { + M5timer.run(); +} +``` + +## Enable() + +**Syntax:** + +void Enable(int numTimer) + +**Description:** + +enables the specified timer + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| numTimer | int | timer id | + + +**Example:** + +```arduino +#include +#include "utility/M5Timer.h" + +M5Timer M5timer; +int timerId = 1; +void setup() { + M5.begin(); + M5timer.enable(timerId); +} +void loop() { + M5timer.run(); + if (M5timer.isEnabled(timerId)){ + M5.Lcd.setCursor(0, 0); + M5.Lcd.print("Timer is enable "); + M5.Lcd.println(millis()/1000); + } +} +``` + +## isEnabled() + +**Syntax:** + +boolean isEnabled(int numTimer) + +**Description:** + +returns true if the specified timer is enabled + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| numTimer | int | timer id | + + +**Example:** + +```arduino +#include +#include "utility/M5Timer.h" + +M5Timer M5timer; +int timerId = 1; +void setup() { + M5.begin(); + M5timer.enable(timerId); +} +void loop() { + M5timer.run(); + if (M5timer.isEnabled(timerId)){ + M5.Lcd.setCursor(0, 0); + M5.Lcd.print("Timer is enable "); + M5.Lcd.println(millis()/1000); + } +} +``` + +## Disable() + +**Syntax:** + +void Disable(int numTimer) + +**Description:** + +disables the specified timer + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| numTimer | int | timer id | + + +**Example:** + +```arduino +#include +#include "utility/M5Timer.h" + +M5Timer M5timer; +int timerId = 1; +void setup() { + M5.begin(); + M5timer.enable(timerId); +} +void loop() { + M5timer.run(); + if (M5timer.isEnabled(timerId)){ + M5.Lcd.setCursor(0, 0); + M5.Lcd.print("Timer is enable "); + M5.Lcd.println(millis()/1000); + } + while (millis() > 5000){ + M5timer.disable(timerId); + } +} +``` diff --git a/docs/en/api/axp192_m5stickc.md b/docs/en/api/axp192_m5stickc.md index b9a983d0..9faa61b1 100644 --- a/docs/en/api/axp192_m5stickc.md +++ b/docs/en/api/axp192_m5stickc.md @@ -21,6 +21,124 @@ void setup() { void loop() {} ``` +## GetWarningLeve() + +**Syntax:** + +uint8_t GetWarningLeve(void); + +**Description: get current warning level.** + +**Example:** + +```arduino +#include +int level; + +void setup() { + M5.begin(); +} +void loop() { + level = M5.Axp.GetWarningLeve(); + M5.Lcd.setCursor(0, 0); + M5.Lcd.print(level); +} +``` + +## LightSleep() + +**Syntax:** + +void LightSleep(uint64_t time_in_us = 0) + +**Description: control ESP32 into LightSleep Mode ,Press power swith to wakeup.** + +| parameter | description | +| --- | --- | +| time_in_us| sleep time in us| + +**Example:** + +```arduino +#include + +int count = 0; +void setup() { + M5.begin(); + M5.Lcd.fillScreen(WHITE); + pinMode(M5_BUTTON_HOME,INPUT_PULLUP); +} +void loop() { + if(digitalRead(M5_BUTTON_HOME) == LOW){ + while(digitalRead(M5_BUTTON_HOME) == LOW); + M5.Axp.LightSleep(SLEEP_SEC(5)); //SLEEP_SEC(us) (((uint64_t)us) * 1000000L) + } + count++; + M5.Lcd.setCursor(60, 30); + M5.Lcd.setTextColor(BLACK, WHITE); + M5.Lcd.print(count); +} +``` + +## SetSleep() + +**Syntax:** + +void SetSleep(void); + +**Description: control external device into Sleep Mode,Press power switch to wakeup.** + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.fillScreen(WHITE); + pinMode(M5_BUTTON_HOME,INPUT_PULLUP); + M5.Lcd.setCursor(60, 30); + M5.Lcd.print("SLEEP"); +} +void loop() { + if(digitalRead(M5_BUTTON_HOME) == LOW){ + while(digitalRead(M5_BUTTON_HOME) == LOW); + M5.Axp.SetSleep(); + } +} +``` + +## DeepSleep() + +**Syntax:** + +void DeepSleep(uint64_t time_in_us = 0) + +**Description: control external device into DeepSleep Mode,When timeout device auto wakeup.** + +**Example:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Lcd.setRotation(3); + M5.Lcd.fillScreen(WHITE); + M5.Lcd.setTextColor(BLACK, WHITE); + pinMode(M5_BUTTON_HOME,INPUT_PULLUP); + M5.Lcd.setCursor(60, 30); + M5.Lcd.print("SLEEP"); +} + +void loop() { + if(digitalRead(M5_BUTTON_HOME) == LOW){ + while(digitalRead(M5_BUTTON_HOME) == LOW); + M5.Axp.DeepSleep(SLEEP_SEC(5)); + } +} +``` + ## ScreenBreath() **Syntax:** diff --git a/docs/en/api/button.md b/docs/en/api/button.md index 06a0fb4a..ff52da19 100644 --- a/docs/en/api/button.md +++ b/docs/en/api/button.md @@ -4,7 +4,7 @@ **Syntax:** -uint8_t read(); +uint8_t read() **Description:** @@ -30,7 +30,7 @@ void loop() { **Syntax:** -uint8_t isPressed(); +uint8_t isPressed() **Description:** @@ -60,7 +60,7 @@ void loop() { **Syntax:** -uint8_t wasPressed(); +uint8_t wasPressed() **Description:** @@ -86,6 +86,40 @@ void loop() { } ``` +## releasedFor() + +**Syntax:** + +uint8_t releasedFor(uint32_t ms) + +**Description:** + +releasedFor(ms) check to see if the button is pressed (or released), and has been in that state for the specified time in milliseconds. Returns false (0) or true (1) accordingly. + +**Example:** + +```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); + } +} +``` + + + + + ## pressedFor() **Syntax:** @@ -119,3 +153,94 @@ void loop() { } } ``` + +## lastChange() + +**Syntax:** + +uint32_t lastChange(void); + +**Description:** + +Returns the last state time point . + +**Example:** + +```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); +} +``` + +## wasReleasefor() + +**Syntax:** + +uint8_t wasReleasefor(uint32_t ms); + +**Description:** + +releasedFor(ms) check to see if the button is released, and has been in that state for the specifiedtime in milliseconds. Returns false (0) or true (1) accordingly . + +**Example:** + +```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.releasedFor(3000)) { + M5.Lcd.clear(BLACK); + } +} +``` + +## wasReleased() + +**Syntax:** + +uint8_t wasReleased(void) + +**Description:** + +This function returns 1 only once each time the button is pressed. 1: pressed, 0: released. + +**Example:** + +```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"); + } +} +``` \ No newline at end of file diff --git a/docs/en/api/eeprom.md b/docs/en/api/eeprom.md new file mode 100644 index 00000000..032898a4 --- /dev/null +++ b/docs/en/api/eeprom.md @@ -0,0 +1,66 @@ +## EEPROM.begin() + +**Syntax:** + +EEPROM.begin(size) + +**Description:** + +Load before use +Open EEPROM,Size is the maximum address + 1 of the data bytes to be read and written, ranging from 1 to 4096. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| size | int | EEPROM size | + +## EEPROM.write() + +**Syntax:** + +EEPROM.write(addr, data) + +**Description:** + +Load before use +Write data to storage space. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| addr | int | Address of storage space | +| data | int | Actual Write Data | + +## EEPROM.commit() + +**Syntax:** + +EEPROM.commit() + +**Description:** + +Load before use +This function needs to be called every time an address is written. + +**Function argument** + +None + +## EEPROM.read() + +**Syntax:** + +EEPROM.read(addr) + +**Description:** + +Load before use +Reading data from storage space. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| addr | int | Address of storage space | \ No newline at end of file diff --git a/docs/en/api/gpio.md b/docs/en/api/gpio.md index 0b57d019..b930ed63 100644 --- a/docs/en/api/gpio.md +++ b/docs/en/api/gpio.md @@ -48,7 +48,7 @@ **Syntax:** -int digitalRead(uint8_t pin); +int digitalRead(uint8_t pin) **Description:** @@ -81,7 +81,7 @@ pin21_data = digitalRead(21); **Syntax:** -void digitalWrite(uint8_t pin, uint8_t val); +void digitalWrite(uint8_t pin, uint8_t val) **Description:** @@ -115,7 +115,7 @@ digitalWrite(2,1); **Syntax:** -void pinMode(uint8_t pin, uint8_t mode); +void pinMode(uint8_t pin, uint8_t mode) **Description:** @@ -149,7 +149,7 @@ pinMode(2,INPUT); ## analogRead() **Syntax:** -uint16_t analogRead(uint8_t pin); +uint16_t analogRead(uint8_t pin) **Description:** @@ -180,7 +180,7 @@ ret=analogRead(35); **Syntax:** -void dacWrite(uint8_t pin, uint8_t value); +void dacWrite(uint8_t pin, uint8_t value) **Description:** @@ -211,7 +211,7 @@ dacWrite(25,0x40); **Syntax:** -double ledcSetup(uint8_t channel, double freq, uint8_t resolution_bits); +double ledcSetup(uint8_t channel, double freq, uint8_t resolution_bits) **Description:** @@ -241,7 +241,7 @@ It is good to recognize that it is a number to memorize the setting. **Syntax:** -void ledcAttachPin(uint8_t pin, uint8_t chan); +void ledcAttachPin(uint8_t pin, uint8_t chan) **Description:** @@ -263,7 +263,7 @@ None. **Syntax:** -void ledcWrite(uint8_t chan, uint32_t duty); +void ledcWrite(uint8_t chan, uint32_t duty) **Description:** @@ -291,7 +291,7 @@ When specifying with 8 bits, specifying 0xFF results in 100% output. **Syntax:** -void ledcDetachPin(uint8_t pin); +void ledcDetachPin(uint8_t pin) **Description:** @@ -307,3 +307,310 @@ Release the assigned port and stop the output. **Function return value:** None. + +## analogSetCycles() + +**Syntax:** + +void analogSetCycles(uint8_t cycles) + +**Description:** + +Set the period of a single sampling, value 1-255, default 8. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| cycles | uint8_t | sampling period | + +**Function return value:** + +None + +## analogSetWidth() + +**Syntax:** + +void analogSetWidth(uint8_t bits) + +**Description:** + +Set the ADC sampling resolution to 9-12, default to 12. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| bits | uint8_t | sampling resolution | + +**Function return value:** + +None + +## analogReadResolution() + +**Syntax:** + +void analogReadResolution(uint8_t bits) + +**Description:** + +Set the reading resolution of analog data, value 1 to 16, default is 12. If it is between 9 and 12, it will be equal to the set hardware resolution, otherwise the value will be moved. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| bits | uint8_t | sampling resolution | + +**Function return value:** + +None + +## analogSetSamples() + +**Syntax:** + +void analogSetSamples(uint8_t samples) + +**Description:** + +Set the actual sampling times of single sampling, take the value of 1 ~ 255, default is 1; + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| samples | uint8_t | sampling times | + +**Function return value:** + +None + + + +## analogSetAttenuation() + +**Syntax:** + +void analogSetAttenuation(adc_attenuation_t attenuation) + +**Description:** + +Set the global input attenuation of ADC to ADC_0db, ADC_2_5db, ADC_6db, ADC_11db, default to 11 DB + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| attenuation | adc_attenuation_t | attenuation | + +**Function return value:** + +None + + +## analogSetPinAttenuation() + +**Syntax:** + +void analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation) + +**Description:** + +Setting input attenuation for a single IO port + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| pin | uint8_t | specified pin | +| attenuation | adc_attenuation_t | attenuation | + +**Function return value:** + +None + + +## hallRead() + +**Syntax:** + +int hallRead(void)); + +**Description:** + +Read Hall Sensor. + +**Function argument** + +None + +**Function return value:** + +None. + + +## attachInterrupt() + +**Syntax:** + +void attachInterrupt(pin, ISR(callback function), interrupt type/mode) + +**Description:** + +set pin interrupt. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| pin | uint8_t | pin No. | +| ISR | callcack function | which function you want excute | +| interrupt | mode | CHANGE/RISING/FALLING | + +**Function return value:** + +None. + +## detachInterrupt() + +**Syntax:** + +void detachInterrupt(pin) + +**Description:** + +Prohibit specified pin interruptio. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| pin | uint8_t | pin No. | + +**Function return value:** + +None. + +## ledcReadFreq() + +**Syntax:** + +double ledcReadFreq(uint8_t channel) + +**Description:** + +Returns the current frequency of the specified channel. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| channel | uint8_t | specified channel | + +**Function return value:** + +current frequency + +## ledcRead() + +**Syntax:** + +uint32_t ledcRead(uint8_t channel) + +**Description:** + +Returns the value of the specified channel duty cycle. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| channel | uint8_t | specified channel | + +**Function return value:** + +duty cycle + +## adcAttachPin() + +**Syntax:** + +bool adcAttachPin(uint8_t pin) + +**Description:** + +This is Non-blocking mode.Connect pins to ADC (and remove any other analog modes that may be opened). + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| pin | uint8_t | specified pin | + +**Function return value:** + +Return 1 if boot succeeds + + +## adcStart() + +**Syntax:** + +bool adcStart(uint8_t pin) + +**Description:** + +This is Non-blocking Start ADC Conversion on Connected Pins. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| pin | uint8_t | specified pin | + +**Function return value:** + +Return 1 if boot succeeds + +## adcBusy() + +**Syntax:** + +bool adcBusy(uint8_t pin) + +**Description:** + +This is Non-blocking mode Check whether the ADC conversion is in progress. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| pin | uint8_t | specified pin | + +**Function return value:** + +Conversion returning 1 + +## adcEnd() + +**Syntax:** + +uint16_t adcEnd(uint8_t pin) + +**Description:** + +This is Non-blocking mode Get the result of the transformation (wait if it's not finished). + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| pin | uint8_t | specified pin | + +**Function return value:** + +Returns the conversion result \ No newline at end of file diff --git a/docs/en/api/lcd.md b/docs/en/api/lcd.md index 6e0e0966..aa6e9a60 100644 --- a/docs/en/api/lcd.md +++ b/docs/en/api/lcd.md @@ -478,7 +478,7 @@ lcd.setTextColor(lcd.ORANGE, lcd.DARKCYAN) setCursor(uint16_t x0, uint16_t y0); - + **Function: Move the cursor to (x0, y0).** @@ -500,6 +500,101 @@ from m5ui import * lcd.drawPixel(22,22,lcd.RED) ``` --> +## getCursorX() + +**Syntax:** + +uint16_t getCursorX(void); + + + +**Function: get the cursor of x.** + +**Example:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.print("Hello "); + +int X = M5.Lcd.getCursorX(); + +M5.Lcd.print(X); +``` + +## getCursorY() + +**Syntax:** + +uint16_t getCursorY(void); + + + +**Function: get the cursor of y.** + +**Example:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.setCursor(0, 20); +M5.Lcd.print("Hello "); + +int Y = M5.Lcd.getCursorY(); + +M5.Lcd.print(Y); +``` + +##setTextSize() + +**Syntax:** + +setTextSize(uint8_t); + + + +**Function: set the Size of Text.** + +**Example:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.setTextSize(7); + +M5.Lcd.print("Hello"); +``` + +##clear() + +**Syntax:** + +void clear(uint16_t color); + + + +**Function: fill color use of clear screen.** + +**Example:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.print("Hello"); + +delay(2000); + +M5.Lcd.clear(BLACK); +``` + ## drawPixel() **Syntax:** @@ -532,23 +627,23 @@ lcd.drawPixel(22,22,lcd.RED) ``` --> -## drawPixel() +## alphaBlend() **Description:** -Draws a pixel of a specified color at a specified position. +Blend foreground and background and return new colour. **Syntax:** -drawPixel(int16_t x, int16_t y, [uint16_t color]); +uint16_t alphaBlend(uint8_t alpha, uint16_t fgc, uint16_t bgc); **Function argument:** | argument | Description | type | | --- | --- | -- | -| x | Coordinate X | int16_t | -| y | Coordinate Y | int16_t | -| color | Pixel color. (Optional) | uint16_t | +| alpha | transparency | uint8_t | +| fgc | Foreground color | uint16_t | +| bgc | Background color | uint16_t | **Example of use:** @@ -556,7 +651,12 @@ Draws a pixel of a specified color at a specified position. #include M5.begin(); -M5.Lcd.drawPixel(22, 22, RED); + +int val = M5.Lcd.alphaBlend(128, 0X00FF00, 0XFF0000); + +M5.Lcd.fillRect(0, 0, 320, 240, val); + +M5.Lcd.print(val); ``` ## drawChar() @@ -589,6 +689,58 @@ 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); ``` +## drawNumber() + +**Description:** + +draw a long integer. + +**Syntax:** + +drawNumber(long long_num, int32_t poX, int32_t poY); + +**Function argument:** + +| Argument | Type | Description | +| --- | --- | --- | +| long_num | long | number | +| poX | int32_t | coordinate of X | +| poY | int32_t | coordinate of Y | + +**Example of use:** + +```arduino +#include + +M5.Lcd.drawNumber(12345, 160, 120); +``` + +## drawFloat() + +**Description:** + +drawFloat, prints 7 non zero digits maximum + +**Syntax:** + +int16_t drawFloat(float floatNumber, uint8_t dp, int32_t poX, int32_t poY); + +**Function argument:** + +| Argument | Type | Description | +| --- | --- | --- | +| floatNumber | float | number | +| dp | uint8_t | Within seven decimal places | +| poX | int32_t | coordinate of Y | +| poY | int32_t | coordinate of Y | + +**Example of use:** + +```arduino +#include + +M5.Lcd.drawFloat(12.345, 3, 160, 120); +``` ## drawFastVLine() @@ -676,6 +828,90 @@ from m5ui import * lcd.drawLine(0,0,12,12,lcd.WHITE) ``` --> +## drawCircleHelper() + +**Syntax:** + +drawCircleHelper( int32_t x0, int32_t y0, int32_t r, uint8_t cornername, uint32_t color); + +**Function: Draw a quarter circle with the center at the point x0 and y0, with radius r, and a quarter C, and a color from 0 to 65535** + +| Argument | Type | Description | +| --- | --- | --- | +| x0 | int32_t | x0 position of center point | +| y0 | int32_t | y0 position of center point | +| r | int32_t | radius | +| cornername| int32_t | quarter corn | +|color| uint32_t | color 0~65535 | + +**Example:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.drawCircleHelper(160, 120, 30, 4, 0XFF00FF); +``` + + + +## drawCircle() + +**Syntax:** + +drawCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color); + +**Function: Draw a circle on point(x0, y0), Radis is r with color** + +| Argument | Type | Description | +| --- | --- | --- | +| x0 | int32_t | x0 position of center point | +| y0 | int32_t | y0 position of center point | +| r | int32_t | radius | +|color| uint32_t | color 0~65535 | + +**Example:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.drawCircle(160, 120, 30, 0XFF00FF); +``` + +## fillCircle() + +**Syntax:** + +fillCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color); + +**Function: Draw a filled circle on point(x0, y0), Radis is r with color** + +| Argument | Type | Description | +| --- | --- | --- | +| x0 | int32_t | x0 position of center point | +| y0 | int32_t | y0 position of center point | +| r | int32_t | radius | +|color| uint32_t | color 0~65535 | + +**Example:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.fillCircle(160, 120, 30, 0XFF00FF); +``` + ## drawTriangle() **Syntax:** @@ -1045,6 +1281,333 @@ Load a font M5.Lcd.loadFont("filename", SD); ``` +## setTextWrap() + +**Description:** + +Whether to automatically wrap the display + +**Syntax:** + +setTextWrap(boolean wrapX, boolean wrapY) + +**Function argument:** + +| argument | type | Description | +| --- | --- | --- | +| wrapX | boolean | X direction | +| wrapY | boolean | Y direction | + +**Example of use:** + +```arduino +#include + +M5.Lcd.setTextWrap(ture, true); +``` + +## setTextDatum() + +**Description:** + +Set the text position reference datum + +**Syntax:** + +setTextDatum(uint8_t datum) + +**Function argument:** + +| argument | type | Description | +| --- | --- | --- | +| TL_DATUM | uint8_t | Top left (default) | +| TC_DATUM | uint8_t | Top centre | +| TR_DATUM | uint8_t | Top right | +| ML_DATUM | uint8_t | Middle left | +| MC_DATUM | uint8_t | Middle centre | +| MR_DATUM | uint8_t | Middle right | +| BL_DATUM | uint8_t | Bottom left | +| BC_DATUM | uint8_t | Bottom centre | +| BR_DATUM | uint8_t | Bottom right | + +**Example of use:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.setTextDatum(MC_DATUM); + +M5.Lcd.drawString("hello", 160, 120, 2); +``` + +## setTextPadding() + +**Description:** + +text background padding some pixel to over-write the old text + +**Syntax:** + +setTextPadding(uint16_t x_width) + +**Function argument:** + +| argument | type | Description | +| --- | --- | --- | +| x_width | uint16_t | Blanked area will be width of pixels | + +**Example of use:** + +```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); +``` + +## getRotation() + +**Description:** + +Return the rotation value (as used by setRotation()) + +**Syntax:** + +uint8_t getRotation(void) + +**Function argument:** + +None + +**Example of use:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.print(M5.Lcd.getRotation()); +``` + +## width() + +**Description:** + +Return the pixel width of display (per current rotation) + +**Syntax:** + +int16_t width(void) + +**Function argument:** + +None + +**Example of use:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.print(M5.Lcd.width()); +``` + +## hight() + +**Description:** + +Return the pixel height of display (per current rotation) + +**Syntax:** + +int16_t height(void) + +**Function argument:** + +None + +**Example of use:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.print(M5.Lcd.height()); +``` + +## textWidth() + +**Description:** + +Return the width in pixels of a string in a given font + +**Syntax:** + +int16_t textWidth(const String& string) + +**Function argument:** + +| argument | type | Description | +| --- | --- | --- | +| string | const String& | text String | + +**Example of use:** + +```arduino +#include + +M5.begin(); + +String text = "hello "; + +M5.Lcd.print(text); + +M5.Lcd.print(M5.Lcd.textWidth(text)); +``` + +## getTextDatum() + +**Description:** + +Return the text datum value (as used by setTextDatum()) + +**Syntax:** + +uint8_t setRotation(void) + +**Function argument:** + +None + +**Example of use:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.setTextDatum(MC_DATUM); + +M5.Lcd.print(M5.Lcd.getTextDatum()); +``` + +##int16_t fontHeight() + +**Description:** + +rn the height of a font (yAdvance for free fonts) + +**Syntax:** + +int16_t fontHeight(void) + +**Function argument:** + +None + +**Example of use:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.print(M5.Lcd.fontHeight()); +``` + +##drawCentreString() + +**Description:** + +draw string centred on dX + +**Syntax:** + +int16_t drawCentreString(const String& string, int32_t dX, int32_t poY, uint8_t font) + +**Function argument:** + +| argument | type | Description | +| --- | --- | --- | +| string | const String& | text String | +| dX | int32_t | center point on dX | +| poY | int32_t | coordinate Y | +| font | uint8_t | font name | + +**Example of use:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.drawCentreString("hello", 160, 0, 2); +``` + +##drawRightString() + +**Description:** + +draw string right justified to dX,deprecated, use setTextDatum() + +**Syntax:** + +int16_t drawRightString(const String& string, int32_t dX, int32_t poY, uint8_t font) + +**Function argument:** + +| argument | type | Description | +| --- | --- | --- | +| string | const String& | text String | +| dX | int32_t | Right eage on dX | +| poY | int32_t | coordinate Y | +| font | uint8_t | font name | + +**Example of use:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.drawRightString("hello", 160, 0, 2); +``` + +##int16_t fontHeight() + +**Description:** + +rn the height of a font (yAdvance for free fonts) + +**Syntax:** + +int16_t fontHeight(void) + +**Function argument:** + +None + +**Example of use:** + +```arduino +#include + +M5.begin(); + +M5.Lcd.print(M5.Lcd.fontHeight()); +``` + ## unloadFont() **Description:** @@ -1184,6 +1747,211 @@ M5.begin(); M5.Lcd.printf("A=%d",a); ``` +##createSprite() + +**Description:** + + Create a sprite of width x height pixels, return a pointer to the RAM area + +**Syntax:** + +void* createSprite(int16_t w, int16_t h) + +**Function argument:** + +| argument | type | Description | +| --- | --- | -- | +| w | int16_t | create sprite width | +| h | int16_t | create sprite height | + +**Example of use:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.createSprite(70, 80); +``` + +## deleteSprite() + +**Description:** + + Delete the sprite to free up memory (RAM) + +**Syntax:** + +deleteSprite(void) + +**Function argument:** + +None + +**Example of use:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.createSprite(70, 80); + +img.deleteSprite(); +``` + +## setColorDepth() + +**Description:** + + set the colour depth to 1, 8 or 16 bits,Can be used to change depth an existing sprite + +**Syntax:** + +void setColorDepth(int8_t bit) + +**Function argument:** + +| argument | type | Description | +| --- | --- | -- | +| bit | int8_t | color depth bits | + +**Example of use:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.setColorDepth(8); + +img.createSprite(70, 80); +``` + +## fillSprite() + +**Description:** + +Fill the whole sprite with defined colour + +**Syntax:** + +void fillSprite(uint32_t color) + +**Function argument:** + +| argument | type | Description | +| --- | --- | -- | +| color | int32_t | filled color | + +**Example of use:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.createSprite(70, 80); + +img.fillSprite(WHITE); +``` + +## pushSprite() + +**Description:** + +Push the sprite to the TFT at x, y,Optionally a "transparent" colour can be defined, pixels of that colour will not be rendered + +**Syntax:** + +void pushSprite(int32_t x, int32_t y, uint16_t transparent) + +**Function argument:** + +| argument | type | Description | +| --- | --- | -- | +| x | int32_t | coordinate x | +| y | int32_t | coordinate y | +| transparent | int16_t | optional | + + +**Example of use:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.createSprite(70, 80); + +img.pushSprite(35, 40, WHITE); +``` + +## width() + +**Description:** + +Return the width of the sprite + +**Syntax:** + +int16_t width(void) + +**Function argument:** + +None + +**Example of use:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.createSprite(70, 80); + +M5.Lcd.print(img.width()); +``` + +## height() + +**Description:** + +Return the height of the sprite + +**Syntax:** + +int16_t height(void) + +**Function argument:** + +None + +**Example of use:** + +```arduino +#include + +M5.begin(); + +TFT_eSprite img = TFT_eSprite(&M5.Lcd); + +img.createSprite(70, 80); + +M5.Lcd.print(img.height()); +``` ## Usage {docsify-ignore} diff --git a/docs/en/api/mpu9250.md b/docs/en/api/mpu9250.md index 924cc44b..ed3dfd0b 100644 --- a/docs/en/api/mpu9250.md +++ b/docs/en/api/mpu9250.md @@ -260,4 +260,44 @@ void loop() { } delay(500); } -``` \ No newline at end of file +``` + +## readTempData() + +**Syntax:** + +int16_t readTempData(void); + +**Description:** + +This function reads the temperature. + +**Example:** + +```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); +} +``` + diff --git a/docs/en/api/rtc.md b/docs/en/api/rtc.md new file mode 100644 index 00000000..0e060533 --- /dev/null +++ b/docs/en/api/rtc.md @@ -0,0 +1,139 @@ +## SetTime() + +**Syntax:** + +void SetTime(RTC_TimeTypeDef* RTC_TimeStruct) + +**Description:** + +Set time with the value of the structure member variable + +**Example:** + +```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() + +**Syntax:** + +void GetTime(RTC_TimeTypeDef* RTC_TimeStruct) + +**Description:** + +Get time with the value of the structure member variable + +**Example:** + +```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() + +**Syntax:** + +void SetData(RTC_TimeTypeDef* RTC_DateStruct) + +**Description:** + +Set date with the value of the structure member variable + +**Example:** + +```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() + +**Syntax:** + +void GetData(RTC_TimeTypeDef* RTC_DateStruct) + +**Description:** + +Get date with the value of the structure member variable + +**Example:** + +```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/en/api/sh200q_m5stickc.md b/docs/en/api/sh200q_m5stickc.md index b4b7a4d8..14b0eaa9 100644 --- a/docs/en/api/sh200q_m5stickc.md +++ b/docs/en/api/sh200q_m5stickc.md @@ -83,4 +83,32 @@ void loop() { ((float)accZ) * M5.IMU.aRes); delay(500); } +``` + + +## getTempData() + +**Syntax:** + +void getTempData(float* t); + +**Description: It get SH200Q tempurature data.** + +**Example:** + +```arduino +#include + +float temp = 0; + +void setup() { + M5.begin(); + M5.IMU.Init(); +} +void loop() { + M5.IMU.getTempData(&temp); + M5.Lcd.setCursor(0, 0); + M5.Lcd.printf("Temperature : %.2f C", temp); + delay(1000); +} ``` \ No newline at end of file diff --git a/docs/en/api/speaker.md b/docs/en/api/speaker.md index 9cb02dec..90fbb7fb 100644 --- a/docs/en/api/speaker.md +++ b/docs/en/api/speaker.md @@ -85,3 +85,23 @@ void setup() { M5.Speaker.setBeep(900, 1000); } ``` +## mute() + +**Description:** + +Mute the sound . + +**Syntax:** + +void mute(void); + +**Example of use:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Speaker.mute(); +} +``` \ No newline at end of file diff --git a/docs/en/api/ticker.md b/docs/en/api/ticker.md new file mode 100644 index 00000000..47dda798 --- /dev/null +++ b/docs/en/api/ticker.md @@ -0,0 +1,134 @@ +## once() + +**Syntax:** + +void once(float seconds, callback_t callback) + +**Description:** + +Load before use +Execute a command in seconds, which is executed only once. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| seconds | float | Set time | +| callback | callback_t | Custom callback function | + +## once_ms() + +**Syntax:** + +void once_ms(uint32_t milliseconds, callback_t callback) + +**Description:** + +Load before use +Execute a command in milliseconds, which is executed only once. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| milliseconds | float | Set time | +| callback | callback_t | Custom callback function | + +## attach() + +**Syntax:** + +void attach(float seconds, void (*callback)(TArg), TArg arg) + +**Description:** + +Load before use +Execute commands with parameters after every seconds. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| seconds | float | Set time | +| *callback | callback_t | Custom callback function | +| TArg | arg | function arguments | + +## attach_ms() + +**Syntax:** + +void attach_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg) + +**Description:** + +Load before use +Execute commands with parameters after every milliseconds. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| milliseconds | float | Set time | +| *callback | callback_t | Custom callback function | +| TArg | arg | function arguments | + +## attach() + +**Syntax:** + +void attach(float seconds, callback_t callback) + +**Description:** + +Load before use +Execute the command after every second with no parameters. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| seconds | float | Set time | +| callback | callback_t | Custom callback function | + +## attach_ms() + +**Syntax:** + +void attach_ms(uint32_t milliseconds, callback_t callback) + +**Description:** + +Load before use +Execute the command after every milliseconds with no parameters. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| seconds | float | Set time | +| callback | callback_t | Custom callback function | + +## Usage {docsify-ignore} + +```arduino +#include +#include + +Ticker tickerSetHigh; +Ticker tickerSetLow; + +void display(int number) { + M5.Lcd.setCursor(0, 0); + M5.Lcd.print(number); +} +void setup() { + M5.begin(); + tickerSetLow.attach_ms(1000, display, 0); + tickerSetHigh.attach_ms(2000, display, 1); +} +void loop() { +} + + + +``` \ No newline at end of file diff --git a/docs/en/api/wifi.md b/docs/en/api/wifi.md new file mode 100644 index 00000000..395f6557 --- /dev/null +++ b/docs/en/api/wifi.md @@ -0,0 +1,479 @@ +## WiFi.softAP() + +**Syntax:** + +bool WiFi.softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden, int max_connection) + +**Description:** + +Load before use +Use this method to open AP mode and return true after successful opening + +**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_hidden | Whether to hide SSID 1:hidden 0:not| int | +| max_conncetion | Maximum Accessibility Number 1-4 | int | + +## WiFi.softAPConfig() + +**Syntax:** + +bool softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet) + +**Description:** + +Load before use +set AP IP address + +**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 | + +## WiFi.softAPdisconnect() + +**Syntax:** + +bool softAPdisconnect(bool wifioff = false) + +**Description:** + +Load before use +Turn off the current AP and restore the network settings if wifioff is true + +**Function argument** + +| Argument | Description | Type | +| --- | --- | -- | +| wifioff | Restore settings | bool | + +## WiFi.softAPgetStationNum() + +**Syntax:** + +uint8_t softAPgetStationNum() + +**Description:** + +Load before use +Returns the number of clients connected to AP + +**Function argument** + +None + +## WiFi.softAPIP() + +**Syntax:** + +IPAddress softAPIP() + +**Description:** + +Load before use +Returns current IP of AP + +**Function argument** + +None + +## WiFi.softAPsetHostname() + +**Syntax:** + +bool softAPsetHostname(const char * hostname) + +**Description:** + +Load before use +Set Hostname if success return true + +**Function argument** + +| Argument | Description | Type | +| --- | --- | -- | +| hostname | set Hostname | const char* | + +## WiFi.softAPgetHostname() + +**Syntax:** + +const char * softAPgetHostname() + +**Description:** + +Load before use +Get Hostname if success return true + +**Function argument** + +None + + +## WiFi.softAPmacAddress() + +**Syntax:** + +String softAPmacAddress(void) + +**Description:** + +Load before use +return MAC address + +**Function argument** + +None + +## WiFi.begin() + +**Syntax:** + +wl_status_t begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true) + +**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* | +| channel | channel number | int32_t | +| bssid | MAC address of WiFi hotspot, optional parameters | const uint8_t* | +| connect | Establish a connection | bool | + +## WiFi.config() + +**Syntax:** + +bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000) + +**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 | +| dns1 | DNS address | IPAddress | +| dns2 | DNS address | IPAddress | + + +## WiFi.disconnect() + +**Syntax:** + +bool disconnect(bool wifioff = false, bool eraseap = false) + +**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** + +| Argument | Description | Type | +| --- | --- | -- | +| wifioff | Restore settings | bool | +| eraseap | erase ap from flash | bool | + +## WiFi.isConnected() + +**Syntax:** + +bool isConnected() + +**Description:** + +Load before use +Returns whether the network has been accessed or not. + +**Function argument** + +None + +## WiFi.setAutoReconnect() + +**Syntax:** + +bool setAutoReconnect(bool autoReconnect) + +**Description:** + +Load before use +RSetting up automatic reconnection after disconnection. + +**Function argument** + +None + +## WiFi.setAutoReconnect() + +**Syntax:** + +bool getAutoReconnect() + +**Description:** + +Load before use +Setting up automatic reconnection after disconnection. + +**Function argument** + +None + +## WiFi.localIP() + +**Syntax:** + +IPAddress localIP() + +**Description:** + +Load before use +Return local IP address. + +**Function argument** + +None + +## WiFi.subnetMask() + +**Syntax:** + +IPAddress subnetMask() + +**Description:** + +Load before use +Return subnet mask. + +**Function argument** + +None + +## WiFi.gatewayIP() + +**Syntax:** + +IPAddress gatewayIP() + +**Description:** + +Load before use +Return gateway IP address. + +**Function argument** + +None + +## WiFi.dnsIP() + +**Syntax:** + +IPAddress dnsIP(uint8_t dns_no = 0) + +**Description:** + +Load before use +Return DNS address. + +**Function argument** + +None + +## WiFi.macAddress() + +**Syntax:** + +String macAddress() + +**Description:** + +Load before use +Return MAC address. + +**Function argument** + +None + +## WiFi.getHostname() + +**Syntax:** + +const char * getHostname() + +**Description:** + +Load before use +Return Hostname. + +**Function argument** + +None + +## WiFi.status() + +**Syntax:** + +wl_status_t status() + +**Description:** + +Load before use +Return WIFI status. + +**Function return value** + +| value |Description | +| --- | --- | +| 255 | WL_NO_SHIELD | +| 0 | WL_IDLE_STATUS | +| 1 | WL_NO_SSID_AVAIL | +| 2 | WL_SCAN_COMPLETED | +| 3 | WL_CONNECTED | +| 4 | WL_CONNECT_FAILED | +| 5 | WL_CONNECTION_LOST | +| 6 | WL_DISCONNECTED | + + +## WiFi.scanNetworks() + +**Syntax:** + +int16_t scanNetworks(bool async = false, bool show_hidden = false, bool passive = false, uint32_t max_ms_per_chan = 300) + +**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 | + +## WiFi.scanComplete() + +**Syntax:** + +int16_t scanComplete() + +**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** + +| 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 | + +## WiFi.scanDelete() + +**Syntax:** + +void scanDelete() + +**Description:** + +Load before use +Delete scan results in memory. + +**Function argument** + +None + +## WiFi.SSID() + +**Syntax:** + +String SSID(uint8_t networkItem) + +**Description:** + +Load before use +Returns the scanned network name. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| networkItem | uint8_t | SSID item | + + +## WiFi.encryptionType() + +**Syntax:** + +wifi_auth_mode_t encryptionType(uint8_t networkItem) + +**Description:** + +Load before use +Returns the type of network encryption scanned. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| networkItem | uint8_t | SSID item | + +## WiFi.RSSI() + +**Syntax:** + +int32_t RSSI(uint8_t networkItem) + +**Description:** + +Load before use +Return the scanned network signal strength. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| networkItem | uint8_t | RSSI item | + +## WiFi.channel() + +**Syntax:** + +int32_t channel(uint8_t networkItem) + +**Description:** + +Load before use +Return the scanned network channel number. + +**Function argument** + +| Function argument |Type |Description | +| --- | --- | --- | +| networkItem | uint8_t | channel item | +