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 Macro module.
import com.mbientlab.metawear.module.Macro;
final Macro macro = board.getModule(Macro.class);
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
Macros can be set to run on boot by calling startRecord
with true
.
import com.mbientlab.metawear.module.Led;
final Led led = mwBoard.getModule(Led.class);
macro.startRecord(true);
led.editPattern(Led.Color.GREEN, Led.PatternPreset.SOLID)
.commit();
led.play();
macro.endRecordAsync().continueWith(new Continuation<Byte, Void>() {
@Override
public Void then(Task<Byte> task) throws Exception {
Log.i("MainActivity", "Macro ID = " + task.getResult());
return null;
}
});