Merge remote-tracking branch 'remotes/origin/master'

Former-commit-id: e159c4757880a0f77f59c6b23775856e4fd4b8fe
This commit is contained in:
T. van der Zwan
2013-09-24 11:28:33 +02:00
50 changed files with 3337 additions and 215 deletions

View File

@@ -3,7 +3,10 @@
/// Simple structure to contain the values of a color transformation
struct ColorTransformValues
{
/// The value for the red color-channel
double valueRed;
/// The value for the green color-channel
double valueGreen;
/// The value for the blue color-channel
double valueBlue;
};

View File

@@ -10,13 +10,25 @@
// hyperion-remote includes
#include "ColorTransformValues.h"
/// Data parameter for a color
typedef vlofgren::PODParameter<QColor> ColorParameter;
/// Data parameter for an image
typedef vlofgren::PODParameter<QImage> ImageParameter;
/// Data parameter for color transform values (list of three values)
typedef vlofgren::PODParameter<ColorTransformValues> TransformParameter;
namespace vlofgren {
///
/// Translates a string (as passed on the commandline) to a color
///
/// @param[in] s The string (as passed on the commandline)
///
/// @return The translated color
///
/// @throws Parameter::ParameterRejected If the string did not result in a color
///
template<>
QColor ColorParameter::validate(const std::string& s) throw (Parameter::ParameterRejected)
{

View File

@@ -15,30 +15,74 @@
// hyperion-remote includes
#include "ColorTransformValues.h"
///
/// Connection class to setup an connection to the hyperion server and execute commands
///
class JsonConnection
{
public:
///
/// Constructor
///
/// @param address The address of the Hyperion server (for example "192.168.0.32:19444)
/// @param printJson Boolean indicating if the sent and received json is written to stdout
///
JsonConnection(const std::string & address, bool printJson);
///
/// Destructor
///
~JsonConnection();
///
/// Set all leds to the specified color
///
/// @param color The color
/// @param priority The priority
/// @param duration The duration in milliseconds
///
void setColor(QColor color, int priority, int duration);
///
/// Set the leds according to the given image (assume the image is stretched to the display size)
///
/// @param image The image
/// @param priority The priority
/// @param duration The duration in milliseconds
///
void setImage(QImage image, int priority, int duration);
///
/// Retrieve a list of all occupied priority channels
///
/// @return String with the server info
///
QString getServerInfo();
///
/// Clear the given priority channel
///
/// @param priority The priority
///
void clear(int priority);
///
/// Clear all priority channels
///
void clearAll();
///
/// Set the color transform of the leds
/// Note that providing a NULL will leave the settings on the server unchanged
///
/// @note Note that providing a NULL will leave the settings on the server unchanged
///
/// @param saturation The HSV saturation gain
/// @param value The HSV value gain
/// @param threshold The threshold
/// @param gamma The gamma value
/// @param blacklevel The blacklevel
/// @param whitelevel The whitelevel
///
void setTransform(
double * saturation,
double * value,
@@ -48,13 +92,28 @@ public:
ColorTransformValues * whitelevel);
private:
///
/// Send a json command message and receive its reply
///
/// @param message The message to send
///
/// @return The returned reply
///
Json::Value sendMessage(const Json::Value & message);
///
/// Parse a reply message
///
/// @param reply The received reply
///
/// @return true if the reply indicates success
///
bool parseReply(const Json::Value & reply);
private:
/// Flag for printing all send and received json-messages to the standard out
bool _printJson;
/// The TCP-Socket with the connection to the server
QTcpSocket _socket;
};

View File

@@ -83,7 +83,7 @@ int main(int argc, char** argv)
}
const Json::Value & videoCheckerConfig = config["xbmcVideoChecker"];
XBMCVideoChecker xbmcVideoChecker(videoCheckerConfig["xbmcAddress"].asString(), videoCheckerConfig["xbmcTcpPort"].asUInt(), 1000, &hyperion, 999);
XBMCVideoChecker xbmcVideoChecker(videoCheckerConfig["xbmcAddress"].asString(), videoCheckerConfig["xbmcTcpPort"].asUInt(), 1000, true, true, true, true);
if (videoCheckerConfig["enable"].asBool())
{
xbmcVideoChecker.start();
@@ -97,6 +97,7 @@ int main(int argc, char** argv)
frameGrabberConfig["height"].asUInt(),
frameGrabberConfig["frequency_Hz"].asUInt(),
&hyperion);
QObject::connect(&xbmcVideoChecker, SIGNAL(grabbingMode(GrabbingMode)), &dispmanx, SLOT(setGrabbingMode(GrabbingMode)));
dispmanx.start();
std::cout << "Frame grabber created and started" << std::endl;

View File

@@ -6,6 +6,7 @@ if(PNG_FOUND)
include_directories(${PNG_INCLUDE_DIR})
add_executable(viewpng
FbWriter.h
ViewPng.cpp)
target_link_libraries(viewpng

View File

@@ -12,14 +12,27 @@
#include <utils/RgbImage.h>
///
/// FbWriter allows direct access tot the FrameBuffer. It writes and image to the framebuffer,
/// adjusting the resolution as required. When destructed the FrameBuffer is switch to original
/// configuration.
///
class FbWriter
{
public:
///
/// Constructs the FrameBuffer writer opening the FrameBuffer device and storing the current
/// configuration.
///
FbWriter()
{
initialise();
}
///
/// Destructor of the write. Switches the FrameBuffer to its origianl configuration and closes
/// the FrameBuffer
///
~FbWriter()
{
if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &orig_vinfo))
@@ -30,26 +43,33 @@ public:
close(fbfd);
}
///
/// Initialises the write, opening the FrameBuffer
///
/// @return Zero on succes else negative
///
int initialise()
{
// Open the file for reading and writing
fbfd = open("/dev/fb0", O_RDWR);
if (!fbfd)
{
printf("Error: cannot open framebuffer device.\n");
return(-1);
std::cerr << "Error: cannot open framebuffer device." << std::endl;
return -1;
}
printf("The framebuffer device was opened successfully.\n");
// Get fixed screen information
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo))
{
printf("Error reading fixed information.\n");
std::cerr << "Error reading fixed information.\n" << std::endl;
return -1;
}
// Get variable screen information
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &orig_vinfo))
{
printf("Error reading variable information.\n");
std::cerr << "Error reading variable information.\n" << std::endl;
return -1;
}
printf("Original %dx%d, %dbpp\n", orig_vinfo.xres, orig_vinfo.yres, orig_vinfo.bits_per_pixel );
@@ -57,6 +77,12 @@ public:
return 0;
}
///
/// Writes the given RGB Image to the FrameBuffer. When required the resolution of the
/// FrameBuffer is asjusted to match the given image
///
/// @param image The RGB Image
///
void writeImage(const RgbImage& image)
{
std::cout << "Writing image [" << image.width() << "x" << image.height() << "]" << std::endl;
@@ -93,23 +119,16 @@ public:
for (unsigned iY=0; iY<image.height(); ++iY)
{
memcpy(fbp + iY*finfo.line_length, &(image(0, iY)), image.width()*3);
// for (unsigned iX=0; iX<image.width(); ++iX)
// {
// const unsigned pixOffset = iX*3 + iY*finfo.line_length;
// fbp[pixOffset ] = image(iX, iY).red;
// fbp[pixOffset+1] = image(iX, iY).green;
// fbp[pixOffset+2] = image(iX, iY).blue;
// }
}
std::cout << "FINISHED COPYING IMAGE TO FRAMEBUFFER" << std::endl;
// cleanup
munmap(fbp, screensize);
}
// The identifier of the FrameBuffer File-Device
/// The identifier of the FrameBuffer File-Device
int fbfd;
// The 'Fixed' screen information
/// The 'Fixed' screen information
fb_fix_screeninfo finfo;
// The original 'Variable' screen information
/// The original 'Variable' screen information
fb_var_screeninfo orig_vinfo;
};