getDataAsRgb static method
List<int>
getDataAsRgb(
- String entertainmentConfigurationId,
- List<
EntertainmentStreamCommand> commands
Creates a packet to send to the bridge, using RGB color space encoding.
The entertainmentConfigurationId
parameter is the ID of the
entertainment configuration to send the data to. Note, any channel that is
using XY instead of RGB will be ignored.
The channels
are the channels that are having their colors set, and what
color they are being set to.
Returns a list of bytes representing the packet.
Implementation
static List<int> getDataAsRgb(
String entertainmentConfigurationId,
List<EntertainmentStreamCommand> commands,
) {
final List<int> packet =
_getPacketBase(ColorMode.rgb, 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! ColorRgb) continue;
// Only allow 20 commands per packet.
if (counter >= 20) break;
packet.add(command.channel);
packet.addAll(
_formatRgb(
(command.color as ColorRgb).r,
(command.color as ColorRgb).g,
(command.color as ColorRgb).b,
),
);
counter++;
}
return packet;
}