From b4d7836fdb38f46bddc661bcac1061f19a3a5307 Mon Sep 17 00:00:00 2001 From: LiHuashen <854410664@qq.com> Date: Fri, 30 Nov 2018 17:31:47 +0800 Subject: [PATCH] add "api reference" --- docs/en/api_reference.md | 5 +- docs/en/api_reference/api_lcd.md | 280 ++--------------- docs/en/api_reference/api_speaker.md | 15 + docs/en/api_reference/peripherals/api_gpio.md | 21 ++ docs/index.md | 10 +- docs/ja/README.md | 8 +- docs/ja/api_reference.md | 5 +- docs/ja/api_reference/api_lcd.md | 265 ++-------------- docs/ja/api_reference/api_speaker.md | 15 + docs/ja/api_reference/peripherals/api_gpio.md | 21 ++ docs/ja/sidebar.md | 2 +- docs/sidebar.md | 2 +- docs/zh_CN/README.md | 16 +- docs/zh_CN/api_reference.md | 5 +- docs/zh_CN/api_reference/api_lcd.md | 288 +++--------------- docs/zh_CN/api_reference/api_speaker.md | 15 + .../api_reference/peripherals/api_gpio.md | 21 ++ docs/zh_CN/sidebar.md | 2 +- 18 files changed, 243 insertions(+), 753 deletions(-) create mode 100644 docs/en/api_reference/api_speaker.md create mode 100644 docs/en/api_reference/peripherals/api_gpio.md create mode 100644 docs/ja/api_reference/api_speaker.md create mode 100644 docs/ja/api_reference/peripherals/api_gpio.md create mode 100644 docs/zh_CN/api_reference/api_speaker.md create mode 100644 docs/zh_CN/api_reference/peripherals/api_gpio.md diff --git a/docs/en/api_reference.md b/docs/en/api_reference.md index 4fe65b0c..d954243b 100644 --- a/docs/en/api_reference.md +++ b/docs/en/api_reference.md @@ -2,4 +2,7 @@ [中文](/zh_CN/api_reference) | English | [日本語](/ja/api_reference) -- [LCD](/en/api_reference/api_lcd) \ No newline at end of file +## [LCD](en/api_reference/api_lcd) +## [Peripherals](en/api_reference/peripherals/api_gpio) +### 1. [GPIO](en/api_reference/peripherals/api_gpio) +## [Speaker](en/api_reference/api_speaker) diff --git a/docs/en/api_reference/api_lcd.md b/docs/en/api_reference/api_lcd.md index 61c77c4e..dd9f15c7 100644 --- a/docs/en/api_reference/api_lcd.md +++ b/docs/en/api_reference/api_lcd.md @@ -1,287 +1,73 @@ # LCD -### buildAllPlatforms -> StyleDictionary.buildAllPlatforms() ⇒ [style-dictionary](#module_style-dictionary) - - - - -The only top-level method that needs to be called -to build the Style Dictionary. - -**Example** -```js -const StyleDictionary = require('style-dictionary').extend('config.json'); -StyleDictionary.buildAllPlatforms(); -``` - -* * * - -### buildPlatform -> StyleDictionary.buildPlatform(platform) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Takes a platform and performs all transforms to -the properties object (non-mutative) then -builds all the files and performs any actions. This is useful if you only want to -build the artifacts of one platform to speed up the build process. - -This method is also used internally in [buildAllPlatforms](#buildAllPlatforms) to -build each platform defined in the config. +### setbrightness +> M5.Lcd.setbrightness(uint8_t brightness); +Set the brightness of LCD. | Param | Type | Description | | --- | --- | --- | -| platform | String | Name of the platform you want to build. | +| brightness | uint8_t | brightness(0-254) | **Example** -```js -StyleDictionary.buildPlatform('web'); -``` -```bash -$ style-dictionary build --platform web +```c++ +M5.Lcd.setbrightness(100); ``` * * * -### cleanAllPlatforms -> StyleDictionary.cleanAllPlatforms() ⇒ [style-dictionary](#module_style-dictionary) - - - - -Does the reverse of [buildAllPlatforms](#buildAllPlatforms) by -performing a clean on each platform. This removes all the files -defined in the platform and calls the undo method on any actions. - - -* * * - -### cleanPlatform -> StyleDictionary.cleanPlatform(platform) ⇒ [style-dictionary](#module_style-dictionary) - -Takes a platform and performs all transforms to -the properties object (non-mutative) then -cleans all the files and perfoms the undo method of any [actions](actions). - - -| Param | Type | -| --- | --- | -| platform | String | - - -* * * - -### exportPlatform -> StyleDictionary.exportPlatform(platform) ⇒ Object - -Exports a properties object with applied -platform transforms. - -This is useful if you want to use a style -dictionary in JS build tools like webpack. +### fillScreen +> M5.Lcd.fillScreen(uint16_t color); +Set the color to display of the whole LCD. | Param | Type | Description | | --- | --- | --- | -| platform | String | The platform to be exported. Must be defined on the style dictionary. | - - -* * * - -### extend -> StyleDictionary.extend(config) ⇒ [style-dictionary](#module_style-dictionary) - - -Create a Style Dictionary - - -| Param | Type | Description | -| --- | --- | --- | -| config | [Config](#Config) | Configuration options to build your style dictionary. If you pass a string, it will be used as a path to a JSON config file. You can also pass an object with the configuration. | +| color | uint16_t | color value | **Example** -```js -const StyleDictionary = require('style-dictionary').extend('config.json'); - -const StyleDictionary = require('style-dictionary').extend({ - source: ['properties/*.json'], - platforms: { - scss: { - transformGroup: 'scss', - buildPath: 'build/', - files: [{ - destination: 'variables.scss', - format: 'scss/variables' - }] - } - // ... - } -}); +```c++ +M5.Lcd.fillScreen(RED); +delay(500); +M5.Lcd.fillScreen(WHITE); +delay(500); ``` * * * -### registerAction -> StyleDictionary.registerAction(action) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Adds a custom action to the style property builder. Custom -actions can do whatever you need, such as: copying files, -base64'ing files, running other build scripts, etc. -After you register a custom action, you then use that -action in a platform your config.json - -Actions run after the files in a platform are generated so you -can perform operations on files generated by the style dictionary. -Actions are run sequentially, if you write synchronous code then -it will block other actions, or if you use asynchronous code like Promises -it will not block. +### fillRect +> M5.Lcd.fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); +Draw a filled rectangle. | Param | Type | Description | | --- | --- | --- | -| action | Object | | -| action.name | String | The name of the action | -| action.do | function | The action in the form of a function. | -| [action.undo] | function | A function that undoes the action. | +| x, y | int16_t | offset of x, y direction | +| w, h | int16_t | width and height of graphics | +| color | uint16_t | color to fill | **Example** -```js -StyleDictionary.registerAction({ - name: 'copy_assets', - do: function(dictionary, config) { - console.log('Copying assets directory'); - fs.copySync('assets', config.buildPath + 'assets'); - }, - undo: function(dictionary, config) { - console.log('Cleaning assets directory'); - fs.removeSync(config.buildPath + 'assets'); - } -}); +```c++ +M5.Lcd.fillRect(50,50,60,150,WHITE); ``` * * * -### registerFormat -> StyleDictionary.registerFormat(format) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Add a custom format to the style dictionary +### fillRoundRect +> M5.Lcd.fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); +Draw a filled round rectangle. | Param | Type | Description | | --- | --- | --- | -| format | Object | | -| format.name | String | Name of the format to be referenced in your config.json | -| format.formatter | function | Function to perform the format. Takes 2 arguments, `dictionary` and `config` Must return a string. | +| x, y | int16_t | offset of x, y direction | +| w, h | int16_t | width and height of graphics | +| radius | int16_t | fillet radius | +| color | uint16_t | color to fill | **Example** -```js -StyleDictionary.registerFormat({ - name: 'json', - formatter: function(dictionary, config) { - return JSON.stringify(dictionary.properties, null, 2); - } -}) +```c++ +M5.Lcd.fillRoundRect(50,50,60,150,4,WHITE); ``` -* * * - -### registerTemplate -> StyleDictionary.registerTemplate(template) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Add a custom template to the Style Dictionary - - -| Param | Type | Description | -| --- | --- | --- | -| template | Object | | -| template.name | String | The name of your template. You will refer to this in your config.json file. | -| template.template | String | Path to your lodash template | - -**Example** -```js -StyleDictionary.registerTemplate({ - name: 'Swift/colors', - template: __dirname + '/templates/swift/colors.template' -}); -``` - -* * * - -### registerTransform -> StyleDictionary.registerTransform(transform) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Add a custom transform to the Style Dictionary -Transforms can manipulate a property's name, value, or attributes - - -| Param | Type | Description | -| --- | --- | --- | -| transform | Object | Transform object | -| transform.type | String | Type of transform, can be: name, attribute, or value | -| transform.name | String | Name of the transformer so a transformGroup can call a list of transforms. | -| [transform.matcher] | function | Matcher function, return boolean if transform should be applied. If you omit the matcher function, it will match all properties. | -| transform.transformer | function | Performs a transform on a property object, should return a string or object depending on the type. Will only update certain properties so you can't mess up property objects on accident. | - -**Example** -```js -StyleDictionary.registerTransform({ - name: 'time/seconds', - type: 'value', - matcher: function(prop) { - return prop.attributes.category === 'time'; - }, - transformer: function(prop) { - // Note the use of prop.original.value, - // before any transforms are performed, the build system - // clones the original property to the 'original' attribute. - return (parseInt(prop.original.value) / 1000).toString() + 's'; - } -}); -``` - -* * * - -### registerTransformGroup -> StyleDictionary.registerTransformGroup(transformGroup) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Add a custom transformGroup to the Style Dictionary, which is a -group of transforms. - - -| Param | Type | Description | -| --- | --- | --- | -| transformGroup | Object | | -| transformGroup.name | String | Name of the transform group that will be referenced in config.json | -| transformGroup.transforms | Array.<String> | Array of strings that reference the name of transforms to be applied in order. Transforms must be defined and match the name or there will be an error at build time. | - -**Example** -```js -StyleDictionary.registerTransformGroup({ - name: 'Swift', - transforms: [ - 'attribute/cti', - 'size/pt', - 'name/cti' - ] -}); -``` - -* * * +* * * \ No newline at end of file diff --git a/docs/en/api_reference/api_speaker.md b/docs/en/api_reference/api_speaker.md new file mode 100644 index 00000000..8936220a --- /dev/null +++ b/docs/en/api_reference/api_speaker.md @@ -0,0 +1,15 @@ +# Speaker + +### tone +> M5.Speaker.tone(uint32_t freq); + +Set the pitch of speaker. + +| Param | Type | Description | +| --- | --- | --- | +| freq | uint32_t | frequency | + +**Example** +```c++ +M5.Speaker.tone(100); +``` \ No newline at end of file diff --git a/docs/en/api_reference/peripherals/api_gpio.md b/docs/en/api_reference/peripherals/api_gpio.md new file mode 100644 index 00000000..76abbad3 --- /dev/null +++ b/docs/en/api_reference/peripherals/api_gpio.md @@ -0,0 +1,21 @@ +# GPIO + +*Refer to GPIO API of [Arduino](http://www.arduino.cc)* + +### digitalRead +> uint32 digitalRead(uint8 pin); + +Read the value of `pin` + +| Param | Type | Description | +| --- | --- | --- | +| pin | uint8 | the number of pin | + +Return: + digital level(0/1) + +**Example** +```c++ +uint32_t pin21_data; +pin21_data = digitalRead(21); +``` \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 29e89e52..e387668b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,13 +7,13 @@ **Welcome to M5Stack Documents!** -?> **Tip** The underline words designate `more info` links leading to advanced sections about the described task. +?> The underline words designate `more info` links leading to advanced sections about the described task. -## Introduction + \ No newline at end of file diff --git a/docs/ja/README.md b/docs/ja/README.md index 7320a0bc..8521d0f2 100644 --- a/docs/ja/README.md +++ b/docs/ja/README.md @@ -11,7 +11,7 @@ Screenshot of coverpage --> -## 製品紹介 + diff --git a/docs/ja/api_reference.md b/docs/ja/api_reference.md index ebd30e4a..b4dba569 100644 --- a/docs/ja/api_reference.md +++ b/docs/ja/api_reference.md @@ -2,4 +2,7 @@ [中文](/zh_CN/api_reference) | [English](/en/api_reference) | 日本語 -- [LCD](ja/api_reference/api_lcd) \ No newline at end of file +## [LCD](ja/api_reference/api_lcd) +## [Peripherals](ja/api_reference/peripherals/api_gpio) +### 1. [GPIO](ja/api_reference/peripherals/api_gpio) +## [Speaker](ja/api_reference/api_speaker) \ No newline at end of file diff --git a/docs/ja/api_reference/api_lcd.md b/docs/ja/api_reference/api_lcd.md index d94e2554..dd9f15c7 100644 --- a/docs/ja/api_reference/api_lcd.md +++ b/docs/ja/api_reference/api_lcd.md @@ -1,272 +1,73 @@ # LCD - \ No newline at end of file +* * * \ No newline at end of file diff --git a/docs/ja/api_reference/api_speaker.md b/docs/ja/api_reference/api_speaker.md new file mode 100644 index 00000000..8936220a --- /dev/null +++ b/docs/ja/api_reference/api_speaker.md @@ -0,0 +1,15 @@ +# Speaker + +### tone +> M5.Speaker.tone(uint32_t freq); + +Set the pitch of speaker. + +| Param | Type | Description | +| --- | --- | --- | +| freq | uint32_t | frequency | + +**Example** +```c++ +M5.Speaker.tone(100); +``` \ No newline at end of file diff --git a/docs/ja/api_reference/peripherals/api_gpio.md b/docs/ja/api_reference/peripherals/api_gpio.md new file mode 100644 index 00000000..76abbad3 --- /dev/null +++ b/docs/ja/api_reference/peripherals/api_gpio.md @@ -0,0 +1,21 @@ +# GPIO + +*Refer to GPIO API of [Arduino](http://www.arduino.cc)* + +### digitalRead +> uint32 digitalRead(uint8 pin); + +Read the value of `pin` + +| Param | Type | Description | +| --- | --- | --- | +| pin | uint8 | the number of pin | + +Return: + digital level(0/1) + +**Example** +```c++ +uint32_t pin21_data; +pin21_data = digitalRead(21); +``` \ No newline at end of file diff --git a/docs/ja/sidebar.md b/docs/ja/sidebar.md index 88d332ee..d62485b1 100644 --- a/docs/ja/sidebar.md +++ b/docs/ja/sidebar.md @@ -1,5 +1,5 @@ - [製品ドキュメント](ja/product_documents) -- [クイックスタート](ja/quick_start) + - [API リファレンス](ja/api_reference) - [M5Stack アプリケーション](ja/m5stack_cases) - [その他のドキュメント](ja/related_documents) diff --git a/docs/sidebar.md b/docs/sidebar.md index 36d729a8..0f415d71 100644 --- a/docs/sidebar.md +++ b/docs/sidebar.md @@ -1,5 +1,5 @@ - [Product Documents](en/product_documents) -- [Quick Start](en/quick_start) + - [API Reference](en/api_reference) - [M5Stack Cases](en/m5stack_cases) - [Related Documents](en/related_documents) diff --git a/docs/zh_CN/README.md b/docs/zh_CN/README.md index 60a5fb5c..9724aec2 100644 --- a/docs/zh_CN/README.md +++ b/docs/zh_CN/README.md @@ -1,19 +1,19 @@ # M5Stack -**Welcome to M5Stack Documents!** - [![Codacy grade](https://img.shields.io/codacy/grade/860d40719cbd4e0f91e145b87ec7c29a.svg?style=flat-square)](https://www.codacy.com/app/watson8544/M5Stack-Documentation-docsify?utm_source=github.com&utm_medium=referral&utm_content=watson8544/M5Stack-Documentation-docsify&utm_campaign=Badge_Grade) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://github.com/watson8544/M5Stack-Documentation-docsify/blob/master/LICENSE) [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2Fjhildenbiddle%2Fdocsify-themeable&hashtags=css,docsify,developers,frontend) Star -?> **提示** 点击下划线的蓝色字体可以跳转到对应链接。 +**欢迎阅读M5Stack文档!** + +?> 点击下划线的蓝色字体可以跳转到对应链接。 -## 介绍(Introduction) + -## 联系方式(Contact & Support) +## 联系方式 - :computer: 访问[官网](http://www.m5stack.com)了解最新的产品 - :busts_in_silhouette: 登录我们的[论坛](http://forum.m5stack.com)了解更多基于M5产品的创意设计 - :mailbox_with_mail: 如果你有对产品有任何疑问或有更好的建议,请联系我们的[邮箱](tech@m5stack.com) - :convenience_store: 如果你想继续购买我们的产品,请访问我们的[官方旗舰店](http://www.aliexpress.com/store/all-wholesale-products/3226069.html?spm=2114.12010108.100004.3.7e3a5379KoyhDo) -## License + diff --git a/docs/zh_CN/api_reference.md b/docs/zh_CN/api_reference.md index 3e9361ea..a0655df4 100644 --- a/docs/zh_CN/api_reference.md +++ b/docs/zh_CN/api_reference.md @@ -2,4 +2,7 @@ 中文 | [English](/en/api_reference) | [日本語](/ja/api_reference) -- [LCD](zh_CN/api_reference/api_lcd) \ No newline at end of file +## [LCD](zh_CN/api_reference/api_lcd) +## [Peripherals](zh_CN/api_reference/peripherals/api_gpio) +### 1. [GPIO](zh_CN/api_reference/peripherals/api_gpio) +## [Speaker](zh_CN/api_reference/api_speaker) diff --git a/docs/zh_CN/api_reference/api_lcd.md b/docs/zh_CN/api_reference/api_lcd.md index 61c77c4e..a186603a 100644 --- a/docs/zh_CN/api_reference/api_lcd.md +++ b/docs/zh_CN/api_reference/api_lcd.md @@ -1,287 +1,73 @@ # LCD -### buildAllPlatforms -> StyleDictionary.buildAllPlatforms() ⇒ [style-dictionary](#module_style-dictionary) - - - - -The only top-level method that needs to be called -to build the Style Dictionary. - -**Example** -```js -const StyleDictionary = require('style-dictionary').extend('config.json'); -StyleDictionary.buildAllPlatforms(); -``` - -* * * - -### buildPlatform -> StyleDictionary.buildPlatform(platform) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Takes a platform and performs all transforms to -the properties object (non-mutative) then -builds all the files and performs any actions. This is useful if you only want to -build the artifacts of one platform to speed up the build process. - -This method is also used internally in [buildAllPlatforms](#buildAllPlatforms) to -build each platform defined in the config. +### setbrightness +> M5.Lcd.setbrightness(uint8_t brightness); +设置LCD屏幕的亮度 | Param | Type | Description | | --- | --- | --- | -| platform | String | Name of the platform you want to build. | +| brightness | uint8_t | 亮度值(0-254) | -**Example** -```js -StyleDictionary.buildPlatform('web'); -``` -```bash -$ style-dictionary build --platform web +**例程** +```c++ +M5.Lcd.setbrightness(100); ``` * * * -### cleanAllPlatforms -> StyleDictionary.cleanAllPlatforms() ⇒ [style-dictionary](#module_style-dictionary) - - - - -Does the reverse of [buildAllPlatforms](#buildAllPlatforms) by -performing a clean on each platform. This removes all the files -defined in the platform and calls the undo method on any actions. - - -* * * - -### cleanPlatform -> StyleDictionary.cleanPlatform(platform) ⇒ [style-dictionary](#module_style-dictionary) - -Takes a platform and performs all transforms to -the properties object (non-mutative) then -cleans all the files and perfoms the undo method of any [actions](actions). - - -| Param | Type | -| --- | --- | -| platform | String | - - -* * * - -### exportPlatform -> StyleDictionary.exportPlatform(platform) ⇒ Object - -Exports a properties object with applied -platform transforms. - -This is useful if you want to use a style -dictionary in JS build tools like webpack. +### fillScreen +> M5.Lcd.fillScreen(uint16_t color); +设置全屏颜色 | Param | Type | Description | | --- | --- | --- | -| platform | String | The platform to be exported. Must be defined on the style dictionary. | +| color | uint16_t | 颜色值 | - -* * * - -### extend -> StyleDictionary.extend(config) ⇒ [style-dictionary](#module_style-dictionary) - - -Create a Style Dictionary - - -| Param | Type | Description | -| --- | --- | --- | -| config | [Config](#Config) | Configuration options to build your style dictionary. If you pass a string, it will be used as a path to a JSON config file. You can also pass an object with the configuration. | - -**Example** -```js -const StyleDictionary = require('style-dictionary').extend('config.json'); - -const StyleDictionary = require('style-dictionary').extend({ - source: ['properties/*.json'], - platforms: { - scss: { - transformGroup: 'scss', - buildPath: 'build/', - files: [{ - destination: 'variables.scss', - format: 'scss/variables' - }] - } - // ... - } -}); +**例程** +```c++ +M5.Lcd.fillScreen(RED); +delay(500); +M5.Lcd.fillScreen(WHITE); +delay(500); ``` * * * -### registerAction -> StyleDictionary.registerAction(action) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Adds a custom action to the style property builder. Custom -actions can do whatever you need, such as: copying files, -base64'ing files, running other build scripts, etc. -After you register a custom action, you then use that -action in a platform your config.json - -Actions run after the files in a platform are generated so you -can perform operations on files generated by the style dictionary. -Actions are run sequentially, if you write synchronous code then -it will block other actions, or if you use asynchronous code like Promises -it will not block. +### fillRect +> M5.Lcd.fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); +画填充形式的矩形图形 | Param | Type | Description | | --- | --- | --- | -| action | Object | | -| action.name | String | The name of the action | -| action.do | function | The action in the form of a function. | -| [action.undo] | function | A function that undoes the action. | +| x, y | int16_t | x和y方向的偏移量 | +| w, h | int16_t | 图形宽和高 | +| color | uint16_t | 填充的颜色 | -**Example** -```js -StyleDictionary.registerAction({ - name: 'copy_assets', - do: function(dictionary, config) { - console.log('Copying assets directory'); - fs.copySync('assets', config.buildPath + 'assets'); - }, - undo: function(dictionary, config) { - console.log('Cleaning assets directory'); - fs.removeSync(config.buildPath + 'assets'); - } -}); +**例程** +```c++ +M5.Lcd.fillRect(50,50,60,150,WHITE); ``` * * * -### registerFormat -> StyleDictionary.registerFormat(format) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Add a custom format to the style dictionary +### fillRoundRect +> M5.Lcd.fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); +画填充形式的圆角矩形图形 | Param | Type | Description | | --- | --- | --- | -| format | Object | | -| format.name | String | Name of the format to be referenced in your config.json | -| format.formatter | function | Function to perform the format. Takes 2 arguments, `dictionary` and `config` Must return a string. | +| x, y | int16_t | x和y方向的偏移量 | +| w, h | int16_t | 图形宽和高 | +| radius | int16_t | 圆角半径 | +| color | uint16_t | 填充的颜色 | -**Example** -```js -StyleDictionary.registerFormat({ - name: 'json', - formatter: function(dictionary, config) { - return JSON.stringify(dictionary.properties, null, 2); - } -}) +**例程** +```c++ +M5.Lcd.fillRoundRect(50,50,60,150,4,WHITE); ``` -* * * - -### registerTemplate -> StyleDictionary.registerTemplate(template) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Add a custom template to the Style Dictionary - - -| Param | Type | Description | -| --- | --- | --- | -| template | Object | | -| template.name | String | The name of your template. You will refer to this in your config.json file. | -| template.template | String | Path to your lodash template | - -**Example** -```js -StyleDictionary.registerTemplate({ - name: 'Swift/colors', - template: __dirname + '/templates/swift/colors.template' -}); -``` - -* * * - -### registerTransform -> StyleDictionary.registerTransform(transform) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Add a custom transform to the Style Dictionary -Transforms can manipulate a property's name, value, or attributes - - -| Param | Type | Description | -| --- | --- | --- | -| transform | Object | Transform object | -| transform.type | String | Type of transform, can be: name, attribute, or value | -| transform.name | String | Name of the transformer so a transformGroup can call a list of transforms. | -| [transform.matcher] | function | Matcher function, return boolean if transform should be applied. If you omit the matcher function, it will match all properties. | -| transform.transformer | function | Performs a transform on a property object, should return a string or object depending on the type. Will only update certain properties so you can't mess up property objects on accident. | - -**Example** -```js -StyleDictionary.registerTransform({ - name: 'time/seconds', - type: 'value', - matcher: function(prop) { - return prop.attributes.category === 'time'; - }, - transformer: function(prop) { - // Note the use of prop.original.value, - // before any transforms are performed, the build system - // clones the original property to the 'original' attribute. - return (parseInt(prop.original.value) / 1000).toString() + 's'; - } -}); -``` - -* * * - -### registerTransformGroup -> StyleDictionary.registerTransformGroup(transformGroup) ⇒ [style-dictionary](#module_style-dictionary) - - - - -Add a custom transformGroup to the Style Dictionary, which is a -group of transforms. - - -| Param | Type | Description | -| --- | --- | --- | -| transformGroup | Object | | -| transformGroup.name | String | Name of the transform group that will be referenced in config.json | -| transformGroup.transforms | Array.<String> | Array of strings that reference the name of transforms to be applied in order. Transforms must be defined and match the name or there will be an error at build time. | - -**Example** -```js -StyleDictionary.registerTransformGroup({ - name: 'Swift', - transforms: [ - 'attribute/cti', - 'size/pt', - 'name/cti' - ] -}); -``` - -* * * +* * * \ No newline at end of file diff --git a/docs/zh_CN/api_reference/api_speaker.md b/docs/zh_CN/api_reference/api_speaker.md new file mode 100644 index 00000000..0aea5190 --- /dev/null +++ b/docs/zh_CN/api_reference/api_speaker.md @@ -0,0 +1,15 @@ +# Speaker + +### tone +> M5.Speaker.tone(uint32_t freq); + +设置声音音高 + +| Param | Type | Description | +| --- | --- | --- | +| freq | uint32_t | 频率 | + +**例程** +```c++ +M5.Speaker.tone(100); +``` \ No newline at end of file diff --git a/docs/zh_CN/api_reference/peripherals/api_gpio.md b/docs/zh_CN/api_reference/peripherals/api_gpio.md new file mode 100644 index 00000000..98112db5 --- /dev/null +++ b/docs/zh_CN/api_reference/peripherals/api_gpio.md @@ -0,0 +1,21 @@ +# GPIO + +*使用Arduino库的GPIO API* + +### digitalRead +> uint32 digitalRead(uint8 pin); + +读取数字引脚电平值 + +| Param | Type | Description | +| --- | --- | --- | +| pin | uint8 | 引脚编号 | + +Return: + 电平值(0/1) + +**例程** +```c++ +uint32_t pin21_data; +pin21_data = digitalRead(21); +``` \ No newline at end of file diff --git a/docs/zh_CN/sidebar.md b/docs/zh_CN/sidebar.md index 030a0f9f..d7d3175d 100644 --- a/docs/zh_CN/sidebar.md +++ b/docs/zh_CN/sidebar.md @@ -1,5 +1,5 @@ - [产品介绍](zh_CN/product_documents) -- [快速上手](zh_CN/quick_start) + - [API参考](zh_CN/api_reference) - [M5Stack案例](zh_CN/m5stack_cases) - [相关文档](zh_CN/related_documents)