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:

  1. Call StartRecord to put the API in macro mode
  2. Use the MetaWear commands that you want programmed
  3. 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);

Erasing Macros

Erasing macros is done with the EraseAll method. The erase operation will not occur until you disconnect from the board.

macro.EraseAll();
metawear.GetModule<IDebug>().DisconnectAsync();