Skip to content

Commit

Permalink
Station 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyu-Zhao committed Aug 8, 2022
1 parent c3e294b commit 9109992
Show file tree
Hide file tree
Showing 115 changed files with 62,663 additions and 25 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ jobs:
matrix:
path:
- check: './' # path to include
exclude: '' # path to exclude
# - check: 'src'
# exclude: ''
# - check: 'examples'
# exclude: ''
exclude: '(Fonts|utility)' # path to exclude
steps:
- uses: actions/checkout@v2
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.5.0
uses: jidicula/clang-format-action@v4.8.0
with:
clang-format-version: '13'
check-path: ${{ matrix.path['check'] }}
Expand Down
43 changes: 24 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
# M5Template-C-CPP
# M5Station Library

### SKU:xxx
English | [中文](README_cn.md)

Template for M5Stack C and CPP projects.
<img src="https://static-cdn.m5stack.com/resource/docs/products/core/station_bat/station_bat_01.webp" alt="M5Station_P1" width="350" height="350">
<img src="https://static-cdn.m5stack.com/resource/docs/products/core/station_485/station_485_01.webp" alt="M5Station_P1" width="350" height="350">

## Steps
**For the Detailed documentation of M5Station BAT, Please [Click here](https://docs.m5stack.com/en/core/station_bat)**

1. Change [clang format check path](./.github/workflows/clang-format-check.yml#L9-L15).
2. Add License content to [LICENSE](/LICENSE).
3. Change this [README.md](./README.md#L1-L8).
4. Change link on line 78 of [bug-report.yml](./.github/ISSUE_TEMPLATE/bug-report.yml#L78).
**For the Detailed documentation of M5Station 485, Please [Click here](https://docs.m5stack.com/en/core/station_485)**

<!-- Example
# M5Unit-ENV
**In order to buy M5Station 485, Please [Click here](https://shop.m5stack.com/products/m5stack-station-esp32-iot-development-kit-rs485-version)**

## Overview
## Description

### SKU:U001 & U001-B & U001-C
**M5Station** is a multi-purpose `industrial level` programmable embedded controller with Espressif `ESP32` SOC, integrated `Wi-Fi` and 'BT' solution, dual core low-power `Xtensa® 32-bit LX6` microprocessor, main frequency up to `240MHz`. Onboard `16M FLASH`, integrated `240*135 1.14" full colour HD IPS display` + `physical keypad` + `rich peripherals, two sets of six expansion ports`+ `Low-power sleep/wakeup function`+Integrated IMU `MPU6886`(BAT only). Supports two types of power supply `USB Type-C, internal rechargeable 18650 battery (BAT only)/RS485(485 only)`. The integrated high power density boost DC/DC converter SCT12A0DHKR on board ensures the `stability` of the electrical equipment even in complex applications. This device is suitable for industrial control, intelligent buildings, multi-channel data acquisition nodes and prototyping applications.

Contains M5Stack-**UNIT ENV** series related case programs.ENV is an environmental sensor with integrated SHT30 and QMP6988 internally to detect temperature, humidity, and atmospheric pressure data.

## Related Link
## Version differentiation

- [Document & Datasheet](https://docs.m5stack.com/en/unit/envIII)
| M5Station-485 | M5Station-BAT |
| ---------------------------- | ---------------------------------------------------------- |
| PWR485 (RS485 + power input) | MPU6886 on board, can carry two 18650 batteries (parallel) |

## Required Libraries:
- [Schematic PDF](https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/schematic/Core/M5Station_v1.2.pdf)

- [Adafruit_BMP280_Library](https://github.com/adafruit/Adafruit_BMP280_Library)

## License
<!-- ## More Information
- [M5Unit-ENV - MIT](LICENSE) -->
**UIFlow Quick Start**: [Click Here](https://docs.m5stack.com/en/quick_start/core2/uiflow)
**MicroPython API**: [Click Here](https://docs.m5stack.com/en/quick_start/core2/mpy)
**Arduino IDE Development**: [Click Here](https://docs.m5stack.com/en/quick_start/core2/arduino)
**M5Core2 Arduino API**: [Click Here](https://docs.m5stack.com/en/api/core2/axp192_core2)
**PinMap**: [Click Here](https://docs.m5stack.com/en/core/core2) -->
41 changes: 41 additions & 0 deletions README_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# M5Station Library

中文 | [English](README_cn.md)


<img src="https://static-cdn.m5stack.com/resource/docs/products/core/station_bat/station_bat_01.webp" alt="M5Station_P1" width="350" height="350">
<img src="https://static-cdn.m5stack.com/resource/docs/products/core/station_485/station_485_01.webp" alt="M5Station_P1" width="350" height="350">

**查看 M5Station BAT 的详细介绍文档, [点击这里](https://docs.m5stack.com/zh_CN/core/m5station_bat)**

**查看 M5Station 485 的详细介绍文档, [点击这里](https://docs.m5stack.com/zh_CN/core/m5station_485)**

**如果想要购买 M5Station 485, [点击这里](https://m.tb.cn/h.fzLB7RG?tk=1Ukd2HWjTqZ)**

## 描述

The integrated high power density boost DC/DC converter SCT12A0DHKR on board ensures the `stability` of the electrical equipment even in complex applications. This device is suitable for industrial control, intelligent buildings, multi-channel data acquisition nodes and prototyping applications.

**M5Station-485** 是一款多用途`工业级`可编程嵌入式控制器 ,采用乐鑫 `ESP32` 主控芯片, 集成 `Wi-Fi` 方案, 搭载双核低功耗 `Xtensa® 32-bit LX6` 微处理器, 主频高达 `240MHz`. 板载 `16M FLASH`, 集成 `240*135 1.14英寸全彩高清IPS显示面板` + `实体按键面板` + `丰富外设、两组六个拓展接口`+`低功耗休眠/定时唤醒`+内部集成IMU `MPU6886`(BAT only). 支持多种供电方式 `USB Type-C, PWR485, 内部可充电电池(BAT only)/RS485(485 only)`. 板载集成高功率密度的全集成升压DC/DC转换器SCT12A0DHKR, 即使是在复杂的应用场景也能够保障电气设备运行的 `稳定性`. 该控制器适用于工业现场控制、智能楼宇、多路数据采集节点以及开发者原型设计等应用场景.


## 版本区分

| M5Station-485 | M5Station-BAT |
| -------------------------- | -------------------------------------- |
| 搭载PWR485(RS485+电源输入) | 板载MPU6886、可搭载两节18650电池(并联) |

- [Schematic PDF](https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/schematic/Core/M5Station_v1.2.pdf)


<!-- ## More Information
**UIFlow Quick Start**: [Click Here](https://docs.m5stack.com/en/quick_start/core2/uiflow)
**MicroPython API**: [Click Here](https://docs.m5stack.com/en/quick_start/core2/mpy)
**Arduino IDE Development**: [Click Here](https://docs.m5stack.com/en/quick_start/core2/arduino)
**M5Core2 Arduino API**: [Click Here](https://docs.m5stack.com/en/api/core2/axp192_core2)
**PinMap**: [Click Here](https://docs.m5stack.com/en/core/core2) -->
43 changes: 43 additions & 0 deletions example/Basics/Button/Button.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
*******************************************************************************
* Copyright (c) 2022 by M5Stack
* Equipped with M5Station sample source code
* 配套 M5Station 示例源代码
* Visit for more information: https://docs.m5stack.com/en/core/station_485
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/core/station_485
*
* Describe: Button example. 按键示例
* Date: 2022/8/4
*******************************************************************************
Press button A/B/C to display the corresponding output on the screen and serial.
按下按键A/B/C,在屏幕和串口上显示相应输出
*/
#include <M5Station.h>
/* After M5Station is started or reset
the program in the setUp () function will be run, and this part will only be
run once. 在 M5Station
启动或者复位后,即会开始执行setup()函数中的程序,该部分只会执行一次。 */
void setup() {
M5.begin(); // Init M5Station. 初始化 M5Station
M5.Lcd.setCursor(80, 0);
M5.Lcd.setTextColor(ORANGE);
M5.Lcd.println("Pls press A/B/C");
}

/* After the program in setup() runs, it runs the program in loop()
The loop() function is an infinite loop in which the program runs repeatedly
在setup()函数中的程序执行完后,会接着执行loop()函数中的程序
loop()函数是一个死循环,其中的程序会不断的重复运行 */
void loop() {
M5.update(); // Read the press state of the key. 读取按键 A, B, C 的状态
if (M5.BtnA.wasReleased() || M5.BtnA.pressedFor(1000)) {
Serial.print('A');
M5.Lcd.print('A');
} else if (M5.BtnB.wasReleased() || M5.BtnB.pressedFor(1000)) {
Serial.print('B');
M5.Lcd.print('B');
} else if (M5.BtnC.wasReleased() || M5.BtnC.pressedFor(1000)) {
Serial.print('C');
M5.Lcd.print('C');
}
}
62 changes: 62 additions & 0 deletions example/Basics/Display/Display.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
*******************************************************************************
* Copyright (c) 2021 by M5Stack
* Equipped with M5Station sample source code
* 配套 M5Station 示例源代码
* Visit for more information: https://docs.m5stack.com/en/core/station_485
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/core/station_485
*
* Describe: Display.
* Date: 2022/8/4
*******************************************************************************
*/
#include <M5Station.h>

/* After M5Station is started or reset the program in the setUp ()
function will be run, and this part will only be run once.
在 M5Station
启动或者复位后,即会开始执行setup()函数中的程序,该部分只会执行一次。 */
void setup() {
M5.begin();
// Lcd display
M5.Lcd.fillScreen(WHITE);
delay(500);
M5.Lcd.fillScreen(RED);
delay(500);
M5.Lcd.fillScreen(GREEN);
delay(500);
M5.Lcd.fillScreen(BLUE);
delay(500);
M5.Lcd.fillScreen(BLACK);
delay(500);

// text print. 文字打印
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setCursor(0, 10);
M5.Lcd.setTextColor(WHITE);
M5.Lcd.setTextSize(1);
M5.Lcd.printf("Display Test!");

// draw graphic. 绘图🌹
delay(1000);
M5.Lcd.drawRect(15, 55, 50, 50, BLUE);
delay(1000);
M5.Lcd.fillRect(15, 55, 50, 50, BLUE);
delay(1000);
M5.Lcd.drawCircle(40, 80, 30, RED);
delay(1000);
M5.Lcd.fillCircle(40, 80, 30, RED);
delay(1000);
}

/* After the program in setup() runs, it runs the program in loop()
The loop() function is an infinite loop in which the program runs repeatedly
在setup()函数中的程序执行完后,会接着执行loop()函数中的程序
loop()函数是一个死循环,其中的程序会不断的重复运行 */
void loop() {
// rand draw
M5.Lcd.fillTriangle(random(M5.Lcd.width() - 1), random(M5.Lcd.height() - 1),
random(M5.Lcd.width() - 1), random(M5.Lcd.height() - 1),
random(M5.Lcd.width() - 1), random(M5.Lcd.height() - 1),
random(0xfffe));
}
32 changes: 32 additions & 0 deletions example/Basics/HelloWorld/HelloWorld.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
*******************************************************************************
* Copyright (c) 2021 by M5Stack
* Equipped with M5Station sample source code
* 配套 M5Station 示例源代码
* Visit for more information: https://docs.m5stack.com/en/core/station_485
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/core/station_485
*
* Describe: Hello World.
* Date: 2022/8/4
*******************************************************************************
*/
#include <M5Station.h>

/* After M5Station is started or reset the program in the setUp ()
function will be run, and this part will only be run once.
在 M5Station
启动或者复位后,即会开始执行setup()函数中的程序,该部分只会执行一次。 */
void setup() {
M5.begin(); // Initialize M5Station. 初始化 M5Station
M5.Lcd.setTextSize(3); // Set font size. 设置字体大小
// LCD display. Lcd显示
M5.Lcd.print("Hello World");
Serial.print("Hello World");
}

/* After the program in setup() runs, it runs the program in loop()
The loop() function is an infinite loop in which the program runs repeatedly
在setup()函数中的程序执行完后,会接着执行loop()函数中的程序
loop()函数是一个死循环,其中的程序会不断的重复运行 */
void loop() {
}
55 changes: 55 additions & 0 deletions example/Basics/INA3221/INA3221.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
*******************************************************************************
* Copyright (c) 2022 by M5Stack
* Equipped with M5Station sample source code
* 配套 M5Station 示例源代码
* Visit for more information: https://docs.m5stack.com/en/core/station_485
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/core/station_485
*
* Describe: Current and voltage meters. 电流电压计
* Date: 2022/8/5
*******************************************************************************
Measuring port currents and voltages
测量端口电流及电压
*/
#include <M5Station.h>
/* After M5Station is started or reset
the program in the setUp () function will be run, and this part will only be
run once. 在 M5Station
启动或者复位后,即会开始执行setup()函数中的程序,该部分只会执行一次。 */
void setup() {
M5.begin(); // Init M5Station. 初始化 M5Station
M5.Lcd.setTextColor(ORANGE);
M5.Lcd.setTextFont(2);
M5.Lcd.setTextSize(1);
M5.Lcd.setCursor(35, 0);
M5.Lcd.print("Current and voltage meters");
}

/* After the program in setup() runs, it runs the program in loop()
The loop() function is an infinite loop in which the program runs repeatedly
在setup()函数中的程序执行完后,会接着执行loop()函数中的程序
loop()函数是一个死循环,其中的程序会不断的重复运行 */
void loop() {
M5.Lcd.fillRect(0, 30, 240, 95, BLACK);
M5.Lcd.setCursor(25, 40);
M5.Lcd.printf("A1%3.0f ma %1.1fV A2%3.0f ma %1.1fV\r",
M5.INA1.getCurrent(INA3221_CH1) * 1000,
M5.INA1.getVoltage(INA3221_CH1),
M5.INA1.getCurrent(INA3221_CH2) * 1000,
M5.INA1.getVoltage(INA3221_CH2));
M5.Lcd.setCursor(25, 55);
M5.Lcd.printf("B1%3.0f ma %1.1fV B2%3.0f ma %1.1fV\r",
M5.INA1.getCurrent(INA3221_CH3) * 1000,
M5.INA1.getVoltage(INA3221_CH3),
M5.INA2.getCurrent(INA3221_CH1) * 1000,
M5.INA2.getVoltage(INA3221_CH1));
M5.Lcd.setCursor(25, 70);
M5.Lcd.printf("C1%3.0f ma %1.1fV C2%3.0f ma %1.1fV\r",
M5.INA2.getCurrent(INA3221_CH2) * 1000,
M5.INA2.getVoltage(INA3221_CH2),
M5.INA2.getCurrent(INA3221_CH3) * 1000,
M5.INA2.getVoltage(INA3221_CH3));

delay(1000);
}
71 changes: 71 additions & 0 deletions example/Basics/MPU6886/MPU6886.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
*******************************************************************************
* Copyright (c) 2022 by M5Stack
* Equipped with M5Station sample source code
* 配套 M5Station 示例源代码
* Visit for more information: https://docs.m5stack.com/en/core/station_bat
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/core/station_bat
*
* Describe: MPU6886 example. 惯性传感器
* Date: 2022/8/4
*******************************************************************************
*/
#include <M5Station.h>

float accX = 0.0F; // Define variables for storing inertial sensor data
float accY = 0.0F; //定义存储惯性传感器相关数据的相关变量
float accZ = 0.0F;

float gyroX = 0.0F;
float gyroY = 0.0F;
float gyroZ = 0.0F;

float pitch = 0.0F;
float roll = 0.0F;
float yaw = 0.0F;

float temp = 0.0F;

/* After M5Station is started or reset
the program in the setUp () function will be run, and this part will only be run
once. 在 M5Station
启动或者复位后,即会开始执行setup()函数中的程序,该部分只会执行一次。 */
void setup() {
M5.begin(); // Init M5Station. 初始化 M5Station
while (M5.IMU.Init()) { // Init IMU sensor. 初始化惯性传感器
Serial.println("IMU init failed");
delay(1000);
}
}

void loop() {
// Stores the triaxial gyroscope data of the inertial sensor to the relevant
// variable. 将惯性传感器的三轴陀螺仪数据存储至相关变量
M5.IMU.getGyroData(&gyroX, &gyroY, &gyroZ);
M5.IMU.getAccelData(
&accX, &accY,
&accZ); // Stores the triaxial accelerometer. 存储三轴加速度计数据
M5.IMU.getAhrsData(
&pitch, &roll,
&yaw); // Stores the inertial sensor attitude. 存储惯性传感器的姿态
M5.IMU.getTempData(&temp); // Stores the inertial sensor temperature to
// temp. 存储惯性传感器的温度
// gyroscope output related.
//陀螺仪输出相关
Serial.printf("gyroX:%6.2f gyroY:%6.2f gyroZ:%6.2f o/s\n", gyroX, gyroY,
gyroZ);

// Accelerometer output is related
//加速度计输出相关
Serial.printf("accX:%5.2f accY:%5.2f accZ:%5.2f G\n", accX, accY, accZ);

// Pose output is related
//姿态输出相关
Serial.printf("pitch:%5.2f roll:%5.2f yaw:%5.2f deg\n", pitch, roll, yaw);

// Inertial sensor temperature output related
//惯性传感器温度输出相关
Serial.printf("Temperature:%.2f C\n\n", temp);

delay(100); // Delay 100ms. 延迟100ms
}
Loading

0 comments on commit 9109992

Please sign in to comment.