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 channels
are the channels that are having their colors set, and what
color they are being set to. Note, any channel that is using RGB instead
of XY will be ignored.
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;
}