Changed format of proto color from bytes array to int32

Former-commit-id: 7dcf0256a81bfafb4a8f69a5a2e2a582d43a1d0d
This commit is contained in:
johan 2013-10-13 20:22:32 +02:00
parent 91dcbd0758
commit d526b8c9c1
3 changed files with 8 additions and 11 deletions

View File

@ -33,7 +33,7 @@
"color" :
{
"hsv" : {
"saturationGain" : 1.5,
"saturationGain" : 1.2,
"valueGain" : 1.5
},
"red" :

View File

@ -8,6 +8,7 @@
#include <iterator>
// Qt includes
#include <QRgb>
#include <QResource>
#include <QDateTime>
@ -116,17 +117,13 @@ void ProtoClientConnection::handleMessage(const proto::HyperionRequest & message
void ProtoClientConnection::handleColorCommand(const proto::ColorRequest &message)
{
if (message.rgbcolor().size() != 3)
{
sendErrorReply("The rgbcolor field requires a length of 3");
return;
}
// extract parameters
int priority = message.priority();
int duration = message.has_duration() ? message.duration() : -1;
const std::string & rgbColor = message.rgbcolor();
RgbColor color = {uint8_t(rgbColor[0]), uint8_t(rgbColor[1]), uint8_t(rgbColor[2])};
RgbColor color;
color.red = qRed(message.rgbcolor());
color.green = qGreen(message.rgbcolor());
color.blue = qBlue(message.rgbcolor());
// set output
_hyperion->setColor(priority, color, duration);

View File

@ -23,8 +23,8 @@ message ColorRequest {
// priority to use when setting the color
required int32 priority = 1;
// 3-byte value containing the rgb color
required bytes rgbColor = 2;
// integer value containing the rgb color (0x00RRGGBB)
required int32 rgbColor = 2;
// duration of the request (negative results in infinite)
optional int32 duration = 3;