mirror of
https://github.com/m5stack/m5-docs.git
synced 2026-05-20 10:23:01 -07:00
Merge branch 'master' of github.com:m5stack/m5-docs
This commit is contained in:
@@ -0,0 +1,416 @@
|
||||
## EPD Driver
|
||||
|
||||
>The M5PAPER is equipped with an e-ink screen with a resolution of 540*960 @ 4.7" and supports 16 levels of grayscale display. In the `M5.begin()` initialization, the instance `M5EPD_Driver EPD = M5EPD_Driver();` has been created and initialized. With the following screen driver, you can push the content-drawn data to the screen.
|
||||
|
||||
- `m5epd_err_t begin(int8_t sck, int8_t mosi, int8_t miso, int8_t cs, int8_t busy, int8_t rst = -1);`
|
||||
|
||||
- **Function: Clear screen content/true initializes screen with UPDATE_MODE_INIT mode/false Clear 8951 buffer**
|
||||
- `m5epd_err_t Clear(bool init = false);`
|
||||
|
||||
- **Functions: Write full frame data / 4 bit per pixel**.
|
||||
- `m5epd_err_t WriteFullGram4bpp(const uint8_t *gram);`
|
||||
|
||||
- **Function: Write local data in specified area / 4 bit per pixel**.
|
||||
- `m5epd_err_t WritePartGram4bpp(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint8_t *gram);`
|
||||
|
||||
- **Function: Fill specified data in specified area**.
|
||||
- `m5epd_err_t FillPartGram4bpp(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t data);`
|
||||
|
||||
- **Functions: Set screen rotation angle/usually set to 90°**.
|
||||
- `m5epd_err_t SetRotation(uint16_t rotate = IT8951_ROTATE_0);`
|
||||
|
||||
- **Function: flushes the data in the buffer to full screen in the specified mode**.
|
||||
- `m5epd_err_t UpdateFull(m5epd_update_mode_t mode);`
|
||||
|
||||
- **Function: flushes the data in the buffer to the specified area of the screen in the specified mode**.
|
||||
- `m5epd_err_t UpdateArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h, m5epd_update_mode_t mode);`
|
||||
|
||||
- **Functions: get refresh times**
|
||||
- `uint16_t UpdateCount(void);`
|
||||
|
||||
- **Function: Read the screen rotation angle**.
|
||||
- `uint8_t GetRotate(void) {return _rotate;};`
|
||||
|
||||
- **Function: Read screen orientation**
|
||||
- `uint8_t GetDirection(void) {return _direction;};`
|
||||
|
||||
- **Functions: reset refresh times**
|
||||
- `void ResetUpdateCount(void);`
|
||||
|
||||
- **Function: detects if 8951 is busy**.
|
||||
- `m5epd_err_t CheckAFSR(void);`
|
||||
|
||||
- **Function: set color inverse color**
|
||||
- `void SetColorReverse(bool is_reverse);`
|
||||
|
||||
## Canvas
|
||||
|
||||
>The library uses the `Canvas` class for drawing patterns, which provides a variety of drawing APIs (including drawing strings, rectangles, triangles, circles, image data, etc.). To use it, you need to create a canvas instance and pass it to the screen driver, as shown in the following code.
|
||||
|
||||
```
|
||||
#include <M5EPD.h>
|
||||
|
||||
M5EPD_Canvas canvas(&M5.EPD);
|
||||
```
|
||||
|
||||
### Create/delete Canvas
|
||||
|
||||
>Before we can start drawing, we need to create a drawing area using the Canvas instance.
|
||||
|
||||
- **Function: Create Canvas**
|
||||
- `void *createCanvas(int16_t width, int16_t height, uint8_t frames = 1) { return TFT_eSprite::createSprite(width, height, frames); };`
|
||||
|
||||
- **Function: Delete Canvas**
|
||||
- `void deleteCanvas(void) { TFT_eSprite::deleteSprite(); }`
|
||||
|
||||
```
|
||||
#include <M5EPD.h>
|
||||
|
||||
M5EPD_Canvas canvas(&M5.EPD);
|
||||
|
||||
M5.begin();
|
||||
M5.EPD.SetRotation(90);
|
||||
canvas.createCanvas(400, 300);
|
||||
|
||||
```
|
||||
|
||||
### Push Canvas
|
||||
|
||||
>After drawing the content using the Draw API, we need to use the `push` API to push the drawn area to the screen.
|
||||
|
||||
// Re-implement functions
|
||||
|
||||
- **Function: Get pointer to the Canvas buffer**.
|
||||
- `void *frameBuffer(int8_t f = 1);`
|
||||
|
||||
- **Function: Push the Canvas to the specified area of the screen, and specify the refresh mode**.
|
||||
- `void pushCanvas(int32_t x, int32_t y, m5epd_update_mode_t mode);`
|
||||
|
||||
- **Functions: Push Canvas to screen position 0, 0, assign refresh mode**.
|
||||
- `void pushCanvas(m5epd_update_mode_t mode);`
|
||||
|
||||
- **Function: Draw to the specified Canvas**.
|
||||
- `void pushToCanvas(int32_t x, int32_t y, M5EPD_Canvas* canvas);`
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
#include <M5EPD.h>
|
||||
|
||||
M5EPD_Canvas canvas(&M5.EPD);
|
||||
|
||||
void setup()
|
||||
{
|
||||
M5.begin();
|
||||
M5.EPD.SetRotation(90);
|
||||
M5.EPD.Clear(true);
|
||||
canvas.createCanvas(540, 960);
|
||||
canvas.setTextSize(3);
|
||||
canvas.drawString("Hello World!", 50, 350);
|
||||
canvas.drawString("Hello M5Stack!", 45, 450);
|
||||
canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Update Mode
|
||||
|
||||
>To use `pushCanvas`, we need to pass a refresh mode parameter. The library `m5epd_update_mode_t` already enumerates several different update modes.
|
||||
|
||||
```
|
||||
typedef enum // Typical
|
||||
{ // Ghosting Update Time Usage
|
||||
UPDATE_MODE_INIT = 0, // * N/A 2000ms Display initialization,
|
||||
UPDATE_MODE_DU = 1, // Low 260ms Monochrome menu, text input, and touch screen input 1bit Gray level
|
||||
UPDATE_MODE_GC16 = 2, // * Very Low 450ms High quality images
|
||||
UPDATE_MODE_GL16 = 3, // * Medium 450ms Text with white background
|
||||
UPDATE_MODE_GLR16 = 4, // Low 450ms Text with white background
|
||||
UPDATE_MODE_GLD16 = 5, // Low 450ms Text and graphics with white background
|
||||
UPDATE_MODE_DU4 = 6, // * Medium 120ms Fast page flipping at reduced contrast 1bit Gray level Slightly faster than DU, larger afterimage relative to DU
|
||||
UPDATE_MODE_A2 = 7, // Medium 290ms Anti-aliased text in menus / touch and screen input 2bit Gray level
|
||||
UPDATE_MODE_NONE = 8 Uploading to the 8951 cache without refreshing allows you to accumulate multiple uploads and then refresh all content at once.
|
||||
} m5epd_update_mode_t; // The ones marked with * are more commonly used
|
||||
|
||||
```
|
||||
|
||||
>The refresh quality is relatively good for `UPDATE_MODE_GC16`, `UPDATE_MODE_GL16` , `UPDATE_MODE_GLR16` , `UPDATE_MODE_GLD16`.
|
||||
|
||||
## Canvas API
|
||||
|
||||
- **Function: Fill Draw Area**
|
||||
- `void fillCanvas(uint32_t color);`
|
||||
|
||||
- **Function: Push Buffer Data**
|
||||
- `void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, const uint8_t *data);`
|
||||
- `void pushImage(int32_t x, int32_t y, int32_t w, int32_t h, uint8_t transp, const uint8_t *data);`
|
||||
|
||||
- **Function: Read pixel color**
|
||||
- `uint16_t readPixel(int32_t x, int32_t y);`
|
||||
|
||||
- **Function: Draw pixels**
|
||||
- `void drawPixel(int32_t x, int32_t y, uint32_t color);`
|
||||
|
||||
- **Function: Draw QR code**
|
||||
- `void qrcode(const char *string, uint16_t x = 50, uint16_t y = 10, uint16_t width = 220, uint8_t version = 6);`
|
||||
- `void qrcode(const String &string, uint16_t x = 50, uint16_t y = 10, uint16_t width = 220, uint8_t version = 6);`
|
||||
|
||||
- **Functions: draw squares with center points**
|
||||
- `void fillCenterSquare(int32_t cx, int32_t cy, uint16_t w, uint8_t color);`
|
||||
|
||||
- **Function: Read the buffer size of the current Canvas image**.
|
||||
- `uint32_t getBufferSize(void) {return _buffer_size;}`
|
||||
|
||||
- **Functions: set inverse color**
|
||||
- `void ReverseColor(void);`
|
||||
|
||||
- **Function: set local inverse color**
|
||||
- `void ReversePartColor(int32_t x, int32_t y, int32_t w, int32_t h);`
|
||||
|
||||
- **Function: Canvas Copy**
|
||||
- `void operator=(const M5EPD_Canvas &src);`
|
||||
|
||||
- **Function: Set screen driver**
|
||||
- `void setDriver(M5EPD_Driver *driver);`
|
||||
|
||||
## JPG/BMP/PNG
|
||||
|
||||
- **Function: Drawing images with Bmp file data**
|
||||
- `bool drawBmpFile(fs::FS &fs, const char *path, uint16_t x, uint16_t y);
|
||||
- `bool drawBmpFile(fs::FS &fs, String path, uint16_t x, uint16_t y);`
|
||||
|
||||
|
||||
- **Function: Draw images using Jpg file data**.
|
||||
- `bool drawJpgFile(fs::FS &fs, const char *path, uint16_t x = 0,
|
||||
uint16_t y = 0, uint16_t maxWidth = 0, uint16_t maxHeight = 0,
|
||||
uint16_t offX = 0, uint16_t offY = 0,
|
||||
jpeg_div_t scale = JPEG_DIV_NONE);`
|
||||
|
||||
- `bool drawJpgFile(fs::FS &fs, String path, uint16_t x = 0,
|
||||
uint16_t y = 0, uint16_t maxWidth = 0, uint16_t maxHeight = 0,
|
||||
uint16_t offX = 0, uint16_t offY = 0,
|
||||
jpeg_div_t scale = JPEG_DIV_NONE);`
|
||||
|
||||
- **Function: Draw images using Png file data**.
|
||||
- `bool drawPngFile(fs::FS &fs, const char *path, uint16_t x = 0, uint16_t y = 0,
|
||||
uint16_t maxWidth = 0, uint16_t maxHeight = 0,
|
||||
uint16_t offX = 0, uint16_t offY = 0,
|
||||
double scale = 1.0, uint8_t alphaThreshold = 127);`
|
||||
|
||||
- `bool drawPngFile(fs::FS &fs, String path, uint16_t x = 0, uint16_t y = 0,
|
||||
uint16_t maxWidth = 0, uint16_t maxHeight = 0,
|
||||
uint16_t offX = 0, uint16_t offY = 0,
|
||||
double scale = 1.0, uint8_t alphaThreshold = 127);`
|
||||
|
||||
- **Function: Draw images using memory Jpg data**.
|
||||
- `bool drawJpg(const uint8_t *jpg_data, size_t jpg_len, uint16_t x = 0,
|
||||
uint16_t y = 0, uint16_t maxWidth = 0, uint16_t maxHeight = 0,
|
||||
uint16_t offX = 0, uint16_t offY = 0,
|
||||
jpeg_div_t scale = JPEG_DIV_NONE);`
|
||||
|
||||
- **Function: Draw images using Jpg's Url/Network resource data**.
|
||||
- `bool drawJpgUrl(String url, uint16_t x = 0,
|
||||
uint16_t y = 0, uint16_t maxWidth = 0, uint16_t maxHeight = 0,
|
||||
uint16_t offX = 0, uint16_t offY = 0, jpeg_div_t scale = JPEG_DIV_NONE);`
|
||||
|
||||
|
||||
- **Functions: Draw images using Png's Url/Network resource data**.
|
||||
- `bool drawPngUrl(const char *url, uint16_t x = 0, uint16_t y = 0,
|
||||
uint16_t maxWidth = 0, uint16_t maxHeight = 0,
|
||||
uint16_t offX = 0, uint16_t offY = 0,
|
||||
double scale = 1.0, uint8_t alphaThreshold = 127);`
|
||||
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
#include <M5EPD.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
M5EPD_Canvas canvas(&M5.EPD);
|
||||
|
||||
void setup()
|
||||
{
|
||||
M5.begin();
|
||||
M5.EPD.SetRotation(90);
|
||||
M5.EPD.Clear(true);
|
||||
WiFi.begin("WIFI-SSID", "WIFI-PASSWORD");
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
|
||||
canvas.createCanvas(540, 960);
|
||||
canvas.setTextSize(3);
|
||||
canvas.drawJpgUrl("https://m5stack.oss-cn-shenzhen.aliyuncs.com/image/example_pic/flower.jpg");
|
||||
canvas.pushCanvas(0,0,UPDATE_MODE_GC16);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Text
|
||||
|
||||
>Here are some common text drawing APIs.
|
||||
|
||||
- **Function: set font color**
|
||||
- `void setTextColor(uint16_t color) { TFT_eSPI::setTextColor(color); }`
|
||||
- `void setTextColor(uint16_t fgcolor, uint16_t bgcolor) { TFT_eSPI::setTextColor(fgcolor, bgcolor); }`
|
||||
|
||||
- **Function: set font size**
|
||||
- `void setTextSize(uint8_t size) { TFT_eSPI::setTextSize(size); }`
|
||||
|
||||
- **Function: set text line wrap**
|
||||
- `void setTextWrap(boolean wrapX, boolean wrapY = false) { TFT_eSPI::setTextWrap(wrapX, wrapY); }`
|
||||
|
||||
- **Functions: Setting Text Baseline**
|
||||
- `void setTextDatum(uint8_t datum) { TFT_eSPI::setTextDatum(datum); }`
|
||||
|
||||
- **Functions: set text Padding**
|
||||
- `void setTextPadding(uint16_t x_width) { TFT_eSPI::setTextPadding(x_width); }`
|
||||
|
||||
- **Functions: plotting integers**
|
||||
- `int16_t drawNumber(long long_num, int32_t poX, int32_t poY, uint8_t font) { return TFT_eSPI::drawNumber(long_num, poX, poY, font); }`
|
||||
- `int16_t drawNumber(long long_num, int32_t poX, int32_t poY) { return TFT_eSPI::drawNumber(long_num, poX, poY); }`
|
||||
|
||||
- **Functions: plot floating point number**
|
||||
- `int16_t drawFloat(float floatNumber, uint8_t decimal, int32_t poX, int32_t poY, uint8_t font) { return TFT_eSPI::drawFloat(floatNumber, decimal, poX, poY, font); }`
|
||||
- `int16_t drawFloat(float floatNumber, uint8_t decimal, int32_t poX, int32_t poY) { return TFT_eSPI::drawFloat(floatNumber, decimal, poX, poY); }`
|
||||
|
||||
- **Function: Draw string**
|
||||
- `int16_t drawString(const char *string, int32_t poX, int32_t poY, uint8_t font) { return TFT_eSPI::drawString(string, poX, poY, font); }`
|
||||
- `int16_t drawString(const char *string, int32_t poX, int32_t poY) { return TFT_eSPI::drawString(string, poX, poY); }`
|
||||
- `int16_t drawString(const String &string, int32_t poX, int32_t poY, uint8_t font) { return TFT_eSPI::drawString(string, poX, poY, font); }`
|
||||
- `int16_t drawString(const String &string, int32_t poX, int32_t poY) { return TFT_eSPI::drawString(string, poX, poY); }`
|
||||
|
||||
- **Functions: decode UTF8 string/return Unicode value**.
|
||||
- `uint16_t decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining) { return TFT_eSPI::decodeUTF8(buf, index, remaining); };`
|
||||
- `uint16_t decodeUTF8(uint8_t *buf, uint16_t *index, uint16_t remaining, uint8_t *length) { return TFT_eSPI::decodeUTF8(buf, index, remaining, length); };`
|
||||
|
||||
- **Functions: draw characters**
|
||||
- `int16_t drawChar(uint16_t uniCode, int32_t x, int32_t y) { return TFT_eSprite::drawChar(uniCode, x, y); }`
|
||||
- `int16_t drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font) { return TFT_eSprite::drawChar(uniCode, x, y, font); }`
|
||||
- `void drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32_t bg, uint8_t size) { TFT_eSprite::drawChar(x, y, c, color, bg, size); }`
|
||||
|
||||
- **Function: get text width**
|
||||
- `int16_t textWidth(const char *string, uint8_t font) {return TFT_eSPI::textWidth(string, font);}`
|
||||
- `int16_t textWidth(const char *string) {return TFT_eSPI::textWidth(string);}`
|
||||
- `int16_t textWidth(const String& string, uint8_t font) {return TFT_eSPI::textWidth(string, font);}`
|
||||
- `int16_t textWidth(const String& string) {return TFT_eSPI::textWidth(string);}`
|
||||
|
||||
## Drawing
|
||||
|
||||
>Here are some common drawing APIs.
|
||||
|
||||
// Parent functions - drawing
|
||||
|
||||
- **Function: Draw circles**
|
||||
- `void drawCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color) { TFT_eSPI::drawCircle(x0, y0, r, color); }`
|
||||
|
||||
- **Function: Draw circles helper**
|
||||
- `void drawCircleHelper(int32_t x0, int32_t y0, int32_t r, uint8_t cornername, uint32_t color) { TFT_eSPI::drawCircleHelper(x0, y0, r, cornername, color); }`
|
||||
|
||||
- **Function:draw filled circles**
|
||||
- `void fillCircle(int32_t x0, int32_t y0, int32_t r, uint32_t color) { TFT_eSPI::fillCircle(x0, y0, r, color); }`
|
||||
|
||||
- **Function:draw filled circles helper**
|
||||
- `void fillCircleHelper(int32_t x0, int32_t y0, int32_t r, uint8_t cornername, int32_t delta, uint32_t color) { TFT_eSPI::fillCircleHelper(x0, y0, r, cornername, delta, color); }`
|
||||
|
||||
- **Function: Draw a line**
|
||||
- `void drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color) { TFT_eSprite::drawLine(x0, y0, x1, y1, color); }`
|
||||
- `void drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint8_t thickness, uint8_t color);`
|
||||
|
||||
- **Function: Quickly draw vertical lines**.
|
||||
- `void drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color) { TFT_eSprite::drawFastVLine(x, y, h, color); }`
|
||||
- `void drawFastVLine(int32_t x, int32_t y, int32_t h, uint8_t thickness, uint8_t color);`
|
||||
|
||||
- **Function: Draw ellipse**
|
||||
- `void drawEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint16_t color) { TFT_eSPI::drawEllipse(x0, y0, rx, ry, color); }`
|
||||
|
||||
- **Function: Draw filled ellipse**.
|
||||
- `void fillEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint16_t color) { TFT_eSPI::fillEllipse(x0, y0, rx, ry, color); }`
|
||||
|
||||
- **Function: Draw rect**
|
||||
- `void drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color) { TFT_eSPI::drawRect(x, y, w, h, color); }`
|
||||
|
||||
- **Function: Draw filled rect**
|
||||
- `void fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);`
|
||||
|
||||
- **Functions: draw rounded rectangles**
|
||||
- `void drawRoundRect(int32_t x0, int32_t y0, int32_t w, int32_t h, int32_t radius, uint32_t color) { TFT_eSPI::drawRoundRect(x0, y0, w, h, radius, color); }`
|
||||
|
||||
- **Function: Draw filled rounded rectangles**.
|
||||
- `void fillRoundRect(int32_t x0, int32_t y0, int32_t w, int32_t h, int32_t radius, uint32_t color) { TFT_eSPI::fillRoundRect(x0, y0, w, h, radius, color); }`
|
||||
|
||||
- **Functions: Drawing triangles**
|
||||
- `void drawTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t color) { TFT_eSPI::drawTriangle(x0, y0, x1, y1, x2, y2, color); }`
|
||||
|
||||
- **Functions: Draw filled triangles**
|
||||
- `void fillTriangle(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t color) { TFT_eSPI::fillTriangle(x0, y0, x1, y1, x2, y2, color); }`
|
||||
|
||||
## print
|
||||
|
||||
>Here are some function overrides for print formatted output.
|
||||
|
||||
// Parent functions - Print
|
||||
- `size_t printf(const char * format, ...) __attribute__ ((format (printf, 2, 3)));`
|
||||
|
||||
- `size_t print(const __FlashStringHelper *x){return Print::print(x);}`
|
||||
|
||||
- `size_t print(const String &x){return Print::print(x);}`
|
||||
|
||||
- `size_t print(const char x[]){return Print::print(x);}`
|
||||
|
||||
- `size_t print(char x){return Print::print(x);}`
|
||||
|
||||
- `size_t print(unsigned char x, int y = DEC){return Print::print(x, y);}`
|
||||
|
||||
- `size_t print(int x, int y = DEC){return Print::print(x, y);}`
|
||||
|
||||
- `size_t print(unsigned int x, int y = DEC){return Print::print(x, y);}`
|
||||
|
||||
- `size_t print(long x, int y = DEC){return Print::print(x, y);}`
|
||||
|
||||
- `size_t print(unsigned long x, int y = DEC){return Print::print(x, y);}`
|
||||
|
||||
- `size_t print(double x, int y = 2){return Print::print(x, y);}`
|
||||
|
||||
- `size_t print(const Printable& x){return Print::print(x);}`
|
||||
|
||||
- `size_t print(struct tm * timeinfo, const char * format = NULL){return Print::print(timeinfo, format);}`
|
||||
|
||||
- `size_t println(const __FlashStringHelper *x){return Print::println(x);}`
|
||||
|
||||
- `size_t println(const String &x){return Print::println(x);}`
|
||||
|
||||
- `size_t println(const char x[]){return Print::println(x);}`
|
||||
|
||||
- `size_t println(char x){return Print::println(x);}`
|
||||
|
||||
- `size_t println(unsigned char x, int y = DEC){return Print::println(x, y);}`
|
||||
|
||||
- `size_t println(int x, int y = DEC){return Print::println(x, y);}`
|
||||
|
||||
- `size_t println(unsigned int x, int y = DEC){return Print::println(x, y);}`
|
||||
|
||||
- `size_t println(long x, int y = DEC){return Print::println(x, y);}`
|
||||
|
||||
- `size_t println(unsigned long x, int y = DEC){return Print::println(x, y);}`
|
||||
|
||||
- `size_t println(double x, int y = 2){return Print::println(x, y);}`
|
||||
|
||||
- `size_t println(const Printable& x){return Print::println(x);}`
|
||||
|
||||
- `size_t println(struct tm * timeinfo, const char * format = NULL){return Print::println(timeinfo, format);}`
|
||||
|
||||
- `size_t println(void){return Print::println();}`
|
||||
@@ -0,0 +1,349 @@
|
||||
# System & Button & SHT30 & POWER & RTC
|
||||
|
||||
## begin()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
`void begin(bool touchEnable = true, bool SDEnable = true, bool SerialEnable = true, bool BatteryADCEnable = true, bool I2CEnable = false);`
|
||||
|
||||
**Functions: touch screen initialization , TF Card , UART , battery ADC reading , I2C**
|
||||
|
||||
**Example:**
|
||||
|
||||
```arduino
|
||||
#include <M5EPD.h>
|
||||
|
||||
void setup() {
|
||||
M5.begin(true,true,true,true,true);
|
||||
}
|
||||
```
|
||||
|
||||
## Button
|
||||
|
||||
**Function: detects device key status**
|
||||
|
||||
```
|
||||
Button(uint8_t pin, uint8_t invert, uint32_t dbTime);
|
||||
uint8_t read();
|
||||
uint8_t isPressed();
|
||||
uint8_t isReleased();
|
||||
uint8_t wasPressed();
|
||||
uint8_t wasReleased();
|
||||
uint8_t pressedFor(uint32_t ms);
|
||||
uint8_t releasedFor(uint32_t ms);
|
||||
uint8_t wasReleasefor(uint32_t ms);
|
||||
uint32_t lastChange();
|
||||
|
||||
```
|
||||
|
||||
## update()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
`void update();`
|
||||
|
||||
**Functions: refresh device key status**
|
||||
|
||||
|
||||
**Example:**
|
||||
|
||||
```arduino
|
||||
|
||||
if( M5.BtnL.wasPressed())
|
||||
{
|
||||
Serial.printf("BtnL wasPressed!");
|
||||
}
|
||||
M5.update();
|
||||
|
||||
```
|
||||
|
||||
## SHT30
|
||||
|
||||
**Function: Read the temperature and humidity detected by the SHT30**.
|
||||
|
||||
```
|
||||
float GetTemperature(TemperatureScale Degree = Cel);
|
||||
float GetRelHumidity();
|
||||
float GetAbsHumidity(AbsHumidityScale Scale = Torr);
|
||||
```
|
||||
|
||||
**Refresh detection data (need to call the API to get new detection values)**
|
||||
|
||||
`void UpdateData();`
|
||||
|
||||
**Example:**
|
||||
|
||||
```arduino
|
||||
#include <M5EPD.h>
|
||||
|
||||
char temStr[10];
|
||||
char humStr[10];
|
||||
|
||||
float tem;
|
||||
float hum;
|
||||
|
||||
M5EPD_Canvas canvas(&M5.EPD);
|
||||
void setup()
|
||||
{
|
||||
M5.begin();
|
||||
M5.SHT30.Begin();
|
||||
M5.EPD.SetRotation(90);
|
||||
M5.EPD.Clear(true);
|
||||
canvas.createCanvas(400, 300);
|
||||
canvas.setTextSize(2);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
M5.SHT30.UpdateData();
|
||||
tem = M5.SHT30.GetTemperature();
|
||||
hum = M5.SHT30.GetRelHumidity();
|
||||
Serial.printf("Temperatura: %2.2f*C Humedad: %0.2f%%\r\n", tem, hum);
|
||||
dtostrf(tem, 2, 2 , temStr);
|
||||
dtostrf(hum, 2, 2 , humStr);
|
||||
canvas.drawString("Temperatura:" + String(temStr) + "*C", 100, 100);
|
||||
canvas.drawString("Humedad:" + String(humStr) , 100, 200);
|
||||
canvas.pushCanvas(0,300,UPDATE_MODE_A2);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Related pin definitions
|
||||
|
||||
```
|
||||
#define M5EPD_MAIN_PWR_PIN 2
|
||||
#define M5EPD_CS_PIN 15
|
||||
#define M5EPD_SCK_PIN 14
|
||||
#define M5EPD_MOSI_PIN 12
|
||||
#define M5EPD_BUSY_PIN 27
|
||||
#define M5EPD_MISO_PIN 13
|
||||
#define M5EPD_EXT_PWR_EN_PIN 5
|
||||
#define M5EPD_EPD_PWR_EN_PIN 23
|
||||
#define M5EPD_KEY_RIGHT_PIN 39
|
||||
#define M5EPD_KEY_PUSH_PIN 38
|
||||
#define M5EPD_KEY_LEFT_PIN 37
|
||||
#define M5EPD_BAT_VOL_PIN 35
|
||||
#define M5EPD_PORTC_W_PIN 19
|
||||
#define M5EPD_PORTC_Y_PIN 18
|
||||
#define M5EPD_PORTB_W_PIN 33
|
||||
#define M5EPD_PORTB_Y_PIN 26
|
||||
#define M5EPD_PORTA_W_PIN 32
|
||||
#define M5EPD_PORTA_Y_PIN 25
|
||||
```
|
||||
|
||||
## Power
|
||||
|
||||
- **Function: Enable Expansion Port Power**
|
||||
- `void enableEXTPower() { digitalWrite(M5EPD_EXT_PWR_EN_PIN, 1); }`
|
||||
|
||||
- **Functions: power off expansion port**.
|
||||
- `void disableEXTPower() { digitalWrite(M5EPD_EXT_PWR_EN_PIN, 0); }`
|
||||
|
||||
- **Function: Enable Ink Screen Power**
|
||||
- `void enableEPDPower() { digitalWrite(M5EPD_EPD_PWR_EN_PIN, 1); }`
|
||||
|
||||
- **Function: Turn off the power of the ink screen**.
|
||||
- `void disableEPDPower() { digitalWrite(M5EPD_EPD_PWR_EN_PIN, 0); }`
|
||||
|
||||
- **Function: Enable Main Power**
|
||||
- `void enableMainPower() { digitalWrite(M5EPD_MAIN_PWR_PIN, 1); }`
|
||||
|
||||
- **Function: Turn off main power**
|
||||
- `void disableMainPower() { digitalWrite(M5EPD_MAIN_PWR_PIN, 0); }`
|
||||
|
||||
- **Functions: initialize battery ADC detection**
|
||||
- `void BatteryADCBegin();`
|
||||
|
||||
- **Functions: Read battery voltage native ADC value**
|
||||
- `uint32_t getBatteryRaw();`
|
||||
|
||||
- **Function: Read battery voltage**
|
||||
- `uint32_t getBatteryVoltage();`
|
||||
|
||||
## RTC
|
||||
|
||||
?>Please use `M5.RTC.begin();` to initialize RTC related functions before using
|
||||
|
||||
```
|
||||
typedef struct RTC_Time
|
||||
{
|
||||
int8_t hour;
|
||||
int8_t min;
|
||||
int8_t sec;
|
||||
RTC_Time() : hour(), min(), sec() {}
|
||||
RTC_Time(int8_t h, int8_t m, int8_t s) : hour(h), min(m), sec(s) {}
|
||||
} rtc_time_t;
|
||||
|
||||
typedef struct RTC_Date
|
||||
{
|
||||
int8_t week;
|
||||
int8_t mon;
|
||||
int8_t day;
|
||||
int16_t year;
|
||||
RTC_Date() : week(), mon(), day(), year() {}
|
||||
RTC_Date(int8_t w, int8_t m, int8_t d, int16_t y) : week(w), mon(m), day(d), year(y) {}
|
||||
} rtc_date_t;
|
||||
|
||||
```
|
||||
|
||||
## setTime()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
`void setTime(rtc_time_t *time);`
|
||||
|
||||
**Description:**
|
||||
|
||||
Set RTC Time Struct
|
||||
|
||||
## getTime()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
`void getTime(rtc_time_t *time);`
|
||||
|
||||
**Description:**
|
||||
|
||||
Get RTC Time Struct
|
||||
|
||||
## setDate()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
`void setDate(rtc_date_t *date);`
|
||||
|
||||
**Description:**
|
||||
|
||||
Set RTC Date Struct
|
||||
|
||||
## getDate()
|
||||
|
||||
**Syntax:**
|
||||
|
||||
`void getDate(rtc_date_t *date);`
|
||||
|
||||
**Description:**
|
||||
|
||||
Get RTC Date Struct
|
||||
|
||||
**Example:**
|
||||
|
||||
|
||||
```
|
||||
#include <M5EPD.h>
|
||||
|
||||
M5EPD_Canvas canvas(&M5.EPD);
|
||||
|
||||
rtc_time_t RTCtime;
|
||||
rtc_date_t RTCDate;
|
||||
|
||||
char timeStrbuff[64];
|
||||
|
||||
void flushTime(){
|
||||
M5.RTC.getTime(&RTCtime);
|
||||
M5.RTC.getDate(&RTCDate);
|
||||
|
||||
sprintf(timeStrbuff,"%d/%02d/%02d %02d:%02d:%02d",
|
||||
RTCDate.year,RTCDate.mon,RTCDate.day,
|
||||
RTCtime.hour,RTCtime.min,RTCtime.sec);
|
||||
|
||||
canvas.drawString(timeStrbuff, 0, 0);
|
||||
canvas.pushCanvas(100,200,UPDATE_MODE_DU4);
|
||||
}
|
||||
|
||||
void setupTime(){
|
||||
|
||||
RTCtime.hour = 23;
|
||||
RTCtime.min = 33;
|
||||
RTCtime.sec = 33;
|
||||
M5.RTC.setTime(&RTCtime);
|
||||
|
||||
RTCDate.year = 2020;
|
||||
RTCDate.mon = 11;
|
||||
RTCDate.day = 27;
|
||||
M5.RTC.setDate(&RTCDate);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
|
||||
M5.begin();
|
||||
M5.EPD.SetRotation(90);
|
||||
M5.EPD.Clear(true);
|
||||
M5.RTC.begin();
|
||||
canvas.createCanvas(400, 300);
|
||||
canvas.setTextSize(3);
|
||||
setupTime();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
flushTime();
|
||||
delay(1000);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## shutdown()
|
||||
|
||||
### function overload-1:
|
||||
|
||||
Power off and wake up again via PWR button
|
||||
|
||||
`void shutdown();`
|
||||
|
||||
### function overload-2:
|
||||
|
||||
Turn off the power and wake up the device via RTC at the end of the delay based on the number of seconds of incoming delay.
|
||||
|
||||
`int shutdown( int seconds );`
|
||||
|
||||
### function overload-3:
|
||||
|
||||
Turn off the power, pass in the RTC time structure that specifies a certain point in time, and wake up the device via RTC when the `hours`, `minutes`, and `seconds` of that time are met.
|
||||
|
||||
`int shutdown( const rtc_time_t &RTC_TimeStruct);`
|
||||
|
||||
### function overload-4:
|
||||
|
||||
Turn off the power, pass in the RTC time structure specified for a certain point in time, and wake up the device by RTC when the `week number`, `day number`, and `time` of that point in time match at the same time.
|
||||
|
||||
`int shutdown( const rtc_date_t &RTC_DateStruct, const rtc_time_t &RTC_TimeStruct);`
|
||||
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
#include <M5EPD.h>
|
||||
|
||||
M5EPD_Canvas canvas(&M5.EPD);
|
||||
|
||||
void setup()
|
||||
{
|
||||
M5.begin();
|
||||
M5.EPD.SetRotation(90);
|
||||
M5.TP.SetRotation(90);
|
||||
M5.EPD.Clear(true);
|
||||
M5.RTC.begin();
|
||||
canvas.createCanvas(540, 960);
|
||||
canvas.setTextSize(3);
|
||||
canvas.drawString("Press PWR Btn for sleep!", 45, 350);
|
||||
canvas.drawString("after 5 sec wakeup!", 70, 450);
|
||||
canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if(M5.BtnP.wasPressed()){
|
||||
|
||||
canvas.drawString("I'm going to sleep.zzzZZZ~", 45, 550);
|
||||
canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
|
||||
delay(1000);
|
||||
M5.shutdown(5);
|
||||
}
|
||||
M5.update();
|
||||
delay(100);
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,103 @@
|
||||
# TOUCH-GT911
|
||||
|
||||
>This is the M5Stack Paper touchscreen library.
|
||||
|
||||
## GT911
|
||||
|
||||
>In the `M5.begin()` initialization, the instance `GT911 TP = GT911();` has been created and initialized. You can use the API in this instance to get the touch interaction information.
|
||||
|
||||
- **Functions: Initialize I2C bus**.
|
||||
- `esp_err_t begin(uint8_t pin_sda, uint8_t pin_scl, uint8_t pin_int);`
|
||||
|
||||
- **Functions: if there is new screen touch data to be read**.
|
||||
- `bool avaliable();`
|
||||
|
||||
- **Functions: screen refresh detection**
|
||||
- `void update();`
|
||||
|
||||
- **Functions: Set screen rotation angle/usually set to 90°**.
|
||||
- `void SetRotation(uint16_t rotate);`
|
||||
|
||||
- **Function: Read the X-coordinate of the touch finger**.
|
||||
- `uint16_t readFingerX(uint8_t num);`
|
||||
|
||||
- **Function: read touch finger Y coordinate**
|
||||
- `uint16_t readFingerY(uint8_t num);`
|
||||
|
||||
- **Function: Read the touch finger ID coordinates**.
|
||||
- `uint16_t readFingerID(uint8_t num);`
|
||||
|
||||
- **Function: read the size of the rectangle in the area where the touch finger acts**.
|
||||
- `uint16_t readFingerSize(uint8_t num);`
|
||||
|
||||
- **Functions: last read number of fingers touched**
|
||||
- `uint8_t getFingerNum(void);`
|
||||
|
||||
- **Function: detect if the finger is raised**.
|
||||
- `bool isFingerUp(void);`
|
||||
|
||||
- **Function: Clear the current touch state**
|
||||
- `void flush(void);`
|
||||
|
||||
- **Function: Read touch finger information, return to structure instance**
|
||||
- `tp_finger_t readFinger(uint8_t num);`
|
||||
|
||||
```
|
||||
typedef struct
|
||||
{
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint16_t id;
|
||||
uint16_t size;
|
||||
}tp_finger_t;
|
||||
|
||||
```
|
||||
|
||||
**Example:**
|
||||
|
||||
```arduino
|
||||
#include <M5EPD.h>
|
||||
|
||||
M5EPD_Canvas canvas(&M5.EPD);
|
||||
|
||||
int point[2][2];
|
||||
|
||||
void setup()
|
||||
{
|
||||
M5.begin();
|
||||
M5.EPD.SetRotation(90);
|
||||
M5.TP.SetRotation(90);
|
||||
M5.EPD.Clear(true);
|
||||
canvas.createCanvas(540, 960);
|
||||
canvas.setTextSize(5);
|
||||
canvas.drawString("Touch The Screen!", 20, 400);
|
||||
canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
if(M5.TP.avaliable()){
|
||||
if(!M5.TP.isFingerUp()){
|
||||
M5.TP.update();
|
||||
canvas.fillCanvas(0);
|
||||
bool is_upadte = false;
|
||||
for(int i=0;i<2; i++){
|
||||
tp_finger_t FingerItem = M5.TP.readFinger(i);
|
||||
if((point[i][0]!=FingerItem.x)||(point[i][1]!=FingerItem.y)){
|
||||
is_upadte = true;
|
||||
point[i][0] = FingerItem.x;
|
||||
point[i][1] = FingerItem.y;
|
||||
canvas.fillRect(FingerItem.x-50, FingerItem.y-50, 100, 100, 15);
|
||||
Serial.printf("Finger ID:%d-->X: %d*C Y: %d Size: %d\r\n", FingerItem.id, FingerItem.x, FingerItem.y , FingerItem.size);
|
||||
}
|
||||
}
|
||||
if(is_upadte)
|
||||
{
|
||||
canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
@@ -92,6 +92,15 @@ const coreink_api = {
|
||||
"id":"coreink_api"
|
||||
};
|
||||
|
||||
const m5paper_api = {
|
||||
'title':"M5Paper API",
|
||||
'item':{
|
||||
'System & Button & SHT30 & POWER & RTC':'#/en/api/m5paper/system_api',
|
||||
'EPD Canvas':'#/en/api/m5paper/epd_canvas',
|
||||
'TOUCH':'#/en/api/m5paper/touch'
|
||||
},
|
||||
"id":"m5paper_api"
|
||||
};
|
||||
|
||||
var arduino_home_page = new Vue({
|
||||
el:'#arduino_home_page',
|
||||
@@ -102,7 +111,8 @@ var arduino_home_page = new Vue({
|
||||
m5core_api: m5core_api,
|
||||
m5stickc_api: m5stickc_api,
|
||||
m5core2_api: m5core2_api,
|
||||
coreink_api: coreink_api
|
||||
coreink_api: coreink_api,
|
||||
m5paper_api: m5paper_api
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ view the corresponding tutorial&quick-Start.
|
||||
|
||||
<img src="assets/img/product_pics/core/coreink/coreink_note.webp" width="400px">
|
||||
|
||||
?>Warning: Please avoid using high refresh rates,reccommended refresh rate is(15s/per refresh), Do not expose to ultraviolet rays for a long time, otherwise it may cause irreversible damage to the ink screen.
|
||||
?>Warning: Please avoid using high refresh rates,recommended refresh rate is(15s/per refresh), Do not expose to ultraviolet rays for a long time, otherwise it may cause irreversible damage to the ink screen.
|
||||
|
||||
<img class="pic" src="assets/img/product_pics/core/coreink/coreink_02.webp">
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ For more info on specific pin functions refer to the official ESP32 Docs[ESP32 d
|
||||
|
||||
- **API**
|
||||
|
||||
- [Arduino API](en/arduino/arduino_home_page)
|
||||
- [Arduino API](zh_CN/arduino/arduino_home_page?id=m5paper)
|
||||
|
||||
## Schematic
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ Before use, please make sure that the roverc is fully charged. Charging method:
|
||||
Burn the easyloader firmware of Joyc and roverc with two M5StickC respectively. Insert Joyc and roverc respectively after burning. After power on, roverc will display the MAC address name and battery power. At the same time, Joyc will scan the MAC address name of roverc. Long press the a key of M5StickC on Joyc, and the work will be matched. Left rocker up and down control front and back, left and right control translation, right rocker left and right control steering.
|
||||
|
||||
## Usage
|
||||
Two M5StickCs will be burned into the EasyLoader firmware of JoyC and RoverC respectively. After burning, they will be inserted into JoyC and RoverC respectively. After booting, RoverC will display the hotspot name of "M5AP+2 bytes mac address", and JoyC will scan the mac address name of RoverC. Press and hold the A5 button of the M5StickC on the JoyC for 3 seconds to start scanning the hotspot of the car, and the pairing is successful. After successful pairing, the link icon is highlighted in the upper left corner of the screen, and the joystick value is displayed on the screen. The left and right joysticks are controlled up and down, the left and right controls pan, and the right rocker controls the steering.
|
||||
Two M5StickCs will be burned into the EasyLoader firmware of JoyC and RoverC respectively. After burning, they will be inserted into JoyC and RoverC respectively. After booting, RoverC will display the hotspot name of "M5AP+2 bytes mac address", and JoyC will scan the mac address name of RoverC. Press and hold the Home button of the M5StickC on the JoyC for 3 seconds to start scanning the hotspot of the car, and the pairing is successful. After successful pairing, the link icon is highlighted in the upper left corner of the screen, and the joystick value is displayed on the screen. The left and right joysticks are controlled up and down, the left and right controls pan, and the right rocker controls the steering.
|
||||
|
||||
|
||||
MotorControl:
|
||||
|
||||
@@ -133,7 +133,7 @@ MotorControl:
|
||||
### 1. Arduino IDE
|
||||
|
||||
Use with JoyC HAT(without servo gripper), please click [here](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Hat/RoverC)
|
||||
Before use, please make sure that the RoverC is fully charged. Charging method: insert M5StickC/M5StickC Plus into the RoverC, and connect the USB cable for charging.Burn the easyloader firmware of JoyC and RoverC with two M5StickC respectively. Insert JoyC and RoverC respectively after burning. After power on, RoverC will display the MAC address name and battery level. At the same time, JoyC will scan for the MAC address of RoverC. Long press the A key of M5StickC on Joyc, and the two will be paired. Left thumbstick controlls forward and back motion, left and right control translation, right thumbstick controls left and right steering.
|
||||
Before use, please make sure that the RoverC is fully charged. Charging method: insert M5StickC/M5StickC Plus into the RoverC, and connect the USB cable for charging.Burn the easyloader firmware of JoyC and RoverC with two M5StickC respectively. Insert JoyC and RoverC respectively after burning. After power on, RoverC will display the MAC address name and battery level. At the same time, JoyC will scan for the MAC address of RoverC. Long press the Home button of M5StickC on Joyc, and the two will be paired. Left thumbstick controlls forward and back motion, left and right control translation, right thumbstick controls left and right steering.
|
||||
|
||||
Independent(with servo gripper) usage [here](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Application/RoverC_PRO_Arduino_Alone)
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# 24AWG 4-CORE Shielded Cable
|
||||
|
||||
<el-tag effect="plain">SKU:A034</el-tag>
|
||||
|
||||
<div class="product_pic"><img src="assets/img/product_pics/accessory/grove_cable_01.webp"></div>
|
||||
|
||||
## 描述
|
||||
|
||||
**24AWG 4-CORE Shielded Cable**M5Stack的一款双绞线屏蔽线缆,4部
|
||||
|
||||
开发体系中常用的硬件连接导线,所有的控制器Core、功能Unit都能够兼容GROVE接口.GROVE线由4条导线组成,其中两条用作数据信号,其余两条用作"VCC"与"GND",我们提供了不同的长度选择,以满足不同的应用需求.
|
||||
|
||||
<img src="assets/img/product_pics/accessory/grove_cable_02.webp" width="100%" height="100%">
|
||||
|
||||
<img src="assets/img/product_pics/accessory/grove_cable_03.webp" width="80%" height="80%">
|
||||
|
||||
<img src="assets/img/product_pics/accessory/grove_cable_04.webp" width="80%" height="80%">
|
||||
|
||||
## 特性
|
||||
|
||||
- 5 种规格: 10cm, 20cm, 0.5m, 1m, 2m
|
||||
|
||||
## 重量尺寸
|
||||
- 10cm (5/pcs)
|
||||
- 重量:21g
|
||||
- 20cm (5/pcs)
|
||||
- 重量:22g
|
||||
- 50cm (2/pcs)
|
||||
- 重量:21g
|
||||
- 100cm (1/pcs)
|
||||
- 重量:20g
|
||||
- 200cm (1/pcs)
|
||||
- 重量:36g
|
||||
|
||||
<script>
|
||||
|
||||
var purchase_link = 'https://m5stack.com/collections/m5-accessory/products/4pin-buckled-grove-cable';
|
||||
|
||||
anchor_search(purchase_link);
|
||||
scrollFunc();
|
||||
|
||||
</script>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,40 +6,40 @@
|
||||
|
||||
>在`M5.begin()`初始化中,已经创建了实例`GT911 TP = GT911();`并进行了初始化. 你可以用该实例中的API获取触摸交互信息。
|
||||
|
||||
- 初始化I2C总线
|
||||
- **功能:初始化I2C总线**
|
||||
- `esp_err_t begin(uint8_t pin_sda, uint8_t pin_scl, uint8_t pin_int);`
|
||||
|
||||
- 是否有新的屏幕触摸数据待读取
|
||||
- **功能:是否有新的屏幕触摸数据待读取**
|
||||
- `bool avaliable();`
|
||||
|
||||
- 刷新屏幕检测
|
||||
- **功能:刷新屏幕检测**
|
||||
- `void update();`
|
||||
|
||||
- 设置屏幕旋转角度
|
||||
- **功能:设置屏幕旋转角度/通常设置为90°**
|
||||
- `void SetRotation(uint16_t rotate);`
|
||||
|
||||
- 读取触摸手指X坐标
|
||||
- **功能:读取触摸手指X坐标**
|
||||
- `uint16_t readFingerX(uint8_t num);`
|
||||
|
||||
- 读取触摸手指Y坐标
|
||||
- **功能:读取触摸手指Y坐标**
|
||||
- `uint16_t readFingerY(uint8_t num);`
|
||||
|
||||
- 读取触摸手指ID坐标
|
||||
- **功能:读取触摸手指ID坐标**
|
||||
- `uint16_t readFingerID(uint8_t num);`
|
||||
|
||||
- 读取触摸手指作用区域矩形大小
|
||||
- **功能:读取触摸手指作用区域矩形大小**
|
||||
- `uint16_t readFingerSize(uint8_t num);`
|
||||
|
||||
- 最后一次读取触摸手指数量
|
||||
- **功能:最后一次读取触摸手指数量**
|
||||
- `uint8_t getFingerNum(void);`
|
||||
|
||||
- 检测手指是否抬起
|
||||
- **功能:检测手指是否抬起**
|
||||
- `bool isFingerUp(void);`
|
||||
|
||||
- 将当前触摸状态清空
|
||||
- **功能:将当前触摸状态清空**
|
||||
- `void flush(void);`
|
||||
|
||||
- 读取触摸手指信息,返回结构体实例
|
||||
- **功能:读取触摸手指信息,返回结构体实例**
|
||||
- `tp_finger_t readFinger(uint8_t num);`
|
||||
|
||||
```
|
||||
|
||||
@@ -91,6 +91,16 @@ const coreink_api = {
|
||||
"id":"coreink_api"
|
||||
};
|
||||
|
||||
const m5paper_api = {
|
||||
'title':"M5Paper API",
|
||||
'item':{
|
||||
'System & Button & SHT30 & POWER & RTC':'#/zh_CN/api/m5paper/system_api',
|
||||
'EPD Canvas':'#/zh_CN/api/m5paper/epd_canvas',
|
||||
'TOUCH':'#/zh_CN/api/m5paper/touch'
|
||||
},
|
||||
"id":"m5paper_api"
|
||||
};
|
||||
|
||||
|
||||
var arduino_home_page = new Vue({
|
||||
el:'#arduino_home_page',
|
||||
@@ -101,7 +111,8 @@ var arduino_home_page = new Vue({
|
||||
m5core_api: m5core_api,
|
||||
m5stickc_api: m5stickc_api,
|
||||
m5core2_api: m5core2_api,
|
||||
coreink_api: coreink_api
|
||||
coreink_api: coreink_api,
|
||||
m5paper_api: m5paper_api
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
|
||||
- **API**
|
||||
|
||||
- [Arduino API](zh_CN/arduino/arduino_home_page)
|
||||
- [Arduino API](zh_CN/arduino/arduino_home_page?id=m5paper)
|
||||
|
||||
## 原理图
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
## 使用说明
|
||||
使用前请确保RoverC已经充满电,充电方式:将M5StickC插入RoverC,并连接USB线缆进行充电.
|
||||
分别将两台M5StickC烧录JoyC与RoverC的EasyLoader固件,烧录后分别插入JoyC与RoverC,开机后RoverC会显示"M5AP+2字节mac地址"热点名称,同时JoyC会扫描到RoverC的mac地址名,长按3秒JoyC上的M5StickC的A键,开始扫描小车的热点,即可配对成功。成功配对后屏幕左上角会高亮显示链接图标,同时屏幕显示摇杆数值。左摇杆上下控制前后,左右控制平移,右摇杆左右控制转向。
|
||||
分别将两台M5StickC烧录JoyC与RoverC的EasyLoader固件,烧录后分别插入JoyC与RoverC,开机后RoverC会显示"M5AP+2字节mac地址"热点名称,同时JoyC会扫描到RoverC的mac地址名,长按3秒JoyC上的M5StickC的Home键,开始扫描小车的热点,即可配对成功。成功配对后屏幕左上角会高亮显示链接图标,同时屏幕显示摇杆数值。左摇杆上下控制前后,左右控制平移,右摇杆左右控制转向。
|
||||
|
||||
电机控制:
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ MotorControl:
|
||||
### 1. Arduino IDE
|
||||
|
||||
配合摇杆使用(无夹持) [点击此处](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Hat/RoverC)
|
||||
使用前,请确保RoverC充满电。充电方式:将M5StickC/M5StickC Plus插入RoverC,连接USB线充电。分别用两个M5StickC/M5StickC PLUS烧录JoyC和RoverC的EasyLoader固件。然后分别插入JoyC和RoverC。开机后,RoverC将显示MAC地址名称和电池电量。同时,JoyC将扫描RoverC的MAC地址。长按Joyc上M5StickC的A键,两者将配对。左摇杆控制前进和后退运动,左右控制平移,右摇杆控制左右转向。
|
||||
使用前,请确保RoverC充满电。充电方式:将M5StickC/M5StickC Plus插入RoverC,连接USB线充电。分别用两个M5StickC/M5StickC PLUS烧录JoyC和RoverC的EasyLoader固件。然后分别插入JoyC和RoverC。开机后,RoverC将显示MAC地址名称和电池电量。同时,JoyC将扫描RoverC的MAC地址。长按Joyc上M5StickC的Home键,两者将配对。左摇杆控制前进和后退运动,左右控制平移,右摇杆控制左右转向。
|
||||
|
||||
单独使用参考(含夹持) [点击此处](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Application/RoverC_PRO_Arduino_Alone)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user