M5Stack-mruby is mruby runtime environment on M5Stack micro computer.
M5Stack-mruby provides mruby programming platform in below.
- Execution of mruby application (binary).
- Execution of mruby script in interactive mode.
Change to the directory where you installed esp-idf and get the source code of M5Stack-mruby.
1
2
cd ~/esp
git clone —recursive https://github.com/mimaki/M5Stack-mruby.git
Connect M5Stack and PC with USB cable.
Type below command at M5Stack-mruby directory.
1
make flash
M5Stack-mruby can execute mruby application (binary) compiled with mruby compiler (mrbc).
The mruby compiler (mrbc) is generated in the M5Stack-mruby/components/mruby_component/mruby/bin directory.
The sample program japan.rb and the compile procedure are shown below.
1
2
3
4
LCD.clear
LCD.fill_rect(50, 40, 219, 159, LCD::WHITE)
LCD.fill_circle(160, 120, 50, LCD::RED)
gets
1
M5Stack-mruby/components/mruby_component/mruby/bin/mrbc -o autorun.mrb japan.rb
Insert the microSD with autorun.mrb copied to the root directory into the M5Stack’s SD card slot and power on (or reset) the M5Stack to execute the mruby application saved on the microSD card.
By using a terminal application such as CoolTerm, M5Stack-mruby interactive mode can be used.
The operation when using CoolTerm is shown below.
Connect M5Stack to PC with USB cable, open CoolTerm Options, and set the following items.
Item | Value | Note |
---|---|---|
Port | Mac: SLAB_USBtoUART Windows: COMx |
COMx number if different depending on the environment. |
Baudrate | 115200 | |
Data Bits | 8 | |
Parity | none | |
Stop Bits | 1 |
If you can’t find Port, check if the VCP driver is correctly installed.
Item | Value |
---|---|
Terminal Mode | Line Mode |
Enter Key Emulation | CR |
Local Echo | ON |