mirror of
https://github.com/m5stack/m5-docs.git
synced 2026-05-20 10:23:01 -07:00
4.5 KiB
4.5 KiB
BALA Quick Start {docsify-ignore-all}
?>To program M5Bala, you will need M5Stack Fire or M5GO as main controller.
Prepare
- Install Serial Driver - How to Establish Serial Connection
Development Environment
UIFlow
- Download UIFlow firmware - How to dowmload Firmware
- WiFi Configuration - How to Connect wifi on M5Core
- Align to the POGO Pin, stack M5Core onto the M5Bala wheel.
- Press the Red button on side of M5Core (double click for shutdown).
- Press the button on side of M5Bala bottom to power on (double click for shutdown).
- Open UIFlow website, and switch programming language from
BlocklytoPython.
- Copy the following code to UIFlow and then click
Download.
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
- Setting Arduino development environment - Establish Serail Connection - Get Started with Ardino IDE
- Install
m5stacklibrary inLibrary Manager.
- Install
NeoPixelBuslibrary inLibrary Manager.
- Install
MPU6050_tocknlibrary inLibrary Manager.
-
Make sure that M5Core has connected to PC, then click
Tools->Portfor selecting the corresponding serial port on Arduino IDE. -
click
Tools->Board:to selectM5Stack-Core-ESP32orM5Stack-Fire.
git clone --recursive https://github.com/m5stack/M5Bala.git
- Click
Sketch->Include Library->Add .ZIP Library.... selectM5Balayou just cloned from github.
- Open a bala example: Click
File->Examples->M5Bala->Basic.
- Compile and upload.