Macro¶
The on-board flash memory can also be used to store MetaWear commands instead of sensor data. Recorded commands can be executed any time after being programmed with the IMacro module.
using MbientLab.MetaWear.Core;
IMacro macro = metawear.GetModule<IMacro>();
Recording Commands¶
To record commands:
- Call StartRecord to put the API in macro mode
- Use the MetaWear commands that you want programmed
- Exit macro mode with EndRecordAsync
By default, macros will be executed on boot. Call StartRecord
with false
to disable this behavior.
using MbientLab.MetaWear.Peripheral
ILed led = metawear.GetModule<ILed>();
macro.StartRecord();
led.EditPattern(Color.Blue)
.RiseTime(0).Duration(1000)
.Count(5).HighTime(500)
.HighIntensity(16).LowIntensity(16)
.Commit();
led.Play();
var id = await macro.EndRecord();
Console.WriteLine("Macro ID = " + id);