mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Merge remote-tracking branch 'refs/remotes/hyperion-project/master' into travisci
This commit is contained in:
commit
58d433e309
13
.gitignore
vendored
13
.gitignore
vendored
@ -1,5 +1,18 @@
|
||||
*.swp
|
||||
/*.user
|
||||
/build*
|
||||
.DS_Store
|
||||
CMakeFiles/
|
||||
__/
|
||||
|
||||
# Ignoring autogenerated files
|
||||
*.cmake
|
||||
Makefile
|
||||
qrc_*.cpp
|
||||
*.qrc.depends
|
||||
moc_*.cpp
|
||||
moc_*.cpp_parameters
|
||||
CMakeCache.txt
|
||||
*.log
|
||||
/HyperionConfig.h
|
||||
/lib
|
||||
|
@ -1,32 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# for executing in non travis environment
|
||||
[ -z "$TRAVIS_OS_NAME" ] && TRAVIS_OS_NAME="$( uname -s | tr '[:upper:]' '[:lower:]' )"
|
||||
|
||||
[ -z "$TRAVIS_OS_NAME" ] && TRAVIS_OS_NAME="$(uname -s | tr 'A-Z' 'a-z')"
|
||||
|
||||
######################################
|
||||
## COMPILE HYPERION
|
||||
# Detect number of processor cores
|
||||
|
||||
# compile hyperion on osx
|
||||
if [[ $TRAVIS_OS_NAME == 'osx' ]]
|
||||
then
|
||||
if [[ $TRAVIS_OS_NAME == 'osx' || $TRAVIS_OS_NAME == 'darwin' ]]; then
|
||||
procs=$(sysctl -n hw.ncpu | xargs)
|
||||
echo "Processes: $procs"
|
||||
|
||||
mkdir build || exit 1
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON -Wno-dev .. || exit 2
|
||||
make -j$procs || exit 3
|
||||
# make -j$(nproc) package || exit 4 # currently osx(dmg) package creation not implemented
|
||||
elif [[ $TRAVIS_OS_NAME == 'linux' ]]; then
|
||||
procs=$(nproc)
|
||||
else
|
||||
# For most modern systems, including the pi, this is a sane default
|
||||
procs=4
|
||||
fi
|
||||
|
||||
# compile hyperion on linux
|
||||
if [[ $TRAVIS_OS_NAME == 'linux' ]]
|
||||
then
|
||||
mkdir build || exit 1
|
||||
cd build
|
||||
cmake -DPLATFORM=x86-dev -DCMAKE_BUILD_TYPE=Release .. || exit 2
|
||||
make -j$(nproc) || exit 3
|
||||
make -j$(nproc) package || exit 4
|
||||
|
||||
# Compile hyperion
|
||||
|
||||
mkdir build || exit 1
|
||||
cd build
|
||||
cmake -DPLATFORM=x86-dev -DCMAKE_BUILD_TYPE=Debug .. || exit 2
|
||||
make -j$(nproc) || exit 3
|
||||
|
||||
|
||||
# Build the package on Linux
|
||||
|
||||
if [[ $TRAVIS_OS_NAME == 'linux' ]]; then
|
||||
make -j$(nproc) package || exit 4
|
||||
fi
|
||||
|
||||
|
@ -1,18 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# for executing in non travis environment
|
||||
[ -z "$TRAVIS_OS_NAME" ] && TRAVIS_OS_NAME="$( uname -s | tr '[:upper:]' '[:lower:]' )"
|
||||
|
||||
# install osx deps for hyperion compile
|
||||
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
|
||||
if [[ $TRAVIS_OS_NAME == 'osx' || $TRAVIS_OS_NAME == 'darwin' ]]
|
||||
then
|
||||
echo "Install OSX deps"
|
||||
time brew update
|
||||
time brew install qt5 || true
|
||||
time brew install libusb || true
|
||||
time brew install cmake || true
|
||||
time brew install doxygen || true
|
||||
fi
|
||||
|
||||
# install linux deps for hyperion compile
|
||||
if [[ $TRAVIS_OS_NAME == 'linux' ]]; then
|
||||
elif [[ $TRAVIS_OS_NAME == 'linux' ]]
|
||||
then
|
||||
echo "Install linux deps"
|
||||
sudo apt-get -qq update
|
||||
sudo apt-get install -qq -y qtbase5-dev libqt5serialport5-dev libusb-1.0-0-dev python-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev doxygen
|
||||
else
|
||||
echo "Unsupported platform: $TRAVIS_OS_NAME"
|
||||
exit 5
|
||||
fi
|
||||
|
||||
|
111
CMakeLists.txt
111
CMakeLists.txt
@ -30,55 +30,58 @@ SET ( DEFAULT_USE_SHARED_AVAHI_LIBS OFF )
|
||||
SET ( DEFAULT_USE_AVAHI_LIBS ON )
|
||||
SET ( DEFAULT_TESTS OFF )
|
||||
|
||||
if ( NOT DEFINED PLATFORM )
|
||||
if ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86" )
|
||||
SET( PLATFORM "x86")
|
||||
elseif ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" )
|
||||
SET( PLATFORM "rpi")
|
||||
EXEC_PROGRAM( "nproc" OUTPUT_VARIABLE SYSTEM_CPU_CORES )
|
||||
FILE( READ /proc/cpuinfo SYSTEM_CPUINFO )
|
||||
STRING ( TOLOWER "${SYSTEM_CPUINFO}" SYSTEM_CPUINFO )
|
||||
if ( "${SYSTEM_CPUINFO}" MATCHES "amlogic" )
|
||||
SET( PLATFORM "wetek" )
|
||||
elseif( SYSTEM_CPU_CORES GREATER 1 AND "${SYSTEM_CPUINFO}" MATCHES "bcm" )
|
||||
SET( PLATFORM "rpi-pwm" )
|
||||
endif()
|
||||
endif()
|
||||
if ( PLATFORM )
|
||||
message( STATUS "PLATFORM is not defined, evaluated platform: ${PLATFORM}")
|
||||
else()
|
||||
message( FATAL_ERROR "PLATFORM is not defined and could not be evaluated. Set -DPLATFORM=<rpi|pri-pwm|wetek|x86>")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if ( "${PLATFORM}" STREQUAL "rpi" )
|
||||
SET ( DEFAULT_DISPMANX ON )
|
||||
elseif ( "${PLATFORM}" STREQUAL "rpi-pwm" )
|
||||
SET ( DEFAULT_DISPMANX ON )
|
||||
SET ( DEFAULT_WS2812BPWM ON )
|
||||
SET ( DEFAULT_WS281XPWM ON )
|
||||
elseif ( "${PLATFORM}" STREQUAL "wetek" )
|
||||
SET ( DEFAULT_AMLOGIC ON )
|
||||
elseif ( "${PLATFORM}" STREQUAL "x86" )
|
||||
SET ( DEFAULT_X11 ON )
|
||||
SET ( DEFAULT_USE_SHARED_AVAHI_LIBS ON )
|
||||
elseif ( "${PLATFORM}" STREQUAL "x86-dev" )
|
||||
SET ( DEFAULT_X11 ON )
|
||||
SET ( DEFAULT_AMLOGIC ON)
|
||||
SET ( DEFAULT_WS281XPWM ON )
|
||||
SET ( DEFAULT_USE_SHARED_AVAHI_LIBS ON )
|
||||
SET ( DEFAULT_TESTS ON )
|
||||
elseif ( "${PLATFORM}" STREQUAL "imx6" )
|
||||
SET ( DEFAULT_FB ON )
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/usr/local/opt/qt5")
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/usr/local/opt/qt5")
|
||||
include_directories("/opt/X11/include/")
|
||||
SET ( DEFAULT_OSX ON )
|
||||
SET ( DEFAULT_V4L2 OFF )
|
||||
SET ( DEFAULT_V4L2 OFF )
|
||||
SET ( DEFAULT_SPIDEV OFF )
|
||||
SET ( DEFAULT_FB OFF )
|
||||
SET ( DEFAULT_USE_AVAHI_LIBS OFF )
|
||||
else ()
|
||||
if ( NOT DEFINED PLATFORM )
|
||||
if ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86" )
|
||||
SET( PLATFORM "x86")
|
||||
elseif ( "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm" )
|
||||
SET( PLATFORM "rpi")
|
||||
EXEC_PROGRAM( "nproc" OUTPUT_VARIABLE SYSTEM_CPU_CORES )
|
||||
FILE( READ /proc/cpuinfo SYSTEM_CPUINFO )
|
||||
STRING ( TOLOWER "${SYSTEM_CPUINFO}" SYSTEM_CPUINFO )
|
||||
if ( "${SYSTEM_CPUINFO}" MATCHES "amlogic" )
|
||||
SET( PLATFORM "wetek" )
|
||||
elseif( SYSTEM_CPU_CORES GREATER 1 AND "${SYSTEM_CPUINFO}" MATCHES "bcm" )
|
||||
SET( PLATFORM "rpi-pwm" )
|
||||
endif()
|
||||
endif()
|
||||
if ( PLATFORM )
|
||||
message( STATUS "PLATFORM is not defined, evaluated platform: ${PLATFORM}")
|
||||
else()
|
||||
message( FATAL_ERROR "PLATFORM is not defined and could not be evaluated. Set -DPLATFORM=<rpi|pri-pwm|wetek|x86>")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if ( "${PLATFORM}" STREQUAL "rpi" )
|
||||
SET ( DEFAULT_DISPMANX ON )
|
||||
elseif ( "${PLATFORM}" STREQUAL "rpi-pwm" )
|
||||
SET ( DEFAULT_DISPMANX ON )
|
||||
SET ( DEFAULT_WS2812BPWM ON )
|
||||
SET ( DEFAULT_WS281XPWM ON )
|
||||
elseif ( "${PLATFORM}" STREQUAL "wetek" )
|
||||
SET ( DEFAULT_AMLOGIC ON )
|
||||
elseif ( "${PLATFORM}" STREQUAL "x86" )
|
||||
SET ( DEFAULT_X11 ON )
|
||||
SET ( DEFAULT_USE_SHARED_AVAHI_LIBS ON )
|
||||
elseif ( "${PLATFORM}" STREQUAL "x86-dev" )
|
||||
SET ( DEFAULT_X11 ON )
|
||||
SET ( DEFAULT_AMLOGIC ON)
|
||||
SET ( DEFAULT_WS281XPWM ON )
|
||||
SET ( DEFAULT_USE_SHARED_AVAHI_LIBS ON )
|
||||
SET ( DEFAULT_TESTS ON )
|
||||
elseif ( "${PLATFORM}" STREQUAL "imx6" )
|
||||
SET ( DEFAULT_FB ON )
|
||||
endif()
|
||||
SET ( DEFAULT_WS281XPWM OFF )
|
||||
SET ( DEFAULT_USE_AVAHI_LIBS OFF )
|
||||
SET ( DEFAULT_USE_SHARED_AVAHI_LIBS OFF )
|
||||
endif ()
|
||||
|
||||
# set the build options
|
||||
@ -124,10 +127,6 @@ message(STATUS "ENABLE_PROFILER = " ${ENABLE_PROFILER})
|
||||
SET ( PROTOBUF_INSTALL_BIN_DIR ${CMAKE_BINARY_DIR}/proto )
|
||||
SET ( PROTOBUF_INSTALL_LIB_DIR ${CMAKE_BINARY_DIR}/proto )
|
||||
|
||||
#if(ENABLE_QT5)
|
||||
# TODO vs ENABLE_QT4?
|
||||
#endif(ENABLE_QT5)
|
||||
|
||||
# Createt the configuration file
|
||||
|
||||
# Add project specific cmake modules (find, etc)
|
||||
@ -156,8 +155,18 @@ include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||
#set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so")
|
||||
|
||||
# enable C++11
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++11 -Wall")
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
if(COMPILER_SUPPORTS_CXX11)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
else()
|
||||
message(STATUS "No support for C++11 detected. Compilation will most likely fail on your compiler")
|
||||
endif()
|
||||
|
||||
SET(QT_MIN_VERSION "5.2.0")
|
||||
find_package(Qt5 COMPONENTS Core Gui Network REQUIRED)
|
||||
|
@ -41,7 +41,7 @@ MyClass::MyClass() : myVarA(0),
|
||||
|
||||
good:
|
||||
MyClass::MyClass()
|
||||
: myVarA(0),
|
||||
: myVarA(0)
|
||||
, myVarB("eee")
|
||||
, myVarC(true)
|
||||
{
|
||||
|
222
assets/webconfig/css/bootstrap-colorpicker.css
vendored
222
assets/webconfig/css/bootstrap-colorpicker.css
vendored
@ -1,222 +0,0 @@
|
||||
/*!
|
||||
* Bootstrap Colorpicker v2.3.3
|
||||
* http://mjolnic.github.io/bootstrap-colorpicker/
|
||||
*
|
||||
* Originally written by (c) 2012 Stefan Petre
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
*
|
||||
*/
|
||||
.colorpicker-saturation {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background-image: url("../img/bootstrap-colorpicker/saturation.png");
|
||||
cursor: crosshair;
|
||||
float: left;
|
||||
}
|
||||
.colorpicker-saturation i {
|
||||
display: block;
|
||||
height: 5px;
|
||||
width: 5px;
|
||||
border: 1px solid #000;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin: -4px 0 0 -4px;
|
||||
}
|
||||
.colorpicker-saturation i b {
|
||||
display: block;
|
||||
height: 5px;
|
||||
width: 5px;
|
||||
border: 1px solid #fff;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.colorpicker-hue,
|
||||
.colorpicker-alpha {
|
||||
width: 15px;
|
||||
height: 100px;
|
||||
float: left;
|
||||
cursor: row-resize;
|
||||
margin-left: 4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.colorpicker-hue i,
|
||||
.colorpicker-alpha i {
|
||||
display: block;
|
||||
height: 1px;
|
||||
background: #000;
|
||||
border-top: 1px solid #fff;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
margin-top: -1px;
|
||||
}
|
||||
.colorpicker-hue {
|
||||
background-image: url("../img/bootstrap-colorpicker/hue.png");
|
||||
}
|
||||
.colorpicker-alpha {
|
||||
background-image: url("../img/bootstrap-colorpicker/alpha.png");
|
||||
display: none;
|
||||
}
|
||||
.colorpicker-saturation,
|
||||
.colorpicker-hue,
|
||||
.colorpicker-alpha {
|
||||
background-size: contain;
|
||||
}
|
||||
.colorpicker {
|
||||
padding: 4px;
|
||||
min-width: 130px;
|
||||
margin-top: 1px;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
z-index: 2500;
|
||||
}
|
||||
.colorpicker:before,
|
||||
.colorpicker:after {
|
||||
display: table;
|
||||
content: "";
|
||||
line-height: 0;
|
||||
}
|
||||
.colorpicker:after {
|
||||
clear: both;
|
||||
}
|
||||
.colorpicker:before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
border-left: 7px solid transparent;
|
||||
border-right: 7px solid transparent;
|
||||
border-bottom: 7px solid #ccc;
|
||||
border-bottom-color: rgba(0, 0, 0, 0.2);
|
||||
position: absolute;
|
||||
top: -7px;
|
||||
left: 6px;
|
||||
}
|
||||
.colorpicker:after {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
border-left: 6px solid transparent;
|
||||
border-right: 6px solid transparent;
|
||||
border-bottom: 6px solid #ffffff;
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
left: 7px;
|
||||
}
|
||||
.colorpicker div {
|
||||
position: relative;
|
||||
}
|
||||
.colorpicker.colorpicker-with-alpha {
|
||||
min-width: 140px;
|
||||
}
|
||||
.colorpicker.colorpicker-with-alpha .colorpicker-alpha {
|
||||
display: block;
|
||||
}
|
||||
.colorpicker-color {
|
||||
height: 10px;
|
||||
margin-top: 5px;
|
||||
clear: both;
|
||||
background-image: url("../img/bootstrap-colorpicker/alpha.png");
|
||||
background-position: 0 100%;
|
||||
}
|
||||
.colorpicker-color div {
|
||||
height: 10px;
|
||||
}
|
||||
.colorpicker-selectors {
|
||||
display: none;
|
||||
height: 10px;
|
||||
margin-top: 5px;
|
||||
clear: both;
|
||||
}
|
||||
.colorpicker-selectors i {
|
||||
cursor: pointer;
|
||||
float: left;
|
||||
height: 10px;
|
||||
width: 10px;
|
||||
}
|
||||
.colorpicker-selectors i + i {
|
||||
margin-left: 3px;
|
||||
}
|
||||
.colorpicker-element .input-group-addon i,
|
||||
.colorpicker-element .add-on i {
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
height: 16px;
|
||||
vertical-align: text-top;
|
||||
width: 16px;
|
||||
}
|
||||
.colorpicker.colorpicker-inline {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
float: none;
|
||||
z-index: auto;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal {
|
||||
width: 110px;
|
||||
min-width: 110px;
|
||||
height: auto;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-saturation {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-color {
|
||||
width: 100px;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-hue,
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-alpha {
|
||||
width: 100px;
|
||||
height: 15px;
|
||||
float: left;
|
||||
cursor: col-resize;
|
||||
margin-left: 0px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-hue i,
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-alpha i {
|
||||
display: block;
|
||||
height: 15px;
|
||||
background: #ffffff;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 1px;
|
||||
border: none;
|
||||
margin-top: 0px;
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-hue {
|
||||
background-image: url("../img/bootstrap-colorpicker/hue-horizontal.png");
|
||||
}
|
||||
.colorpicker.colorpicker-horizontal .colorpicker-alpha {
|
||||
background-image: url("../img/bootstrap-colorpicker/alpha-horizontal.png");
|
||||
}
|
||||
.colorpicker.colorpicker-hidden {
|
||||
display: none;
|
||||
}
|
||||
.colorpicker.colorpicker-visible {
|
||||
display: block;
|
||||
}
|
||||
.colorpicker-inline.colorpicker-visible {
|
||||
display: inline-block;
|
||||
}
|
||||
.colorpicker-right:before {
|
||||
left: auto;
|
||||
right: 6px;
|
||||
}
|
||||
.colorpicker-right:after {
|
||||
left: auto;
|
||||
right: 7px;
|
||||
}
|
||||
.colorpicker-no-arrow:before {
|
||||
border-right: 0;
|
||||
border-left: 0;
|
||||
}
|
||||
.colorpicker-no-arrow:after {
|
||||
border-right: 0;
|
||||
border-left: 0;
|
||||
}
|
||||
/*# sourceMappingURL=bootstrap-colorpicker.css.map */
|
10
assets/webconfig/css/bootstrap-colorpicker.min.css
vendored
Normal file
10
assets/webconfig/css/bootstrap-colorpicker.min.css
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/*!
|
||||
* Bootstrap Colorpicker v2.3.3
|
||||
* http://mjolnic.github.io/bootstrap-colorpicker/
|
||||
*
|
||||
* Originally written by (c) 2012 Stefan Petre
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
*
|
||||
*/.colorpicker-saturation{width:100px;height:100px;background-image:url(../img/bootstrap-colorpicker/saturation.png);cursor:crosshair;float:left}.colorpicker-saturation i{display:block;height:5px;width:5px;border:1px solid #000;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;position:absolute;top:0;left:0;margin:-4px 0 0 -4px}.colorpicker-saturation i b{display:block;height:5px;width:5px;border:1px solid #fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.colorpicker-alpha,.colorpicker-hue{width:15px;height:100px;float:left;cursor:row-resize;margin-left:4px;margin-bottom:4px}.colorpicker-alpha i,.colorpicker-hue i{display:block;height:1px;background:#000;border-top:1px solid #fff;position:absolute;top:0;left:0;width:100%;margin-top:-1px}.colorpicker-hue{background-image:url(../img/bootstrap-colorpicker/hue.png)}.colorpicker-alpha{background-image:url(../img/bootstrap-colorpicker/alpha.png);display:none}.colorpicker-alpha,.colorpicker-hue,.colorpicker-saturation{background-size:contain}.colorpicker{padding:4px;min-width:130px;margin-top:1px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;z-index:2500}.colorpicker:after,.colorpicker:before{display:table;content:"";line-height:0}.colorpicker:after{clear:both}.colorpicker:before{content:'';display:inline-block;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-bottom-color:rgba(0,0,0,.2);position:absolute;top:-7px;left:6px}.colorpicker:after{content:'';display:inline-block;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #fff;position:absolute;top:-6px;left:7px}.colorpicker div{position:relative}.colorpicker.colorpicker-with-alpha{min-width:140px}.colorpicker.colorpicker-with-alpha .colorpicker-alpha{display:block}.colorpicker-color{height:10px;margin-top:5px;clear:both;background-image:url(../img/bootstrap-colorpicker/alpha.png);background-position:0 100%}.colorpicker-color div{height:10px}.colorpicker-selectors{display:none;height:10px;margin-top:5px;clear:both}.colorpicker-selectors i{cursor:pointer;float:left;height:10px;width:10px}.colorpicker-selectors i+i{margin-left:3px}.colorpicker-element .add-on i,.colorpicker-element .input-group-addon i{display:inline-block;cursor:pointer;height:16px;vertical-align:text-top;width:16px}.colorpicker.colorpicker-inline{position:relative;display:inline-block;float:none;z-index:auto}.colorpicker.colorpicker-horizontal{width:110px;min-width:110px;height:auto}.colorpicker.colorpicker-horizontal .colorpicker-saturation{margin-bottom:4px}.colorpicker.colorpicker-horizontal .colorpicker-color{width:100px}.colorpicker.colorpicker-horizontal .colorpicker-alpha,.colorpicker.colorpicker-horizontal .colorpicker-hue{width:100px;height:15px;float:left;cursor:col-resize;margin-left:0;margin-bottom:4px}.colorpicker.colorpicker-horizontal .colorpicker-alpha i,.colorpicker.colorpicker-horizontal .colorpicker-hue i{display:block;height:15px;background:#fff;position:absolute;top:0;left:0;width:1px;border:none;margin-top:0}.colorpicker.colorpicker-horizontal .colorpicker-hue{background-image:url(../img/bootstrap-colorpicker/hue-horizontal.png)}.colorpicker.colorpicker-horizontal .colorpicker-alpha{background-image:url(../img/bootstrap-colorpicker/alpha-horizontal.png)}.colorpicker.colorpicker-hidden{display:none}.colorpicker.colorpicker-visible{display:block}.colorpicker-inline.colorpicker-visible{display:inline-block}.colorpicker-right:before{left:auto;right:6px}.colorpicker-right:after{left:auto;right:7px}.colorpicker-no-arrow:before{border-right:0;border-left:0}.colorpicker-no-arrow:after{border-right:0;border-left:0}
|
||||
/*# sourceMappingURL=bootstrap-colorpicker.min.css.map */
|
1
assets/webconfig/css/bootstrap-colorpicker.min.css.map
Normal file
1
assets/webconfig/css/bootstrap-colorpicker.min.css.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["src/less/colorpicker.less"],"names":[],"mappings":";;;;;;;;AAqBA,wBACE,MAAA,MACA,OAAA,MAXA,iBAAsB,iDAatB,OAAA,UACA,MAAA,KACA,0BACE,QAAA,MACA,OAAA,IACA,MAAA,IACA,OAAA,IAAA,MAAA,KAfF,sBAAA,IACA,mBAAA,IACA,cAAA,IAeE,SAAA,SACA,IAAA,EACA,KAAA,EACA,OAAA,KAAA,EAAA,EAAA,KACA,4BACE,QAAA,MACA,OAAA,IACA,MAAA,IACA,OAAA,IAAA,MAAA,KAzBJ,sBAAA,IACA,mBAAA,IACA,cAAA,IA8BF,mBADA,iBAEE,MAAA,KACA,OAAA,MACA,MAAA,KACA,OAAA,WACA,YAAA,IACA,cAAA,IAIiB,qBADF,mBAEf,QAAA,MACA,OAAA,IACA,WAAA,KACA,WAAA,IAAA,MAAA,KACA,SAAA,SACA,IAAA,EACA,KAAA,EACA,MAAA,KACA,WAAA,KAGF,iBA1DE,iBAAsB,0CA8DxB,mBA9DE,iBAAsB,4CAgEtB,QAAA,KAKF,mBADA,iBADA,wBAGE,gBAAA,QAGF,aACE,QAAA,IACA,UAAA,MACA,WAAA,IAxEA,sBAAA,IACA,mBAAA,IACA,cAAA,IAwEA,QAAA,KAIU,mBADA,oBAEV,QAAA,MACA,QAAA,GACA,YAAA,EAGU,mBACV,MAAA,KAGU,oBACV,QAAA,GACA,QAAA,aACA,YAAA,IAAA,MAAA,YACA,aAAA,IAAA,MAAA,YACA,cAAA,IAAA,MAAA,KACA,oBAAA,eACA,SAAA,SACA,IAAA,KACA,KAAA,IAGU,mBACV,QAAA,GACA,QAAA,aACA,YAAA,IAAA,MAAA,YACA,aAAA,IAAA,MAAA,YACA,cAAA,IAAA,MAAA,KACA,SAAA,SACA,IAAA,KACA,KAAA,IAGW,iBACX,SAAA,SAGU,oCACV,UAAA,MAGkC,uDAClC,QAAA,MAGF,mBACE,OAAA,KACA,WAAA,IACA,MAAA,KAlIA,iBAAsB,4CAoItB,oBAAA,EAAA,KAGiB,uBACjB,OAAA,KAGF,uBACE,QAAA,KACA,OAAA,KACA,WAAA,IACA,MAAA,KAGqB,yBACrB,OAAA,QACA,MAAA,KACA,OAAA,KACA,MAAA,KAGuB,2BACvB,YAAA,IAI2B,+BADW,0CAEtC,QAAA,aACA,OAAA,QACA,OAAA,KACA,eAAA,SACA,MAAA,KAGU,gCACV,SAAA,SACA,QAAA,aACA,MAAA,KACA,QAAA,KAGU,oCACV,MAAA,MACA,UAAA,MACA,OAAA,KAGkC,4DAClC,cAAA,IAGkC,uDAClC,MAAA,MAIkC,uDADA,qDAElC,MAAA,MACA,OAAA,KACA,MAAA,KACA,OAAA,WACA,YAAA,EACA,cAAA,IAIqD,yDADF,uDAEnD,QAAA,MACA,OAAA,KACA,WAAA,KACA,SAAA,SACA,IAAA,EACA,KAAA,EACA,MAAA,IACA,OAAA,KACA,WAAA,EAGkC,qDAlNlC,iBAAsB,qDAsNY,uDAtNlC,iBAAsB,uDA0NZ,gCACV,QAAA,KAGU,iCACV,QAAA,MAGiB,wCACjB,QAAA,aAGgB,0BAChB,KAAA,KACA,MAAA,IAGgB,yBAChB,KAAA,KACA,MAAA,IAGmB,6BACnB,aAAA,EACA,YAAA,EAGmB,4BACnB,aAAA,EACA,YAAA"}
|
@ -5,8 +5,12 @@
|
||||
url("../fonts/Roboto-Regular.ttf") format('ttf');
|
||||
}
|
||||
body{font-family:Roboto,"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:15px;}
|
||||
/*remove padding on all col elements for mobile view*/
|
||||
@media (max-width: 767px){div[class*="col-"] {padding:0;}}
|
||||
/*icon spacing*/
|
||||
.fa-fw{margin-right:5px;}
|
||||
/*borderless table*/
|
||||
table.borderless td,table.borderless th{border: none !important;}
|
||||
|
||||
/*Header*/
|
||||
.navbar-brand{padding: 5px;height:90px;}
|
||||
|
@ -12,20 +12,25 @@
|
||||
<title>Hyperion - WebUI</title>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="js/jquery.min.js"></script>
|
||||
<script src="js/lib/jquery.min.js"></script>
|
||||
|
||||
<script src="js/hyperion.js"></script>
|
||||
|
||||
<!-- Colorpicker -->
|
||||
<script src="js/lib/bootstrap-colorpicker.min.js"></script>
|
||||
<link href="css/bootstrap-colorpicker.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Bootstrap Switch -->
|
||||
<script src="js/bootstrap-switch.min.js"></script>
|
||||
<script src="js/lib/bootstrap-switch.min.js"></script>
|
||||
<link href="css/bootstrap-switch.min.css" rel="stylesheet">
|
||||
|
||||
<!-- JSONForm -->
|
||||
<script src="js/underscore.js"></script>
|
||||
<script src="js/jsonform.js"></script>
|
||||
<script src="js/lib/underscore.js"></script>
|
||||
<script src="js/lib/jsonform.js"></script>
|
||||
|
||||
<!--Language Support -->
|
||||
<script src="js/jquery-lang.js" charset="utf-8" type="text/javascript"></script>
|
||||
<script src="js/js.cookie.js"></script>
|
||||
<script src="js/lib/jquery-lang.js" charset="utf-8" type="text/javascript"></script>
|
||||
<script src="js/lib/js.cookie.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Create language switcher instance
|
||||
@ -285,43 +290,45 @@
|
||||
<li>
|
||||
<a class="active" href="index.html"><i class="fa fa-dashboard fa-fw"></i><span lang="en" data-lang-token="main_menu_dashboard_token">Dashboard</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#"><i class="fa fa-cog fa-fw"></i><span lang="en" data-lang-token="main_menu_configuration_token">Configuration</span><span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level">
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_confGeneral"><i class="fa fa-play-circle-o fa-fw"></i><span lang="en" data-lang-token="main_menu_general_conf_token">General</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_confKodi"><i class="fa fa-play-circle-o fa-fw"></i><span lang="en" data-lang-token="main_menu_kodiwatch_token">Kodi Watch</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_huebridge"><i class="fa fa-cog fa-fw"></i><span lang="en" data-lang-token="main_menu_huebridge_token">Hue Bridge</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#"><i class="fa fa-lightbulb-o fa-fw"></i><span lang="en" data-lang-token="main_menu_remotecontrol_token">Remote Control</span><span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level">
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_lighttest"><i class="fa fa-lightbulb-o fa-fw"></i><span lang="en" data-lang-token="main_menu_colors_token">Colors</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_effects"><i class="fa fa-certificate fa-fw"></i><span lang="en" data-lang-token="main_menu_effects_token">Effects</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_support"><i class="fa fa-info fa-fw"></i><span lang="en" data-lang-token="main_menu_support_token">Support</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#"><i class="fa fa-cog fa-fw"></i><span lang="en" data-lang-token="main_menu_system_token">System</span><span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level">
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_update"><i class="fa fa-download fa-fw"></i><span lang="en" data-lang-token="main_menu_update_token">Update</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#"><i class="fa fa-cog fa-fw"></i><span lang="en" data-lang-token="main_menu_configuration_token">Configuration</span><span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level">
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_confGeneral"><i class="fa fa-play-circle-o fa-fw"></i><span lang="en" data-lang-token="main_menu_general_conf_token">General</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_confKodi"><i class="fa fa-play-circle-o fa-fw"></i><span lang="en" data-lang-token="main_menu_kodiwatch_token">Kodi Watch</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_huebridge"><i class="fa fa-cog fa-fw"></i><span lang="en" data-lang-token="main_menu_huebridge_token">Hue Bridge</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#"><i class="fa fa-lightbulb-o fa-fw"></i><span lang="en" data-lang-token="main_menu_remotecontrol_token">Remote Control</span><span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level">
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_lighttest"><i class="fa fa-lightbulb-o fa-fw"></i><span lang="en" data-lang-token="main_menu_colors_token">Colors</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_effects"><i class="fa fa-certificate fa-fw"></i><span lang="en" data-lang-token="main_menu_effects_token">Effects</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_components"><i class="fa fa-list fa-fw"></i><span lang="en" data-lang-token="main_menu_component_token">Components</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_support"><i class="fa fa-info fa-fw"></i><span lang="en" data-lang-token="main_menu_support_token">Support</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="inactive" href="#"><i class="fa fa-cog fa-fw"></i><span lang="en" data-lang-token="main_menu_system_token">System</span><span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level">
|
||||
<li>
|
||||
<a class="inactive" href="#" id="load_update"><i class="fa fa-download fa-fw"></i><span lang="en" data-lang-token="main_menu_update_token">Update</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
@ -340,10 +347,6 @@
|
||||
<h4 lang="en" data-lang-token="dashboard_label_intro">The dashboard give you a quick overview about the status of Hyperion and show you the latest news of the Hyperion Blog.</h4>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="alert alert-info alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<strong>Info!</strong> A newer version of Hyperion is available!
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
@ -351,9 +354,24 @@
|
||||
<span lang="en" data-lang-token="dashboard_label_infobox_title">Information</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p lang="en" data-lang-token="dashboard_label_infobox_currenthyp">Your Hyperion version:</p>
|
||||
<p lang="en" data-lang-token="dashboard_label_infobox_latesthyp">Latest version:</p>
|
||||
<p lang="en" data-lang-token="dashboard_label_infobox_device">Device:</p>
|
||||
<table class="table borderless">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td lang="en" data-lang-token="dashboard_label_infobox_currenthyp">Your Hyperion version:</td>
|
||||
<td id="currentversion"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td lang="en" data-lang-token="dashboard_label_infobox_latesthyp">Latest version:</td>
|
||||
<td id="latestversion"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td lang="en" data-lang-token="dashboard_label_infobox_device">Device:</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr>
|
||||
<span id="versioninforesult"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -416,13 +434,13 @@
|
||||
|
||||
|
||||
<!-- Bootstrap Core JavaScript -->
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
<script src="js/lib/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Metis Menu Plugin JavaScript -->
|
||||
<script src="js/metisMenu.min.js"></script>
|
||||
<script src="js/lib/metisMenu.min.js"></script>
|
||||
|
||||
<!-- Custom Theme JavaScript -->
|
||||
<script src="js/sb-admin-2.js"></script>
|
||||
<script src="js/lib/sb-admin-2.js"></script>
|
||||
<script>
|
||||
|
||||
$(document).ready( function() {
|
||||
@ -433,6 +451,10 @@
|
||||
$("#load_effects").on("click", function() {
|
||||
$("#page-wrapper").load("effects.html");
|
||||
});
|
||||
|
||||
$("#load_components").on("click", function() {
|
||||
$("#page-wrapper").load("remote_components.html");
|
||||
});
|
||||
|
||||
$("#load_huebridge").on("click", function() {
|
||||
$("#page-wrapper").load("huebridge.html");
|
||||
@ -445,11 +467,11 @@
|
||||
$("#load_confKodi").on("click", function() {
|
||||
$("#page-wrapper").load("kodiconf.html");
|
||||
});
|
||||
|
||||
|
||||
$("#load_update").on("click", function() {
|
||||
$("#page-wrapper").load("update.html");
|
||||
});
|
||||
|
||||
|
||||
$("#load_confGeneral").on("click", function() {
|
||||
$("#page-wrapper").load("generalconf.html");
|
||||
});
|
||||
@ -457,6 +479,47 @@
|
||||
//Change all Checkboxes to Switches
|
||||
$("[type='checkbox']").bootstrapSwitch();
|
||||
|
||||
// vesion check
|
||||
var currentVersion;
|
||||
var cleanCurrentVersion;
|
||||
var latestVersion;
|
||||
var cleanLatestVersion;
|
||||
|
||||
webSocket = new WebSocket('ws://'+document.location.hostname+':19444');
|
||||
var serverInfo;
|
||||
|
||||
webSocket.onerror = function(event) {
|
||||
alert(event.data);
|
||||
};
|
||||
|
||||
|
||||
webSocket.onopen = function(event) {
|
||||
webSocket.send('{"command":"serverinfo"}');
|
||||
};
|
||||
|
||||
webSocket.onmessage = function(response){
|
||||
responseJSON = JSON.parse(response.data );
|
||||
currentVersion = responseJSON.info.hyperion[0].version;
|
||||
cleanCurrentVersion = currentVersion.replace(/\./g, '');
|
||||
|
||||
$.get( "https://raw.githubusercontent.com/hyperion-project/hyperion.ng/master/version.json", function( data ) {
|
||||
var responseJSON = JSON.parse(data);
|
||||
latestVersion = responseJSON[0].versionnr;
|
||||
cleanLatestVersion = latestVersion.replace(/\./g, '');
|
||||
|
||||
$('#currentversion').append(' V'+currentVersion);
|
||||
$('#latestversion').append(' V'+latestVersion);
|
||||
|
||||
if ( cleanCurrentVersion < cleanLatestVersion ) {
|
||||
$('#versioninforesult').append('<div lang="en" data-lang-token="dashboard_message_infobox_updatewarning" style="margin:0px;" class="alert alert-warning">A newer version of Hyperion is available!</div>');
|
||||
}
|
||||
else{
|
||||
$('#versioninforesult').append('<div lang="en" data-lang-token="dashboard_message_infobox_updatesuccess" style="margin:0px;" class="alert alert-success">You run the latest version of Hyperion.</div>');
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
$(function(){
|
||||
var sidebar = $('#side-menu'); // cache sidebar to a variable for performance
|
||||
|
1106
assets/webconfig/js/bootstrap-colorpicker.js
vendored
1106
assets/webconfig/js/bootstrap-colorpicker.js
vendored
File diff suppressed because it is too large
Load Diff
5
assets/webconfig/js/lib/bootstrap-colorpicker.min.js
vendored
Normal file
5
assets/webconfig/js/lib/bootstrap-colorpicker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -16,6 +16,8 @@
|
||||
"dashboard_label_infobox_device" : "Geräteinformation:",
|
||||
"dashboard_label_componentbox_title" : "Komponenten Status",
|
||||
"dashboard_label_newsbox_title" : "Die letzten Blogposts",
|
||||
"dashboard_message_infobox_updatewarning" : "Eine aktuellere Version von Hyperion ist verfügbar!",
|
||||
"dashboard_message_infobox_updatesuccess" : "Du nutzt die aktuellste Version von Hyperion.",
|
||||
"main_menu_dashboard_token" : "Dashboard",
|
||||
"main_menu_configuration_token" : "Konfiguration",
|
||||
"main_menu_kodiwatch_token" : "Kodi Überwachung",
|
||||
@ -23,14 +25,17 @@
|
||||
"main_menu_remotecontrol_token" : "Fernbedienung",
|
||||
"main_menu_colors_token" : "Farben",
|
||||
"main_menu_effects_token" : "Effekte",
|
||||
"main_menu_component_token" : "Komponenten",
|
||||
"main_menu_support_token" : "Hilfe",
|
||||
"main_menu_update_token" : "Update",
|
||||
"main_menu_system_token" : "System",
|
||||
"main_menu_general_conf_token":"Allgemein",
|
||||
"remote_colors_label_color":"Farbe: ",
|
||||
"remote_colors_button_reset":"Farbe zurücksetzen",
|
||||
"remote_effects_intro" : "Die Effekt-Fernbedienung ermöglicht es dir Effekte zu starten für Demonstrations- oder Testzwecke. Vergessse nicht den Effekt wieder zu stoppen, wenn du fertig bist.",
|
||||
"remote_effects_label_effects":"Effekte",
|
||||
"remote_effects_label_stopeffect":"Stoppe Effekte",
|
||||
"remote_components_intro" : "Die Komponenten-Fenbedienung ermöglicht es dir Komponenten von Hyperion zu starten und stoppen. Beachte: Dies ist nur temporär und geht nach einem Neustart verloren. Möchtest du dauerhaft Komponenten aktivieren/deaktivieren benutze die Konfigurationsseiten.",
|
||||
"hue_button_create_user_token":"Benutzer anlegen",
|
||||
"hue_press_link_modal":"Link Taste auf der Hue Bridge drücken und mit Button bestätigen.",
|
||||
"hue_press_link_modal_failure":"Bitte drücke die Link Taste auf deiner Hue Bridge.",
|
||||
@ -63,7 +68,7 @@
|
||||
"update_label_description" : "Beschreibung:",
|
||||
"update_button_install" : "Installieren",
|
||||
"update_button_changelog" : "Zeige Änderungsprotokoll",
|
||||
"update_label_type" : "Art:"
|
||||
"update_label_type" : "Art:",
|
||||
"remote_general_conf_intro" : "Hier kannst du allgemeine Einstellungen von Hyperion vornehmen.",
|
||||
"generalConfForm_jsonform-0-elt-logger.level" : "Stufe Logging",
|
||||
"generalConfForm_jsonform-0-elt-jsonServer.port" : "Port",
|
||||
|
@ -1,6 +1,3 @@
|
||||
<script src="js/bootstrap-colorpicker.js"></script>
|
||||
<link href="css/bootstrap-colorpicker.css" rel="stylesheet">
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
42
assets/webconfig/remote_components.html
Normal file
42
assets/webconfig/remote_components.html
Normal file
@ -0,0 +1,42 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header" lang="en" data-lang-token="main_menu_component_token">Effects</h1>
|
||||
<div class="introd">
|
||||
<h4 lang="en" data-lang-token="remote_components_intro">The components remote enables you to disable and enable certain components of Hyperion during runtime. Keep in mind this persist just until the next reboot! To enable/disable components permament, use the configuration section.</h4>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="col-lg-12" id="componentsbutton">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
webSocket = new WebSocket('ws://'+document.location.hostname+':19444');
|
||||
|
||||
new Enum('SMOOTHING', 'BLACKBORDER', 'KODICHECKER', 'FORWARDER', 'UDPLISTENER', 'BOBLIGHT_SERVER','GRABBER');
|
||||
|
||||
function Enum() {
|
||||
for (var i in arguments) {
|
||||
this[arguments[i]] = i;
|
||||
$('#componentsbutton').append('<button type="button" class="btn btn-success" onclick="compenable(\''+arguments[i]+'\')"><i class="fa fa-play"></i></button> '+arguments[i]+'<br />');
|
||||
$('#componentsbutton').append('<button type="button" class="btn btn-danger" onclick="compdisable(\''+arguments[i]+'\')"><i class="fa fa-play"></i></button> '+arguments[i]+'<br />');
|
||||
}
|
||||
}
|
||||
|
||||
function compenable(comp){
|
||||
|
||||
webSocket.send('{"command":"componentstate","componentstate":{"component":"'+comp+'","state":true}}');
|
||||
console.log('enable: '+comp);
|
||||
|
||||
}
|
||||
function compdisable(comp){
|
||||
|
||||
webSocket.send('{"command":"componentstate","componentstate":{"component":"'+comp+'","state":false}}');
|
||||
console.log('disable: '+comp);
|
||||
|
||||
}
|
||||
|
||||
</script>
|
@ -18,7 +18,7 @@ $.get( "https://raw.githubusercontent.com/hyperion-project/hyperion.ng/master/ve
|
||||
var vlist = JSON.parse(data);
|
||||
for (key in vlist)
|
||||
{
|
||||
$('#versionlist').append('<div class="col-lg-6"><div class="panel panel-default"><div class="panel-heading"><i class="fa fa-television fa-fw"></i>Hyperion V'+key+'</div><div class="panel-body"><p><span style="font-weight:bold;" lang="en" data-lang-token="update_label_type">Type:</span> '+ vlist[key].channel +'</p><p><span style="font-weight:bold;" lang="en" data-lang-token="update_label_description">Description:</span> '+vlist[key].versiondesc+'</p><hr><a class="btn btn-primary" href="'+ vlist[key].versionchangelog +'" target="_blank"><i class="fa fa-list fa-fw"></i><span style="font-weight:bold;" lang="en" data-lang-token="update_button_changelog">Full changelog</span></a><button type="button" class="btn btn-warning pull-right"><i class="fa fa-download fa-fw"></i><span lang="en" data-lang-token="update_button_install">Install</span></button></div></div></div>');
|
||||
$('#versionlist').append('<div class="col-lg-6"><div class="panel panel-default"><div class="panel-heading"><i class="fa fa-television fa-fw"></i>Hyperion V'+vlist[key].versionnr+'</div><div class="panel-body"><p><span style="font-weight:bold;" lang="en" data-lang-token="update_label_type">Type:</span> '+ vlist[key].channel +'</p><p><span style="font-weight:bold;" lang="en" data-lang-token="update_label_description">Description:</span> '+vlist[key].versiondesc+'</p><hr><a class="btn btn-primary" href="'+ vlist[key].versionchangelog +'" target="_blank"><i class="fa fa-list fa-fw"></i><span style="font-weight:bold;" lang="en" data-lang-token="update_button_changelog">Full changelog</span></a><button type="button" class="btn btn-warning pull-right"><i class="fa fa-download fa-fw"></i><span lang="en" data-lang-token="update_button_install">Install</span></button></div></div></div>');
|
||||
}
|
||||
|
||||
});
|
||||
|
1
bin/.gitignore
vendored
Normal file
1
bin/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
protoc
|
1
config/.gitignore
vendored
Normal file
1
config/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/*.json
|
1
dependencies/CMakeLists.txt
vendored
1
dependencies/CMakeLists.txt
vendored
@ -1,4 +1,3 @@
|
||||
add_subdirectory(build/getoptPlusPlus)
|
||||
add_subdirectory(build/hidapi)
|
||||
add_subdirectory(build/jsoncpp)
|
||||
add_subdirectory(build/tinkerforge)
|
||||
|
BIN
dependencies/LightberryHDUSBAPA1021.1.zip
vendored
BIN
dependencies/LightberryHDUSBAPA1021.1.zip
vendored
Binary file not shown.
@ -1,9 +0,0 @@
|
||||
project(getoptPlusPlus)
|
||||
|
||||
include_directories(
|
||||
../../include/getoptPlusPlus)
|
||||
|
||||
add_library(getoptPlusPlus
|
||||
../../include/getoptPlusPlus/getoptpp.h
|
||||
../../include/getoptPlusPlus/parameter.include.cc
|
||||
getoptpp.cc)
|
66
dependencies/build/getoptPlusPlus/COPYING
vendored
66
dependencies/build/getoptPlusPlus/COPYING
vendored
@ -1,66 +0,0 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
|
||||
|
||||
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
||||
|
||||
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
||||
|
||||
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
|
||||
|
||||
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
||||
|
||||
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
||||
|
||||
* a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
||||
* b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
||||
|
||||
* a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
||||
* b) Accompany the object code with a copy of the GNU GPL and this license document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
||||
|
||||
* a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
||||
* b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
||||
* c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
||||
* d) Do one of the following:
|
||||
o 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
||||
o 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
||||
* e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
||||
|
||||
* a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
||||
* b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
||||
|
16
dependencies/build/getoptPlusPlus/Makefile
vendored
16
dependencies/build/getoptPlusPlus/Makefile
vendored
@ -1,16 +0,0 @@
|
||||
SOURCES=getoptpp.cc test.cc
|
||||
HEADERS=getoptpp.h
|
||||
OBJECTS=$(SOURCES:.cc=.o)
|
||||
LDFLAGS=
|
||||
CXXFLAGS=-O0 -ggdb -Wall
|
||||
CFLAGS=$(CXXFLAGS)
|
||||
CC=g++
|
||||
TARGET=getopt-test
|
||||
|
||||
all: $(TARGET)
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CXX) $(LDFLAGS) -o $(TARGET) $(OBJECTS)
|
||||
$(SOURCES): $(HEADERS)
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) $(OBJECTS) *~
|
8
dependencies/build/getoptPlusPlus/README
vendored
8
dependencies/build/getoptPlusPlus/README
vendored
@ -1,8 +0,0 @@
|
||||
A very small class library that replaces getopt() and
|
||||
getopt_long()-functionality with a more C++-friendly approach.
|
||||
|
||||
Additionally, it does not rely on UNIX-specific code.
|
||||
|
||||
See test.cc for a sample application and COPYING for license information.
|
||||
|
||||
|
1630
dependencies/build/getoptPlusPlus/config.doxygen
vendored
1630
dependencies/build/getoptPlusPlus/config.doxygen
vendored
File diff suppressed because it is too large
Load Diff
357
dependencies/build/getoptPlusPlus/getoptpp.cc
vendored
357
dependencies/build/getoptPlusPlus/getoptpp.cc
vendored
@ -1,357 +0,0 @@
|
||||
/* (C) 2011 Viktor Lofgren
|
||||
*
|
||||
* This program 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
|
||||
* any later version.
|
||||
*
|
||||
* This program 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/>.
|
||||
*/
|
||||
|
||||
#include "getoptpp.h"
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace vlofgren {
|
||||
|
||||
/*
|
||||
*
|
||||
* Class OptionsParser
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
OptionsParser::OptionsParser(const char* programDesc) : fprogramDesc(programDesc) {}
|
||||
OptionsParser::~OptionsParser() {}
|
||||
|
||||
ParameterSet& OptionsParser::getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
void OptionsParser::parse(int argc, const char* argv[]) throw(runtime_error)
|
||||
{
|
||||
argv0 = argv[0];
|
||||
|
||||
if(argc == 1) return;
|
||||
|
||||
vector<string> v(&argv[1], &argv[argc]);
|
||||
|
||||
ParserState state(/* *this,*/ v);
|
||||
|
||||
for(; !state.end(); state.advance()) {
|
||||
|
||||
std::list<Parameter*>::iterator i;
|
||||
|
||||
for(i = parameters.parameters.begin();
|
||||
i != parameters.parameters.end(); i++)
|
||||
{
|
||||
int n = 0;
|
||||
try
|
||||
{
|
||||
n = (*i)->receive(state);
|
||||
}
|
||||
catch(Parameter::ExpectedArgument &)
|
||||
{
|
||||
throw Parameter::ExpectedArgument(state.get() + ": expected an argument");
|
||||
}
|
||||
catch(Parameter::UnexpectedArgument &)
|
||||
{
|
||||
throw Parameter::UnexpectedArgument(state.get() + ": did not expect an argument");
|
||||
}
|
||||
catch(Switchable::SwitchingError &)
|
||||
{
|
||||
throw Parameter::ParameterRejected(state.get() + ": parameter already set");
|
||||
}
|
||||
catch(Parameter::ParameterRejected & pr) {
|
||||
std::string what = pr.what();
|
||||
if(what.length())
|
||||
{
|
||||
throw Parameter::ParameterRejected(state.get() + ": " + what);
|
||||
}
|
||||
throw Parameter::ParameterRejected(state.get() + " (unspecified error)");
|
||||
}
|
||||
|
||||
for (int j = 1; j < n; ++j)
|
||||
{
|
||||
state.advance();
|
||||
}
|
||||
|
||||
if(n != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(i == parameters.parameters.end()) {
|
||||
std::string file = state.get();
|
||||
if(file == "--") {
|
||||
state.advance();
|
||||
break;
|
||||
}
|
||||
else if(file.at(0) == '-')
|
||||
throw Parameter::ParameterRejected(string("Bad parameter: ") + file);
|
||||
else files.push_back(state.get());
|
||||
}
|
||||
}
|
||||
|
||||
if(!state.end()) for(; !state.end(); state.advance()) {
|
||||
files.push_back(state.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OptionsParser::usage() const {
|
||||
cerr << fprogramDesc << endl;
|
||||
cerr << "Build time: " << __DATE__ << " " << __TIME__ << endl << endl;
|
||||
cerr << "Usage: " << programName() << " [OPTIONS]" << endl << endl;
|
||||
|
||||
cerr << "Parameters: " << endl;
|
||||
|
||||
int totalWidth = 80;
|
||||
int usageWidth = 33;
|
||||
|
||||
// read total width from the terminal
|
||||
struct winsize w;
|
||||
if (ioctl(0, TIOCGWINSZ, &w) == 0)
|
||||
{
|
||||
if (w.ws_col > totalWidth)
|
||||
totalWidth = w.ws_col;
|
||||
}
|
||||
|
||||
std::list<Parameter*>::const_iterator i;
|
||||
for(i = parameters.parameters.begin();
|
||||
i != parameters.parameters.end(); i++)
|
||||
{
|
||||
cerr.width(usageWidth);
|
||||
cerr << std::left << " " + (*i)->usageLine();
|
||||
|
||||
std::string description = (*i)->description();
|
||||
while (int(description.length()) > (totalWidth - usageWidth))
|
||||
{
|
||||
size_t pos = description.find_last_of(' ', totalWidth - usageWidth);
|
||||
cerr << description.substr(0, pos) << std::endl << std::string(usageWidth - 1, ' ');
|
||||
description = description.substr(pos);
|
||||
}
|
||||
cerr << description << endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const vector<string>& OptionsParser::getFiles() const {
|
||||
return files;
|
||||
}
|
||||
|
||||
const string& OptionsParser::programName() const {
|
||||
return argv0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parameter set
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
ParameterSet::ParameterSet(const ParameterSet& ps) {
|
||||
throw new runtime_error("ParameterSet not copyable");
|
||||
}
|
||||
|
||||
ParameterSet::~ParameterSet() {
|
||||
for(std::list<Parameter*>::iterator i = parameters.begin();
|
||||
i != parameters.end(); i++)
|
||||
{
|
||||
delete *i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* The typical use case for command line arguments makes linear searching completely
|
||||
* acceptable here.
|
||||
*/
|
||||
|
||||
Parameter& ParameterSet::operator[](char c) const {
|
||||
for(std::list<Parameter*>::const_iterator i = parameters.begin(); i!= parameters.end(); i++) {
|
||||
if((*i)->shortOption() == c) return *(*i);
|
||||
}
|
||||
throw out_of_range("ParameterSet["+string(&c)+string("]"));
|
||||
}
|
||||
|
||||
|
||||
Parameter& ParameterSet::operator[](const string& param) const {
|
||||
for(std::list<Parameter*>::const_iterator i = parameters.begin(); i!= parameters.end(); i++) {
|
||||
if((*i)->longOption() == param) return *(*i);
|
||||
}
|
||||
throw out_of_range("ParameterSet["+param+"]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Class ParserState
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
ParserState::ParserState(/*OptionsParser &opts, */vector<string>& args) :
|
||||
/*opts(opts),*/ arguments(args), iterator(args.begin())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const string ParserState::peek() const {
|
||||
vector<string>::const_iterator next = iterator+1;
|
||||
if(next != arguments.end()) return *next;
|
||||
else return "";
|
||||
|
||||
}
|
||||
|
||||
const string ParserState::get() const {
|
||||
if(!end()) return *iterator;
|
||||
else return "";
|
||||
}
|
||||
|
||||
void ParserState::advance() {
|
||||
iterator++;
|
||||
}
|
||||
|
||||
bool ParserState::end() const {
|
||||
return iterator == arguments.end();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Class Parameter
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
Parameter::Parameter(char shortOption, const std::string & longOption, const std::string & description) :
|
||||
fshortOption(shortOption), flongOption(longOption), fdescription(description)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Parameter::~Parameter() {}
|
||||
|
||||
const string& Parameter::description() const { return fdescription; }
|
||||
const string& Parameter::longOption() const { return flongOption; }
|
||||
bool Parameter::hasShortOption() const { return fshortOption != 0x0; }
|
||||
char Parameter::shortOption() const { assert(hasShortOption()); return fshortOption; }
|
||||
|
||||
/*
|
||||
*
|
||||
* Class Switchable
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
bool Switchable::isSet() const { return fset; }
|
||||
Switchable::~Switchable() {};
|
||||
Switchable::Switchable() : fset(false) {}
|
||||
|
||||
void MultiSwitchable::set() throw (Switchable::SwitchingError) { fset = true; }
|
||||
MultiSwitchable::~MultiSwitchable() {}
|
||||
|
||||
|
||||
void UniquelySwitchable::set() throw (Switchable::SwitchingError) {
|
||||
if(UniquelySwitchable::isSet()) throw Switchable::SwitchingError();
|
||||
fset = true;
|
||||
}
|
||||
UniquelySwitchable::~UniquelySwitchable() {}
|
||||
|
||||
|
||||
PresettableUniquelySwitchable::~PresettableUniquelySwitchable() {}
|
||||
bool PresettableUniquelySwitchable::isSet() const {
|
||||
return UniquelySwitchable::isSet() || fpreset.isSet();
|
||||
}
|
||||
void PresettableUniquelySwitchable::set() throw (Switchable::SwitchingError)
|
||||
{
|
||||
UniquelySwitchable::set();
|
||||
}
|
||||
void PresettableUniquelySwitchable::preset() {
|
||||
fpreset.set();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* PODParameter specializations
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
template<>
|
||||
PODParameter<string>::PODParameter(char shortOption, const char *longOption,
|
||||
const char* description) : CommonParameter<PresettableUniquelySwitchable>(shortOption, longOption, description) {
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
int PODParameter<int>::validate(const string &s) throw(Parameter::ParameterRejected)
|
||||
{
|
||||
// This is sadly necessary for strto*-functions to operate on
|
||||
// const char*. The function doesn't write to the memory, though,
|
||||
// so it's quite safe.
|
||||
|
||||
char* cstr = const_cast<char*>(s.c_str());
|
||||
if(*cstr == '\0') throw ParameterRejected("No argument given");
|
||||
|
||||
long l = strtol(cstr, &cstr, 10);
|
||||
if(*cstr != '\0') throw ParameterRejected("Expected int");
|
||||
|
||||
if(l > INT_MAX || l < INT_MIN) {
|
||||
throw ParameterRejected("Expected int");
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
template<>
|
||||
long PODParameter<long>::validate(const string &s) throw(Parameter::ParameterRejected)
|
||||
{
|
||||
char* cstr = const_cast<char*>(s.c_str());
|
||||
if(*cstr == '\0') throw ParameterRejected("No argument given");
|
||||
|
||||
long l = strtol(cstr, &cstr, 10);
|
||||
if(*cstr != '\0') throw ParameterRejected("Expected long");
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
template<>
|
||||
double PODParameter<double>::validate(const string &s) throw(Parameter::ParameterRejected)
|
||||
{
|
||||
char* cstr = const_cast<char*>(s.c_str());
|
||||
if(*cstr == '\0') throw ParameterRejected("No argument given");
|
||||
|
||||
double d = strtod(cstr, &cstr);
|
||||
if(*cstr != '\0') throw ParameterRejected("Expected double");
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
template<>
|
||||
string PODParameter<string>::validate(const string &s) throw(Parameter::ParameterRejected)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
} //namespace
|
196
dependencies/build/getoptPlusPlus/test.cc
vendored
196
dependencies/build/getoptPlusPlus/test.cc
vendored
@ -1,196 +0,0 @@
|
||||
/* (C) 2011 Viktor Lofgren
|
||||
*
|
||||
* This program 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
|
||||
* any later version.
|
||||
*
|
||||
* This program 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/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "getoptpp.h"
|
||||
#include <cstdlib>
|
||||
#include <cctype>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
using namespace vlofgren;
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
/*
|
||||
*
|
||||
* This is one way of adding new parameter types,
|
||||
* inheriting existing types and adding new validation.
|
||||
*
|
||||
* In this case, StringParameter (which is a typedef of PODParameter<string> gets
|
||||
* a new validator that only accepts strings with only letters.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class AlphabeticParameter : public StringParameter {
|
||||
public:
|
||||
AlphabeticParameter(char shortName, const char* longName, const char* description) :
|
||||
StringParameter(shortName, longName, description) {}
|
||||
virtual ~AlphabeticParameter() {}
|
||||
|
||||
void receiveSwitch() throw(Parameter::ParameterRejected) {
|
||||
throw Parameter::ParameterRejected();
|
||||
}
|
||||
|
||||
|
||||
/* isalpha may be a macro */
|
||||
static bool isNotAlpha(char c) { return !isalpha(c); }
|
||||
|
||||
virtual string validate(const string& arg) throw(Parameter::ParameterRejected) {
|
||||
int nonalpha = count_if(arg.begin(), arg.end(), isNotAlpha);
|
||||
|
||||
|
||||
if(nonalpha) throw Parameter::ParameterRejected("I only want numbers");
|
||||
else return arg;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
*
|
||||
* The other way is to specialize the PODParameter class
|
||||
*
|
||||
*/
|
||||
|
||||
enum RockPaperScissor { ROCK, PAPER, SCISSOR } ;
|
||||
|
||||
namespace vlofgren {
|
||||
// needs to live in the vlofgren namespace for whatever reason
|
||||
template<> enum RockPaperScissor
|
||||
PODParameter<enum RockPaperScissor>::validate(const string &s) throw(Parameter::ParameterRejected)
|
||||
{
|
||||
if(s == "rock")
|
||||
return ROCK;
|
||||
else if(s == "paper")
|
||||
return PAPER;
|
||||
else if(s == "scissor")
|
||||
return SCISSOR;
|
||||
else {
|
||||
throw ParameterRejected("Invalid argument");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
typedef PODParameter<enum RockPaperScissor> RockPaperScissorParameter;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Dummy program
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
|
||||
// Create a parser
|
||||
|
||||
OptionsParser optp("An example program (that also runs some tests)");
|
||||
ParameterSet& ps = optp.getParameters();
|
||||
|
||||
/* An alternative option is to simply extend the options parser and set all this up
|
||||
* in the constructor.
|
||||
*/
|
||||
|
||||
ps.add<SwitchParameter>('f', "foo", "Enable the foo system (no argument)");
|
||||
ps.add<StringParameter>('b', "bar", "Enable the bar system (string argument)");
|
||||
ps.add<PODParameter<double> >('z', "baz", "Enable the baz system (floating point argument");
|
||||
|
||||
PODParameter<int>& i = ps.add<PODParameter<int> >('i', "foobar", "Enable the foobar system (integer argument");
|
||||
i.setDefault(15);
|
||||
|
||||
ps.add<AlphabeticParameter>('a', "alpha", "Custom parameter that requires a string of letters");
|
||||
ps.add<RockPaperScissorParameter>('r', "rps", "Takes the values rock, paper or scissor");
|
||||
ps.add<SwitchParameter>('h', "help", "Display help screen");
|
||||
|
||||
|
||||
// Register the parameters with the parser
|
||||
|
||||
try {
|
||||
// Parse argv
|
||||
optp.parse(argc, argv);
|
||||
|
||||
// Test for the help flag
|
||||
if(ps['h'].isSet()) {
|
||||
optp.usage();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// Print out what values the parameters were given
|
||||
|
||||
cout << "The following parameters were set:" << endl;
|
||||
|
||||
cout << "foo: " << (ps['f'].isSet() ? "true" : "false") << endl;
|
||||
cout << "bar: \"" << ps['b'].get<string>() << "\""<< endl;
|
||||
cout << "baz: ";
|
||||
|
||||
if(ps['z'].isSet()) {
|
||||
cout << ps['z'].get<double>() << endl;
|
||||
} else {
|
||||
cout << "not set" << endl;
|
||||
}
|
||||
|
||||
/* You can also save the return value from ParserSet::add() if
|
||||
* you feel the operator[].get<T>() stuff is a bit much */
|
||||
cout << "foobar: ";
|
||||
if(i.isSet()) {
|
||||
cout << i.get<int>() << endl;
|
||||
} else {
|
||||
cout << "not set" << endl;
|
||||
}
|
||||
cout << "alpha: ";
|
||||
if(ps["alpha"].isSet()) {
|
||||
cout << ps["alpha"].get<string>() << endl;
|
||||
} else {
|
||||
cout << "not set" << endl;
|
||||
}
|
||||
|
||||
cout << "rps: ";
|
||||
if(ps["rps"].isSet()) {
|
||||
cout << ps["rps"].get<enum RockPaperScissor>() << endl;
|
||||
} else {
|
||||
cout << "not set" << endl;
|
||||
}
|
||||
|
||||
} catch(Parameter::ParameterRejected &p){
|
||||
// This will happen if the user has fed some malformed parameter to the program
|
||||
cerr << p.what() << endl;
|
||||
optp.usage();
|
||||
return EXIT_FAILURE;
|
||||
} catch(runtime_error &e) {
|
||||
// This will happen if you try to access a parameter that hasn't been set
|
||||
cerr << e.what() << endl;
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// List what non-parameter options were given (typically files)
|
||||
cout << "The following file arguments were given:" << endl;
|
||||
|
||||
vector<string> files = optp.getFiles();
|
||||
for(vector<string>::iterator i = files.begin(); i != files.end(); i++) {
|
||||
cout << "\t" << *i << endl;
|
||||
}
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
BIN
dependencies/getoptPlusPlus-master-20130810.zip
vendored
BIN
dependencies/getoptPlusPlus-master-20130810.zip
vendored
Binary file not shown.
398
dependencies/include/getoptPlusPlus/getoptpp.h
vendored
398
dependencies/include/getoptPlusPlus/getoptpp.h
vendored
@ -1,398 +0,0 @@
|
||||
/* (C) 2011 Viktor Lofgren
|
||||
*
|
||||
* This program 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
|
||||
* any later version.
|
||||
*
|
||||
* This program 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modifications:
|
||||
*
|
||||
* - Removed using namespace std from header
|
||||
* - Changed Parameter container type from std::set to std::list to presume order
|
||||
* - Changed arguments of Parameters to be a seperated arguments on the command line
|
||||
* - Make the choice of receiving arguments or not in subclasses of CommonParameter
|
||||
*/
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
#ifndef GETOPTPP_H
|
||||
#define GETOPTPP_H
|
||||
|
||||
namespace vlofgren {
|
||||
|
||||
class Parameter;
|
||||
class ParserState;
|
||||
|
||||
class OptionsParser;
|
||||
|
||||
/** Container for a set of parameters */
|
||||
|
||||
class ParameterSet {
|
||||
public:
|
||||
|
||||
/** Find a parameter by short option form */
|
||||
Parameter& operator[](char c) const;
|
||||
|
||||
/** Find a parameter by long option form. */
|
||||
Parameter& operator[](const std::string &s) const;
|
||||
|
||||
/** Factory method that adds a new parameter of
|
||||
* type T to the set.
|
||||
*
|
||||
* This is just for convenience. It allows ParameterSet
|
||||
* to manage the pointers, as well as (usually) making the
|
||||
* code slightly easier to read.
|
||||
*
|
||||
* Do not try to add non-Parameter types lest you will invoke
|
||||
* the wrath of gcc's template error messages.
|
||||
*
|
||||
* @returns The created parameter. The reference is valid
|
||||
* as long as ParameterSet exists.
|
||||
*/
|
||||
template<typename T>
|
||||
T &add(char shortName, const char* longName, const char* description);
|
||||
|
||||
ParameterSet() {}
|
||||
~ParameterSet();
|
||||
protected:
|
||||
friend class OptionsParser;
|
||||
std::list<Parameter*> parameters;
|
||||
|
||||
private:
|
||||
ParameterSet(const ParameterSet& ps);
|
||||
};
|
||||
|
||||
/** getopt()-style parser for command line arguments
|
||||
*
|
||||
* Matches each element in argv against given
|
||||
* parameters, and collects non-parameter arguments
|
||||
* (typically files) in a vector.
|
||||
*
|
||||
*/
|
||||
|
||||
class OptionsParser {
|
||||
public:
|
||||
OptionsParser(const char *programDesc);
|
||||
virtual ~OptionsParser();
|
||||
|
||||
ParameterSet& getParameters();
|
||||
|
||||
/** Parse command line arguments */
|
||||
void parse(int argc, const char* argv[]) throw(std::runtime_error);
|
||||
|
||||
/** Generate a usage screen */
|
||||
void usage() const;
|
||||
|
||||
/** Return the name of the program, as
|
||||
* given by argv[0]
|
||||
*/
|
||||
const std::string& programName() const;
|
||||
|
||||
/** Return a vector of each non-parameter */
|
||||
const std::vector<std::string>& getFiles() const;
|
||||
protected:
|
||||
std::string argv0;
|
||||
std::string fprogramDesc;
|
||||
|
||||
ParameterSet parameters;
|
||||
std::vector<std::string> files;
|
||||
|
||||
friend class ParserState;
|
||||
};
|
||||
|
||||
/**
|
||||
* Corresponds to the state of the parsing, basically just a wrapper
|
||||
* for a const_iterator that handles nicer.
|
||||
*/
|
||||
|
||||
class ParserState {
|
||||
public:
|
||||
const std::string peek() const;
|
||||
const std::string get() const;
|
||||
void advance();
|
||||
bool end() const;
|
||||
protected:
|
||||
ParserState(/*OptionsParser &opts,*/ std::vector<std::string>& args);
|
||||
private:
|
||||
friend class OptionsParser;
|
||||
|
||||
// OptionsParser &opts;
|
||||
const std::vector<std::string> &arguments;
|
||||
std::vector<std::string>::const_iterator iterator;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Abstract base class of all parameters
|
||||
*
|
||||
*/
|
||||
|
||||
class Parameter {
|
||||
public:
|
||||
|
||||
/** Generic exception thrown when a parameter is malformed
|
||||
*/
|
||||
class ParameterRejected : public std::runtime_error {
|
||||
public:
|
||||
ParameterRejected(const std::string& s) : std::runtime_error(s) {}
|
||||
ParameterRejected() : runtime_error("") {}
|
||||
};
|
||||
|
||||
/** Exception thrown when a parameter did not expect an argument */
|
||||
class UnexpectedArgument : public ParameterRejected {
|
||||
public:
|
||||
UnexpectedArgument(const std::string &s) : ParameterRejected(s) {}
|
||||
UnexpectedArgument() {}
|
||||
};
|
||||
|
||||
/** Exception thrown when a parameter expected an argument */
|
||||
class ExpectedArgument : public ParameterRejected {
|
||||
public:
|
||||
ExpectedArgument(const std::string &s) : ParameterRejected(s) {}
|
||||
ExpectedArgument() {}
|
||||
};
|
||||
|
||||
Parameter(char shortOption, const std::string & longOption, const std::string & description);
|
||||
|
||||
virtual ~Parameter();
|
||||
|
||||
/** Test whether the parameter has been set */
|
||||
virtual bool isSet() const = 0;
|
||||
|
||||
/** This parameter's line in OptionsParser::usage() */
|
||||
virtual std::string usageLine() const = 0;
|
||||
|
||||
/** Description of the parameter (rightmost field in OptionsParser::usage()) */
|
||||
const std::string& description() const;
|
||||
|
||||
/** The long name of this parameter (e.g. "--option"), without the dash. */
|
||||
const std::string& longOption() const;
|
||||
|
||||
/** Check if this parameters has a short option */
|
||||
bool hasShortOption() const;
|
||||
|
||||
/** The short name of this parameter (e.g. "-o"), without the dash. */
|
||||
char shortOption() const;
|
||||
|
||||
protected:
|
||||
|
||||
/** Receive a potential parameter from the parser (and determien if it's ours)
|
||||
*
|
||||
* The parser will pass each potential parameter through it's registered parameters'
|
||||
* receive function.
|
||||
*
|
||||
* @throw ParameterRejected if the parameter belongs to us, but is malformed somehow.
|
||||
*
|
||||
* @param state Allows access to the current argument. This is a fairly powerful
|
||||
* iterator that technically allows for more complex grammar than what is
|
||||
* presently used.
|
||||
*/
|
||||
virtual int receive(ParserState& state) throw(ParameterRejected) = 0;
|
||||
|
||||
friend class OptionsParser;
|
||||
|
||||
char fshortOption;
|
||||
const std::string flongOption;
|
||||
const std::string fdescription;
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
*
|
||||
* Abstract base class of all parameters
|
||||
*
|
||||
*/
|
||||
|
||||
class Switchable;
|
||||
|
||||
/** Base class for most parameter implementations.
|
||||
*
|
||||
* It parses the argument in receive() and if it matches,
|
||||
* calls receiveSwitch() or receiveArgument() which are implemented
|
||||
* in child classes.
|
||||
*
|
||||
* The SwitchingBehavior mixin determines what happens if the argument
|
||||
* is set multiple times.
|
||||
*/
|
||||
|
||||
template<typename SwitchingBehavior=Switchable>
|
||||
class CommonParameter : public Parameter, protected SwitchingBehavior {
|
||||
public:
|
||||
|
||||
/** Test whether the parameter has been set */
|
||||
virtual bool isSet() const;
|
||||
|
||||
CommonParameter(char shortOption, const char *longOption,
|
||||
const char* description);
|
||||
virtual ~CommonParameter();
|
||||
|
||||
virtual std::string usageLine() const;
|
||||
|
||||
protected:
|
||||
/** Parse the argument given by state, and dispatch either
|
||||
* receiveSwitch() or receiveArgument() accordingly.
|
||||
*
|
||||
* @param state The current argument being parsed.
|
||||
* @return The number of parameters taken from the input
|
||||
*/
|
||||
virtual int receive(ParserState& state) throw(ParameterRejected) = 0;
|
||||
};
|
||||
|
||||
/** This class (used as a mixin) defines how a parameter
|
||||
* behaves when switched on, specifically when switched on multiple times.
|
||||
*
|
||||
*/
|
||||
class Switchable {
|
||||
public:
|
||||
class SwitchingError : public Parameter::ParameterRejected {};
|
||||
|
||||
/** Test whether the parameter has been set */
|
||||
virtual bool isSet() const;
|
||||
|
||||
/** Set the parameter
|
||||
*
|
||||
*/
|
||||
virtual void set() throw (SwitchingError) = 0;
|
||||
|
||||
virtual ~Switchable();
|
||||
Switchable();
|
||||
protected:
|
||||
bool fset;
|
||||
};
|
||||
|
||||
/** Switching behavior that does not complain when set multiple times. */
|
||||
class MultiSwitchable : public Switchable {
|
||||
public:
|
||||
virtual ~MultiSwitchable();
|
||||
virtual void set() throw(SwitchingError);
|
||||
|
||||
};
|
||||
|
||||
/** Switching behavior that allows switching only once.
|
||||
*
|
||||
* This is typically what you want if your parameter has an argument.
|
||||
*
|
||||
*/
|
||||
class UniquelySwitchable : public Switchable {
|
||||
public:
|
||||
|
||||
virtual ~UniquelySwitchable();
|
||||
|
||||
/** Set the parameter
|
||||
*
|
||||
* @throw SwitchingError Thrown if the parameter is already set.
|
||||
*/
|
||||
virtual void set() throw (SwitchingError);
|
||||
};
|
||||
|
||||
/** Switching behavior that makes possible allows presettable parameters,
|
||||
* that is, it can either be set by the program, or by a command line argument,
|
||||
* and the command-line part is UniquelySwitchable, but the program part
|
||||
* is MultiSwitchable (and is set by preset())
|
||||
*
|
||||
*
|
||||
*/
|
||||
class PresettableUniquelySwitchable : public UniquelySwitchable {
|
||||
public:
|
||||
|
||||
/** Test whether the parameter has been set OR preset */
|
||||
virtual bool isSet() const;
|
||||
|
||||
/** Call if the parameter has been set.
|
||||
*
|
||||
* @throw SwitchingError thrown if the parameter is already set
|
||||
* (doesn't care if it's been pre-set)
|
||||
*/
|
||||
virtual void set() throw (Switchable::SwitchingError);
|
||||
|
||||
/** Call if the parameter has been preset */
|
||||
virtual void preset();
|
||||
|
||||
virtual ~PresettableUniquelySwitchable();
|
||||
private:
|
||||
MultiSwitchable fpreset;
|
||||
};
|
||||
|
||||
/* Parameter that does not take an argument, and throws an exception
|
||||
* if an argument is given */
|
||||
|
||||
template<typename SwitchingBehavior=MultiSwitchable>
|
||||
class SwitchParameter : public CommonParameter<SwitchingBehavior> {
|
||||
public:
|
||||
SwitchParameter(char shortOption, const char *longOption,
|
||||
const char* description);
|
||||
virtual ~SwitchParameter();
|
||||
|
||||
protected:
|
||||
virtual int receive(ParserState& state) throw(Parameter::ParameterRejected);
|
||||
};
|
||||
|
||||
/** Plain-Old-Data parameter. Performs input validation.
|
||||
*
|
||||
* Currently only supports int, long and double, but extending
|
||||
* it to other types (even non-POD) is as easy as partial template specialization.
|
||||
*
|
||||
* Specifically, you need to specialize validate().
|
||||
*/
|
||||
|
||||
template<typename T, typename SwitchingBehavior=PresettableUniquelySwitchable>
|
||||
class PODParameter : public CommonParameter<SwitchingBehavior> {
|
||||
public:
|
||||
PODParameter(char shortOption, const char *longOption,
|
||||
const char* description);
|
||||
virtual ~PODParameter();
|
||||
|
||||
/* Retreive the value of the argument. Throws an exception if
|
||||
* the value hasn't been set (test with isSet())
|
||||
*/
|
||||
T getValue() const;
|
||||
|
||||
/** Type-casting operator, for convenience. */
|
||||
operator T() const;
|
||||
|
||||
/** Set a default value for this parameter */
|
||||
virtual void setDefault(T value);
|
||||
|
||||
std::string usageLine() const;
|
||||
protected:
|
||||
virtual int receive(ParserState& state) throw(Parameter::ParameterRejected);
|
||||
|
||||
/** Validation function for the data type.
|
||||
*
|
||||
* @throw ParameterRejected if the argument does not conform to this data type.
|
||||
* @return the value corresponding to the argument.
|
||||
*/
|
||||
virtual T validate(const std::string& s) throw (Parameter::ParameterRejected);
|
||||
|
||||
T value;
|
||||
};
|
||||
|
||||
|
||||
typedef PODParameter<int> IntParameter;
|
||||
typedef PODParameter<long> LongParameter;
|
||||
typedef PODParameter<double> DoubleParameter;
|
||||
typedef PODParameter<std::string> StringParameter;
|
||||
|
||||
#include "parameter.include.cc"
|
||||
|
||||
} //namespace
|
||||
|
||||
#endif
|
@ -1,177 +0,0 @@
|
||||
/* (C) 2011 Viktor Lofgren
|
||||
*
|
||||
* This program 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
|
||||
* any later version.
|
||||
*
|
||||
* This program 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/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef GETOPTPP_H
|
||||
|
||||
|
||||
/* This file contains template voodoo, and due to the unique way GCC handles
|
||||
* templates, it needs to be included as a header (and it -is-). Do not attempt to
|
||||
* compile this file directly!
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
T &ParameterSet::add(char shortName, const char* longName, const char* description) {
|
||||
T* p = new T(shortName, longName, description);
|
||||
parameters.push_back(p);
|
||||
return *p;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Class CommonParameter implementation
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
template<typename SwitchingBehavior>
|
||||
CommonParameter<SwitchingBehavior>::~CommonParameter() {}
|
||||
|
||||
template<typename SwitchingBehavior>
|
||||
CommonParameter<SwitchingBehavior>::CommonParameter(char shortOption, const char *longOption,
|
||||
const char* description) : Parameter(shortOption, longOption, description) {}
|
||||
|
||||
template<typename SwitchingBehavior>
|
||||
bool CommonParameter<SwitchingBehavior>::isSet() const{
|
||||
return SwitchingBehavior::isSet();
|
||||
}
|
||||
|
||||
template<typename SwitchingBehavior>
|
||||
std::string CommonParameter<SwitchingBehavior>::usageLine() const {
|
||||
std::stringstream strstr;
|
||||
|
||||
if (hasShortOption())
|
||||
{
|
||||
strstr << "-" << shortOption() << ", ";
|
||||
}
|
||||
else
|
||||
{
|
||||
strstr << " ";
|
||||
}
|
||||
strstr.width(20);
|
||||
strstr << std::left << "--" + longOption();
|
||||
|
||||
return strstr.str();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Class SwitchParameter
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
template<typename SwitchingBehavior>
|
||||
SwitchParameter<SwitchingBehavior>::SwitchParameter(char shortOption, const char *longOption,
|
||||
const char* description) : CommonParameter<SwitchingBehavior>(shortOption, longOption, description) {}
|
||||
template<typename SwitchingBehavior>
|
||||
SwitchParameter<SwitchingBehavior>::~SwitchParameter() {}
|
||||
|
||||
template<typename SwitchingBehavior>
|
||||
int SwitchParameter<SwitchingBehavior>::receive(ParserState& state) throw(Parameter::ParameterRejected) {
|
||||
|
||||
const std::string arg = state.get();
|
||||
|
||||
if(arg.at(0) != '-') return false;
|
||||
|
||||
if ((arg.at(1) == '-' && arg.substr(2) == this->longOption()) ||
|
||||
(this->hasShortOption() && arg.at(1) == this->shortOption() && arg.length() == 2))
|
||||
{
|
||||
this->set();
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* PODParameter stuff
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
template<typename T, typename SwitchingBehavior>
|
||||
PODParameter<T, SwitchingBehavior>::PODParameter(char shortOption, const char *longOption,
|
||||
const char* description) : CommonParameter<PresettableUniquelySwitchable>(shortOption, longOption, description) {}
|
||||
|
||||
template<typename T, typename SwitchingBehavior>
|
||||
PODParameter<T, SwitchingBehavior>::~PODParameter() {}
|
||||
|
||||
template<typename T, typename SwitchingBehavior>
|
||||
PODParameter<T, SwitchingBehavior>::operator T() const { return getValue(); }
|
||||
|
||||
template<typename T, typename SwitchingBehavior>
|
||||
void PODParameter<T, SwitchingBehavior>::setDefault(T value) {
|
||||
PresettableUniquelySwitchable::preset();
|
||||
this->value = value;
|
||||
}
|
||||
|
||||
template<typename T, typename SwitchingBehavior>
|
||||
T PODParameter<T, SwitchingBehavior>::getValue() const {
|
||||
if(!this->isSet()) {
|
||||
throw std::runtime_error(
|
||||
std::string("Attempting to retreive the argument of parameter") + this->longOption() + " but it hasn't been set!");
|
||||
}
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
template<typename T, typename SwitchingBehavior>
|
||||
std::string PODParameter<T, SwitchingBehavior>::usageLine() const {
|
||||
std::stringstream strstr;
|
||||
|
||||
if (this->hasShortOption())
|
||||
{
|
||||
strstr << "-" << this->shortOption() << ", ";
|
||||
}
|
||||
else
|
||||
{
|
||||
strstr << " ";
|
||||
}
|
||||
strstr.width(20);
|
||||
strstr << std::left << "--" + this->longOption() + " <arg>";
|
||||
|
||||
return strstr.str();
|
||||
}
|
||||
|
||||
template<typename T, typename SwitchingBehavior>
|
||||
int PODParameter<T, SwitchingBehavior>::receive(ParserState& state) throw(Parameter::ParameterRejected) {
|
||||
|
||||
const std::string arg = state.get();
|
||||
|
||||
if(arg.at(0) != '-') return false;
|
||||
|
||||
if((arg.at(1) == '-' && arg.substr(2) == this->longOption()) ||
|
||||
(this->hasShortOption() && arg.at(1) == this->shortOption() && arg.length() == 2))
|
||||
{
|
||||
// retrieve the argument
|
||||
std::string arg1 = state.peek();
|
||||
if (arg1.length() == 0)
|
||||
{
|
||||
throw Parameter::ExpectedArgument(arg + ": expected an argument");
|
||||
return 1;
|
||||
}
|
||||
|
||||
this->set();
|
||||
value = this->validate(arg1);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
BIN
dependencies/wjwwood-serial-master-20131105.zip
vendored
BIN
dependencies/wjwwood-serial-master-20131105.zip
vendored
Binary file not shown.
3
doc/.gitignore
vendored
Normal file
3
doc/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/hyperion-build-doc.sh
|
||||
/hyperion.doxygen
|
||||
/html/
|
35
include/commandline/BooleanOption.h
Normal file
35
include/commandline/BooleanOption.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef HYPERION_BOOLEANOPTION_H
|
||||
#define HYPERION_BOOLEANOPTION_H
|
||||
|
||||
|
||||
#include <QtCore>
|
||||
#include "Option.h"
|
||||
|
||||
namespace commandline
|
||||
{
|
||||
|
||||
class BooleanOption: public Option
|
||||
{
|
||||
public:
|
||||
BooleanOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: Option(name, description, QString(), QString())
|
||||
{}
|
||||
BooleanOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: Option(names, description, QString(), QString())
|
||||
{}
|
||||
BooleanOption(const QCommandLineOption &other)
|
||||
: Option(other)
|
||||
{}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_BOOLEANOPTION_H
|
41
include/commandline/ColorOption.h
Normal file
41
include/commandline/ColorOption.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef HYPERION_COLOROPTION_H
|
||||
#define HYPERION_COLOROPTION_H
|
||||
|
||||
#include "Option.h"
|
||||
#include <QColor>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
namespace commandline
|
||||
{
|
||||
|
||||
class ColorOption: public Option
|
||||
{
|
||||
protected:
|
||||
QColor _color;
|
||||
public:
|
||||
ColorOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: Option(name, description, valueName, defaultValue)
|
||||
{}
|
||||
ColorOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: Option(names, description, valueName, defaultValue)
|
||||
{}
|
||||
ColorOption(const QCommandLineOption &other)
|
||||
: Option(other)
|
||||
{}
|
||||
|
||||
virtual bool validate(Parser & parser, QString & value) override;
|
||||
QColor getColor(Parser &parser)
|
||||
{ return _color; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_COLOROPTION_H
|
41
include/commandline/ColorsOption.h
Normal file
41
include/commandline/ColorsOption.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef HYPERION_COLORSOPTION_H
|
||||
#define HYPERION_COLORSOPTION_H
|
||||
|
||||
#include "Option.h"
|
||||
#include <QColor>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
namespace commandline
|
||||
{
|
||||
|
||||
class ColorsOption: public Option
|
||||
{
|
||||
protected:
|
||||
QList<QColor> _colors;
|
||||
public:
|
||||
ColorsOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: Option(name, description, valueName, defaultValue)
|
||||
{}
|
||||
ColorsOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: Option(names, description, valueName, defaultValue)
|
||||
{}
|
||||
ColorsOption(const QCommandLineOption &other)
|
||||
: Option(other)
|
||||
{}
|
||||
|
||||
virtual bool validate(Parser & parser, QString & value) override;
|
||||
QList<QColor> &getColors(Parser &parser)
|
||||
{ return _colors; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_COLOROPTION_H
|
40
include/commandline/DoubleOption.h
Normal file
40
include/commandline/DoubleOption.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef HYPERION_DOUBLECOMMANDLINEOPTION_H
|
||||
#define HYPERION_DOUBLECOMMANDLINEOPTION_H
|
||||
|
||||
#include <QtCore>
|
||||
#include "ValidatorOption.h"
|
||||
|
||||
namespace commandline
|
||||
{
|
||||
|
||||
class DoubleOption: public ValidatorOption
|
||||
{
|
||||
protected:
|
||||
double _double;
|
||||
public:
|
||||
DoubleOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
|
||||
: ValidatorOption(name, description, valueName, defaultValue)
|
||||
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }
|
||||
DoubleOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
|
||||
: ValidatorOption(names, description, valueName, defaultValue)
|
||||
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }
|
||||
DoubleOption(const QCommandLineOption &other,
|
||||
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
|
||||
: ValidatorOption(other)
|
||||
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }
|
||||
|
||||
double getDouble(Parser &parser, bool *ok = 0);
|
||||
double *getDoublePtr(Parser &parser, bool *ok = 0);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_DOUBLECOMMANDLINEOPTION_H
|
41
include/commandline/ImageOption.h
Normal file
41
include/commandline/ImageOption.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef HYPERION_IMAGEOPTION_H
|
||||
#define HYPERION_IMAGEOPTION_H
|
||||
|
||||
#include "Option.h"
|
||||
#include <QImage>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
namespace commandline
|
||||
{
|
||||
|
||||
class ImageOption: public Option
|
||||
{
|
||||
protected:
|
||||
QImage _image;
|
||||
public:
|
||||
ImageOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: Option(name, description, valueName, defaultValue)
|
||||
{}
|
||||
ImageOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: Option(names, description, valueName, defaultValue)
|
||||
{}
|
||||
ImageOption(const QCommandLineOption &other)
|
||||
: Option(other)
|
||||
{}
|
||||
|
||||
virtual bool validate(Parser & parser, QString & value) override;
|
||||
QImage &getImage(Parser &parser)
|
||||
{ return _image; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_IMAGEOPTION_H
|
41
include/commandline/IntOption.h
Normal file
41
include/commandline/IntOption.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef HYPERION_INTCOMMANDLINEOPTION_H
|
||||
#define HYPERION_INTCOMMANDLINEOPTION_H
|
||||
|
||||
#include <limits>
|
||||
#include <QtCore>
|
||||
#include "ValidatorOption.h"
|
||||
|
||||
namespace commandline
|
||||
{
|
||||
|
||||
class IntOption: public ValidatorOption
|
||||
{
|
||||
protected:
|
||||
int _int;
|
||||
public:
|
||||
IntOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
int minimum = std::numeric_limits<int>::min(), int maximum = std::numeric_limits<int>::max())
|
||||
: ValidatorOption(name, description, valueName, defaultValue)
|
||||
{ setValidator(new QIntValidator(minimum, maximum)); }
|
||||
IntOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
int minimum = std::numeric_limits<int>::min(), int maximum = std::numeric_limits<int>::max())
|
||||
: ValidatorOption(names, description, valueName, defaultValue)
|
||||
{ setValidator(new QIntValidator(minimum, maximum)); }
|
||||
IntOption(const QCommandLineOption &other,
|
||||
int minimum = std::numeric_limits<int>::min(), int maximum = std::numeric_limits<int>::max())
|
||||
: ValidatorOption(other)
|
||||
{ setValidator(new QIntValidator(minimum, maximum)); }
|
||||
|
||||
int getInt(Parser &parser, bool *ok = 0, int base = 10);
|
||||
int *getIntPtr(Parser &parser, bool *ok = 0, int base = 10);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_INTCOMMANDLINEOPTION_H
|
49
include/commandline/Option.h
Normal file
49
include/commandline/Option.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef HYPERION_OPTION_H
|
||||
#define HYPERION_OPTION_H
|
||||
|
||||
#include <QCommandLineOption>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
namespace commandline
|
||||
{
|
||||
|
||||
class Parser;
|
||||
|
||||
/* Note, this class and all it's derivatives store the validated results for caching. This means that unlike the
|
||||
* regular QCommandLineOption it is _not_ idempotent! */
|
||||
class Option: public QCommandLineOption
|
||||
{
|
||||
protected:
|
||||
QString _error;
|
||||
public:
|
||||
Option(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString::null,
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: QCommandLineOption(name, description, valueName, defaultValue)
|
||||
{}
|
||||
Option(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString::null,
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: QCommandLineOption(names, description, valueName, defaultValue)
|
||||
{}
|
||||
Option(const QCommandLineOption &other)
|
||||
: QCommandLineOption(other)
|
||||
{}
|
||||
|
||||
virtual bool validate(Parser &parser, QString &value);
|
||||
QString name()
|
||||
{ return this->names().last();}
|
||||
QString getError()
|
||||
{ return this->_error; }
|
||||
QString value(Parser &parser);
|
||||
std::string getStdString(Parser &parser);
|
||||
std::wstring getStdWString(Parser &parser);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_OPTION_H
|
120
include/commandline/Parser.h
Normal file
120
include/commandline/Parser.h
Normal file
@ -0,0 +1,120 @@
|
||||
#ifndef HYPERION_COMMANDLINEPARSER_H
|
||||
#define HYPERION_COMMANDLINEPARSER_H
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
#include "ColorOption.h"
|
||||
#include "ColorsOption.h"
|
||||
#include "DoubleOption.h"
|
||||
#include "ImageOption.h"
|
||||
#include "IntOption.h"
|
||||
#include "Option.h"
|
||||
#include "RegularExpressionOption.h"
|
||||
#include "SwitchOption.h"
|
||||
#include "ValidatorOption.h"
|
||||
#include "BooleanOption.h"
|
||||
|
||||
namespace commandline
|
||||
{
|
||||
|
||||
class Parser : public QObject
|
||||
{
|
||||
protected:
|
||||
QHash<QString, Option *> _options;
|
||||
QString _errorText;
|
||||
/* No public inheritance because we need to modify a few methods */
|
||||
QCommandLineParser _parser;
|
||||
|
||||
QStringList _getNames(const char shortOption, const QString longOption);
|
||||
QString _getDescription(const QString description, const QString default_=QString());
|
||||
|
||||
public:
|
||||
bool parse(const QStringList &arguments);
|
||||
void process(const QStringList &arguments);
|
||||
void process(const QCoreApplication &app);
|
||||
QString errorText() const;
|
||||
|
||||
template<class OptionT, class ... Args>
|
||||
OptionT &add(
|
||||
const char shortOption,
|
||||
const QString longOption,
|
||||
const QString description,
|
||||
const QString default_,
|
||||
Args ... args)
|
||||
{
|
||||
OptionT * option = new OptionT(
|
||||
_getNames(shortOption, longOption),
|
||||
_getDescription(description, default_),
|
||||
longOption,
|
||||
default_,
|
||||
args...);
|
||||
addOption(option);
|
||||
return *option;
|
||||
}
|
||||
|
||||
/* gcc does not support default arguments for variadic templates which
|
||||
* makes this method necessary */
|
||||
template<class OptionT>
|
||||
OptionT &add(
|
||||
const char shortOption,
|
||||
const QString longOption,
|
||||
const QString description,
|
||||
const QString default_ = QString())
|
||||
{
|
||||
OptionT * option = new OptionT(
|
||||
_getNames(shortOption, longOption),
|
||||
_getDescription(description, default_),
|
||||
longOption,
|
||||
default_);
|
||||
addOption(option);
|
||||
return *option;
|
||||
}
|
||||
|
||||
Parser(QString description=QString())
|
||||
{if(description.size())setApplicationDescription(description);};
|
||||
QCommandLineOption addHelpOption()
|
||||
{ return _parser.addHelpOption(); }
|
||||
bool addOption(Option &option);
|
||||
bool addOption(Option *option);
|
||||
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString())
|
||||
{ _parser.addPositionalArgument(name, description, syntax); }
|
||||
QCommandLineOption addVersionOption()
|
||||
{ return _parser.addVersionOption(); }
|
||||
QString applicationDescription() const
|
||||
{ return _parser.applicationDescription(); }
|
||||
void clearPositionalArguments()
|
||||
{ _parser.clearPositionalArguments(); }
|
||||
QString helpText() const
|
||||
{ return _parser.helpText(); }
|
||||
bool isSet(const QString &name) const
|
||||
{ return _parser.isSet(name); }
|
||||
bool isSet(const Option &option) const
|
||||
{ return _parser.isSet(option); }
|
||||
bool isSet(const Option *option) const
|
||||
{ return _parser.isSet(*option); }
|
||||
QStringList optionNames() const
|
||||
{ return _parser.optionNames(); }
|
||||
QStringList positionalArguments() const
|
||||
{ return _parser.positionalArguments(); }
|
||||
void setApplicationDescription(const QString &description)
|
||||
{ _parser.setApplicationDescription(description); }
|
||||
void setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode)
|
||||
{ _parser.setSingleDashWordOptionMode(singleDashWordOptionMode); }
|
||||
void showHelp(int exitCode = 0)
|
||||
{ _parser.showHelp(exitCode); }
|
||||
QStringList unknownOptionNames() const
|
||||
{ return _parser.unknownOptionNames(); }
|
||||
QString value(const QString &optionName) const
|
||||
{ return _parser.value(optionName); }
|
||||
QString value(const Option &option) const
|
||||
{ return _parser.value(option); }
|
||||
QStringList values(const QString &optionName) const
|
||||
{ return _parser.values(optionName); }
|
||||
QStringList values(const Option &option) const
|
||||
{ return _parser.values(option); }
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_COMMANDLINEPARSER_H
|
71
include/commandline/RegularExpressionOption.h
Normal file
71
include/commandline/RegularExpressionOption.h
Normal file
@ -0,0 +1,71 @@
|
||||
#ifndef HYPERION_REGULAREXPRESSIONCOMMANDLINEOPTION_H
|
||||
#define HYPERION_REGULAREXPRESSIONCOMMANDLINEOPTION_H
|
||||
|
||||
#include <QtCore>
|
||||
#include <QRegularExpression>
|
||||
#include "ValidatorOption.h"
|
||||
|
||||
namespace commandline
|
||||
{
|
||||
|
||||
class RegularExpressionOption: public ValidatorOption
|
||||
{
|
||||
public:
|
||||
RegularExpressionOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString())
|
||||
: ValidatorOption(name, description, valueName, defaultValue)
|
||||
{}
|
||||
RegularExpressionOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString())
|
||||
: ValidatorOption(names, description, valueName, defaultValue)
|
||||
{}
|
||||
RegularExpressionOption(const QCommandLineOption &other)
|
||||
: ValidatorOption(other)
|
||||
{}
|
||||
|
||||
RegularExpressionOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
const QRegularExpression &expression = QRegularExpression())
|
||||
: ValidatorOption(name, description, valueName, defaultValue)
|
||||
{ setValidator(new QRegularExpressionValidator(expression)); }
|
||||
RegularExpressionOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
const QRegularExpression &expression = QRegularExpression())
|
||||
: ValidatorOption(names, description, valueName, defaultValue)
|
||||
{ setValidator(new QRegularExpressionValidator(expression)); }
|
||||
RegularExpressionOption(const QCommandLineOption &other,
|
||||
const QRegularExpression &expression = QRegularExpression())
|
||||
: ValidatorOption(other)
|
||||
{ setValidator(new QRegularExpressionValidator(expression)); }
|
||||
|
||||
RegularExpressionOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
const QString &expression = QString())
|
||||
: ValidatorOption(name, description, valueName, defaultValue)
|
||||
{ setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); }
|
||||
RegularExpressionOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
const QString &expression = QString())
|
||||
: ValidatorOption(names, description, valueName, defaultValue)
|
||||
{ setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); }
|
||||
RegularExpressionOption(const QCommandLineOption &other,
|
||||
const QString &expression = QString())
|
||||
: ValidatorOption(other)
|
||||
{ setValidator(new QRegularExpressionValidator(QRegularExpression(expression))); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_REGULAREXPRESSIONCOMMANDLINEOPTION_H
|
45
include/commandline/SwitchOption.h
Normal file
45
include/commandline/SwitchOption.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef HYPERION_SWITCHCOMMANDLINEOPTION_H
|
||||
#define HYPERION_SWITCHCOMMANDLINEOPTION_H
|
||||
|
||||
#include <QtCore>
|
||||
#include "Option.h"
|
||||
|
||||
namespace commandline
|
||||
{
|
||||
|
||||
template <class T>
|
||||
class SwitchOption: public Option
|
||||
{
|
||||
protected:
|
||||
QMap<QString, T> _switches;
|
||||
public:
|
||||
SwitchOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
const QMap<QString, T> &switches=QMap<QString, T>())
|
||||
: Option(name, description, valueName, defaultValue), _switches(switches)
|
||||
{}
|
||||
SwitchOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
const QMap<QString, T> &switches=QMap<QString, T>())
|
||||
: Option(names, description, valueName, defaultValue), _switches(switches)
|
||||
{}
|
||||
SwitchOption(const QCommandLineOption &other, const QMap<QString, T> &switches)
|
||||
: Option(other), _switches(switches)
|
||||
{}
|
||||
|
||||
const QMap<QString, T> &getSwitches() const{return _switches;};
|
||||
virtual bool validate(Parser &parser, QString &switch_) override{return hasSwitch(switch_);}
|
||||
bool hasSwitch(const QString &switch_){return _switches.contains(switch_.toLower());}
|
||||
void setSwitches(const QMap<QString, T> &_switches){this->_switches = _switches;}
|
||||
void addSwitch(const QString &switch_, T value=T()){_switches[switch_.toLower()] = value;}
|
||||
void removeSwitch(const QString &switch_){_switches.remove(switch_.toLower());}
|
||||
T & switchValue(Parser & parser){return _switches[value(parser).toLower()];}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_SWITCHCOMMANDLINEOPTION_H
|
42
include/commandline/ValidatorOption.h
Normal file
42
include/commandline/ValidatorOption.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef HYPERION_COMMANDLINEOPTION_H
|
||||
#define HYPERION_COMMANDLINEOPTION_H
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
#include <commandline/Option.h>
|
||||
|
||||
namespace commandline
|
||||
{
|
||||
|
||||
class ValidatorOption: public Option
|
||||
{
|
||||
protected:
|
||||
const QValidator *validator;
|
||||
virtual void setValidator(const QValidator *validator);
|
||||
public:
|
||||
ValidatorOption(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
const QValidator *validator = nullptr)
|
||||
: Option(name, description, valueName, defaultValue), validator(validator)
|
||||
{}
|
||||
ValidatorOption(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString(),
|
||||
const QValidator *validator = nullptr)
|
||||
: Option(names, description, valueName, defaultValue), validator(validator)
|
||||
{}
|
||||
ValidatorOption(const QCommandLineOption &other,
|
||||
const QValidator *validator = nullptr)
|
||||
: Option(other), validator(validator)
|
||||
{}
|
||||
|
||||
virtual const QValidator *getValidator() const;
|
||||
virtual bool validate(Parser & parser, QString &value) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_COMMANDLINEOPTION_H
|
@ -72,6 +72,10 @@ private:
|
||||
XRenderPictureAttributes _pictAttr;
|
||||
Picture _srcPicture;
|
||||
Picture _dstPicture;
|
||||
|
||||
XTransform _transform;
|
||||
int _horizontalDecimation;
|
||||
int _verticalDecimation;
|
||||
|
||||
unsigned _screenWidth;
|
||||
unsigned _screenHeight;
|
||||
|
@ -2,14 +2,21 @@
|
||||
|
||||
// STL incldues
|
||||
#include <vector>
|
||||
|
||||
#include <QObject>
|
||||
#include <map>
|
||||
|
||||
// Utility includes
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <utils/ColorRgbw.h>
|
||||
#include <utils/RgbToRgbw.h>
|
||||
#include <utils/Logger.h>
|
||||
#include <functional>
|
||||
#include <json/json.h>
|
||||
|
||||
class LedDevice;
|
||||
|
||||
typedef LedDevice* ( *LedDeviceCreateFuncType ) ( const Json::Value& );
|
||||
typedef std::map<std::string,LedDeviceCreateFuncType> LedDeviceRegistry;
|
||||
|
||||
///
|
||||
/// Interface (pure virtual base class) for LedDevices.
|
||||
@ -44,6 +51,10 @@ public:
|
||||
///
|
||||
virtual int open();
|
||||
|
||||
static int addToDeviceMap(std::string name, LedDeviceCreateFuncType funcPtr);
|
||||
static const LedDeviceRegistry& getDeviceMap();
|
||||
static void setActiveDevice(std::string dev);
|
||||
static std::string activeDevice() { return _activeDevice; };
|
||||
protected:
|
||||
/// The common Logger instance for all LedDevices
|
||||
Logger * _log;
|
||||
@ -53,4 +64,6 @@ protected:
|
||||
/// The buffer containing the packed RGB values
|
||||
std::vector<uint8_t> _ledBuffer;
|
||||
|
||||
static std::string _activeDevice;
|
||||
static LedDeviceRegistry _ledDeviceMap;
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ class ProtoConnectionWrapper : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ProtoConnectionWrapper(const std::string & address, int priority, int duration_ms, bool skipProtoReply);
|
||||
ProtoConnectionWrapper(const QString &address, int priority, int duration_ms, bool skipProtoReply);
|
||||
virtual ~ProtoConnectionWrapper();
|
||||
|
||||
signals:
|
||||
|
@ -4,6 +4,7 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include)
|
||||
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc)
|
||||
|
||||
add_subdirectory(hyperion)
|
||||
add_subdirectory(commandline)
|
||||
add_subdirectory(blackborder)
|
||||
add_subdirectory(jsonserver)
|
||||
add_subdirectory(protoserver)
|
||||
|
3
libsrc/commandline/BooleanOption.cpp
Normal file
3
libsrc/commandline/BooleanOption.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
#include "commandline/BooleanOption.h"
|
||||
|
||||
using namespace commandline;
|
42
libsrc/commandline/CMakeLists.txt
Normal file
42
libsrc/commandline/CMakeLists.txt
Normal file
@ -0,0 +1,42 @@
|
||||
# Define the current source locations
|
||||
set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/commandline)
|
||||
set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/commandline)
|
||||
|
||||
set(Parser_HEADERS
|
||||
${CURRENT_HEADER_DIR}/ColorOption.h
|
||||
${CURRENT_HEADER_DIR}/ColorsOption.h
|
||||
${CURRENT_HEADER_DIR}/DoubleOption.h
|
||||
${CURRENT_HEADER_DIR}/ImageOption.h
|
||||
${CURRENT_HEADER_DIR}/IntOption.h
|
||||
${CURRENT_HEADER_DIR}/Option.h
|
||||
${CURRENT_HEADER_DIR}/Parser.h
|
||||
${CURRENT_HEADER_DIR}/RegularExpressionOption.h
|
||||
${CURRENT_HEADER_DIR}/SwitchOption.h
|
||||
${CURRENT_HEADER_DIR}/ValidatorOption.h
|
||||
${CURRENT_HEADER_DIR}/BooleanOption.h
|
||||
)
|
||||
|
||||
set(Parser_SOURCES
|
||||
${CURRENT_SOURCE_DIR}/ColorOption.cpp
|
||||
${CURRENT_SOURCE_DIR}/ColorsOption.cpp
|
||||
${CURRENT_SOURCE_DIR}/DoubleOption.cpp
|
||||
${CURRENT_SOURCE_DIR}/ImageOption.cpp
|
||||
${CURRENT_SOURCE_DIR}/IntOption.cpp
|
||||
${CURRENT_SOURCE_DIR}/Option.cpp
|
||||
${CURRENT_SOURCE_DIR}/Parser.cpp
|
||||
${CURRENT_SOURCE_DIR}/RegularExpressionOption.cpp
|
||||
${CURRENT_SOURCE_DIR}/SwitchOption.cpp
|
||||
${CURRENT_SOURCE_DIR}/ValidatorOption.cpp
|
||||
${CURRENT_SOURCE_DIR}/BooleanOption.cpp
|
||||
)
|
||||
|
||||
add_library(commandline
|
||||
${Parser_HEADERS}
|
||||
${Parser_SOURCES}
|
||||
)
|
||||
|
||||
qt5_use_modules(commandline Gui)
|
||||
|
||||
target_link_libraries(commandline
|
||||
hyperion
|
||||
)
|
30
libsrc/commandline/ColorOption.cpp
Normal file
30
libsrc/commandline/ColorOption.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <QRegularExpression>
|
||||
#include "commandline/ColorOption.h"
|
||||
#include "commandline/Parser.h"
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
bool ColorOption::validate(Parser & parser, QString & value)
|
||||
{
|
||||
// Check if we can create the color by name
|
||||
_color = QColor(value);
|
||||
if (_color.isValid()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check if we can create the color by hex RRGGBB getColors
|
||||
_color = QColor(QString("#%1").arg(value));
|
||||
if (_color.isValid()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!parser.isSet(*this)){
|
||||
// Return true if no value is available
|
||||
return true;
|
||||
}
|
||||
|
||||
QStringList error;
|
||||
_error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- "));
|
||||
|
||||
return false;
|
||||
}
|
37
libsrc/commandline/ColorsOption.cpp
Normal file
37
libsrc/commandline/ColorsOption.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include <QRegularExpression>
|
||||
#include "commandline/ColorsOption.h"
|
||||
#include "commandline/Parser.h"
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
bool ColorsOption::validate(Parser & parser, QString & value)
|
||||
{
|
||||
// Clear any old results
|
||||
_colors.clear();
|
||||
|
||||
// Check if we can create the color by name
|
||||
QColor color(value);
|
||||
if (color.isValid()) {
|
||||
_colors.push_back(color);
|
||||
return true;
|
||||
}
|
||||
|
||||
// check if we can create the color by hex RRGGBB getColors
|
||||
QRegularExpression hexRe("^([0-9A-F]{6})+$", QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = hexRe.match(value);
|
||||
if(match.hasMatch()) {
|
||||
Q_FOREACH(const QString m, match.capturedTexts()){
|
||||
_colors.push_back(QColor(QString("#%1").arg(m)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!parser.isSet(*this)){
|
||||
// Return true if no value is available
|
||||
return true;
|
||||
}
|
||||
|
||||
_error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- "));
|
||||
|
||||
return false;
|
||||
}
|
20
libsrc/commandline/DoubleOption.cpp
Normal file
20
libsrc/commandline/DoubleOption.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "commandline/DoubleOption.h"
|
||||
#include "commandline/Parser.h"
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
double DoubleOption::getDouble(Parser &parser, bool *ok)
|
||||
{
|
||||
_double = value(parser).toDouble(ok);
|
||||
return _double;
|
||||
}
|
||||
|
||||
double *DoubleOption::getDoublePtr(Parser &parser, bool *ok)
|
||||
{
|
||||
if (parser.isSet(this)) {
|
||||
getDouble(parser, ok);
|
||||
return &_double;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
18
libsrc/commandline/ImageOption.cpp
Normal file
18
libsrc/commandline/ImageOption.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "commandline/ImageOption.h"
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
bool ImageOption::validate(Parser & parser, QString & value)
|
||||
{
|
||||
if(value.size()){
|
||||
_image = QImage(value);
|
||||
|
||||
if (_image.isNull())
|
||||
{
|
||||
_error = QString("File %1 could not be opened as image").arg(value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
20
libsrc/commandline/IntOption.cpp
Normal file
20
libsrc/commandline/IntOption.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "commandline/IntOption.h"
|
||||
#include "commandline/Parser.h"
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
int IntOption::getInt(Parser &parser, bool *ok, int base)
|
||||
{
|
||||
_int = value(parser).toInt(ok, base);
|
||||
return _int;
|
||||
}
|
||||
|
||||
int *IntOption::getIntPtr(Parser &parser, bool *ok, int base)
|
||||
{
|
||||
if (parser.isSet(this)) {
|
||||
getInt(parser, ok, base);
|
||||
return &_int;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
26
libsrc/commandline/Option.cpp
Normal file
26
libsrc/commandline/Option.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "commandline/Option.h"
|
||||
#include "commandline/Parser.h"
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
bool Option::validate(Parser & parser, QString &value)
|
||||
{
|
||||
/* By default everything is accepted */
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Option::value(Parser &parser)
|
||||
{
|
||||
return parser.value(*this);
|
||||
}
|
||||
|
||||
std::string Option::getStdString(Parser &parser)
|
||||
{
|
||||
return value(parser).toStdString();
|
||||
}
|
||||
|
||||
std::wstring Option::getStdWString(Parser &parser)
|
||||
{
|
||||
return value(parser).toStdWString();
|
||||
}
|
||||
|
90
libsrc/commandline/Parser.cpp
Normal file
90
libsrc/commandline/Parser.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
#include <QtDebug>
|
||||
#include <QtGui>
|
||||
#include "commandline/Parser.h"
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
bool Parser::parse(const QStringList &arguments)
|
||||
{
|
||||
if (!_parser.parse(arguments)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_FOREACH(Option * option, _options) {
|
||||
QString value = this->value(*option);
|
||||
if (!option->validate(*this, value)) {
|
||||
const QString error = option->getError();
|
||||
if (error.size()) {
|
||||
_errorText = tr("%1 is not a valid option for %2\n%3").arg(value, option->name(), error);
|
||||
}
|
||||
else {
|
||||
_errorText = tr("%1 is not a valid option for %2").arg(value, option->name());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Parser::process(const QStringList &arguments)
|
||||
{
|
||||
_parser.process(arguments);
|
||||
if (!parse(arguments)) {
|
||||
|
||||
fprintf(stdout, "%s", qPrintable(tr("Error: %1").arg(_errorText)));
|
||||
showHelp(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::process(const QCoreApplication &app)
|
||||
{
|
||||
Q_UNUSED(app);
|
||||
process(QCoreApplication::arguments());
|
||||
}
|
||||
|
||||
QString Parser::errorText() const
|
||||
{
|
||||
if (_errorText.size()) {
|
||||
return _errorText;
|
||||
}
|
||||
else {
|
||||
return _parser.errorText();
|
||||
}
|
||||
}
|
||||
|
||||
bool Parser::addOption(Option &option)
|
||||
{
|
||||
return addOption(&option);
|
||||
}
|
||||
|
||||
bool Parser::addOption(Option * const option)
|
||||
{
|
||||
_options[option->name()] = option;
|
||||
return _parser.addOption(*option);
|
||||
}
|
||||
QStringList Parser::_getNames(const char shortOption, const QString longOption)
|
||||
{
|
||||
QStringList names;
|
||||
if (shortOption != 0x0) {
|
||||
names << QString(shortOption);
|
||||
}
|
||||
if (longOption.size()) {
|
||||
names << longOption;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
QString Parser::_getDescription(const QString description, const QString default_)
|
||||
{
|
||||
/* Add the translations if available */
|
||||
QString formattedDescription(tr(qPrintable(description)));
|
||||
|
||||
/* Fill in the default if needed */
|
||||
if (default_.size()) {
|
||||
if(!formattedDescription.contains("%1")){
|
||||
formattedDescription += " [default: %1]";
|
||||
}
|
||||
formattedDescription = formattedDescription.arg(default_);
|
||||
}
|
||||
return formattedDescription;
|
||||
}
|
||||
|
4
libsrc/commandline/RegularExpressionOption.cpp
Normal file
4
libsrc/commandline/RegularExpressionOption.cpp
Normal file
@ -0,0 +1,4 @@
|
||||
#include "commandline/RegularExpressionOption.h"
|
||||
|
||||
using namespace commandline;
|
||||
|
5
libsrc/commandline/SwitchOption.cpp
Normal file
5
libsrc/commandline/SwitchOption.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "commandline/SwitchOption.h"
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
|
25
libsrc/commandline/ValidatorOption.cpp
Normal file
25
libsrc/commandline/ValidatorOption.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "commandline/ValidatorOption.h"
|
||||
#include "commandline/Parser.h"
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
bool ValidatorOption::validate(Parser & parser, QString & value)
|
||||
{
|
||||
if (parser.isSet(*this) || !defaultValues().empty()) {
|
||||
int pos = 0;
|
||||
validator->fixup(value);
|
||||
return validator->validate(value, pos) == QValidator::Acceptable;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const QValidator *ValidatorOption::getValidator() const
|
||||
{
|
||||
return validator;
|
||||
}
|
||||
void ValidatorOption::setValidator(const QValidator *validator)
|
||||
{
|
||||
ValidatorOption::validator = validator;
|
||||
}
|
||||
|
@ -6,29 +6,29 @@
|
||||
// X11Grabber includes
|
||||
#include <grabber/X11Grabber.h>
|
||||
|
||||
X11Grabber::X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation) :
|
||||
_imageResampler(),
|
||||
_useXGetImage(useXGetImage),
|
||||
_cropLeft(cropLeft),
|
||||
_cropRight(cropRight),
|
||||
_cropTop(cropTop),
|
||||
_cropBottom(cropBottom),
|
||||
_x11Display(nullptr),
|
||||
_pixmap(None),
|
||||
_srcFormat(nullptr),
|
||||
_dstFormat(nullptr),
|
||||
_srcPicture(None),
|
||||
_dstPicture(None),
|
||||
_screenWidth(0),
|
||||
_screenHeight(0),
|
||||
_croppedWidth(0),
|
||||
_croppedHeight(0),
|
||||
_image(0,0),
|
||||
_log(Logger::getInstance("X11GRABBER"))
|
||||
X11Grabber::X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation)
|
||||
: _imageResampler()
|
||||
, _useXGetImage(useXGetImage)
|
||||
, _cropLeft(cropLeft)
|
||||
, _cropRight(cropRight)
|
||||
, _cropTop(cropTop)
|
||||
, _cropBottom(cropBottom)
|
||||
, _x11Display(nullptr)
|
||||
, _pixmap(None)
|
||||
, _srcFormat(nullptr)
|
||||
, _dstFormat(nullptr)
|
||||
, _srcPicture(None)
|
||||
, _dstPicture(None)
|
||||
, _horizontalDecimation(horizontalPixelDecimation)
|
||||
, _verticalDecimation(verticalPixelDecimation)
|
||||
, _screenWidth(0)
|
||||
, _screenHeight(0)
|
||||
, _croppedWidth(0)
|
||||
, _croppedHeight(0)
|
||||
, _image(0,0)
|
||||
, _log(Logger::getInstance("X11GRABBER"))
|
||||
{
|
||||
_imageResampler.setHorizontalPixelDecimation(horizontalPixelDecimation);
|
||||
_imageResampler.setVerticalPixelDecimation(verticalPixelDecimation);
|
||||
_imageResampler.setCropping(0, 0, 0, 0); // cropping is performed by XShmGetImage or XGetImage
|
||||
_imageResampler.setCropping(0, 0, 0, 0); // cropping is performed by XRender, XShmGetImage or XGetImage
|
||||
memset(&_pictAttr, 0, sizeof(_pictAttr));
|
||||
_pictAttr.repeat = RepeatNone;
|
||||
}
|
||||
@ -51,12 +51,14 @@ void X11Grabber::freeResources()
|
||||
{
|
||||
// Cleanup allocated resources of the X11 grab
|
||||
XDestroyImage(_xImage);
|
||||
if(_XShmAvailable && !_useXGetImage) {
|
||||
if(_XShmAvailable && !_useXGetImage)
|
||||
{
|
||||
XShmDetach(_x11Display, &_shminfo);
|
||||
shmdt(_shminfo.shmaddr);
|
||||
shmctl(_shminfo.shmid, IPC_RMID, 0);
|
||||
}
|
||||
if (_XRenderAvailable && !_useXGetImage) {
|
||||
if (_XRenderAvailable && !_useXGetImage)
|
||||
{
|
||||
XRenderFreePicture(_x11Display, _srcPicture);
|
||||
XRenderFreePicture(_x11Display, _dstPicture);
|
||||
XFreePixmap(_x11Display, _pixmap);
|
||||
@ -65,29 +67,32 @@ void X11Grabber::freeResources()
|
||||
|
||||
void X11Grabber::setupResources()
|
||||
{
|
||||
if(_XShmAvailable && !_useXGetImage) {
|
||||
if(_XShmAvailable && !_useXGetImage)
|
||||
{
|
||||
_xImage = XShmCreateImage(_x11Display, _windowAttr.visual,
|
||||
_windowAttr.depth, ZPixmap, NULL, &_shminfo,
|
||||
_croppedWidth, _croppedHeight);
|
||||
|
||||
_shminfo.shmid = shmget(IPC_PRIVATE, _xImage->bytes_per_line * _xImage->height, IPC_CREAT|0777);
|
||||
_xImage->data = (char*)shmat(_shminfo.shmid,0,0);
|
||||
_shminfo.shmaddr = _xImage->data;
|
||||
_shminfo.readOnly = False;
|
||||
|
||||
XShmAttach(_x11Display, &_shminfo);
|
||||
XShmAttach(_x11Display, &_shminfo);
|
||||
}
|
||||
if (_XRenderAvailable && !_useXGetImage) {
|
||||
if(_XShmPixmapAvailable) {
|
||||
if (_XRenderAvailable && !_useXGetImage)
|
||||
{
|
||||
if(_XShmPixmapAvailable)
|
||||
{
|
||||
_pixmap = XShmCreatePixmap(_x11Display, _window, _xImage->data, &_shminfo, _croppedWidth, _croppedHeight, _windowAttr.depth);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
_pixmap = XCreatePixmap(_x11Display, _window, _croppedWidth, _croppedHeight, _windowAttr.depth);
|
||||
}
|
||||
_srcFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual);
|
||||
_dstFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual);
|
||||
_srcPicture = XRenderCreatePicture(_x11Display, _window, _srcFormat, CPRepeat, &_pictAttr);
|
||||
_dstPicture = XRenderCreatePicture(_x11Display, _pixmap, _dstFormat, CPRepeat, &_pictAttr);
|
||||
XRenderSetPictureFilter(_x11Display, _srcPicture, "bilinear", NULL, 0);
|
||||
XRenderSetPictureFilter(_x11Display, _srcPicture, FilterBilinear, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,9 +102,12 @@ bool X11Grabber::Setup()
|
||||
if (_x11Display == nullptr)
|
||||
{
|
||||
Error(_log, "Unable to open display");
|
||||
if (getenv("DISPLAY")) {
|
||||
if (getenv("DISPLAY"))
|
||||
{
|
||||
Error(_log, "%s",getenv("DISPLAY"));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(_log, "DISPLAY environment variable not set");
|
||||
}
|
||||
return false;
|
||||
@ -113,6 +121,10 @@ bool X11Grabber::Setup()
|
||||
_XShmAvailable = XShmQueryExtension(_x11Display);
|
||||
XShmQueryVersion(_x11Display, &dummy, &dummy, &pixmaps_supported);
|
||||
_XShmPixmapAvailable = pixmaps_supported && XShmPixmapFormat(_x11Display) == ZPixmap;
|
||||
|
||||
// Image scaling is performed by XRender when available, otherwise by ImageResampler
|
||||
_imageResampler.setHorizontalPixelDecimation(_XRenderAvailable ? 1 : _horizontalDecimation);
|
||||
_imageResampler.setVerticalPixelDecimation(_XRenderAvailable ? 1 : _verticalDecimation);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -121,32 +133,67 @@ Image<ColorRgb> & X11Grabber::grab()
|
||||
{
|
||||
updateScreenDimensions();
|
||||
|
||||
if (_XRenderAvailable && !_useXGetImage) {
|
||||
XRenderComposite( _x11Display, // *dpy,
|
||||
PictOpSrc, // op,
|
||||
_srcPicture, // src
|
||||
None, // mask
|
||||
_dstPicture, // dst
|
||||
_cropLeft, // src_x
|
||||
_cropTop, // src_y
|
||||
0, // mask_x
|
||||
0, // mask_y
|
||||
0, // dst_x
|
||||
0, // dst_y
|
||||
_croppedWidth, // width
|
||||
_croppedHeight); // height
|
||||
|
||||
if (_XRenderAvailable && !_useXGetImage)
|
||||
{
|
||||
double scale_x = static_cast<double>(_windowAttr.width / _horizontalDecimation) / static_cast<double>(_windowAttr.width);
|
||||
double scale_y = static_cast<double>(_windowAttr.height / _verticalDecimation) / static_cast<double>(_windowAttr.height);
|
||||
double scale = std::min(scale_y, scale_x);
|
||||
|
||||
_transform =
|
||||
{
|
||||
{
|
||||
{
|
||||
XDoubleToFixed(1),
|
||||
XDoubleToFixed(0),
|
||||
XDoubleToFixed(0)
|
||||
},
|
||||
{
|
||||
XDoubleToFixed(0),
|
||||
XDoubleToFixed(1),
|
||||
XDoubleToFixed(0)
|
||||
},
|
||||
{
|
||||
XDoubleToFixed(0),
|
||||
XDoubleToFixed(0),
|
||||
XDoubleToFixed(scale)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
XRenderSetPictureTransform (_x11Display, _srcPicture, &_transform);
|
||||
|
||||
XRenderComposite( _x11Display, // dpy
|
||||
PictOpSrc, // op
|
||||
_srcPicture, // src
|
||||
None, // mask
|
||||
_dstPicture, // dst
|
||||
_cropLeft / _horizontalDecimation, // src_x _cropLeft
|
||||
_cropTop / _verticalDecimation, // src_y _cropTop
|
||||
0, // mask_x
|
||||
0, // mask_y
|
||||
0, // dst_x
|
||||
0, // dst_y
|
||||
_croppedWidth, // width
|
||||
_croppedHeight); // height
|
||||
|
||||
XSync(_x11Display, False);
|
||||
|
||||
if (_XShmAvailable) {
|
||||
|
||||
if (_XShmAvailable)
|
||||
{
|
||||
XShmGetImage(_x11Display, _pixmap, _xImage, 0, 0, AllPlanes);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
_xImage = XGetImage(_x11Display, _pixmap, 0, 0, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_XShmAvailable && !_useXGetImage) {
|
||||
XShmGetImage(_x11Display, _window, _xImage, _cropLeft, _cropTop, AllPlanes);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
_xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap);
|
||||
}
|
||||
}
|
||||
@ -164,32 +211,67 @@ Image<ColorRgb> & X11Grabber::grab()
|
||||
|
||||
int X11Grabber::grabFrame(Image<ColorRgb> & image)
|
||||
{
|
||||
if (_XRenderAvailable && !_useXGetImage) {
|
||||
XRenderComposite( _x11Display, // *dpy,
|
||||
PictOpSrc, // op,
|
||||
_srcPicture, // src
|
||||
None, // mask
|
||||
_dstPicture, // dst
|
||||
_cropLeft, // src_x
|
||||
_cropTop, // src_y
|
||||
0, // mask_x
|
||||
0, // mask_y
|
||||
0, // dst_x
|
||||
0, // dst_y
|
||||
_croppedWidth, // width
|
||||
_croppedHeight); // height
|
||||
|
||||
if (_XRenderAvailable && !_useXGetImage)
|
||||
{
|
||||
double scale_x = static_cast<double>(_windowAttr.width / _horizontalDecimation) / static_cast<double>(_windowAttr.width);
|
||||
double scale_y = static_cast<double>(_windowAttr.height / _verticalDecimation) / static_cast<double>(_windowAttr.height);
|
||||
double scale = std::min(scale_y, scale_x);
|
||||
|
||||
_transform =
|
||||
{
|
||||
{
|
||||
{
|
||||
XDoubleToFixed(1),
|
||||
XDoubleToFixed(0),
|
||||
XDoubleToFixed(0)
|
||||
},
|
||||
{
|
||||
XDoubleToFixed(0),
|
||||
XDoubleToFixed(1),
|
||||
XDoubleToFixed(0)
|
||||
},
|
||||
{
|
||||
XDoubleToFixed(0),
|
||||
XDoubleToFixed(0),
|
||||
XDoubleToFixed(scale)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
XRenderSetPictureTransform (_x11Display, _srcPicture, &_transform);
|
||||
|
||||
XRenderComposite( _x11Display, // dpy
|
||||
PictOpSrc, // op
|
||||
_srcPicture, // src
|
||||
None, // mask
|
||||
_dstPicture, // dst
|
||||
_cropLeft / _horizontalDecimation, // src_x _cropLeft
|
||||
_cropTop / _verticalDecimation, // src_y _cropTop
|
||||
0, // mask_x
|
||||
0, // mask_y
|
||||
0, // dst_x
|
||||
0, // dst_y
|
||||
_croppedWidth, // width
|
||||
_croppedHeight); // height
|
||||
|
||||
XSync(_x11Display, False);
|
||||
|
||||
if (_XShmAvailable) {
|
||||
|
||||
if (_XShmAvailable)
|
||||
{
|
||||
XShmGetImage(_x11Display, _pixmap, _xImage, 0, 0, AllPlanes);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
_xImage = XGetImage(_x11Display, _pixmap, 0, 0, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_XShmAvailable && !_useXGetImage) {
|
||||
XShmGetImage(_x11Display, _window, _xImage, _cropLeft, _cropTop, AllPlanes);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
_xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap);
|
||||
}
|
||||
}
|
||||
@ -220,7 +302,8 @@ int X11Grabber::updateScreenDimensions()
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_screenWidth || _screenHeight) {
|
||||
if (_screenWidth || _screenHeight)
|
||||
{
|
||||
freeResources();
|
||||
}
|
||||
|
||||
@ -228,20 +311,33 @@ int X11Grabber::updateScreenDimensions()
|
||||
_screenWidth = _windowAttr.width;
|
||||
_screenHeight = _windowAttr.height;
|
||||
|
||||
_croppedWidth = (_screenWidth > unsigned(_cropLeft + _cropRight))
|
||||
? (_screenWidth - _cropLeft - _cropRight)
|
||||
: _screenWidth;
|
||||
|
||||
_croppedHeight = (_screenHeight > unsigned(_cropTop + _cropBottom))
|
||||
? (_screenHeight - _cropTop - _cropBottom)
|
||||
: _screenHeight;
|
||||
|
||||
if (_XRenderAvailable && !_useXGetImage) {
|
||||
// Image scaling is performed by XRender when available, otherwise by ImageResampler
|
||||
if (_XRenderAvailable && !_useXGetImage)
|
||||
{
|
||||
_croppedWidth = (_screenWidth > unsigned(_cropLeft + _cropRight))
|
||||
? ((_screenWidth - _cropLeft - _cropRight) / _horizontalDecimation)
|
||||
: _screenWidth / _horizontalDecimation;
|
||||
|
||||
_croppedHeight = (_screenHeight > unsigned(_cropTop + _cropBottom))
|
||||
? ((_screenHeight - _cropTop - _cropBottom) / _verticalDecimation)
|
||||
: _screenHeight / _verticalDecimation;
|
||||
|
||||
Info(_log, "Using XRender for grabbing");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
_croppedWidth = (_screenWidth > unsigned(_cropLeft + _cropRight))
|
||||
? (_screenWidth - _cropLeft - _cropRight)
|
||||
: _screenWidth;
|
||||
|
||||
_croppedHeight = (_screenHeight > unsigned(_cropTop + _cropBottom))
|
||||
? (_screenHeight - _cropTop - _cropBottom)
|
||||
: _screenHeight;
|
||||
|
||||
Info(_log, "Using XGetImage for grabbing");
|
||||
}
|
||||
|
||||
_image.resize(_croppedWidth, _croppedHeight);
|
||||
setupResources();
|
||||
|
||||
return 1;
|
||||
|
@ -565,7 +565,6 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile)
|
||||
, _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"]))
|
||||
, _raw2ledTemperature(createLedColorsTemperature(_ledString.leds().size(), jsonConfig["color"]))
|
||||
, _raw2ledAdjustment(createLedColorsAdjustment(_ledString.leds().size(), jsonConfig["color"]))
|
||||
, _device(LedDeviceFactory::construct(jsonConfig["device"]))
|
||||
, _effectEngine(nullptr)
|
||||
, _messageForwarder(createMessageForwarder(jsonConfig["forwarder"]))
|
||||
, _jsonConfig(jsonConfig)
|
||||
@ -575,6 +574,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile)
|
||||
, _hwLedCount(_ledString.leds().size())
|
||||
, _sourceAutoSelectEnabled(true)
|
||||
{
|
||||
_device = LedDeviceFactory::construct(jsonConfig["device"]);
|
||||
registerPriority("Off", PriorityMuxer::LOWEST_PRIORITY);
|
||||
|
||||
if (!_raw2ledAdjustment->verifyAdjustments())
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <hyperion/ColorCorrection.h>
|
||||
#include <hyperion/ColorAdjustment.h>
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <leddevice/LedDevice.h>
|
||||
#include <HyperionConfig.h>
|
||||
#include <utils/jsonschema/JsonFactory.h>
|
||||
|
||||
@ -561,13 +562,16 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &, const st
|
||||
const std::list<ActiveEffectDefinition> & activeEffectsDefinitions = _hyperion->getActiveEffects();
|
||||
for (const ActiveEffectDefinition & activeEffectDefinition : activeEffectsDefinitions)
|
||||
{
|
||||
Json::Value activeEffect;
|
||||
activeEffect["script"] = activeEffectDefinition.script;
|
||||
activeEffect["priority"] = activeEffectDefinition.priority;
|
||||
activeEffect["timeout"] = activeEffectDefinition.timeout;
|
||||
activeEffect["args"] = activeEffectDefinition.args;
|
||||
|
||||
activeEffects.append(activeEffect);
|
||||
if (activeEffectDefinition.priority != PriorityMuxer::LOWEST_PRIORITY -1)
|
||||
{
|
||||
Json::Value activeEffect;
|
||||
activeEffect["script"] = activeEffectDefinition.script;
|
||||
activeEffect["priority"] = activeEffectDefinition.priority;
|
||||
activeEffect["timeout"] = activeEffectDefinition.timeout;
|
||||
activeEffect["args"] = activeEffectDefinition.args;
|
||||
|
||||
activeEffects.append(activeEffect);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
@ -624,21 +628,31 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &, const st
|
||||
<< std::hex << unsigned(priorityInfo.ledColors.begin()->blue);
|
||||
|
||||
LEDcolor["HEX Value"].append(hex.str());
|
||||
|
||||
|
||||
activeLedColors.append(LEDcolor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get available led devices
|
||||
info["ledDevices"]["active"] = LedDevice::activeDevice();
|
||||
info["ledDevices"]["available"] = Json::Value(Json::arrayValue);
|
||||
for ( auto dev: LedDevice::getDeviceMap())
|
||||
{
|
||||
info["ledDevices"]["available"].append(dev.first);
|
||||
}
|
||||
|
||||
|
||||
// Add Hyperion Version, build time
|
||||
Json::Value & version = info["hyperion"] = Json::Value(Json::arrayValue);
|
||||
//Json::Value & version =
|
||||
info["hyperion"] = Json::Value(Json::arrayValue);
|
||||
Json::Value ver;
|
||||
ver["jsonrpc_version"] = HYPERION_JSON_VERSION;
|
||||
ver["version"] = HYPERION_VERSION;
|
||||
ver["build"] = HYPERION_BUILD_ID;
|
||||
ver["time"] = __DATE__ " " __TIME__;
|
||||
ver["build"] = HYPERION_BUILD_ID;
|
||||
ver["time"] = __DATE__ " " __TIME__;
|
||||
|
||||
version.append(ver);
|
||||
info["hyperion"].append(ver);
|
||||
|
||||
// send the result
|
||||
sendMessage(result);
|
||||
@ -941,7 +955,7 @@ void JsonClientConnection::handleConfigSetCommand(const Json::Value &message, co
|
||||
sendSuccessReply(command, tan);
|
||||
}
|
||||
} else
|
||||
sendErrorReply("Error while parsing json: Message size " + message.size(), command, tan);
|
||||
sendErrorReply("Error while parsing json: Message size " + std::to_string(message.size()), command, tan);
|
||||
}
|
||||
|
||||
void JsonClientConnection::handleComponentStateCommand(const Json::Value& message, const std::string &command, const int tan)
|
||||
|
@ -15,12 +15,12 @@ include_directories(
|
||||
# Group the headers that go through the MOC compiler
|
||||
SET(Leddevice_QT_HEADERS
|
||||
${CURRENT_HEADER_DIR}/LedDevice.h
|
||||
${CURRENT_SOURCE_DIR}/LedRs232Device.h
|
||||
${CURRENT_SOURCE_DIR}/ProviderRs232.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.h
|
||||
${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h
|
||||
${CURRENT_SOURCE_DIR}/LedHIDDevice.h
|
||||
${CURRENT_SOURCE_DIR}/ProviderHID.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceRawHID.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h
|
||||
)
|
||||
@ -34,13 +34,12 @@ SET(Leddevice_HEADERS
|
||||
${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceSedu.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceFile.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceUdp.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceUdpRaw.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceUdpE131.h
|
||||
${CURRENT_SOURCE_DIR}/LedUdpDevice.h
|
||||
${CURRENT_SOURCE_DIR}/ProviderUdp.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceTpm2.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceTpm2net.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceAtmo.h
|
||||
)
|
||||
|
||||
@ -48,8 +47,8 @@ SET(Leddevice_SOURCES
|
||||
${CURRENT_SOURCE_DIR}/LedDevice.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceFactory.cpp
|
||||
|
||||
${CURRENT_SOURCE_DIR}/LedRs232Device.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedHIDDevice.cpp
|
||||
${CURRENT_SOURCE_DIR}/ProviderRs232.cpp
|
||||
${CURRENT_SOURCE_DIR}/ProviderHID.cpp
|
||||
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.cpp
|
||||
@ -62,20 +61,20 @@ SET(Leddevice_SOURCES
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceSedu.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceFile.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceUdp.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceUdpRaw.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceUdpE131.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedUdpDevice.cpp
|
||||
${CURRENT_SOURCE_DIR}/ProviderUdp.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceTpm2.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceTpm2net.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceAtmo.cpp
|
||||
)
|
||||
|
||||
if(ENABLE_SPIDEV)
|
||||
SET(Leddevice_HEADERS
|
||||
${Leddevice_HEADERS}
|
||||
${CURRENT_SOURCE_DIR}/LedSpiDevice.h
|
||||
${CURRENT_SOURCE_DIR}/ProviderSpi.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceLpd6803.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceLpd8806.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceP9813.h
|
||||
@ -86,7 +85,7 @@ if(ENABLE_SPIDEV)
|
||||
)
|
||||
SET(Leddevice_SOURCES
|
||||
${Leddevice_SOURCES}
|
||||
${CURRENT_SOURCE_DIR}/LedSpiDevice.cpp
|
||||
${CURRENT_SOURCE_DIR}/ProviderSpi.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceLpd6803.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceLpd8806.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceP9813.cpp
|
||||
@ -131,7 +130,13 @@ if(ENABLE_TINKERFORGE)
|
||||
)
|
||||
endif()
|
||||
|
||||
set(LedDevice_RESOURCES
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceSchemas.qrc
|
||||
)
|
||||
|
||||
QT5_WRAP_CPP(Leddevice_HEADERS_MOC ${Leddevice_QT_HEADERS})
|
||||
qt5_add_resources(LedDevice_RESOURCES_RCC ${LedDevice_RESOURCES} OPTIONS "-no-compress")
|
||||
|
||||
|
||||
|
||||
add_library(leddevice
|
||||
@ -139,13 +144,14 @@ add_library(leddevice
|
||||
${Leddevice_QT_HEADERS}
|
||||
${Leddevice_HEADERS_MOC}
|
||||
${Leddevice_SOURCES}
|
||||
${LedDevice_RESOURCES}
|
||||
${LedDevice_RESOURCES_RCC}
|
||||
)
|
||||
|
||||
qt5_use_modules(leddevice Network SerialPort)
|
||||
|
||||
target_link_libraries(leddevice
|
||||
hyperion-utils
|
||||
# serialport
|
||||
${LIBUSB_1_LIBRARIES} #apt-get install libusb-1.0-0-dev
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${QT_LIBRARIES}
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include <leddevice/LedDevice.h>
|
||||
|
||||
LedDeviceRegistry LedDevice::_ledDeviceMap = LedDeviceRegistry();
|
||||
std::string LedDevice::_activeDevice = "";
|
||||
|
||||
LedDevice::LedDevice()
|
||||
: QObject()
|
||||
, _log(Logger::getInstance("LedDevice"))
|
||||
@ -9,8 +12,24 @@ LedDevice::LedDevice()
|
||||
{
|
||||
}
|
||||
|
||||
// dummy implemention
|
||||
int LedDevice::open()
|
||||
{
|
||||
//dummy implemention
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LedDevice::addToDeviceMap(std::string name, LedDeviceCreateFuncType funcPtr)
|
||||
{
|
||||
_ledDeviceMap.emplace(name,funcPtr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const LedDeviceRegistry& LedDevice::getDeviceMap()
|
||||
{
|
||||
return _ledDeviceMap;
|
||||
}
|
||||
|
||||
void LedDevice::setActiveDevice(std::string dev)
|
||||
{
|
||||
_activeDevice = dev;
|
||||
}
|
@ -12,9 +12,15 @@
|
||||
// hyperion local includes
|
||||
#include "LedDeviceAPA102.h"
|
||||
|
||||
LedDeviceAPA102::LedDeviceAPA102(const std::string& outputDevice, const unsigned baudrate)
|
||||
: LedSpiDevice(outputDevice, baudrate, 500000)
|
||||
LedDeviceAPA102::LedDeviceAPA102(const Json::Value &deviceConfig)
|
||||
: ProviderSpi(deviceConfig)
|
||||
{
|
||||
_latchTime_ns = 500000;
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceAPA102::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceAPA102(deviceConfig);
|
||||
}
|
||||
|
||||
int LedDeviceAPA102::write(const std::vector<ColorRgb> &ledValues)
|
||||
|
@ -4,23 +4,24 @@
|
||||
#include <string>
|
||||
|
||||
// hyperion incluse
|
||||
#include "LedSpiDevice.h"
|
||||
#include "ProviderSpi.h"
|
||||
#include <json/json.h>
|
||||
|
||||
///
|
||||
/// Implementation of the LedDevice interface for writing to APA102 led device.
|
||||
///
|
||||
/// APA102 is
|
||||
///
|
||||
class LedDeviceAPA102 : public LedSpiDevice
|
||||
class LedDeviceAPA102 : public ProviderSpi
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs the LedDevice for a string containing leds of the type APA102
|
||||
/// Constructs specific LedDevice
|
||||
///
|
||||
/// @param outputDevice The name of the output device (eg '/dev/spidev.0.0')
|
||||
/// @param baudrate The used baudrate for writing to the output device
|
||||
/// @param deviceConfig json device config
|
||||
///
|
||||
LedDeviceAPA102(const std::string& outputDevice, const unsigned baudrate );
|
||||
LedDeviceAPA102(const Json::Value &deviceConfig);
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
|
||||
|
||||
///
|
||||
|
@ -10,9 +10,10 @@
|
||||
|
||||
// hyperion local includes
|
||||
#include "LedDeviceAdalight.h"
|
||||
#include <leddevice/LedDevice.h>
|
||||
|
||||
LedDeviceAdalight::LedDeviceAdalight(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms)
|
||||
: LedRs232Device(outputDevice, baudrate, delayAfterConnect_ms)
|
||||
LedDeviceAdalight::LedDeviceAdalight(const Json::Value &deviceConfig)
|
||||
: ProviderRs232(deviceConfig)
|
||||
, _timer()
|
||||
{
|
||||
// setup the timer
|
||||
@ -24,6 +25,11 @@ LedDeviceAdalight::LedDeviceAdalight(const std::string& outputDevice, const unsi
|
||||
_timer.start();
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceAdalight::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceAdalight(deviceConfig);
|
||||
}
|
||||
|
||||
int LedDeviceAdalight::write(const std::vector<ColorRgb> & ledValues)
|
||||
{
|
||||
if (_ledBuffer.size() == 0)
|
||||
|
@ -7,23 +7,25 @@
|
||||
#include <QTimer>
|
||||
|
||||
// hyperion include
|
||||
#include "LedRs232Device.h"
|
||||
#include "ProviderRs232.h"
|
||||
|
||||
///
|
||||
/// Implementation of the LedDevice interface for writing to an Adalight led device.
|
||||
///
|
||||
class LedDeviceAdalight : public LedRs232Device
|
||||
class LedDeviceAdalight : public ProviderRs232
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
///
|
||||
/// Constructs the LedDevice for attached Adalight device
|
||||
/// Constructs specific LedDevice
|
||||
///
|
||||
/// @param outputDevice The name of the output device (eg '/dev/ttyS0')
|
||||
/// @param baudrate The used baudrate for writing to the output device
|
||||
/// @param deviceConfig json device config
|
||||
///
|
||||
LedDeviceAdalight(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms);
|
||||
LedDeviceAdalight(const Json::Value &deviceConfig);
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Writes the led color values to the led-device
|
||||
@ -46,3 +48,4 @@ protected:
|
||||
/// every 15 seconds
|
||||
QTimer _timer;
|
||||
};
|
||||
|
||||
|
@ -11,11 +11,17 @@
|
||||
// hyperion local includes
|
||||
#include "LedDeviceAdalightApa102.h"
|
||||
|
||||
LedDeviceAdalightApa102::LedDeviceAdalightApa102(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms)
|
||||
: LedDeviceAdalight(outputDevice, baudrate, delayAfterConnect_ms)
|
||||
LedDeviceAdalightApa102::LedDeviceAdalightApa102(const Json::Value &deviceConfig)
|
||||
: LedDeviceAdalight(deviceConfig)
|
||||
{
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceAdalightApa102::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceAdalightApa102(deviceConfig);
|
||||
}
|
||||
|
||||
|
||||
//comparing to ws2801 adalight, the following changes were needed:
|
||||
// 1- differnt data frame (4 bytes instead of 3)
|
||||
// 2 - in order to accomodate point 1 above, number of leds sent to adalight is increased by 1/3rd
|
||||
|
@ -20,7 +20,10 @@ public:
|
||||
/// @param outputDevice The name of the output device (eg '/dev/ttyS0')
|
||||
/// @param baudrate The used baudrate for writing to the output device
|
||||
///
|
||||
LedDeviceAdalightApa102(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms);
|
||||
LedDeviceAdalightApa102(const Json::Value &deviceConfig);
|
||||
|
||||
/// create leddevice when type in config is set to this type
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Writes the led color values to the led-device
|
||||
@ -33,3 +36,4 @@ public:
|
||||
/// Switch the leds off
|
||||
virtual int switchOff();
|
||||
};
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
// hyperion local includes
|
||||
#include "LedDeviceAtmo.h"
|
||||
|
||||
LedDeviceAtmo::LedDeviceAtmo(const std::string& outputDevice, const unsigned baudrate)
|
||||
: LedRs232Device(outputDevice, baudrate)
|
||||
LedDeviceAtmo::LedDeviceAtmo(const Json::Value &deviceConfig)
|
||||
: ProviderRs232(deviceConfig)
|
||||
{
|
||||
_ledBuffer.resize(4 + 5*3); // 4-byte header, 5 RGB values
|
||||
_ledBuffer[0] = 0xFF; // Startbyte
|
||||
@ -11,6 +11,12 @@ LedDeviceAtmo::LedDeviceAtmo(const std::string& outputDevice, const unsigned bau
|
||||
_ledBuffer[3] = 0x0F; // Number of Databytes send (always! 15)
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceAtmo::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceAtmo(deviceConfig);
|
||||
}
|
||||
|
||||
|
||||
int LedDeviceAtmo::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
// The protocol is shomehow limited. we always need to send exactly 5 channels + header
|
||||
|
@ -4,22 +4,23 @@
|
||||
#include <string>
|
||||
|
||||
// hyperion incluse
|
||||
#include "LedRs232Device.h"
|
||||
#include "ProviderRs232.h"
|
||||
|
||||
///
|
||||
/// Implementation of the LedDevice interface for writing to serial device using tpm2 protocol.
|
||||
///
|
||||
class LedDeviceAtmo : public LedRs232Device
|
||||
class LedDeviceAtmo : public ProviderRs232
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs the LedDevice for attached serial device using supporting tpm2 protocol
|
||||
/// All LEDs in the stripe are handled as one frame
|
||||
/// Constructs specific LedDevice
|
||||
///
|
||||
/// @param outputDevice The name of the output device (eg '/dev/ttyAMA0')
|
||||
/// @param baudrate The used baudrate for writing to the output device
|
||||
/// @param deviceConfig json device config
|
||||
///
|
||||
LedDeviceAtmo(const std::string& outputDevice, const unsigned baudrate);
|
||||
LedDeviceAtmo(const Json::Value &deviceConfig);
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Writes the led color values to the led-device
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
@ -15,23 +16,10 @@ AtmoOrbLight::AtmoOrbLight(unsigned int id) {
|
||||
// Not implemented
|
||||
}
|
||||
|
||||
LedDeviceAtmoOrb::LedDeviceAtmoOrb(
|
||||
const std::string &output,
|
||||
bool useOrbSmoothing,
|
||||
int transitiontime,
|
||||
int skipSmoothingDiff,
|
||||
int port,
|
||||
int numLeds,
|
||||
std::vector<unsigned int> orbIds)
|
||||
LedDeviceAtmoOrb::LedDeviceAtmoOrb(const Json::Value &deviceConfig)
|
||||
: LedDevice()
|
||||
, _multicastGroup(output.c_str())
|
||||
, _useOrbSmoothing(useOrbSmoothing)
|
||||
, _transitiontime(transitiontime)
|
||||
, _skipSmoothingDiff(skipSmoothingDiff)
|
||||
, _multiCastGroupPort(port)
|
||||
, _numLeds(numLeds)
|
||||
, _orbIds(orbIds)
|
||||
{
|
||||
setConfig(deviceConfig);
|
||||
_manager = new QNetworkAccessManager();
|
||||
_groupAddress = QHostAddress(_multicastGroup);
|
||||
|
||||
@ -41,6 +29,44 @@ LedDeviceAtmoOrb::LedDeviceAtmoOrb(
|
||||
joinedMulticastgroup = _udpSocket->joinMulticastGroup(_groupAddress);
|
||||
}
|
||||
|
||||
bool LedDeviceAtmoOrb::setConfig(const Json::Value &deviceConfig)
|
||||
{
|
||||
_multicastGroup = deviceConfig["output"].asString().c_str();
|
||||
_useOrbSmoothing = deviceConfig.get("useOrbSmoothing", false).asBool();
|
||||
_transitiontime = deviceConfig.get("transitiontime", 0).asInt();
|
||||
_skipSmoothingDiff = deviceConfig.get("skipSmoothingDiff", 0).asInt();
|
||||
_multiCastGroupPort = deviceConfig.get("port", 49692).asInt();
|
||||
_numLeds = deviceConfig.get("numLeds", 24).asInt();
|
||||
|
||||
const std::string orbId = deviceConfig["orbIds"].asString();
|
||||
_orbIds.clear();
|
||||
|
||||
// If we find multiple Orb ids separate them and add to list
|
||||
const std::string separator (",");
|
||||
if (orbId.find(separator) != std::string::npos)
|
||||
{
|
||||
std::stringstream ss(orbId);
|
||||
std::vector<int> output;
|
||||
unsigned int i;
|
||||
while (ss >> i)
|
||||
{
|
||||
_orbIds.push_back(i);
|
||||
if (ss.peek() == ',' || ss.peek() == ' ') ss.ignore();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_orbIds.push_back(atoi(orbId.c_str()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceAtmoOrb::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceAtmoOrb(deviceConfig);
|
||||
}
|
||||
|
||||
int LedDeviceAtmoOrb::write(const std::vector <ColorRgb> &ledValues)
|
||||
{
|
||||
// If not in multicast group return
|
||||
|
@ -45,20 +45,21 @@ public:
|
||||
bool joinedMulticastgroup;
|
||||
|
||||
///
|
||||
/// Constructs the device.
|
||||
/// Constructs specific LedDevice
|
||||
///
|
||||
/// @param output is the multicast address of Orbs
|
||||
/// @param transitiontime is optional and not used at the moment
|
||||
/// @param useOrbSmoothing use Orbs own (external) smoothing algorithm (default: false)
|
||||
/// @param skipSmoothingDiff minimal color (0-255) difference to override smoothing so that if current and previously received colors are higher than set dif we override smoothing
|
||||
/// @param port is the multicast port.
|
||||
/// @param numLeds is the total amount of leds per Orb
|
||||
/// @param array containing orb ids
|
||||
/// @param deviceConfig json device config
|
||||
///
|
||||
LedDeviceAtmoOrb(const std::string &output, bool useOrbSmoothing =
|
||||
false, int transitiontime = 0, int skipSmoothingDiff = 0, int port = 49692, int numLeds = 24,
|
||||
std::vector<unsigned int> orbIds = std::vector<unsigned int>());
|
||||
LedDeviceAtmoOrb(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Sets configuration
|
||||
///
|
||||
/// @param deviceConfig the json device config
|
||||
/// @return true if success
|
||||
bool setConfig(const Json::Value &deviceConfig);
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
///
|
||||
/// Destructor of this device
|
||||
///
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <map>
|
||||
|
||||
// Build configuration
|
||||
#include <HyperionConfig.h>
|
||||
@ -10,6 +11,7 @@
|
||||
// Leddevice includes
|
||||
#include <leddevice/LedDeviceFactory.h>
|
||||
#include <utils/Logger.h>
|
||||
#include <leddevice/LedDevice.h>
|
||||
|
||||
// Local Leddevice includes
|
||||
#ifdef ENABLE_SPIDEV
|
||||
@ -35,7 +37,7 @@
|
||||
#include "LedDeviceSedu.h"
|
||||
#include "LedDeviceFile.h"
|
||||
#include "LedDeviceFadeCandy.h"
|
||||
#include "LedDeviceUdp.h"
|
||||
#include "LedDeviceTpm2net.h"
|
||||
#include "LedDeviceUdpRaw.h"
|
||||
#include "LedDeviceUdpE131.h"
|
||||
#include "LedDeviceHyperionUsbasp.h"
|
||||
@ -63,281 +65,81 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
|
||||
std::string type = deviceConfig.get("type", "UNSPECIFIED").asString();
|
||||
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
|
||||
|
||||
// rs232 devices
|
||||
LedDevice::addToDeviceMap("adalight" , LedDeviceAdalight::construct);
|
||||
LedDevice::addToDeviceMap("adalightapa102", LedDeviceAdalightApa102::construct);
|
||||
LedDevice::addToDeviceMap("sedu" , LedDeviceSedu::construct);
|
||||
LedDevice::addToDeviceMap("tpm2" , LedDeviceTpm2::construct);
|
||||
LedDevice::addToDeviceMap("atmo" , LedDeviceAtmo::construct);
|
||||
LedDevice::addToDeviceMap("fadecandy" , LedDeviceFadeCandy::construct);
|
||||
|
||||
// spi devices
|
||||
#ifdef ENABLE_SPIDEV
|
||||
LedDevice::addToDeviceMap("apa102" , LedDeviceAPA102::construct);
|
||||
LedDevice::addToDeviceMap("lpd6803" , LedDeviceLpd6803::construct);
|
||||
LedDevice::addToDeviceMap("lpd8806" , LedDeviceLpd8806::construct);
|
||||
LedDevice::addToDeviceMap("p9813" , LedDeviceP9813::construct);
|
||||
LedDevice::addToDeviceMap("ws2801" , LedDeviceWs2801::construct);
|
||||
LedDevice::addToDeviceMap("ws2812spi" , LedDeviceWs2812SPI::construct);
|
||||
LedDevice::addToDeviceMap("sk6812rgbw-spi", LedDeviceSk6812SPI::construct);
|
||||
#endif
|
||||
|
||||
// pwm devices
|
||||
#ifdef ENABLE_WS2812BPWM
|
||||
LedDevice::addToDeviceMap("ws2812b", LedDeviceWS2812b::construct);
|
||||
#endif
|
||||
#ifdef ENABLE_WS281XPWM
|
||||
LedDevice::addToDeviceMap("ws281x", LedDeviceWS281x::construct);
|
||||
#endif
|
||||
|
||||
// network lights
|
||||
LedDevice::addToDeviceMap("tmp2net", LedDeviceTpm2net::construct);
|
||||
LedDevice::addToDeviceMap("udpraw", LedDeviceUdpRaw::construct);
|
||||
LedDevice::addToDeviceMap("e131", LedDeviceUdpE131::construct);
|
||||
#ifdef ENABLE_TINKERFORGE
|
||||
LedDevice::addToDeviceMap("tinkerforge", LedDeviceTinkerforge::construct);
|
||||
#endif
|
||||
LedDevice::addToDeviceMap("philipshue", LedDevicePhilipsHue::construct);
|
||||
LedDevice::addToDeviceMap("atmoorb", LedDeviceAtmoOrb::construct);
|
||||
|
||||
// direct usb
|
||||
LedDevice::addToDeviceMap("hyperion-usbasp", LedDeviceHyperionUsbasp::construct);
|
||||
LedDevice::addToDeviceMap("rawhid", LedDeviceRawHID::construct);
|
||||
LedDevice::addToDeviceMap("paintpack", LedDevicePaintpack::construct);
|
||||
LedDevice::addToDeviceMap("lightpack", LedDeviceLightpack::construct);
|
||||
LedDevice::addToDeviceMap("multi-lightpack", LedDeviceMultiLightpack::construct);
|
||||
|
||||
// other
|
||||
LedDevice::addToDeviceMap("file", LedDeviceFile::construct);
|
||||
LedDevice::addToDeviceMap("piblaster", LedDevicePiBlaster::construct);
|
||||
|
||||
const LedDeviceRegistry& devList = LedDevice::getDeviceMap();
|
||||
LedDevice* device = nullptr;
|
||||
try
|
||||
{
|
||||
if (false) {}
|
||||
else if (type == "adalight")
|
||||
for ( auto dev: devList)
|
||||
{
|
||||
device = new LedDeviceAdalight(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig["rate"].asInt(),
|
||||
deviceConfig.get("delayAfterConnect",500).asInt()
|
||||
);
|
||||
}
|
||||
else if (type == "adalightapa102")
|
||||
{
|
||||
device = new LedDeviceAdalightApa102(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig["rate"].asInt(),
|
||||
deviceConfig.get("delayAfterConnect",500).asInt()
|
||||
);
|
||||
}
|
||||
#ifdef ENABLE_SPIDEV
|
||||
else if (type == "lpd6803" || type == "ldp6803")
|
||||
{
|
||||
device = new LedDeviceLpd6803(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig["rate"].asInt()
|
||||
);
|
||||
}
|
||||
else if (type == "lpd8806" || type == "ldp8806")
|
||||
{
|
||||
device = new LedDeviceLpd8806(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig["rate"].asInt()
|
||||
);
|
||||
}
|
||||
else if (type == "p9813")
|
||||
{
|
||||
device = new LedDeviceP9813(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig["rate"].asInt()
|
||||
);
|
||||
}
|
||||
else if (type == "apa102")
|
||||
{
|
||||
device = new LedDeviceAPA102(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig["rate"].asInt()
|
||||
);
|
||||
}
|
||||
else if (type == "ws2801" || type == "lightberry")
|
||||
{
|
||||
device = new LedDeviceWs2801(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig["rate"].asInt(),
|
||||
deviceConfig.get("latchtime",500000).asInt(),
|
||||
deviceConfig.get("spimode",0).asInt(),
|
||||
deviceConfig.get("invert",false).asBool()
|
||||
);
|
||||
}
|
||||
else if (type == "ws2812spi")
|
||||
{
|
||||
device = new LedDeviceWs2812SPI(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig.get("rate",2857143).asInt(),
|
||||
deviceConfig.get("spimode",0).asInt(),
|
||||
deviceConfig.get("invert",false).asBool()
|
||||
);
|
||||
}
|
||||
else if (type == "sk6812rgbw-spi")
|
||||
{
|
||||
device = new LedDeviceSk6812SPI(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig.get("rate",2857143).asInt(),
|
||||
deviceConfig.get("white_algorithm","").asString(),
|
||||
deviceConfig.get("spimode",0).asInt(),
|
||||
deviceConfig.get("invert",false).asBool()
|
||||
);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_TINKERFORGE
|
||||
else if (type=="tinkerforge")
|
||||
{
|
||||
device = new LedDeviceTinkerforge(
|
||||
deviceConfig.get("output", "127.0.0.1").asString(),
|
||||
deviceConfig.get("port", 4223).asInt(),
|
||||
deviceConfig["uid"].asString(),
|
||||
deviceConfig["rate"].asInt()
|
||||
);
|
||||
|
||||
}
|
||||
#endif
|
||||
else if (type == "rawhid")
|
||||
{
|
||||
const int delay_ms = deviceConfig["delayAfterConnect"].asInt();
|
||||
auto VendorIdString = deviceConfig.get("VID", "0x2341").asString();
|
||||
auto ProductIdString = deviceConfig.get("PID", "0x8036").asString();
|
||||
|
||||
// Convert HEX values to integer
|
||||
auto VendorId = std::stoul(VendorIdString, nullptr, 16);
|
||||
auto ProductId = std::stoul(ProductIdString, nullptr, 16);
|
||||
|
||||
device = new LedDeviceRawHID(VendorId, ProductId, delay_ms);
|
||||
}
|
||||
else if (type == "lightpack")
|
||||
{
|
||||
device = new LedDeviceLightpack(
|
||||
deviceConfig.get("output", "").asString()
|
||||
);
|
||||
}
|
||||
else if (type == "multi-lightpack")
|
||||
{
|
||||
device = new LedDeviceMultiLightpack();
|
||||
}
|
||||
else if (type == "paintpack")
|
||||
{
|
||||
const int delay_ms = deviceConfig["delayAfterConnect"].asInt();
|
||||
auto VendorIdString = deviceConfig.get("VID", "0x0EBF").asString();
|
||||
auto ProductIdString = deviceConfig.get("PID", "0x0025").asString();
|
||||
|
||||
// Convert HEX values to integer
|
||||
auto VendorId = std::stoul(VendorIdString, nullptr, 16);
|
||||
auto ProductId = std::stoul(ProductIdString, nullptr, 16);
|
||||
|
||||
device = new LedDevicePaintpack(VendorId, ProductId, delay_ms);
|
||||
}
|
||||
else if (type == "piblaster")
|
||||
{
|
||||
const std::string output = deviceConfig.get("output", "").asString();
|
||||
const std::string assignment = deviceConfig.get("assignment", "").asString();
|
||||
const Json::Value gpioMapping = deviceConfig.get("gpiomap", Json::nullValue);
|
||||
|
||||
if (! assignment.empty())
|
||||
if (dev.first == type)
|
||||
{
|
||||
throw std::runtime_error("Piblaster: The piblaster configuration syntax has changed in this version.");
|
||||
device = dev.second(deviceConfig);
|
||||
LedDevice::setActiveDevice(dev.first);
|
||||
Info(log,"LedDevice '%s' configured.", dev.first.c_str());
|
||||
break;
|
||||
}
|
||||
if (gpioMapping.isNull())
|
||||
{
|
||||
throw std::runtime_error("Piblaster: no gpiomap defined.");
|
||||
}
|
||||
device = new LedDevicePiBlaster(output, gpioMapping);
|
||||
}
|
||||
else if (type == "sedu")
|
||||
{
|
||||
device = new LedDeviceSedu(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig["rate"].asInt()
|
||||
);
|
||||
}
|
||||
else if (type == "hyperion-usbasp-ws2801")
|
||||
{
|
||||
device = new LedDeviceHyperionUsbasp(LedDeviceHyperionUsbasp::CMD_WRITE_WS2801);
|
||||
}
|
||||
else if (type == "hyperion-usbasp-ws2812")
|
||||
{
|
||||
device = new LedDeviceHyperionUsbasp(LedDeviceHyperionUsbasp::CMD_WRITE_WS2812);
|
||||
}
|
||||
else if (type == "philipshue")
|
||||
{
|
||||
const std::string output = deviceConfig["output"].asString();
|
||||
const std::string username = deviceConfig.get("username", "newdeveloper").asString();
|
||||
const bool switchOffOnBlack = deviceConfig.get("switchOffOnBlack", true).asBool();
|
||||
const int transitiontime = deviceConfig.get("transitiontime", 1).asInt();
|
||||
std::vector<unsigned int> lightIds;
|
||||
for (Json::Value::ArrayIndex i = 0; i < deviceConfig["lightIds"].size(); i++) {
|
||||
lightIds.push_back(deviceConfig["lightIds"][i].asInt());
|
||||
}
|
||||
device = new LedDevicePhilipsHue(output, username, switchOffOnBlack, transitiontime, lightIds);
|
||||
}
|
||||
else if (type == "atmoorb")
|
||||
{
|
||||
const std::string output = deviceConfig["output"].asString();
|
||||
const bool useOrbSmoothing = deviceConfig.get("useOrbSmoothing", false).asBool();
|
||||
const int transitiontime = deviceConfig.get("transitiontime", 1).asInt();
|
||||
const int skipSmoothingDiff = deviceConfig.get("skipSmoothingDiff", 0).asInt();
|
||||
const int port = deviceConfig.get("port", 1).asInt();
|
||||
const int numLeds = deviceConfig.get("numLeds", 1).asInt();
|
||||
const std::string orbId = deviceConfig["orbIds"].asString();
|
||||
std::vector<unsigned int> orbIds;
|
||||
|
||||
// If we find multiple Orb ids separate them and add to list
|
||||
const std::string separator (",");
|
||||
if (orbId.find(separator) != std::string::npos) {
|
||||
std::stringstream ss(orbId);
|
||||
std::vector<int> output;
|
||||
unsigned int i;
|
||||
while (ss >> i) {
|
||||
orbIds.push_back(i);
|
||||
if (ss.peek() == ',' || ss.peek() == ' ')
|
||||
ss.ignore();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
orbIds.push_back(atoi(orbId.c_str()));
|
||||
}
|
||||
|
||||
device = new LedDeviceAtmoOrb(output, useOrbSmoothing, transitiontime, skipSmoothingDiff, port, numLeds, orbIds);
|
||||
}
|
||||
else if (type == "fadecandy")
|
||||
{
|
||||
device = new LedDeviceFadeCandy(deviceConfig);
|
||||
}
|
||||
else if (type == "udp")
|
||||
{
|
||||
device = new LedDeviceUdp(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig["protocol"].asInt(),
|
||||
deviceConfig["maxpacket"].asInt()
|
||||
);
|
||||
}
|
||||
else if (type == "udpraw")
|
||||
{
|
||||
device = new LedDeviceUdpRaw(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig.get("latchtime",500000).asInt()
|
||||
);
|
||||
}
|
||||
else if (type == "e131")
|
||||
{
|
||||
device = new LedDeviceUdpE131(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig.get("latchtime",500000).asInt(),
|
||||
deviceConfig.get("universe",1).asInt()
|
||||
);
|
||||
}
|
||||
else if (type == "tpm2")
|
||||
{
|
||||
device = new LedDeviceTpm2(
|
||||
deviceConfig["output"].asString(),
|
||||
deviceConfig["rate"].asInt()
|
||||
);
|
||||
}
|
||||
else if (type == "atmo")
|
||||
{
|
||||
device = new LedDeviceAtmo(
|
||||
deviceConfig["output"].asString(),
|
||||
38400
|
||||
);
|
||||
}
|
||||
#ifdef ENABLE_WS2812BPWM
|
||||
else if (type == "ws2812b")
|
||||
{
|
||||
device = new LedDeviceWS2812b();
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_WS281XPWM
|
||||
else if (type == "ws281x")
|
||||
{
|
||||
device = new LedDeviceWS281x(
|
||||
deviceConfig.get("gpio", 18).asInt(),
|
||||
deviceConfig.get("leds", 256).asInt(),
|
||||
deviceConfig.get("freq", (Json::UInt)800000ul).asInt(),
|
||||
deviceConfig.get("dmanum", 5).asInt(),
|
||||
deviceConfig.get("pwmchannel", 0).asInt(),
|
||||
deviceConfig.get("invert", 0).asInt(),
|
||||
deviceConfig.get("rgbw", 0).asInt(),
|
||||
deviceConfig.get("white_algorithm","").asString()
|
||||
);
|
||||
}
|
||||
#endif
|
||||
else if (type == "file")
|
||||
{
|
||||
device = new LedDeviceFile( deviceConfig.get("output", "/dev/null").asString() );
|
||||
}
|
||||
else
|
||||
|
||||
if (device == nullptr)
|
||||
{
|
||||
Error(log, "Dummy device used, because configured device '%s' is unknown", type.c_str() );
|
||||
throw std::runtime_error("unknown device");
|
||||
}
|
||||
}
|
||||
catch(std::exception e)
|
||||
catch(std::exception& e)
|
||||
{
|
||||
|
||||
Error(log, "Dummy device used, because configured device '%s' throws error '%s'", type.c_str(), e.what());
|
||||
device = new LedDeviceFile( "/dev/null" );
|
||||
const Json::Value dummyDeviceConfig;
|
||||
device = LedDeviceFile::construct(Json::nullValue);
|
||||
}
|
||||
|
||||
device->open();
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "LedDeviceFadeCandy.h"
|
||||
|
||||
static const signed MAX_NUM_LEDS = 10000; // OPC can handle 21845 leds - in theory, fadecandy device should handle 10000 leds
|
||||
static const signed MAX_NUM_LEDS = 10000; // OPC can handle 21845 leds - in theory, fadecandy device should handle 10000 leds
|
||||
static const unsigned OPC_SET_PIXELS = 0; // OPC command codes
|
||||
static const unsigned OPC_SYS_EX = 255; // OPC command codes
|
||||
static const unsigned OPC_HEADER_SIZE = 4; // OPC header size
|
||||
@ -10,13 +10,6 @@ LedDeviceFadeCandy::LedDeviceFadeCandy(const Json::Value &deviceConfig)
|
||||
: LedDevice()
|
||||
{
|
||||
setConfig(deviceConfig);
|
||||
_opc_data.resize( OPC_HEADER_SIZE );
|
||||
_opc_data[0] = _channel;
|
||||
_opc_data[1] = OPC_SET_PIXELS;
|
||||
_opc_data[2] = 0;
|
||||
_opc_data[3] = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -25,8 +18,16 @@ LedDeviceFadeCandy::~LedDeviceFadeCandy()
|
||||
_client.close();
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceFadeCandy::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceFadeCandy(deviceConfig);
|
||||
}
|
||||
|
||||
|
||||
bool LedDeviceFadeCandy::setConfig(const Json::Value &deviceConfig)
|
||||
{
|
||||
_client.close();
|
||||
|
||||
_host = deviceConfig.get("output", "127.0.0.1").asString();
|
||||
_port = deviceConfig.get("port", 7890).asInt();
|
||||
_channel = deviceConfig.get("channel", 0).asInt();
|
||||
@ -49,6 +50,12 @@ bool LedDeviceFadeCandy::setConfig(const Json::Value &deviceConfig)
|
||||
_whitePoint_b = whitePointConfig[2].asDouble();
|
||||
}
|
||||
|
||||
_opc_data.resize( OPC_HEADER_SIZE );
|
||||
_opc_data[0] = _channel;
|
||||
_opc_data[1] = OPC_SET_PIXELS;
|
||||
_opc_data[2] = 0;
|
||||
_opc_data[3] = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
// Leddevice includes
|
||||
#include <leddevice/LedDevice.h>
|
||||
#include <json/json.h>
|
||||
|
||||
///
|
||||
/// Implementation of the LedDevice interface for sending to
|
||||
@ -48,6 +47,9 @@ public:
|
||||
///
|
||||
virtual ~LedDeviceFadeCandy();
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Sets configuration
|
||||
///
|
||||
@ -66,7 +68,6 @@ public:
|
||||
/// Switch the leds off
|
||||
virtual int switchOff();
|
||||
|
||||
|
||||
private:
|
||||
QTcpSocket _client;
|
||||
std::string _host;
|
||||
@ -115,3 +116,4 @@ private:
|
||||
void sendFadeCandyConfiguration();
|
||||
|
||||
};
|
||||
|
||||
|
@ -2,16 +2,32 @@
|
||||
// Local-Hyperion includes
|
||||
#include "LedDeviceFile.h"
|
||||
|
||||
LedDeviceFile::LedDeviceFile(const std::string& output)
|
||||
LedDeviceFile::LedDeviceFile(const Json::Value &deviceConfig)
|
||||
: LedDevice()
|
||||
, _ofs( output.empty() ? "/dev/null" : output.c_str())
|
||||
{
|
||||
// empty
|
||||
setConfig(deviceConfig);
|
||||
}
|
||||
|
||||
LedDeviceFile::~LedDeviceFile()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceFile::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceFile(deviceConfig);
|
||||
}
|
||||
|
||||
bool LedDeviceFile::setConfig(const Json::Value &deviceConfig)
|
||||
{
|
||||
if ( _ofs.is_open() )
|
||||
{
|
||||
_ofs.close();
|
||||
}
|
||||
|
||||
std::string fileName = deviceConfig.get("output","/dev/null").asString();
|
||||
_ofs.open( fileName.c_str() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int LedDeviceFile::write(const std::vector<ColorRgb> & ledValues)
|
||||
|
@ -14,15 +14,27 @@ class LedDeviceFile : public LedDevice
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs the test-device, which opens an output stream to the file
|
||||
/// Constructs specific LedDevice
|
||||
///
|
||||
LedDeviceFile(const std::string& output);
|
||||
/// @param deviceConfig json device config
|
||||
///
|
||||
LedDeviceFile(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Destructor of this test-device
|
||||
///
|
||||
virtual ~LedDeviceFile();
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Sets configuration
|
||||
///
|
||||
/// @param deviceConfig the json device config
|
||||
/// @return true if success
|
||||
virtual bool setConfig(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Writes the given led-color values to the output stream
|
||||
///
|
||||
|
@ -11,12 +11,12 @@ uint16_t LedDeviceHyperionUsbasp::_usbProductId = 0x05dc;
|
||||
std::string LedDeviceHyperionUsbasp::_usbProductDescription = "Hyperion led controller";
|
||||
|
||||
|
||||
LedDeviceHyperionUsbasp::LedDeviceHyperionUsbasp(uint8_t writeLedsCommand)
|
||||
LedDeviceHyperionUsbasp::LedDeviceHyperionUsbasp(const Json::Value &deviceConfig)
|
||||
: LedDevice()
|
||||
, _writeLedsCommand(writeLedsCommand)
|
||||
, _libusbContext(nullptr)
|
||||
, _deviceHandle(nullptr)
|
||||
{
|
||||
setConfig(deviceConfig);
|
||||
}
|
||||
|
||||
LedDeviceHyperionUsbasp::~LedDeviceHyperionUsbasp()
|
||||
@ -37,6 +37,25 @@ LedDeviceHyperionUsbasp::~LedDeviceHyperionUsbasp()
|
||||
}
|
||||
}
|
||||
|
||||
bool LedDeviceHyperionUsbasp::setConfig(const Json::Value &deviceConfig)
|
||||
{
|
||||
std::string ledType = deviceConfig.get("output", "ws2801").asString();
|
||||
if (ledType != "ws2801" && ledType != "ws2812")
|
||||
{
|
||||
throw std::runtime_error("HyperionUsbasp: invalid output; must be 'ws2801' or 'ws2812'.");
|
||||
}
|
||||
|
||||
_writeLedsCommand = (ledType == "ws2801") ? CMD_WRITE_WS2801 : CMD_WRITE_WS2812;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceHyperionUsbasp::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceHyperionUsbasp(deviceConfig);
|
||||
}
|
||||
|
||||
|
||||
int LedDeviceHyperionUsbasp::open()
|
||||
{
|
||||
int error;
|
||||
|
@ -24,9 +24,21 @@ public:
|
||||
};
|
||||
|
||||
///
|
||||
/// Constructs the LedDeviceLightpack
|
||||
/// Constructs specific LedDevice
|
||||
///
|
||||
LedDeviceHyperionUsbasp(uint8_t writeLedsCommand);
|
||||
/// @param deviceConfig json device config
|
||||
///
|
||||
LedDeviceHyperionUsbasp(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Sets configuration
|
||||
///
|
||||
/// @param deviceConfig the json device config
|
||||
/// @return true if success
|
||||
bool setConfig(const Json::Value &deviceConfig);
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Destructor of the LedDevice; closes the output device if it is open
|
||||
@ -70,7 +82,7 @@ private:
|
||||
|
||||
private:
|
||||
/// command to write the leds
|
||||
const uint8_t _writeLedsCommand;
|
||||
uint8_t _writeLedsCommand;
|
||||
|
||||
/// libusb context
|
||||
libusb_context * _libusbContext;
|
||||
|
@ -45,6 +45,12 @@ LedDeviceLightpack::LedDeviceLightpack(const std::string & serialNumber)
|
||||
_ledCount = -1;
|
||||
}
|
||||
|
||||
LedDeviceLightpack::LedDeviceLightpack(const Json::Value &deviceConfig)
|
||||
: LedDeviceLightpack()
|
||||
{
|
||||
setConfig(deviceConfig);
|
||||
}
|
||||
|
||||
LedDeviceLightpack::~LedDeviceLightpack()
|
||||
{
|
||||
if (_deviceHandle != nullptr)
|
||||
@ -63,6 +69,18 @@ LedDeviceLightpack::~LedDeviceLightpack()
|
||||
}
|
||||
}
|
||||
|
||||
bool LedDeviceLightpack::setConfig(const Json::Value &deviceConfig)
|
||||
{
|
||||
_serialNumber = deviceConfig.get("output", "").asString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceLightpack::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceLightpack(deviceConfig);
|
||||
}
|
||||
|
||||
int LedDeviceLightpack::open()
|
||||
{
|
||||
int error;
|
||||
|
@ -23,6 +23,22 @@ public:
|
||||
/// @param serialNumber serial output device
|
||||
///
|
||||
LedDeviceLightpack(const std::string & serialNumber = "");
|
||||
///
|
||||
/// Constructs specific LedDevice
|
||||
///
|
||||
/// @param deviceConfig json device config
|
||||
///
|
||||
LedDeviceLightpack(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Sets configuration
|
||||
///
|
||||
/// @param deviceConfig the json device config
|
||||
/// @return true if success
|
||||
bool setConfig(const Json::Value &deviceConfig);
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Destructor of the LedDevice; closes the output device if it is open
|
||||
|
@ -10,11 +10,16 @@
|
||||
// hyperion local includes
|
||||
#include "LedDeviceLpd6803.h"
|
||||
|
||||
LedDeviceLpd6803::LedDeviceLpd6803(const std::string& outputDevice, const unsigned baudrate)
|
||||
: LedSpiDevice(outputDevice, baudrate)
|
||||
LedDeviceLpd6803::LedDeviceLpd6803(const Json::Value &deviceConfig)
|
||||
: ProviderSpi(deviceConfig)
|
||||
{
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceLpd6803::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceLpd6803(deviceConfig);
|
||||
}
|
||||
|
||||
int LedDeviceLpd6803::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
unsigned messageLength = 4 + 2*ledValues.size() + ledValues.size()/8 + 1;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Local hyperion incluse
|
||||
#include "LedSpiDevice.h"
|
||||
#include "ProviderSpi.h"
|
||||
|
||||
///
|
||||
/// Implementation of the LedDevice interface for writing to LDP6803 led device.
|
||||
@ -14,16 +14,18 @@
|
||||
/// (R, G and B in the above illustration) making 16 bits per led. Total bytes = 4 + (2 x number of
|
||||
/// leds)
|
||||
///
|
||||
class LedDeviceLpd6803 : public LedSpiDevice
|
||||
class LedDeviceLpd6803 : public ProviderSpi
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs the LedDevice for a string containing leds of the type LDP6803
|
||||
/// Constructs specific LedDevice
|
||||
///
|
||||
/// @param[in] outputDevice The name of the output device (eg '/dev/spidev0.0')
|
||||
/// @param[in] baudrate The used baudrate for writing to the output device
|
||||
/// @param deviceConfig json device config
|
||||
///
|
||||
LedDeviceLpd6803(const std::string& outputDevice, const unsigned baudrate);
|
||||
LedDeviceLpd6803(const Json::Value &deviceConfig);
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Writes the led color values to the led-device
|
||||
|
@ -10,10 +10,14 @@
|
||||
// hyperion local includes
|
||||
#include "LedDeviceLpd8806.h"
|
||||
|
||||
LedDeviceLpd8806::LedDeviceLpd8806(const std::string& outputDevice, const unsigned baudrate)
|
||||
: LedSpiDevice(outputDevice, baudrate)
|
||||
LedDeviceLpd8806::LedDeviceLpd8806(const Json::Value &deviceConfig)
|
||||
: ProviderSpi(deviceConfig)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceLpd8806::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceLpd8806(deviceConfig);
|
||||
}
|
||||
|
||||
int LedDeviceLpd8806::write(const std::vector<ColorRgb> &ledValues)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Local hyperion incluse
|
||||
#include "LedSpiDevice.h"
|
||||
#include "ProviderSpi.h"
|
||||
|
||||
///
|
||||
/// Implementation of the LedDevice interface for writing to LPD8806 led device.
|
||||
@ -75,16 +75,18 @@
|
||||
///
|
||||
/// The number of zeroes in the 'clear data' is (#led/32 + 1)bytes (or *8 for bits)
|
||||
///
|
||||
class LedDeviceLpd8806 : public LedSpiDevice
|
||||
class LedDeviceLpd8806 : public ProviderSpi
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs the LedDevice for a string containing leds of the type LPD8806
|
||||
/// Constructs specific LedDevice
|
||||
///
|
||||
/// @param[in] outputDevice The name of the output device (eg '/dev/spidev0.0')
|
||||
/// @param[in] baudrate The used baudrate for writing to the output device
|
||||
/// @param deviceConfig json device config
|
||||
///
|
||||
LedDeviceLpd8806(const std::string& outputDevice, const unsigned baudrate);
|
||||
LedDeviceLpd8806(const Json::Value &deviceConfig);
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Writes the led color values to the led-device
|
||||
|
@ -17,7 +17,7 @@ bool compareLightpacks(LedDeviceLightpack * lhs, LedDeviceLightpack * rhs)
|
||||
return lhs->getSerialNumber() < rhs->getSerialNumber();
|
||||
}
|
||||
|
||||
LedDeviceMultiLightpack::LedDeviceMultiLightpack()
|
||||
LedDeviceMultiLightpack::LedDeviceMultiLightpack(const Json::Value &)
|
||||
: LedDevice()
|
||||
, _lightpacks()
|
||||
{
|
||||
@ -31,6 +31,11 @@ LedDeviceMultiLightpack::~LedDeviceMultiLightpack()
|
||||
}
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceMultiLightpack::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceMultiLightpack(deviceConfig);
|
||||
}
|
||||
|
||||
int LedDeviceMultiLightpack::open()
|
||||
{
|
||||
// retrieve a list with Lightpack serials
|
||||
|
@ -20,15 +20,20 @@ class LedDeviceMultiLightpack : public LedDevice
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Constructs the LedDeviceMultiLightpack
|
||||
/// Constructs specific LedDevice
|
||||
///
|
||||
LedDeviceMultiLightpack();
|
||||
/// @param deviceConfig json device config
|
||||
///
|
||||
LedDeviceMultiLightpack(const Json::Value &);
|
||||
|
||||
///
|
||||
/// Destructor of the LedDevice; closes the output device if it is open
|
||||
///
|
||||
virtual ~LedDeviceMultiLightpack();
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const Json::Value &deviceConfig);
|
||||
|
||||
///
|
||||
/// Opens and configures the output device7
|
||||
///
|
||||
|
@ -11,10 +11,14 @@
|
||||
// hyperion local includes
|
||||
#include "LedDeviceP9813.h"
|
||||
|
||||
LedDeviceP9813::LedDeviceP9813(const std::string& outputDevice, const unsigned baudrate)
|
||||
: LedSpiDevice(outputDevice, baudrate, 0)
|
||||
LedDeviceP9813::LedDeviceP9813(const Json::Value &deviceConfig)
|
||||
: ProviderSpi(deviceConfig)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceP9813::construct(const Json::Value &deviceConfig)
|
||||
{
|
||||
return new LedDeviceP9813(deviceConfig);
|
||||
}
|
||||
|
||||
int LedDeviceP9813::write(const std::vector<ColorRgb> &ledValues)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user