add uiflow examples for some uinits

This commit is contained in:
LiHuashen
2018-12-27 13:40:13 +08:00
parent 38fb489e10
commit 88e3065d32
16 changed files with 46 additions and 24 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 17 KiB

+1 -1
View File
@@ -68,7 +68,7 @@ void loop() {
}
```
烧录`GPSRaw.ino`之后,屏幕和串口显示终端会打印如下类似的信息
烧录例程`GPSRaw.ino`之后,屏幕和串口显示终端会打印如下类似的信息
```
$GPGSA,A,1,,,,,,,,,,,,,25.5,25.5,25.5*02
+1 -2
View File
@@ -37,14 +37,13 @@ M5Stack LoRa模块适用于长距离通信,结合多个LoRa模块,能组成
- **[LoRa模块信息](http://wiki.ai-thinker.com/lora) (LoRa)**
?> **Note** 如果堆叠了LoRa模块之后,上电,可是M5Core不能正常显示或者有其他显示问题时,建议在`m5.begin();`语句之前加入如下语句
?> 如果堆叠了LoRa模块之后,上电,可是M5Core不能正常显示或者有其他显示问题时,建议在`m5.begin();`语句之前加入如下语句。因为GPIO5连接到LoRa模块的NSS引脚,该引脚在系统上电的时候需要上拉,从而避免LCD不能显示。
```arduino
pinMode(5,OUTPUT);
digitalWrite(5,HIGH);
m5.begin();
```
?> **Note** 因为GPIO5连接到LoRa模块的NSS引脚,该引脚在系统上电的时候需要上拉,从而避免LCD不能显示。
## 例程
+6 -5
View File
@@ -37,7 +37,7 @@ Color是一个颜色传感器. 通过GROVE接口(I2C)与M5Core相连,能够识
/*
Color test
hardware: M5Stack
please install the Adfruit TCS34725 library first ...
*/
@@ -58,7 +58,8 @@ static uint16_t color16(uint16_t r, uint16_t g, uint16_t b) {
return _color;
}
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS,TCS34725_GAIN_4X);
Adafruit_TCS34725 tcs;
tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS,TCS34725_GAIN_4X);
void setup() {
delay(100);
@@ -80,8 +81,8 @@ void setup() {
void loop() {
uint16_t clear, red, green, blue;
delay(60); // takes 50ms to read
delay(60); // takes 50ms to read
tcs.getRawData(&red, &green, &blue, &clear);
Serial.print("C:\t"); Serial.print(clear);
@@ -97,7 +98,7 @@ void loop() {
b = blue; b /= sum;
r *= 256; g *= 256; b *= 256;
Serial.print("\t");
Serial.print((int)r, HEX); Serial.print((int)g, HEX); Serial.println((int)b, HEX);
Serial.print((int)r,HEX); Serial.print((int)g,HEX); Serial.println((int)b,HEX);
uint16_t _color = color16((int)r, (int)g, (int)b);
M5.Lcd.clear(_color);
}
+25 -7
View File
@@ -7,7 +7,7 @@
:memo:**[描述](#描述)**      :octocat:**[例程](#例程)**      🛒**[购买链接](https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-1172588106.13.51a6425e6lnUwE&id=583664452054)**
<!-- :electric_plug:**[原理图](#原理图)** |:octocat:**[例程](#例程)**| -->
<!-- :memo:**[描述](#描述)**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:octocat:**[例程](#例程)**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:electric_plug:**[原理图](#原理图)**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;🛒**[购买链接](https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-1172588106.13.51a6425e6lnUwE&id=583664452054)** -->
## 描述
@@ -45,15 +45,33 @@
### 1. Arduino IDE
```arduino
GPSRaw.begin(9600);
#include <M5Stack.h>
if(GPSRaw.available()) {
int ch = GPSRaw.read();
/* By default, GPS is connected with M5Core through UART2 */
HardwareSerial GPSRaw(2);
void setup() {
M5.begin();
GPSRaw.begin(9600);// GPS init
Serial.println("hello");
termInit();
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()) {
int ch = Serial.read();
GPSRaw.write(ch);
}
if(GPSRaw.available()) {
int ch = GPSRaw.read();// read GPS information
Serial.write(ch);
termPutchar(ch);
}
}
```
烧录[例程](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Module/GPS/Arduino)之后,屏幕和串口显示终端会打印如下类似的信息
烧录例程`GPSRaw.ino`之后,屏幕和串口显示终端会打印如下类似的信息
```
$GPGSA,A,1,,,,,,,,,,,,,25.5,25.5,25.5*02
@@ -75,6 +93,6 @@ $GPTXT,01,01,01,ANTENNA OPEN*25
### 管脚映射
<table>
<tr><td>M5Core(GROVE C)</td><td>GPIO16</td><td>GPIO17</td></tr><td>5V</td><td>GND</td></tr>
<tr><td>GPS Unit</td><td>TXD</td><td>RXD</td></tr><td>5V</td><td>GND</td></tr>
<tr><td>M5Core(GROVE接口C)</td><td>ESP32串口2接收引脚U2RXD(GPIO16)</td><td>ESP32串口2发送引脚U2TXD(GPIO17)</td><td>5V</td><td>GND</td></tr>
<tr><td>北斗导航Unit</td><td>信号发送引脚TXD</td><td>信号接收引脚RXD</td><td>5V</td><td>GND</td></tr>
</table>
+1 -1
View File
@@ -50,7 +50,7 @@ void loop() {
### 2. UIFlow
<img src="assets/img/product_pics/unit/unit_example/IR/example_unit_ir_01.png" width="50%" height="50%"> <img src="assets/img/product_pics/unit/unit_example/IR/example_unit_ir_02.png" width="30%" height="30%">
<img src="assets/img/product_pics/unit/unit_example/IR/example_unit_ir_01.png" width="30%" height="30%"> <img src="assets/img/product_pics/unit/unit_example/IR/example_unit_ir_02.png" width="50%" height="50%">
具体例程请点击[这里](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Unit/IR/UIFlow)。
+4 -4
View File
@@ -20,6 +20,7 @@ Joystick Unit同样也是与M5Core相连之后,通过PORT A(I2C)控制,其I2
## 特性
- X, Y方向的范围10~250, Z方向(0: 未按下, 1: 按下)
- GROVE接口,支持[UiFlow](http://flow.m5stack.com)编程,[Arduino](http://www.arduino.cc)编程
- Unit内置两个Lego插件孔,方便与Lego件结合
@@ -52,12 +53,11 @@ uint8_t y_data;
uint8_t button_data;
char data[100];
void loop() {
// put your main code here, to run repeatedly:
Wire.requestFrom(JOY_ADDR, 3);
if (Wire.available()) {
x_data = Wire.read();
y_data = Wire.read();
button_data = Wire.read();
x_data = Wire.read();// X(range: 10~250)
y_data = Wire.read();// Y(range: 10~250)
button_data = Wire.read();// Z(0: released 1: pressed)
sprintf(data, "x:%d y:%d button:%d\n", x_data, y_data, button_data);
Serial.print(data);
}
+4 -2
View File
@@ -10,6 +10,8 @@
<mark>LIGHT</mark>是一款光线传感器,内置光敏电阻和10K的可调电阻,可以通过调节可调电阻,从而改变触发信号的光强阈值。Unit的GRVE接口可以输出数字信号或者光强对应的模拟信号(电压信号)。
LIGHT在光强弱的时候,数字引脚输出高电平,即数字信号"1",否则输出"0"。
## 特性
- 10K可调电阻
@@ -44,14 +46,14 @@ uint16_t digitalRead_value = 0;
void loop() {
analogRead_value = analogRead(36);// read analog value of LIGHT
digitalRead_value = digitalRead(26);// read digital value of LIGHT
digitalRead_value = digitalRead(26);
delay(10);
}
```
### 2. UIFlow
<img src="assets/img/product_pics/unit/unit_example/LIGHT/example_unit_light_01.png" width="30%" height="30%"> <img src="assets/img/product_pics/unit/unit_example/LIGHT/example_unit_light_02.png" width="69%" height="69%">
<img src="assets/img/product_pics/unit/unit_example/LIGHT/example_unit_light_01.png" width="28%" height="28%"> <img src="assets/img/product_pics/unit/unit_example/LIGHT/example_unit_light_02.png" width="69%" height="69%">
具体例程请点击[这里](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Unit/LIGHT/UIFlow)。
+4 -2
View File
@@ -10,6 +10,8 @@
<mark>PIR</mark>是一款感应人体(生物)红外信号的Unit,通过该Unit可以感知Unit前面是否有人经过,适用于做人体感应方面的项目。
如果PIR感应到红外变动,信号引脚会输出高电平,否则一直处于低电平状态。
## 特性
- 检测距离:150cm
@@ -37,14 +39,14 @@ void setup() {
}
void loop() {
int value = digitalRead(36);// read the pin
int value = digitalRead(36);// read the pin(0: not detectd 1: detected)
M5.update();
}
```
### 2. UIFlow
<img src="assets/img/product_pics/unit/unit_example/PIR/example_unit_pir_01.png" width="30%" height="30%"> <img src="assets/img/product_pics/unit/unit_example/PIR/example_unit_pir_02.png" width="68%" height="68%">
<img src="assets/img/product_pics/unit/unit_example/PIR/example_unit_pir_01.png" width="30%" height="30%"> <img src="assets/img/product_pics/unit/unit_example/PIR/example_unit_pir_02.png" width="65%" height="65%">
具体例程请点击[这里](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Unit/PIR/UIFlow)。