From 2152511589cfd267f1989d3761ec7721a084a643 Mon Sep 17 00:00:00 2001 From: vany5921 <908744431@qq.com> Date: Fri, 11 Sep 2020 15:37:39 +0800 Subject: [PATCH] add bala2 --- .../en/quick_start/bala2/bala2_quick_start.md | 126 +++--------------- docs/index.md | 3 +- docs/zh_CN/README.md | 3 +- .../quick_start/bala2/bala2_quick_start.md | 93 ++++--------- 4 files changed, 51 insertions(+), 174 deletions(-) diff --git a/docs/en/quick_start/bala2/bala2_quick_start.md b/docs/en/quick_start/bala2/bala2_quick_start.md index 88295a7b..d3ba4bd5 100644 --- a/docs/en/quick_start/bala2/bala2_quick_start.md +++ b/docs/en/quick_start/bala2/bala2_quick_start.md @@ -1,130 +1,46 @@ # BALA2 Quick Start {docsify-ignore-all} -?>To program M5Bala2, you will need M5Stack Gray as main controller. +?>M5Bala2 has been calibrated , if you need to recalibrate, follow the steps below. - +1. Place BALA2 on a horizontal desktop and keep it turned off. -## Prepare Install serial port driver +2. Press and hold the middle key (ButtonB) and the red button on the left at the same time, and let go immediately after the screen lights up. At this time, IMU data will be obtained. Please do not touch them during this time. -### For Windows +3. After the data acquisition is completed, it will automatically enter the calibration mode interface. Press the left/right(ButtonA/ButtonC) key to increase or decrease the correction value. When the value is adjusted to a satisfactory value, press the B key to save the parameter. ->Unzip the downloaded CP210X driver compression package, select the installation program corresponding to your operating system, and double-click to install. - - - -### For Mac - ->Unzip the downloaded CP210X driver compression package, install the program, and double-click the image file to start the installation. - - +4. Restart, BALA2 will run the saved parameters. ## Development Environment -1. [UIFlow](#UIFlow) -2. [Arduino IDE](#Arduino-IDE) - -## UIFlow - -1. - - - -1. Press the Red button on side of M5Core (double click for shutdown). - - - -1. Press the button on side of M5Bala bottom to power on (double click for shutdown). - - - - - -6. Open [UIFlow](http://flow.m5stack.com/) website, and switch programming language from `Blockly` to `Python`. - - - -7. Copy the following code to UIFlow and then click `Download`. - -```python -from m5stack import * -from m5ui import * -from m5bala import M5Bala -import i2c_bus -clear_bg(0x111111) - -m5bala = M5Bala(i2c_bus.get(i2c_bus.M_BUS)) -btnA = M5Button(name="ButtonA", text="ButtonA", visibility=False) -btnB = M5Button(name="ButtonB", text="ButtonB", visibility=False) -btnC = M5Button(name="ButtonC", text="ButtonC", visibility=False) -title0 = M5Title(title="Title", fgcolor=0xFFFFFF, bgcolor=0x0000FF) - -title0.setTitle('calirate start') -wait(2) -sampleCount = 2000 -gyroXSum = 0 -gyroYSum = 0 -gyroZSum = 0 - -for _ in range(sampleCount): - gyroXYZ = m5bala.imu.gyro - gyroXSum += gyroXYZ[0] # X - gyroYSum += gyroXYZ[1] # Y - gyroZSum += gyroXYZ[2] # Z - -gyroXMean = gyroXSum / sampleCount -gyroYMean = gyroYSum / sampleCount -gyroZMean = gyroZSum / sampleCount - -m5bala.imu.setGyroOffsets(gyroXMean, gyroYMean, gyroZMean) - -title0.setTitle('balance start') -while True: - m5bala.balance() - wait(0.001) -``` +[Arduino IDE](#Arduino-IDE) ## Arduino IDE -1. Setting Arduino development environment - [Establish Serail Connection](https://docs.m5stack.com/#/en/related_documents/establish_serial_connection) - [Get Started with Ardino IDE](https://docs.m5stack.com/#/en/quick_start/m5core/m5stack_core_quick_start) +1. [Mac]Refer to this tutorial to configure Arduino IDE(#/zh_CN/arduino/arduino_development.md) + [Windows]Refer to this tutorial to configure Arduino IDE(#/zh_CN/arduino/arduino_development.md) - +2. [Download the Example program](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Application/Bala2) -2. Install `m5stack` library in `Library Manager`. +3. Open the example code in Arduino - +4. Make sure that BALA2 has connected to PC, then click `Tools` -> `Port` for selecting the corresponding serial port on Arduino IDE.. -3. Install `NeoPixelBus` library in `Library Manager`. +5. click `Tools` -> `Board: ` to select `M5Stack-Core-ESP32`. - +6. Compile and upload. -4. Install `MPU6050_tockn` library in `Library Manager`. +## Use of servo - +**Bala::SetServoAngle(uint8_t pos, uint8_t angle)** -5. Make sure that M5Core has connected to PC, then click `Tools` -> `Port` for selecting the corresponding serial port on Arduino IDE. +uint8_t pos servo number(1 - 8),Among them, No. 5 - 8 servos are inside the BALA2 base -6. click `Tools` -> `Board: ` to select `M5Stack-Core-ESP32` or `M5Stack-Fire`. +uint8_t angle servo angle - +**Bala::SetServoPulse(uint8_t pos, uint16_t width)** -7. Clone **[M5Bala](https://github.com/m5stack/M5Bala.git)** by shell command. *If you dont't have Git installed yet, click [here](https://git-scm.com/download/win) and install it.* +uint8_t pos servo number(1 - 8),Among them, No. 5 - 8 servos are inside the BALA2 base -```shell -git clone --recursive https://github.com/m5stack/M5Bala.git -``` +uint16_t width pulse width -8. Click `Sketch` -> `Include Library` -> `Add .ZIP Library...` . select `M5Bala` you just cloned from github. - - - - - -9. Open a bala example: Click `File` -> `Examples` -> `M5Bala` -> `Basic`. - - - -10. Compile and upload. - - - - \ No newline at end of file +**For the use of M5Stack, please refer to [M5Stack GRAY](https://docs.m5stack.com/#/zh_CN/core/gray)** \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 7d96cb75..a1c5596b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -208,7 +208,8 @@ const application_list = [ //Application - {a:"/#/en/app/bala", img:"https://static-cdn.m5stack.com/image/m5-docs_homepage/app/app_bala_01.webp", p:"BALA", sku:"K014" ,kw:"ROBOT", category:"Application"}, + {a:"/#/en/app/bala2", img:"https://m5stack.oss-cn-shenzhen.aliyuncs.com/image/m5-docs_homepage/app/bala2.webp", p:"BALA2", sku:"K014-C" ,kw:"BALA2 ROBOT", category:"Application"}, + {a:"/#/en/app/bala", img:"https://static-cdn.m5stack.com/image/m5-docs_homepage/app/app_bala_01.webp", p:"BALA", sku:"K014" ,kw:"ROBOT"}, {a:"/#/en/app/lidarbot", img:"https://static-cdn.m5stack.com/image/m5-docs_homepage/app/app_lidarbot_01.webp", p:"LidarBOT", sku:"K017" ,kw:"ROBOT"}, {a:"/#/en/app/piano", img:"https://static-cdn.m5stack.com/image/m5-docs_homepage/app/app_piano_01.webp", p:"PIANO", sku:"A047" ,kw:"MUSIC"}, {a:"/#/en/app/flir", img:"https://static-cdn.m5stack.com/image/m5-docs_homepage/app/app_flir_01.webp", p:"FLIR", sku:"K021" ,kw:"FLIR3.0"}, diff --git a/docs/zh_CN/README.md b/docs/zh_CN/README.md index b9266243..b022f0a4 100644 --- a/docs/zh_CN/README.md +++ b/docs/zh_CN/README.md @@ -208,7 +208,8 @@ const application_list = [ //Application - {a:"/#/zh_CN/app/bala", img:"https://static-cdn.m5stack.com/image/m5-docs_homepage/app/app_bala_01.webp", p:"BALA", sku:"K014" ,kw:"ROBOT", category:"Application"}, + {a:"/#/zh_CN/app/bala2", img:"https://m5stack.oss-cn-shenzhen.aliyuncs.com/image/m5-docs_homepage/app/bala2.webp", p:"BALA2", sku:"K014-C" ,kw:"BALA2 ROBOT", category:"Application"}, + {a:"/#/zh_CN/app/bala", img:"https://static-cdn.m5stack.com/image/m5-docs_homepage/app/app_bala_01.webp", p:"BALA", sku:"K014" ,kw:"ROBOT"}, {a:"/#/zh_CN/app/lidarbot", img:"https://static-cdn.m5stack.com/image/m5-docs_homepage/app/app_lidarbot_01.webp", p:"LidarBOT", sku:"K017" ,kw:"ROBOT"}, {a:"/#/zh_CN/app/piano", img:"https://static-cdn.m5stack.com/image/m5-docs_homepage/app/app_piano_01.webp", p:"PIANO", sku:"A047" ,kw:"MUSIC"}, {a:"/#/zh_CN/app/flir", img:"https://static-cdn.m5stack.com/image/m5-docs_homepage/app/app_flir_01.webp", p:"FLIR", sku:"K021" ,kw:"FLIR3.0"}, diff --git a/docs/zh_CN/quick_start/bala2/bala2_quick_start.md b/docs/zh_CN/quick_start/bala2/bala2_quick_start.md index 74c6892b..a6c070cf 100644 --- a/docs/zh_CN/quick_start/bala2/bala2_quick_start.md +++ b/docs/zh_CN/quick_start/bala2/bala2_quick_start.md @@ -1,87 +1,46 @@ # BALA2 上手指南 {docsify-ignore-all} -?>为了使用M5Bala2,需要M5Stack Gray。 +?>M5Bala2在出厂时已做校准,如需重新校准按以下步骤进行。 - +1. 将BALA2放置水平桌面,保持关机状态。 + +2. 同时按住中间按键(ButtonB)和左侧红色按键,待屏幕亮起后立刻松手,此时会获取IMU数据,期间请勿触碰。 + +3. 数据获取完毕后自动进入校准模式界面,按下A/C键可对修正值增加或减小,当调整至满意值时,按下B键保存参数。 + +4. 重新开机,BALA2将已保存的参数运行。 ## 开发环境 -1. [UIFlow编辑](#UIFlow编辑) -2. [Arduino IDE编辑](#Arduino-IDE编辑) - -## UIFlow编辑 - -1. [安装驱动并烧录 UIFlow 固件](https://docs.m5stack.com/#/en/quick_start/m5core/m5stack_core_get_started_MicroPython)参考此教程烧录固件 - -2. 单击M5Core侧边的红色按键开机(快速双击为关机). - -3. 访问 [UIFlow](http://flow.m5stack.com/) , 将编程模式`Blockly` 切换至 `Python`. - -4. 复制粘贴以下代码,并执行程序. - -```python -from m5stack import * -from m5ui import * -from m5bala import M5Bala -import i2c_bus -clear_bg(0x111111) - -m5bala = M5Bala(i2c_bus.get(i2c_bus.M_BUS)) -btnA = M5Button(name="ButtonA", text="ButtonA", visibility=False) -btnB = M5Button(name="ButtonB", text="ButtonB", visibility=False) -btnC = M5Button(name="ButtonC", text="ButtonC", visibility=False) -title0 = M5Title(title="Title", fgcolor=0xFFFFFF, bgcolor=0x0000FF) - -title0.setTitle('calirate start') -wait(2) -sampleCount = 2000 -gyroXSum = 0 -gyroYSum = 0 -gyroZSum = 0 - -for _ in range(sampleCount): - gyroXYZ = m5bala.imu.gyro - gyroXSum += gyroXYZ[0] # X - gyroYSum += gyroXYZ[1] # Y - gyroZSum += gyroXYZ[2] # Z - -gyroXMean = gyroXSum / sampleCount -gyroYMean = gyroYSum / sampleCount -gyroZMean = gyroZSum / sampleCount - -m5bala.imu.setGyroOffsets(gyroXMean, gyroYMean, gyroZMean) - -title0.setTitle('balance start') -while True: - m5bala.balance() - wait(0.001) -``` +[Arduino IDE编辑](#Arduino-IDE编辑) ## Arduino IDE编辑 -1. [Mac用户]参考此教程配置Arduino IDE(#/zh_CN/quick_start/m5core/m5stack_core_get_started_Arduino_MacOS.md) - [Windows用户]参考此教程配置Arduino IDE(#/en/quick_start/m5core/m5stack_core_get_started_Arduino_MacOS.md) +1. [Mac用户]参考此教程配置Arduino IDE(#/zh_CN/arduino/arduino_development.md) + [Windows用户]参考此教程配置Arduino IDE(#/zh_CN/arduino/arduino_development.md) -2. 在Arduino中 +2. [下载示例程序](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Application/Bala2) -7. 使用Shell命令下载 **[M5Bala案例程序](https://github.com/m5stack/M5Bala.git)** . *如果你还未安装Git, [请点击此处](https://git-scm.com/download/win) 进行下载.* +3. 在Arduino中打开示例程序 -```shell -git clone --recursive https://github.com/m5stack/M5Bala.git -``` +3. 将BALA2连接至电脑.点击`Tools`->`Port`中选择设备使用的串行端口 -8. 点击 `Sketch` -> `Include Library` -> `Add .ZIP Library...` . 选择下载好的 `M5Bala` 的文件 +4. 开发板`Board`选项选择`M5Stack-Core-ESP32` - +5. 对代码编译上传 - +## 舵机使用 -9. 打开 BALA 程序案例: 点击 `File` -> `Examples` -> `M5Bala` -> `Basic`. +**Bala::SetServoAngle(uint8_t pos, uint8_t angle)** - +uint8_t pos 舵机序号(1 - 8),其中5 - 8号舵机在BALA底座内部 -10. 编译并上传程序. +uint8_t angle 舵机角度 - +**Bala::SetServoPulse(uint8_t pos, uint16_t width)** - \ No newline at end of file +uint8_t pos 舵机序号(1 - 8),其中5 - 8号舵机在BALA底座内部 + +uint16_t width 脉冲宽度 + +**关于M5Stack的使用请参考[M5Stack GRAY](https://docs.m5stack.com/#/zh_CN/core/gray)** \ No newline at end of file