Files

165 lines
5.0 KiB
Markdown
Raw Permalink Normal View History

2020-03-19 21:06:45 +08:00
# Module ENCODER
2019-01-04 19:42:55 +08:00
<el-tag effect="plain">SKU:A006</el-tag>
2020-03-19 10:58:07 +08:00
2020-04-08 14:09:44 +08:00
<div class="product_pic"><img src="assets/img/product_pics/module/module_encoder_01.webp"><img src="assets/img/product_pics/module/module_encoder_02.webp"></div>
2019-01-04 19:42:55 +08:00
## Description
2021-01-04 13:23:37 +08:00
**ENCODER** is compatible with FACE Kit. You can have it replace the key-card panel inside the FACE kit. It is designed for rotary encoder control, integrated Mega328 microprocessor inside and LEDs around the encoder.
2019-01-04 19:42:55 +08:00
2021-01-29 14:47:53 +08:00
The series communication protocol between M5 core and ENCODER is I2C (The default I2c address is: 0x5E)
2019-01-04 19:42:55 +08:00
2020-04-08 14:09:44 +08:00
<img src="assets/img/product_pics/module/module_encoder_03.webp" width="60%" height="60%">
2019-01-04 19:42:55 +08:00
2019-04-26 18:10:14 +08:00
## Product Features
2019-01-04 19:42:55 +08:00
- 12 RGB Led
2021-01-29 14:47:53 +08:00
- I2C communication
2019-01-04 19:42:55 +08:00
- Simple API for programming
2019-04-26 11:18:55 +08:00
- Mega328 inside
- Encoder detection
2020-05-29 16:36:24 +08:00
2020-06-18 09:30:41 +08:00
## Include
- 1x M5Stack ENCODER Module
2020-05-29 16:36:24 +08:00
## Specification
<table>
<tr style="font-weight:bold">
<td>Resources</td>
<td>Parameter</td>
</tr>
<tr>
<td>RGB LED</td>
<td>x12</td>
</tr>
<tr>
2020-11-18 19:00:45 +08:00
<td>Net weight</td>
2020-05-29 16:36:24 +08:00
<td>27g</td>
</tr>
<tr>
<td>Gross weight</td>
<td>47g</td>
</tr>
<tr>
<td>Product Size</td>
<td>58.2*54.2*28mm</td>
</tr>
<tr>
<td>Package Size</td>
<td>95*65*25mm</td>
</tr>
<tr>
<td>Material</td>
<td>Plastic(PC)</td>
</tr>
</table>
2019-01-04 19:42:55 +08:00
2019-06-14 17:49:23 +08:00
## EasyLoader
>EasyLoader is a concise and fast program writer, which has a built-in case program related to the product. It can be burned to the main control by simple steps to perform a series of function verification. Please install the corresponding driver according to the device type. M5Core host [Please click here to view the CP210X driver installation tutorial](en/arduino/arduino_development), M5StickC/V/T/ATOM series can be used without driver)
2019-06-14 17:49:23 +08:00
<div class="easyloader-box">
<div style="background-color:white;">
2020-04-08 14:09:44 +08:00
<div><img src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/image/easyloader_intro.webp"></div>
<div class="easyloader-btn">
<a href="https://m5stack.oss-cn-shenzhen.aliyuncs.com/EasyLoader/Windows/MODULE/EasyLoader_FACES_Encoder.exe">Windows</a>
2020-04-09 11:28:01 +08:00
<a href="https://m5stack.oss-cn-shenzhen.aliyuncs.com/EasyLoader/MacOS/MODULE/EasyLoader_FACES_Encoder_0x1000.dmg">MacOS</a>
<!-- <a>Linux</a>
<a>MacOS</a> -->
</div>
</div>
<div>
<video id="example_video" controls>
<source src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/video/Product_example_video/Module/FACES_ENCODER.mp4" type="video/mp4">
</video>
<div class="easyloader-mask">
<a>
<svg id="play-btn" t="1583228776634" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4152" width="75" height="75"><path d="M512 0C229.216 0 0 229.216 0 512s229.216 512 512 512 512-229.216 512-512S794.784 0 512 0z m0 928C282.24 928 96 741.76 96 512S282.24 96 512 96s416 186.24 416 416-186.24 416-416 416zM384 288l384 224-384 224z" p-id="4153" fill="#007aff"></path></svg></a>
<p>Description:</p>
<p>Display encoder count and button status, left turn decrease right turn increase.</p>
</div>
</div>
</div>
2019-01-04 19:42:55 +08:00
## Function
**Control single RGB**
2021-02-26 17:27:20 +08:00
```clike
2019-01-04 19:42:55 +08:00
/*
Parameter:
led_index: 0 ~ 11
r, g, b: 0 ~ 254
*/
void Led(int led_index, int r, int g, int b){
2021-01-29 14:47:53 +08:00
// I2C send data
2019-01-04 19:42:55 +08:00
Wire.beginTransmission(Faces_Encoder_I2C_ADDR);
Wire.write(led_index);
Wire.write(r);
Wire.write(g);
Wire.write(b);
Wire.endTransmission();
}
```
**Read encoder increment**
2021-02-26 17:27:20 +08:00
```clike
2019-01-04 19:42:55 +08:00
void get_encoder_increment(void){
int temp_encoder_increment;
2021-01-29 14:47:53 +08:00
// I2C read data
2019-01-04 19:42:55 +08:00
Wire.requestFrom(Faces_Encoder_I2C_ADDR, 3);
if(Wire.available()){
temp_encoder_increment = Wire.read();// get increment
button_state = Wire.read();// get button value
}
if(temp_encoder_increment > 127){//anti-clockwise
direction = 1;// flag for encoder direction
encoder_increment = 256 - temp_encoder_increment;
}
else{// clockwise
direction = 0;
encoder_increment = temp_encoder_increment;
}
}
```
## Related Link
- **[The Firmware of inside MEGA328](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Module/ENCODER/firmware_328p/FacesEncoder328)**
## PinMap
2019-01-04 19:42:55 +08:00
**Mega328 ISP**Download interface Pin foot definition
2019-06-06 20:01:45 +08:00
2020-04-08 14:09:44 +08:00
<img src="assets\img\product_pics\app\mega328_isp.webp" width="30%" height="30%">
2019-06-06 20:01:45 +08:00
2019-06-11 19:20:48 +08:00
## Example
2019-06-06 20:01:45 +08:00
2020-04-24 21:10:31 +08:00
### 1. Arduino IDE
2019-01-04 19:42:55 +08:00
2020-04-30 14:13:25 +08:00
If you want the complete code `faces_encoder.ino`, please click [here](https://github.com/m5stack/M5Stack/tree/master/examples/Face/ENCODER)
2019-01-04 19:42:55 +08:00
2020-04-08 14:09:44 +08:00
<img src="assets/img/product_pics/module/module_example/ENCODER/example_faces_encoder_01.webp" width="55%" height="55%">
2019-01-04 19:42:55 +08:00
2020-04-24 21:10:31 +08:00
### 2. UIFlow
2019-01-04 19:42:55 +08:00
2020-04-08 14:09:44 +08:00
<img src="assets/img/product_pics/module/module_example/ENCODER/encoder.webp" >
2020-02-11 18:00:45 +08:00
2021-01-04 13:23:37 +08:00
<el-divider content-position="right">Last updated: 2020-12-24</el-divider>
2020-02-11 18:00:45 +08:00
<script>
var purchase_link = 'https://m5stack.com/collections/m5-module/products/encoder-module';
anchor_search(purchase_link);
scrollFunc();
2021-01-04 13:23:37 +08:00
</script>