Added simple QT-based grabber.

Moved ImageToLedsMap from include to libsrc.
Moved instantiation of objects to Hyperion (no JSON required outside this class).
This commit is contained in:
T. van der Zwan
2013-08-13 11:10:45 +02:00
parent 491d6ff608
commit 39b98386dd
32 changed files with 1065 additions and 508 deletions

View File

@@ -2,6 +2,12 @@
add_executable(WriteConfig
WriteConfig.cpp)
add_executable(HyperionDispmanx
HyperionMain.cpp)
target_link_libraries(HyperionDispmanx
hyperion)
add_executable(boblight-dispmanx
boblight-dispmanx.cpp
flagmanager.h
@@ -27,12 +33,12 @@ target_link_libraries(boblight-dispmanx
bob2hyperion
${BCM_LIBRARIES})
add_executable(HyperionDispmanX
HyperionDispmanX.cpp)
#add_executable(HyperionDispmanX
# HyperionDispmanX.cpp)
target_link_libraries(HyperionDispmanX
hyperion
${BCM_LIBRARIES})
#target_link_libraries(HyperionDispmanX
# hyperion
# ${BCM_LIBRARIES})
# Find the libPNG

View File

@@ -43,7 +43,7 @@ int main(int /*argc*/, char** /*argv*/)
}
Hyperion hyperion(raspiConfig);
dispmanx_process(hyperion, sRunning);
// dispmanx_process(hyperion, sRunning);
return 0;
}

17
src/HyperionMain.cpp Normal file
View File

@@ -0,0 +1,17 @@
// QT includes
#include <QCoreApplication>
// Hyperion includes
#include <hyperion/DispmanxWrapper.h>
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
DispmanxWrapper dispmanx;
dispmanx.start();
app.exec();
}

View File

@@ -144,10 +144,10 @@ int main(int argc, char** argv)
FbWriter fbWriter;
Hyperion raspiLight(raspiConfig);
raspiLight.setInputSize(image->width(), image->height());
// raspiLight.setInputSize(image->width(), image->height());
fbWriter.writeImage(*image);
raspiLight(*image);
// raspiLight(*image);
sleep(5);

View File

@@ -1,17 +1,17 @@
/*
* boblight
* Copyright (C) Bob 2009
*
* Copyright (C) Bob 2009
*
* boblight is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* boblight is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -35,16 +35,16 @@ CArguments::CArguments(int argc, char** argv)
if (m_argc == 0)
{
m_argv = NULL;
m_argv = NULL;
}
else
{
m_argv = new char*[m_argc];
for (int i = 0; i < m_argc; i++)
{
m_argv[i] = new char[strlen(argv[i]) + 1];
strcpy(m_argv[i], argv[i]);
}
m_argv = new char*[m_argc];
for (int i = 0; i < m_argc; i++)
{
m_argv[i] = new char[strlen(argv[i]) + 1];
strcpy(m_argv[i], argv[i]);
}
}
}
@@ -53,11 +53,11 @@ CArguments::~CArguments()
{
if (m_argv)
{
for (int i = 0; i < m_argc; i++)
{
delete[] m_argv[i];
}
delete[] m_argv;
for (int i = 0; i < m_argc; i++)
{
delete[] m_argv[i];
}
delete[] m_argv;
}
}
@@ -87,75 +87,75 @@ void CFlagManager::ParseFlags(int tempargc, char** tempargv)
int c;
opterr = 0; //we don't want to print error messages
while ((c = getopt(argc, argv, m_flags.c_str())) != -1)
{
if (c == 'p') //priority
{
option = optarg;
if (!StrToInt(option, m_priority) || m_priority < 0 || m_priority > 255)
{
throw string("Wrong option " + string(optarg) + " for argument -p");
}
}
else if (c == 's') //address[:port]
{
option = optarg;
//store address in string and set the char* to it
m_straddress = option.substr(0, option.find(':'));
m_address = m_straddress.c_str();
if (c == 'p') //priority
{
option = optarg;
if (!StrToInt(option, m_priority) || m_priority < 0 || m_priority > 255)
{
throw string("Wrong option " + string(optarg) + " for argument -p");
}
}
else if (c == 's') //address[:port]
{
option = optarg;
//store address in string and set the char* to it
m_straddress = option.substr(0, option.find(':'));
m_address = m_straddress.c_str();
if (option.find(':') != string::npos) //check if we have a port
{
option = option.substr(option.find(':') + 1);
string word;
if (!StrToInt(option, m_port) || m_port < 0 || m_port > 65535)
{
throw string("Wrong option " + string(optarg) + " for argument -s");
}
}
}
else if (c == 'o') //option for libboblight
{
m_options.push_back(optarg);
}
else if (c == 'l') //list libboblight options
{
m_printboblightoptions = true;
return;
}
else if (c == 'h') //print help message
{
m_printhelp = true;
return;
}
else if (c == 'f')
{
m_fork = true;
}
else if (c == 'y')
{
if (!StrToBool(optarg, m_sync))
{
throw string("Wrong value " + string(optarg) + " for sync mode");
}
}
else if (c == '?') //unknown option
{
//check if we know this option, but expected an argument
if (m_flags.find(ToString((char)optopt) + ":") != string::npos)
{
throw string("Option " + ToString((char)optopt) + "requires an argument");
}
else
{
throw string("Unkown option " + ToString((char)optopt));
}
}
else
{
ParseFlagsExtended(argc, argv, c, optarg); //pass our argument to a derived class
}
if (option.find(':') != string::npos) //check if we have a port
{
option = option.substr(option.find(':') + 1);
string word;
if (!StrToInt(option, m_port) || m_port < 0 || m_port > 65535)
{
throw string("Wrong option " + string(optarg) + " for argument -s");
}
}
}
else if (c == 'o') //option for libboblight
{
m_options.push_back(optarg);
}
else if (c == 'l') //list libboblight options
{
m_printboblightoptions = true;
return;
}
else if (c == 'h') //print help message
{
m_printhelp = true;
return;
}
else if (c == 'f')
{
m_fork = true;
}
else if (c == 'y')
{
if (!StrToBool(optarg, m_sync))
{
throw string("Wrong value " + string(optarg) + " for sync mode");
}
}
else if (c == '?') //unknown option
{
//check if we know this option, but expected an argument
if (m_flags.find(ToString((char)optopt) + ":") != string::npos)
{
throw string("Option " + ToString((char)optopt) + "requires an argument");
}
else
{
throw string("Unkown option " + ToString((char)optopt));
}
}
else
{
ParseFlagsExtended(argc, argv, c, optarg); //pass our argument to a derived class
}
}
PostGetopt(optind, argc, argv); //some postprocessing
@@ -169,7 +169,7 @@ void CFlagManager::PrintBoblightOptions()
for (int i = 0; i < nroptions; i++)
{
cout << boblight_getoptiondescript(boblight, i) << "\n";
cout << boblight_getoptiondescript(boblight, i) << "\n";
}
boblight_destroy(boblight);
@@ -178,74 +178,74 @@ void CFlagManager::PrintBoblightOptions()
void CFlagManager::ParseBoblightOptions(void* boblight)
{
int nrlights = boblight_getnrlights(boblight);
for (int i = 0; i < m_options.size(); i++)
for (size_t i = 0; i < m_options.size(); i++)
{
string option = m_options[i];
string lightname;
string optionname;
string optionvalue;
int lightnr = -1;
string option = m_options[i];
string lightname;
string optionname;
string optionvalue;
int lightnr = -1;
//check if we have a lightname, otherwise we use all lights
if (option.find(':') != string::npos)
{
lightname = option.substr(0, option.find(':'));
if (option.find(':') == option.size() - 1) //check if : isn't the last char in the string
{
throw string("wrong option \"" + option + "\", syntax is [light:]option=value");
}
option = option.substr(option.find(':') + 1); //shave off the lightname
//check if we have a lightname, otherwise we use all lights
if (option.find(':') != string::npos)
{
lightname = option.substr(0, option.find(':'));
if (option.find(':') == option.size() - 1) //check if : isn't the last char in the string
{
throw string("wrong option \"" + option + "\", syntax is [light:]option=value");
}
option = option.substr(option.find(':') + 1); //shave off the lightname
//check which light this is
bool lightfound = false;
for (int j = 0; j < nrlights; j++)
{
if (lightname == boblight_getlightname(boblight, j))
{
lightfound = true;
lightnr = j;
break;
}
}
if (!lightfound)
{
throw string("light \"" + lightname + "\" used in option \"" + m_options[i] + "\" doesn't exist");
}
}
//check which light this is
bool lightfound = false;
for (int j = 0; j < nrlights; j++)
{
if (lightname == boblight_getlightname(boblight, j))
{
lightfound = true;
lightnr = j;
break;
}
}
if (!lightfound)
{
throw string("light \"" + lightname + "\" used in option \"" + m_options[i] + "\" doesn't exist");
}
}
//check if '=' exists and it's not at the end of the string
if (option.find('=') == string::npos || option.find('=') == option.size() - 1)
{
throw string("wrong option \"" + option + "\", syntax is [light:]option=value");
}
//check if '=' exists and it's not at the end of the string
if (option.find('=') == string::npos || option.find('=') == option.size() - 1)
{
throw string("wrong option \"" + option + "\", syntax is [light:]option=value");
}
optionname = option.substr(0, option.find('=')); //option name is everything before = (already shaved off the lightname here)
optionvalue = option.substr(option.find('=') + 1); //value is everything after =
optionname = option.substr(0, option.find('=')); //option name is everything before = (already shaved off the lightname here)
optionvalue = option.substr(option.find('=') + 1); //value is everything after =
option = optionname + " " + optionvalue; //libboblight wants syntax without =
option = optionname + " " + optionvalue; //libboblight wants syntax without =
//bitch if we can't set this option
if (!boblight_setoption(boblight, lightnr, option.c_str()))
{
throw string(boblight_geterror(boblight));
}
//bitch if we can't set this option
if (!boblight_setoption(boblight, lightnr, option.c_str()))
{
throw string(boblight_geterror(boblight));
}
}
}
bool CFlagManager::SetVideoGamma()
{
for (int i = 0; i < m_options.size(); i++)
for (size_t i = 0; i < m_options.size(); i++)
{
string option = m_options[i];
if (option.find(':') != string::npos)
option = option.substr(option.find(':') + 1); //shave off the lightname
string option = m_options[i];
if (option.find(':') != string::npos)
option = option.substr(option.find(':') + 1); //shave off the lightname
if (option.find('=') != string::npos)
{
if (option.substr(0, option.find('=')) == "gamma")
return false; //gamma set by user, don't override
}
if (option.find('=') != string::npos)
{
if (option.substr(0, option.find('=')) == "gamma")
return false; //gamma set by user, don't override
}
}
m_options.push_back("gamma=" + ToString(VIDEOGAMMA));

View File

@@ -1,17 +1,17 @@
/*
* boblight
* Copyright (C) Bob 2009
*
* Copyright (C) Bob 2009
*
* boblight is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* boblight is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -96,15 +96,15 @@ inline A Round(B value)
{
if (value == 0.0)
{
return 0;
return 0;
}
else if (value > 0.0)
{
return (A)(value + 0.5);
return (A)(value + 0.5);
}
else
{
return (A)(value - 0.5);
return (A)(value - 0.5);
}
}
@@ -135,7 +135,7 @@ inline bool StrToInt(const std::string& data, int& value)
inline bool StrToInt(const std::string& data, int64_t& value)
{
return sscanf(data.c_str(), "%ld", &value) == 1;
return sscanf(data.c_str(), "%lld", &value) == 1;
}
inline bool HexStrToInt(const std::string& data, int& value)
@@ -145,7 +145,7 @@ inline bool HexStrToInt(const std::string& data, int& value)
inline bool HexStrToInt(const std::string& data, int64_t& value)
{
return sscanf(data.c_str(), "%x", &value) == 1;
return sscanf(data.c_str(), "%llx", &value) == 1;
}
inline bool StrToFloat(const std::string& data, float& value)
@@ -163,26 +163,26 @@ inline bool StrToBool(const std::string& data, bool& value)
std::string data2 = data;
std::string word;
if (!GetWord(data2, word))
return false;
return false;
if (word == "1" || word == "true" || word == "on" || word == "yes")
{
value = true;
return true;
value = true;
return true;
}
else if (word == "0" || word == "false" || word == "off" || word == "no")
{
value = false;
return true;
value = false;
return true;
}
else
{
int ivalue;
if (StrToInt(word, ivalue))
{
value = ivalue != 0;
return true;
}
int ivalue;
if (StrToInt(word, ivalue))
{
value = ivalue != 0;
return true;
}
}
return false;