LED blinking indefinitely in JavaScript
in JavaScript
I would like to replicate the indefinite red blinking that occurs in the MetaBase app, but I haven't been able to translate the underlying code.
Where can I use the const to REPEAT_INDEFINITELY that is listed in the docs? I saw how it can be used in Java but not JavaScript
const uint8_t MBL_MW_LED_REPEAT_INDEFINITELY = 0xff
var pattern = new MetaWear.LedPattern();
// Load a LED pattern already in firmware
MetaWear.mbl_mw_led_load_preset_pattern(pattern.ref(), MetaWear.LedPreset.BLINK);
// Send pattern to Board
MetaWear.mbl_mw_led_write_pattern(device.board, pattern.ref(), MetaWear.LedColor.RED);
// Tell board to play pattern
MetaWear.mbl_mw_led_play(device.board);
setTimeout(function () {
device.on('disconnect', function () {
process.exit(0);
});
// Stop LED
MetaWear.mbl_mw_led_stop_and_clear(device.board);
Comments
For reference, I tried to assign:
But it threw a reference error.
It's hard to figure out what the syntax is supposed to be with the SDK sometimes.
Nevermind - I hard coded a value for the unsigned integer.
hey @jjm345,
It sounds like you might just have had the wrong type for MBL_MW_LED_REPEAT_INDEFINITELY.