diff --git a/docs/en/api/lcd.md b/docs/en/api/lcd.md index a72ce8e9..6e0e0966 100644 --- a/docs/en/api/lcd.md +++ b/docs/en/api/lcd.md @@ -2,6 +2,412 @@ *The screen pixel is 320x240, with the top left corner of the screen as the origin (0,0)* +Color codes are predefined and can be used. + +| Definition | Value | R | G | B | +| --- | --- | -- | -- | -- | +|TFT_BLACK | 0x0000 | 0| 0| 0 | +|TFT_NAVY | 0x000F | 0| 0| 128 | +|TFT_DARKGREEN | 0x03E0 | 0| 128| 0 | +|TFT_MAROON | 0x7800 | 128| 0| 0 | +|TFT_PURPLE | 0x780F | 128| 0| 128 | +|TFT_OLIVE | 0x7BE0 | 128| 128| 0 | +|TFT_LIGHTGREY | 0xC618 | 192| 192| 192 | +|TFT_DARKGREY | 0x7BEF | 128| 128| 128 | +|TFT_BLUE | 0x001F | 0| 0| 255 | +|TFT_GREENYELLOW| 0xB7E0 | 180| 255| 0 | +|TFT_GREEN | 0x07E0 | 0| 255| 0 | +|TFT_YELLOW | 0xFFE0 | 255| 255| 0 | +|TFT_ORANGE | 0xFDA0 | 255| 180| 0 | +|TFT_PINK | 0xFC9F |255 | 255| 16 | +|TFT_CYAN | 0x07FF | 0| 255| 255 | +|TFT_DARKCYAN | 0x03EF | 0| 128| 128 | +|TFT_RED | 0xF800 | 255| 0| 0 | +|TFT_MAGENTA | 0xF81F | 255| 0| 255 | +|TFT_WHITE | 0xFFFF | 255| 255| 255 | + +## begin() + +**Description:** + +Initialize it for use. + +**Syntax:** + +begin(); + +**Function argument:** + +None + +**Function return value:** + +None + +**Note:** + +1)If you do not want to initialize the LCD with M5.begin( ), call this function before using the display. + + +## sleep() + +**Description:** + +Switch the display to energy saving mode + +**Syntax:** + +sleep(); + +**Function argument:** + +None + +**Function return value:** + +None + +**Note:** + +1) Call wakeup () function to wake up. + +2) Since the LCD backlight of M5Stack is controlled separately, please adjust it with the setBrightness () function if necessary. + +**Example of use:** + +```arduino +#include + +M5.Lcd.sleep(); +M5.Lcd.setBrightness(0); +``` + +## wakeup() + +**Description:** + +Restore the display from energy saving mode + +**Syntax:** + +wakeup(); + +**Function argument:** + +None + +**Function return value:** + +None + +**Note:** + +1) Since the LCD backlight of M5Stack is controlled separately, please adjust it with the setBrightness () function if necessary. + +**Example of use:** + +```arduino +#include + +M5.Lcd.wakeup(); +M5.Lcd.setBrightness(200); +``` + +## setBrightness() + +**Description:** + +Adjust the display backlight. + +**Syntax:** + +setBrightness(uint8_t brightness); + +**Function argument:** + + +| argument | type | Description | +| --- | --- | -- | +| brightness | uint8_t | Brightness (0: Off - 255:Full) | + +**Function return value:** + +None. + +**Note:** + +1) The backlight is controlled by PWM (44.1 KHz). + +2) Many backlights have a direct effect on battery consumption. + +**Example of use:** + +```arduino +#include + +M5.Lcd.setBrightness(200); +``` + +## progressBar() + +**Description:** + +Display a bar that shows the progress. + +**Syntax:** + +progressBar(int x, int y, int w, int h, uint8_t val); + +**Function argument:** + + +| argument | type | Description | +| --- | --- | -- | +| x | int | Coordinate X(left corner) | +| y | int | Coordinate Y(left corner) | +| w | int | width (px) | +| h | int | height(px) | +| val | uint8_t | progress(0-100%) | + + +**Function return value:** + +None + +**Note:** + +1) The color is expressed in blue (0x09F1). + +2) Please erase the background beforehand to draw only the additional amount. + +**Example of use:** + +```arduino +#include + + M5.Lcd.fillRect(0,0,240,20,0); + M5.Lcd.progressBar(0,0,240,20, 20); +``` + +## qrcode() + +**Description:** + +Generate a QR code. + +**Syntax:** + +qrcode(const char *string, uint16_t x, uint16_t y, uint8_t width, uint8_t version); + +qrcode(const String &string, uint16_t x, uint16_t y, uint8_t width, uint8_t version); + +**Function argument:** + + +| argument | type | Description | +| --- | --- | -- | +| val | string / String& | String to embed in QR | +| x | uint16_t | Coordinate X(left corner) | +| y | uint16_t | Coordinate Y(left corner) | +| width | uint8_t | width (px) | +| version | uint8_t | QR code version | + + +**Function return value:** + +None + +**Note:** + +1) Please indicate the appropriate QR code version according to the number of characters. + +**Example of use:** + +```arduino +#include + + M5.Lcd.qrcode("http://www.m5stack.com",50,10,220,6); + +``` + +## drawBitmap() + +**Description:** + +Draw a bitmap + +**Syntax:** + +drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint16_t *data); + +drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, uint16_t *data); + +drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint16_t *data, uint16_t transparent); + +drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint8_t *data); + +drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, uint8_t *data); + +**Function argument:** + + +| argument | type | Description | +| --- | --- | -- | +| x0 | uint16_t | Coordinate X(left corner) | +| y0 | uint16_t | Coordinate Y(left corner) | +| w | int16_t | width (px) | +| h | int16_t | height(px) | +| data | uint16_t* / uint8_t*| image data | +| transparent | uint16_t | Transparent color code | + +**Function return value:** + +None + +**Note:** + +1) The color code is expressed by a total of 16 bits: red 5 bits, green 6 bits and blue 5 bits from the top. + +**Example of use:** + +See sample sketch:M5Stack->Advanced->drawXBitmap + + +## drawBmpFile() + +**Description:** + +Read a bitmap from a file and draw it. + +**Syntax:** + +drawBmpFile(fs::FS &fs, const char *path, uint16_t x, uint16_t y); + + +**Function argument:** + + +| argument | type | Description | +| --- | --- | -- | +| fs | fs::FS | File stream | +| path | const char * | file path | +| x | int16_t | Coordinate X(left corner) | +| y | int16_t | Coordinate Y(left corner) | + +**Function return value:** + +None + +**Note:** + +1) It may not be possible to expand depending on the size and the number of bits. + +**Example of use:** + +```arduino +#include + M5.Lcd.drawBmpFile(SD, "/p2.bmp",0,0); +``` + + +## drawJpg() + +**Description:** + +Read JPEG data from memory and draw it. + +**Syntax:** + +void 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 argument:** + + +| argument | type | Description | +| --- | --- | -- | +| jpg_data |uint8_t * | top of data | +| jpg_len | size_t | data length | +| x | uint16_t | Coordinate X (left corner) | +| y | uint16_t | Coordinate Y (left corner) | +|maxWidth | uint16_t | Maximum width (px) | +|maxHeight | uint16_t | Maximum height (px) | +| offX | uint16_t |offset X (px) | +| offY | uint16_t |offset Y (px) | +| scale | jpeg_div_t | scale | + + +scale (jpeg_div_t): + +| Definition |Description | +| --- | -- | +| JPEG_DIV_NONE|no care.| +| JPEG_DIV_2 |1/2| +| JPEG_DIV_4 |1/4| +| JPEG_DIV_8 |1/8| +| JPEG_DIV_MAX |MAX| + + +**Function return value:** + +None + +**Note:** + +1) Depending on the size, the number of bits and the format (progressive etc.), it may not be possible to expand. + +## drawJpgFile() + +**Description:** + +Read JPEG data from a file and draw it. + +**Syntax:** + +void 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); + + +**Function argument:** + +| argument | type | Description | +| --- | --- | -- | +| fs |fs::FS &| file stream | +| path | const char * | file path | +| x | uint16_t | Coordinate X(left corner) | +| y | uint16_t | Coordinate Y(left corner) | +|maxWidth | uint16_t | Max Width (px) | +|maxHeight | uint16_t | Max Height (px) | +| offX | uint16_t | Offset X (px) | +| offY | uint16_t | Offset Y (px) | +| scale | jpeg_div_t | Scale | + + +Scale(jpeg_div_t): + +| Definition |Description | +| --- | -- | +| JPEG_DIV_NONE|no care.| +| JPEG_DIV_2 |1/2| +| JPEG_DIV_4 |1/4| +| JPEG_DIV_8 |1/8| +| JPEG_DIV_MAX |MAX| + + +**Function return value:** + +None + +**Note:** + +1) Depending on the size and format (progressive etc.), it may not be possible to expand. + + ## fillScreen() **Syntax:** @@ -125,11 +531,125 @@ from m5ui import * lcd.drawPixel(22,22,lcd.RED) ``` --> + +## drawPixel() + +**Description:** + +Draws a pixel of a specified color at a specified position. + +**Syntax:** + +drawPixel(int16_t x, int16_t y, [uint16_t color]); + +**Function argument:** + +| argument | Description | type | +| --- | --- | -- | +| x | Coordinate X | int16_t | +| y | Coordinate Y | int16_t | +| color | Pixel color. (Optional) | uint16_t | + +**Example of use:** + +```arduino +#include + +M5.begin(); +M5.Lcd.drawPixel(22, 22, RED); +``` + +## drawChar() + +**Description:** + +Draws a straight line of the specified color from the specified start point to the end point. + +**Syntax:** + +drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32_t bg, uint8_t size); + +**Function argument:** + +| argument | type | Description | +| --- | --- | -- | +| x | int32_t | Coordinate X (upper left) | +| y | int32_t | Coordinate Y (upper left) | +| c | uint16_t | Character code | +|color | uint32_t | Drawing color | +|bg | uint32_t | Background color | +|size | uint8_t | Character size | + +**Example of use:** + +```arduino +#include + + M5.begin(); + M5.Lcd.drawChar(0,0,'A',TFT_GREEN,TFT_BLACK,3); +``` + + +## drawFastVLine() + +**Description:** + +Draw a vertical line from X to Y. + +**Syntax:** + +drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color); + +**Function argument:** + +| Argument | Type | Description | +| --- | --- | --- | +| x | int16_t | x position of start point | +| y | int16_t | y position of start point | +| h | int16_t | line length | +|color| uint32_t | Line color (optional) | + +**Example of use:** + +```arduino +#include + +M5.Lcd.drawFastHLine(0, 0, 12, TFT_GREEN); +``` + +## drawFastVLine() + +**Description:** + +Draw a horizontal line from X to Y. + +**Syntax:** + +drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color); + +**Function argument:** + +| Argument | Type | Description | +| --- | --- | --- | +| x | int16_t | x position of start point | +| y | int16_t | y position of start point | +| h | int16_t | line length | +|color| uint32_t | Line color (optional) | + +**Example of use:** + +```arduino +#include + +M5.Lcd.drawFastHLine(0, 0, 12, TFT_GREEN); +``` + + ## drawLine() **Syntax:** -drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); +drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); **Function: Draw the line from point (x,y) to point (x1,y1).** @@ -160,7 +680,7 @@ lcd.drawLine(0,0,12,12,lcd.WHITE) **Syntax:** -drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); +drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); **Function: Draw the triangel between points (x,y), (x1,y1) and (x2,y2).** @@ -191,7 +711,7 @@ lcd.drawLine(0,0,12,12,lcd.WHITE) **Syntax:** -fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); +fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); **Function: Fill the triangel between points (x,y), (x1,y1) and (x2,y2).** @@ -222,17 +742,17 @@ lcd.drawLine(0,0,12,12,lcd.WHITE) **Syntax:** -drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); +drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); **Function: Draw the rectangle from the upper left point at (x,y) and width and height.** | Param | Description | | --- | --- | -| w | display phisical width in pixels (display’s smaller dimension) | -| h | display phisical height in pixels (display’s larger dimension) | -| color | color value | - -*If color is not given, current background color is used* +| x | position of point | int16_t | +| y | position of point | int16_t | +| w | width of rectangle | int16_t | +| h | height of rectangle | int16_t | +| color | Line color.(Optional.) | uint16_t | **Example:** @@ -255,17 +775,17 @@ lcd.drawLine(0,0,12,12,lcd.WHITE) **Syntax:** -fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); +fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color); **Function: Fill the rectangle from the upper left point at (x,y) and width and height.** | Param | Description | | --- | --- | -| w | display phisical width in pixels (display’s smaller dimension) | -| h | display phisical height in pixels (display’s larger dimension) | -| color | color value | - -*If color is not given, current background color is used* +| x | position of point | int16_t | +| y | position of point | int16_t | +| w | width of rectangle | int16_t | +| h | height of rectangle | int16_t | +| color | Line color.(Optional.) | uint16_t | **Example:** @@ -288,14 +808,16 @@ lcd.drawLine(0,0,12,12,lcd.WHITE) **Syntax:** -drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); +drawRoundRect(int16_t x0, int16_t y0, int16_t w,int16_t h, int16_t radius, uint16_t color); **Function: Draw the rectangle with rounded corners from the upper left point at (x,y) and width and height. Corner radius is given by radius argument.** | Param | Description | | --- | --- | -| w | display phisical width in pixels (display’s smaller dimension) | -| h | display phisical height in pixels (display’s larger dimension) | +| x | position of point | int16_t | +| y | position of point | int16_t | +| w | width of circle | int16_t | +| h | height of circle | int16_t | | radius | the radius of circle | | color | color value | @@ -318,6 +840,266 @@ from m5ui import * lcd.drawLine(0,0,12,12,lcd.WHITE) ``` --> +## fillRoundRect() + +**Description:** + +Draw a filled square with the upper left point (x, y) and width and height. + +**Syntax:** + +fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, [uint16_t color]); + +**Function argument:** + +| argument | Description | type | +| --- | --- | -- | +| x |coordinate of the top left corner of the rectangle | int16_t | +| y |coordinate of the top left corner of the rectangle | int16_t | +| w | width of rectangle | int16_t | +| h | height of rectangle | int16_t | +| r | corner radius | int16_t | +| color | Color of the square line. Optional. | uint16_t | + +**Example of use:** + +```arduino +#include + +M5.begin(); +M5.Lcd.fillRoundRect(180, 70, 122, 10, 4, BLUE); +``` + + +## drawEllipse() + +**Description:** + +Draw an ellipse with the top left point (x, y) and the width and height. + +**Syntax:** + +drawEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint16_t color); + +**Function argument:** + +| argument | Description | type | +| --- | --- | -- | +| x0 | Center X coordinate of the ellipse | int16_t | +| y0 | Center Y coordinate of the ellipse | int16_t | +| rx | Width of circle | int16_t | +| ry | Height of circle | int16_t | +|color | circle color | uint16_t | + +**Example of use:** + +```arduino +#include + +M5.Lcd.drawEllipse(100,100,20,30, TFT_GREEN); +``` + +## fillEllipse() + +**Description:** + +Draw a filled ellipse, specifying the top left point (x, y) and the width and height. + +**Syntax:** + +fillEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint16_t color); + +**Function argument:** + +| argument | Description | type | +| --- | --- | -- | +| x0 | Center X coordinate of the ellipse | int16_t | +| y0 | Center Y coordinate of the ellipse | int16_t | +| rx | Width of circle | int16_t | +| ry | Height of circle | int16_t | +|color | circle color | uint16_t | + +**Example of use:** + +```arduino +#include + +M5.Lcd.drawEllipse(100,100,20,30, TFT_GREEN); +``` + + +## color565() + +**Description:** + +Change to the color code (rgb 565) used in the function. + +**Syntax:** + +color565(uint8_t red, uint8_t green, uint8_t blue); + +**Function argument:** + +| Argument | Description | Type | +| --- | --- | --- | +| red | red | int8_t | +| green | green | int8_t | +| blue | blue | int8_t | + + +**Function return value:** + +None + +**Example of use:** + +```arduino +#include + + uint16_t colorvalue=0; + colorvalue=color565(255,255,255); + +``` + +## setRotation() + +**Description:** + +Rotate the screen. + +**Syntax:** + +setRotation(uint8_t r); + +**Function argument:** + +| argument | type | Description | +| --- | --- | -- | +| r | uint8_t | Rotation angle r (unit:90 deg) | + + +**Example of use:** + +```arduino +#include + + M5.begin(); + M5.Lcd.setRotation(1); +``` +**Note:** + +1) The display control of M5Stack is rotated by 90 °, and setRotation (1) is executed in M5.Lcd.begin (). + +2) 0 to 3 rotate, 4 to 7 reverse and rotate. + + +## invertDisplay() + +**Description:** + +Reverse the screen color in negative / positive. + +**Syntax:** + +invertDisplay(boolean i); + +**Function argument:** + +| Argument | Type | Description | +| --- | --- |--- | +| i | boolean | true : inverted | + + +**Example of use:** + +```arduino +#include + + M5.begin(); + M5.Lcd.invertDisplay(true); +``` + + +## loadFont() + +**Description:** + +Load a font + +**Syntax:** + +loadFont(String fontName, fs::FS &ffs); + +**Function argument:** + +| argument | type | Description | +| --- | --- | --- | +| fontName | String | font filepath | +| ffs | fs::FS | file stream | + +**Example of use:** + +```arduino +#include + +M5.Lcd.loadFont("filename", SD); +``` + +## unloadFont() + +**Description:** + +Finish using a font + +**Syntax:** + +unloadFont(); + +**Function argument:** + +None + +**Example of use:** + +```arduino +#include + +M5.Lcd.unloadFont(); +``` + +## fontsLoaded() + +**Description:** + +Returns whether you are loading a font + +**Syntax:** + +fontsLoaded(); + +**Function argument:** + +None + +**Function return value:** + +|値 |Description | +|-- |-- | +| true | loaded | +| false | Unread | + +**Example of use:** + +```arduino +#include + +if(M5.Lcd.unloadFont()){ + M5.Lcd.unloadFont(); +} +``` + + + ## print() **Syntax:** @@ -345,6 +1127,64 @@ from m5ui import * lcd.drawLine(0,0,12,12,lcd.WHITE) ``` --> +## drawString() + +**Description:** + +Draw a character + +**Syntax:** + +drawString(const char *string, int32_t poX, int32_t poY, uint8_t font); + +drawString(const char *string, int32_t poX, int32_t poY); + +drawString(const String& string, int32_t poX, int32_t poY, uint8_t font); + +drawString(const String& string, int32_t poX, int32_t poY); + + +**Function argument:** + + +| argument | type | Description | +| --- | --- | -- | +| poX | int32_t | Coordinate X (upper left) | +| poY | int32_t | Coordinate Y (upper left) | +| string | const char * / String & | String | +| font | uint8_t | 1: If use the loaded font | + +**Function return value:** + +None + + + +## printf() + +**Description:** + +Draw the specified string. + +**Syntax:** + +printf("Format specification",arg1...); + +**Note:** + +The format specification can be specified according to the usual C language format. + +**Example of use:** + +```arduino +#include + +int a=1; +M5.begin(); +M5.Lcd.printf("A=%d",a); +``` + + ## Usage {docsify-ignore} ```arduino diff --git a/docs/en/api/power.md b/docs/en/api/power.md index e61ac316..1b9ea243 100644 --- a/docs/en/api/power.md +++ b/docs/en/api/power.md @@ -1,6 +1,6 @@ # Power -* Power related functions depend on the IP5306 chip. Please refer to the data sheet [IP5306] (https://github.com/m5stack/M5-Schematic/blob/master/Core/IIC_IP5306_REG_V1.4.pdf) as required. +*Power related functions depend on the IP5306 chip. Please refer to the data sheet [IP5306](https://github.com/m5stack/M5-Schematic/blob/master/Core/IIC_IP5306_REG_V1.4.pdf) as required.* * The older M5STACK hardware does not support communication with IP5306 chip. When using functions, also consider supporting out of control cases. * diff --git a/docs/en/api/speaker.md b/docs/en/api/speaker.md index 2fe48b55..9cb02dec 100644 --- a/docs/en/api/speaker.md +++ b/docs/en/api/speaker.md @@ -1,6 +1,43 @@ # Speaker -### tone +## begin() + +**Description:** + +Initialize the speaker. + +**Syntax:** + +begin(); + +**Function argument:** + +None + +**Function return value:** + +None + +## end() + +**Description:** + +Mute the speakers and stop the output. + +**Syntax:** + +end(); + +**Function argument:** + +None + +**Function return value:** + +None + + +## tone() **Syntax:** @@ -9,7 +46,7 @@ **Description: Set the pitch of speaker.** | Param | Description | type | -| --- | --- | -- | +| --- | --- | --- | | freq | frequency | uint16_t | | duration | duration (unit: millisecond) | uint16_t | @@ -21,4 +58,30 @@ void setup() { M5.begin(); M5.Speaker.tone(900, 1000); } -``` \ No newline at end of file +``` + +## setBeep() + +**Description:** + +Set the beep sound. + +**Syntax:** + +setBeep(uint16_t freq, uint16_t duration); + +| Argument | Description | Type | +| --- | --- | --- | +| freq | pitch (frequency Hz) | uint16_t | +| duration | beep time (ms), optional. | uint16_t | + +**Example of use:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Speaker.setBeep(900, 1000); +} +``` diff --git a/docs/ja/api/lcd.md b/docs/ja/api/lcd.md index 50744819..d4c37640 100644 --- a/docs/ja/api/lcd.md +++ b/docs/ja/api/lcd.md @@ -2,6 +2,415 @@ スクリーンの解像度は 横320 x 高さ240 で、左上が原点(0, 0)です。 +色コードはあらかじめ定義があり、これらを利用することができます。 + +| 色定義 | 中身 | 説明 | R | G | B | +| --- | --- | -- | -- | -- | -- | +|TFT_BLACK | 0x0000 |黒 | 0| 0| 0 | +|TFT_NAVY | 0x000F |ネイビー | 0| 0| 128 | +|TFT_DARKGREEN | 0x03E0 |濃い緑 | 0| 128| 0 | +|TFT_MAROON | 0x7800 |マロン | 128| 0| 0 | +|TFT_PURPLE | 0x780F |パープル | 128| 0| 128 | +|TFT_OLIVE | 0x7BE0 |オリーブ | 128| 128| 0 | +|TFT_LIGHTGREY | 0xC618 |薄い灰色 | 192| 192| 192 | +|TFT_DARKGREY | 0x7BEF |濃い灰色 | 128| 128| 128 | +|TFT_BLUE | 0x001F |青 | 0| 0| 255 | +|TFT_GREENYELLOW| 0xB7E0 |黄緑 | 180| 255| 0 | +|TFT_GREEN | 0x07E0 |緑 | 0| 255| 0 | +|TFT_YELLOW | 0xFFE0 |黄色 | 255| 255| 0 | +|TFT_ORANGE | 0xFDA0 |オレンジ | 255| 180| 0 | +|TFT_PINK | 0xFC9F |ピンク |255 | 255| 16 | +|TFT_CYAN | 0x07FF |シアン | 0| 255| 255 | +|TFT_DARKCYAN | 0x03EF |濃いシアン | 0| 128| 128 | +|TFT_RED | 0xF800 |赤 | 255| 0| 0 | +|TFT_MAGENTA | 0xF81F |マゼンダ | 255| 0| 255 | +|TFT_WHITE | 0xFFFF |白 | 255| 255| 255 | + + +## begin() + +**機能:** + +使用できるように初期化を行います。 + +**構文:** + +begin(); + +**引数:** + +なし + +**戻り値:** + +なし + +**情報:** + +1)M5.begin( )でLCDの初期化を行わない場合は、ディスプレイを使う前にこの関数を呼んでください。 + + +## sleep() + +**機能:** + +ディスプレイを省エネモードに移行させます + +**構文:** + +sleep(); + +**引数:** + +なし + +**戻り値:** + +なし + +**情報:** + +1)スリープを解除するには、wakeup()関数を呼んでください。 + +2)M5StackのLCDバックライトは別に制御しているため、必要に応じてsetBrightness( )関数で調整してください。 + +**使用例:** + +```arduino +#include + +M5.Lcd.sleep(); +M5.Lcd.setBrightness(0); +``` + +## wakeup() + +**機能:** + +ディスプレイを省エネモードから復帰させます + +**構文:** + +wakeup(); + +**引数:** + +なし + +**戻り値:** + +なし + +**情報:** + +1)M5StackのLCDバックライトは別に制御しているため、必要に応じてsetBrightness( )関数で調整してください。 + +**使用例:** + +```arduino +#include + +M5.Lcd.wakeup(); +M5.Lcd.setBrightness(200); +``` + + +## setBrightness() + +**機能:** + +ディスプレイのバックライトを調整します。 + +**構文:** + +setBrightness(uint8_t brightness); + +**引数:** + + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| brightness | uint8_t | 明るさ(0:消灯~255:全灯) | + +**戻り値:** + +なし + +**情報:** + +1)バックライトはPWM(44.1KHz)で制御されています。 + +2)バックライトを多用するとバッテリー消費に直接的な影響があります。 + +**使用例:** + +```arduino +#include + +M5.Lcd.setBrightness(200); +``` + +## progressBar() + +**機能:** + +進捗を表すバーを表示します。 + +**構文:** + +progressBar(int x, int y, int w, int h, uint8_t val); + +**引数:** + + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| x | int | 座標X(左上) | +| y | int | 座標Y(左上) | +| w | int | 幅 (px) | +| h | int | 高さ(px) | +| val | uint8_t | 進捗(0-100%) | + + +**戻り値:** + +なし + +**情報:** + +1)色は青色(0x09F1)で表現されます。 + +2)追加分しか描画しないため、あらかじめ背景を消しておいてください。 + +**使用例:** + +```arduino +#include + + M5.Lcd.fillRect(0,0,240,20,0); + M5.Lcd.progressBar(0,0,240,20, 20); +``` + + +## qrcode() + +**機能:** + +QRコードを生成します。 + +**構文:** + +qrcode(const char *string, uint16_t x, uint16_t y, uint8_t width, uint8_t version); + +qrcode(const String &string, uint16_t x, uint16_t y, uint8_t width, uint8_t version); + +**引数:** + + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| val | string / String& | QRに埋め込む文字列 | +| x | uint16_t | 座標X(左上) | +| y | uint16_t | 座標Y(左上) | +| width | uint8_t | 幅 (px) | +| version | uint8_t | QRコードバージョン | + + +**戻り値:** + +なし + +**情報:** + +1)文字数に合わせて適切なQRコードバージョンを指示してください。 + +**使用例:** + +```arduino +#include + + M5.Lcd.qrcode("http://www.m5stack.com",50,10,220,6); + +``` + +## drawBitmap() + +**機能:** + +ビットマップを描画します。 + +**構文:** + +drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint16_t *data); + +drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, uint16_t *data); + +drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint16_t *data, uint16_t transparent); + +drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint8_t *data); + +drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, uint8_t *data); + +**引数:** + + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| x0 | int16_t | 座標X(左上) | +| y0 | int16_t | 座標Y(左上) | +| w | int16_t | 幅 (px) | +| h | int16_t | 高さ(px) | +| data | uint16_t* / uint8_t*| 画像データ | +| transparent | uint16_t | 透明色コード | + +**戻り値:** + +なし + +**情報:** + +1)カラーコードは上位より赤5ビット、緑6ビット、青5ビットの計16ビットであらわされます。 + +**使用例:** + +サンプルスケッチを参照:M5Stack->Advanced->drawXBitmap + + +## drawBmpFile() + +**機能:** + +ファイルからビットマップを読み込み、描画します。 + +**構文:** + +drawBmpFile(fs::FS &fs, const char *path, uint16_t x, uint16_t y); + + +**引数:** + + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| fs | fs::FS | ファイルデバイス | +| path | const char * | ファイル名 | +| x | int16_t | 座標X(左上) | +| y | int16_t | 座標Y(左上) | + +**戻り値:** + +なし + +**情報:** + +1)サイズ、ビット数によっては展開できないことがあります。 + +**使用例:** + +```arduino +#include + M5.Lcd.drawBmpFile(SD, "/p2.bmp",0,0); +``` + + +## drawJpg() + +**機能:** + +メモリからJPEGデータを読み込み、描画します。 + +**構文:** + +void 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); + + +**引数:** + + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| jpg_data |uint8_t * | 格納場所の先頭 | +| jpg_len | size_t | データ長 | +| x | uint16_t | 座標X(左上) | +| y | uint16_t | 座標Y(左上) | +|maxWidth | uint16_t | 最大幅 (px) | +|maxHeight | uint16_t | 最大高さ (px) | +| offX | uint16_t |オフセットX (px) | +| offY | uint16_t | オフセットY (px) | +| scale | jpeg_div_t | 座標Y(左上) | + + +スケール(jpeg_div_t)引数: + +| 名前 |説明 | +| --- | -- | +| JPEG_DIV_NONE|等倍| +| JPEG_DIV_2 |1/2| +| JPEG_DIV_4 |1/4| +| JPEG_DIV_8 |1/8| +| JPEG_DIV_MAX |最大| + + +**戻り値:** + +なし + +**情報:** + +1)サイズ、ビット数、フォーマット(プログレッシブ等)によっては展開できないことがあります。 + +## drawJpgFile() + +**機能:** + +ファイルからJPEGデータを読み込み、描画します。 + +**構文:** + +void 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); + + +**引数:** + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| fs |fs::FS &| ファイルデバイス | +| path | const char * | ファイルがある場所 | +| x | uint16_t | 座標X(左上) | +| y | uint16_t | 座標Y(左上) | +|maxWidth | uint16_t | 最大幅 (px) | +|maxHeight | uint16_t | 最大高さ (px) | +| offX | uint16_t |オフセットX (px) | +| offY | uint16_t | オフセットY (px) | +| scale | jpeg_div_t |スケール | + + +スケール(jpeg_div_t)引数: + +| 名前 |説明 | +| --- | -- | +| JPEG_DIV_NONE|等倍| +| JPEG_DIV_2 |1/2| +| JPEG_DIV_4 |1/4| +| JPEG_DIV_8 |1/8| +| JPEG_DIV_MAX |最大| + + +**戻り値:** + +なし + +**情報:** + +1)サイズ、フォーマット(プログレッシブ等)によっては展開できないことがあります。 + + ## fillScreen() **機能:** @@ -12,6 +421,8 @@ fillScreen(uint16_t color); +**引数:** + | 引数 | 説明 | 型 | | --- | --- | -- | | color | 塗りつぶしの色 | uint16_t | @@ -35,6 +446,8 @@ M5.Lcd.fillScreen(RED); setTextColor(uint16_t color, [uint16_t backgroundcolor]); +**引数:** + | 引数 | 説明 | 型 | | --- | --- | -- | | color | テキストの色 | uint16_t | @@ -74,6 +487,21 @@ M5.Lcd.setCursor(100, 100); M5.Lcd.print("Hello"); ``` +## setTextSize() + +**機能:** + +描画する文字サイズを指定します + +**構文:** + +setTextSize(uint8_t size); + +| 引数 | 説明 | 型 | +| --- | --- | -- | + | size | 文字のサイズ(1-7) | uint8_t | + + ## drawPixel() **機能:** @@ -84,6 +512,8 @@ M5.Lcd.print("Hello"); drawPixel(int16_t x, int16_t y, [uint16_t color]); +**引数:** + | 引数 | 説明 | 型 | | --- | --- | -- | | x | x位置 | int16_t | @@ -99,6 +529,91 @@ M5.begin(); M5.Lcd.drawPixel(22, 22, RED); ``` +## drawChar() + +**機能:** + +指定した始点から終点まで指定色の直線を描画します。 + +**構文:** + +drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32_t bg, uint8_t size); + +**引数:** + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| x | int32_t | 座標X(左上) | +| y | int32_t | 座標Y(左上) | +| c | uint16_t | 文字コード | +| color | uint32_t | 描画色 | +| bg | uint32_t | 背景色 | +| size | uint8_t | 文字サイズ | + +**使用例:** + +```arduino +#include + + M5.begin(); + M5.Lcd.drawChar(0,0,'A',TFT_GREEN,TFT_BLACK,3); +``` + + +## drawFastVLine() + +**機能:** + +XからYまで垂直に線を引きます。 + +**構文:** + +drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color); + +**引数:** + +| 引数 | 型 |説明 | +| --- | --- | -- | +| x | int16_t | 始点のx位置 | +| y | int16_t | 始点のy位置 | +| h | int16_t |線の長さ | +| color | uint32_t |線の色(省略可能) | + +**使用例:** + +```arduino +#include + +M5.Lcd.drawFastHLine(0, 0, 12, TFT_GREEN); +``` + +## drawFastVLine() + +**機能:** + +XからYまで水平に線を引きます。 + +**構文:** + +drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color); + +**引数:** + +| 引数 | 型 |説明 | +| --- | --- | -- | +| x | int16_t | 始点のx位置 | +| y | int16_t | 始点のy位置 | +| w | int16_t |線の長さ | +| color | uint32_t |線の色(省略可能) | + +**使用例:** + +```arduino +#include + +M5.Lcd.drawFastHLine(0, 0, 12, TFT_GREEN); +``` + ## drawLine() **機能:** @@ -109,13 +624,15 @@ M5.Lcd.drawPixel(22, 22, RED); drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, [uint16_t color]); -| 引数 | 説明 | 型 | +**引数:** + +| 引数 | 型 |説明 | | --- | --- | -- | -| x0 | 始点のx位置 | int16_t | -| y0 | 始点のy位置 | int16_t | -| x1 | 終点のx位置 | int16_t | -| y1 | 終点のy位置 | int16_t | -| color | 線の色。省略可能。 | uint16_t | +| x0 | int16_t | 始点のx位置 | +| y0 | int16_t |始点のy位置 | +| x1 | int16_t |終点のx位置 | +| y1 | int16_t |終点のy位置 | +| color | uint16_t |線の色(省略可能) | **使用例:** @@ -136,6 +653,8 @@ M5.Lcd.drawLine(0, 0, 12, 12, WHITE); drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, [uint16_t color]); +**引数:** + | 引数 | 説明 | 型 | | --- | --- | -- | | x0 | 点0のx位置 | int16_t | @@ -165,6 +684,8 @@ M5.Lcd.drawTriangle(22, 22, 69, 98, 51, 22, RED); fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, [uint16_t color]); +**引数:** + | 引数 | 説明 | 型 | | --- | --- | -- | | x0 | 点0のx位置 | int16_t | @@ -194,6 +715,8 @@ M5.Lcd.fillTriangle(22, 22, 69, 98, 51, 22, RED); drawRect(int16_t x, int16_t y, int16_t w, int16_t h, [uint16_t color]); +**引数:** + | 引数 | 説明 | 型 | | --- | --- | -- | | x | 点のx位置 | int16_t | @@ -221,6 +744,8 @@ M5.Lcd.drawRect(180, 12, 122, 10, BLUE); fillRect(int16_t x, int16_t y, int16_t w, int16_t h, [uint16_t color]); +**引数:** + | 引数 | 説明 | 型 | | --- | --- | -- | | x | 点のx位置 | int16_t | @@ -248,6 +773,8 @@ M5.Lcd.fillRect(180, 12, 122, 10, BLUE); drawRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, [uint16_t color]); +**引数:** + | 引数 | 説明 | 型 | | --- | --- | -- | | x | 四角形の左上の頂点のx座標 | int16_t | @@ -265,6 +792,320 @@ M5.Lcd.fillRect(180, 12, 122, 10, BLUE); M5.begin(); M5.Lcd.fillRoundRect(180, 70, 122, 10, 4, BLUE); ``` +## fillRoundRect() + +**機能:** + +左上の点(x,y)と幅と高さを指定して、塗りつぶされた かど丸の四角形を描画します。 + +**構文:** + +fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, [uint16_t color]); + +**引数:** + +| 引数 | 説明 | 型 | +| --- | --- | -- | +| x | 四角形の左上の頂点のx座標 | int16_t | +| y | 四角形の左上の頂点のy座標 | int16_t | +| w | 四角形の幅 | int16_t | +| h | 四角形の高さ | int16_t | +| r | コーナー半径 | int16_t | +| color | 四角形の線の色。省略可能。 | uint16_t | + +**使用例:** + +```arduino +#include + +M5.begin(); +M5.Lcd.fillRoundRect(180, 70, 122, 10, 4, BLUE); +``` + + +## drawEllipse() + +**機能:** + +左上の点(x,y)と幅と高さを指定して、楕円を描画します。 + +**構文:** + +drawEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint16_t color); + +**引数:** + +| 引数 | 説明 | 型 | +| --- | --- | -- | +| x0 | 楕円の中心X座標 | int16_t | +| y0 | 楕円の中心Y座標 | int16_t | +| rx | 円の横幅 | int16_t | +| ry | 円の縦幅 | int16_t | +| color | 円の色 | uint16_t | + +**使用例:** + +```arduino +#include + +M5.Lcd.drawEllipse(100,100,20,30, TFT_GREEN); +``` + +## fillEllipse() + +**機能:** + +左上の点(x,y)と幅と高さを指定して、塗りつぶされた楕円を描画します。 + +**構文:** + +fillEllipse(int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint16_t color); + +**引数:** + +| 引数 | 説明 | 型 | +| --- | --- | -- | +| x0 | 楕円の中心X座標 | int16_t | +| y0 | 楕円の中心Y座標 | int16_t | +| rx | 円の横幅 | int16_t | +| ry | 円の縦幅 | int16_t | +| color | 円の色 | uint16_t | + +**使用例:** + +```arduino +#include + +M5.Lcd.drawEllipse(100,100,20,30, TFT_GREEN); +``` + + +## color565() + +**機能:** + +関数で使用する色コード(rgb565)に変更します。 + +**構文:** + +color565(uint8_t red, uint8_t green, uint8_t blue); + +**引数:** + +| 引数 | 説明 | 型 | +| --- | --- | -- | +| red | 赤 | int8_t | +| green | 緑 | int8_t | +| blue | 青 | int8_t | + + +**戻り値:** + +なし + +**使用例:** + +```arduino +#include + + uint16_t colorvalue=0; + colorvalue=color565(255,255,255); + +``` + +## setRotation() + +**機能:** + +画面を回転させます。 + +**構文:** + +setRotation(uint8_t r); + +**引数:** + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| r | uint8_t | 回転角 r (x 90°)| + + +**使用例:** + +```arduino +#include + + M5.begin(); + M5.Lcd.setRotation(1); +``` +**情報:** + +1)M5Stackのディスプレイ制御は90°回転された制御になっており、M5.Lcd.begin()の中で setRotation(1)が実行されています。 + +2)0~3 は回転、4~7 は画面反転し、回転します。 + +## invertDisplay() + +**機能:** + +画面をネガポジ反転させます。 + +**構文:** + +invertDisplay(boolean i); + +**引数:** + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| i|boolean | 反転するなら true| + + +**使用例:** + +```arduino +#include + + M5.begin(); + M5.Lcd.invertDisplay(true); +``` + + +## loadFont() + +**機能:** + +独自のフォントを読み込みます + +**構文:** + +loadFont(String fontName, fs::FS &ffs); + +**引数:** + +| 引数 | 型 || 説明 +| --- | --- | -- | +| fontName | String | フォントファイル名 | +| ffs | fs::FS | ファイルデバイス | + +**使用例:** + +```arduino +#include + +M5.Lcd.loadFont("filename", SD); +``` + +## unloadFont() + +**機能:** + +独自のフォントの使用を終えます + +**構文:** + +unloadFont(); + +**引数:** + +なし + +**使用例:** + +```arduino +#include + +M5.Lcd.unloadFont(); +``` + +## fontsLoaded() + +**機能:** + +独自のフォントを読み込んでいるかを返します + +**構文:** + +fontsLoaded(); + +**引数:** + +なし + +**戻り値:** + +|値 |説明 | +|-- |-- | +|true |読み込み済み| +|false|未読み込み | + +**使用例:** + +```arduino +#include + +if(M5.Lcd.unloadFont()){ + M5.Lcd.unloadFont(); +} +``` + + +## drawString() + +**機能:** + +文字を描画します。 + +**構文:** + +drawString(const char *string, int32_t poX, int32_t poY, uint8_t font); + +drawString(const char *string, int32_t poX, int32_t poY); + +drawString(const String& string, int32_t poX, int32_t poY, uint8_t font); + +drawString(const String& string, int32_t poX, int32_t poY); + + +**引数:** + + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| poX | int32_t | 座標X(左上) | +| poY | int32_t | 座標Y(左上) | +| string | const char * / String &| 文字列 | +| font | uint8_t | 読み込んだフォントを使うなら 1 | + +**戻り値:** + +なし + + + +## printf() + +**機能:** + +指定の文字列を描画します。 + +**構文:** + +printf("書式指定",arg1...); + +**情報:** + +書式指定は通常のC言語フォーマットに沿った指定ができます。 + +**使用例:** + +```arduino +#include + +int a=1; +M5.begin(); +M5.Lcd.printf("A=%d",a); +``` ## print() diff --git a/docs/ja/api/power.md b/docs/ja/api/power.md index 387af76c..9d54af9e 100644 --- a/docs/ja/api/power.md +++ b/docs/ja/api/power.md @@ -1,6 +1,6 @@ # Power -*電源関連の機能はIP5306チップに依存しています。必要に応じてデータシート[IP5306](https://github.com/m5stack/M5-Schematic/blob/master/Core/IIC_IP5306_REG_V1.4.pdf)を参照してください* +*電源関連の機能はIP5306チップに依存しています。必要に応じてデータシート[IP5306](https://github.com/m5stack/M5-Schematic/blob/master/Core/IIC_IP5306_REG_V1.4.pdf)を参照してください* *古いM5STACKハードウェアの場合、IP5306チップが通信未対応です。機能を使う場合は制御できないケースも考慮してください。* diff --git a/docs/ja/api/speaker.md b/docs/ja/api/speaker.md index 109405ee..5b1a786b 100644 --- a/docs/ja/api/speaker.md +++ b/docs/ja/api/speaker.md @@ -1,5 +1,41 @@ # スピーカー +## begin() + +**機能:** + +スピーカーを初期化します。 + +**構文:** + +begin(); + +**引数:** + +なし + +**戻り値:** + +なし + +## end() + +**機能:** + +スピーカーをミュートし、出力を終了します。 + +**構文:** + +end(); + +**引数:** + +なし + +**戻り値:** + +なし + ## tone() **機能:** @@ -11,7 +47,7 @@ tone(uint16_t freq, [uint32_t duration]); | 引数 | 説明 | 型 | -| --- | --- | -- | +| --- | --- | --- | | freq | 音の高さ(周波数Hz) | uint16_t | | duration | 鳴動時間 (ms)、 省略可能。 | uint16_t | @@ -26,6 +62,32 @@ void setup() { } ``` +## setBeep() + +**機能:** + +Beepで鳴らす音を設定します。 + +**構文:** + +setBeep(uint16_t freq, uint16_t duration); + +| 引数 | 説明 | 型 | +| --- | --- | --- | +| freq | 音の高さ(周波数Hz) | uint16_t | +| duration | 鳴動時間 (ms)、 省略可能。 | uint16_t | + +**使用例:** + +```arduino +#include + +void setup() { + M5.begin(); + M5.Speaker.setBeep(900, 1000); +} +``` + + +## drawString() + +**功能:** + +画一个角色 + +**函数原型:** + +drawString(const char *string, int32_t poX, int32_t poY, uint8_t font); + +drawString(const char *string, int32_t poX, int32_t poY); + +drawString(const String& string, int32_t poX, int32_t poY, uint8_t font); + +drawString(const String& string, int32_t poX, int32_t poY); + + +**参数:** + + +| 引数 | 型 | 説明 | +| --- | --- | -- | +| poX | int32_t | 坐标X(左上角) | +| poY | int32_t | 坐标Y(左上角) | +| string | const char * / String &| 一个字符串 | +| font | uint8_t | 如果使用导入的字体 1 | + +**返回值:** + +无。 + + + +## printf() + +**功能:** + +绘制指定的字符串。 + +**函数原型:** + +printf("格式规范",arg1...); + +**情報:** + +格式规范可以根据通常的C语言格式指定。 + +**使用示例:** + +```arduino +#include + +int a=1; +M5.begin(); +M5.Lcd.printf("A=%d",a); +``` + + * * *