getDataAsXy static method
List<int>
getDataAsXy(
- String entertainmentConfigurationId,
- List<
EntertainmentStreamCommand> commands
Creates a packet to send to the bridge, using XY+brightness color space encoding.
The entertainmentConfigurationId
parameter is the ID of the
entertainment configuration to send the data to.
The commands
are the commands that are being sent to the bridge.
Returns a list of bytes representing the packet.
Implementation
static List<int> getDataAsXy(
String entertainmentConfigurationId,
List<EntertainmentStreamCommand> commands,
) {
final List<int> packet =
_getPacketBase(ColorMode.xy, entertainmentConfigurationId);
// Add every command to the packet.
int counter = 0;
for (final EntertainmentStreamCommand command in commands) {
// Skip any commands that are not using XY color space.
if (command.color is! ColorXy) continue;
// Only allow 20 commands per packet.
if (counter >= 20) break;
packet.add(command.channel);
packet.addAll(
_formatXy(
(command.color as ColorXy).x,
(command.color as ColorXy).y,
(command.color as ColorXy).brightness,
),
);
counter++;
}
return packet;
}