battlecore::rgb

The rgbmodule controls the device's coloured LEDs: setting one or many LEDs, managing maximum brightness, committing changes, and running sweep and flash effects. It also flashes the lights on a paired headset. Include its declarations with include "./battlecore/rgb.bst";.

setOne

Sets a single LED by index to the given colour and brightness.

native void battlecore::rgb.setOne (int lightIndex, int r, int g, int b, int brightness = 255);

setMany

Sets many LEDs at once. Each entry is [r, g, b] or [r, g, b, brightness], and the first entry is LED 0.

native void battlecore::rgb.setMany (int[][] values);

getMaxBrightness / setMaxBrightness

Gets or sets the maximum brightness.

native int  battlecore::rgb.getMaxBrightness ();
native void battlecore::rgb.setMaxBrightness (int newValue);

allOff

Turns all the LEDs off.

native void battlecore::rgb.allOff ();

commit

Sends pending LED changes to the hardware.

native void battlecore::rgb.commit ();

sweep

Runs a sweep across the LEDs in the given colour over duration milliseconds. Pass false for forward to run it in reverse.

native void battlecore::rgb.sweep (int r, int g, int b, int a, int duration, bool forward = true);

flash

Flashes the LEDs in the given colour a number of times, with the on and off times you give.

native void battlecore::rgb.flash (int r, int g, int b, int a, int times = 3, int onDurationMs = 200, int offDurationMs = 100);

headsetFlash

Flashes the lights on the paired headset. headbandModuleis one of the headband's four modules, 0 to 3, or -1 for all of them. The firmware never flashes the headset by itself: when it flashes, and how, is the game's choice.

native bool battlecore::rgb.headsetFlash (int r, int g, int b, int a = 255, int times = 1, int onDurationMs = 60, int offDurationMs = 0, int headbandModule = -1);

The message is sent whether or not a headset is listening, so it returns false only on firmware built without Bluetooth. An IR hit says which module it landed on in evt.data.headsetModule, which is -1 when the hit landed on the tagger itself. So a hit can light the part of the headband that was struck:

module ModuleEnum.IR {
	event EventEnum.IN (EventData evt) => {
		// Faintly all round, brightly where the shot landed.
		battlecore::rgb.headsetFlash(3, 0, 0, 255, 1, 60, 0);
		battlecore::rgb.headsetFlash(255, 0, 0, 255, 1, 60, 0, evt.data.headsetModule);
	}
}