mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Merge pull request #8 from tvdzwan/master
Updating Former-commit-id: 4ab47903c7fa9c7aaa441a0e3c45af615a00c611
This commit is contained in:
commit
9cbc005ee0
@ -43,6 +43,9 @@ message(STATUS "ENABLE_X11 = " ${ENABLE_X11})
|
|||||||
option(ENABLE_QT5 "Enable QT5" OFF)
|
option(ENABLE_QT5 "Enable QT5" OFF)
|
||||||
message(STATUS "ENABLE_QT5 = " ${ENABLE_QT5})
|
message(STATUS "ENABLE_QT5 = " ${ENABLE_QT5})
|
||||||
|
|
||||||
|
option(ENABLE_TESTS "Compile additional test applications" OFF)
|
||||||
|
message(STATUS "ENABLE_TESTS = " ${ENABLE_TESTS})
|
||||||
|
|
||||||
if(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
|
if(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
|
||||||
message(FATAL_ERROR "V4L2 grabber requires PROTOBUF. Disable V4L2 or enable PROTOBUF")
|
message(FATAL_ERROR "V4L2 grabber requires PROTOBUF. Disable V4L2 or enable PROTOBUF")
|
||||||
endif(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
|
endif(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
|
||||||
@ -59,19 +62,26 @@ if(ENABLE_OSX AND ENABLE_DISPMANX)
|
|||||||
message(FATAL_ERROR "dispmanx grabber and osx grabber cannot be used at the same time")
|
message(FATAL_ERROR "dispmanx grabber and osx grabber cannot be used at the same time")
|
||||||
endif(ENABLE_OSX AND ENABLE_DISPMANX)
|
endif(ENABLE_OSX AND ENABLE_DISPMANX)
|
||||||
|
|
||||||
|
|
||||||
|
SET ( PROTOBUF_INSTALL_BIN_DIR ${CMAKE_BINARY_DIR}/proto )
|
||||||
|
SET ( PROTOBUF_INSTALL_LIB_DIR ${CMAKE_BINARY_DIR}/proto )
|
||||||
|
|
||||||
#if(ENABLE_QT5)
|
#if(ENABLE_QT5)
|
||||||
# TODO vs ENABLE_QT4?
|
# TODO vs ENABLE_QT4?
|
||||||
#endif(ENABLE_QT5)
|
#endif(ENABLE_QT5)
|
||||||
|
|
||||||
# Createt the configuration file
|
# Createt the configuration file
|
||||||
|
|
||||||
|
# Add project specific cmake modules (find, etc)
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
|
find_package(GitVersion)
|
||||||
|
|
||||||
# configure a header file to pass some of the CMake settings
|
# configure a header file to pass some of the CMake settings
|
||||||
# to the source code
|
# to the source code
|
||||||
configure_file("${PROJECT_SOURCE_DIR}/HyperionConfig.h.in" "${PROJECT_BINARY_DIR}/HyperionConfig.h")
|
configure_file("${PROJECT_SOURCE_DIR}/HyperionConfig.h.in" "${PROJECT_BINARY_DIR}/HyperionConfig.h")
|
||||||
include_directories("${PROJECT_BINARY_DIR}")
|
include_directories("${PROJECT_BINARY_DIR}")
|
||||||
|
|
||||||
# Add project specific cmake modules (find, etc)
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
||||||
|
|
||||||
if(ENABLE_QT5)
|
if(ENABLE_QT5)
|
||||||
ADD_DEFINITIONS ( -DENABLE_QT5 )
|
ADD_DEFINITIONS ( -DENABLE_QT5 )
|
||||||
#find_package(Qt5Widgets)
|
#find_package(Qt5Widgets)
|
||||||
@ -136,7 +146,10 @@ configure_file(config/hyperion_x86.config.json ${LIBRARY_OUTPUT_PATH} @ONLY)
|
|||||||
add_subdirectory(dependencies)
|
add_subdirectory(dependencies)
|
||||||
add_subdirectory(libsrc)
|
add_subdirectory(libsrc)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(test)
|
if (ENABLE_TESTS)
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif (ENABLE_TESTS)
|
||||||
|
|
||||||
|
|
||||||
# Add the doxygen generation directory
|
# Add the doxygen generation directory
|
||||||
add_subdirectory(doc)
|
add_subdirectory(doc)
|
||||||
|
@ -27,7 +27,7 @@ cd "$HYPERION_DIR/build"
|
|||||||
cmake -DCMAKE_BUILD_TYPE=Release -Wno-dev ..
|
cmake -DCMAKE_BUILD_TYPE=Release -Wno-dev ..
|
||||||
# run cmake to generate make files on the raspberry pi WITH PWM SUPPORT
|
# run cmake to generate make files on the raspberry pi WITH PWM SUPPORT
|
||||||
cmake -DENABLE_WS2812BPWM=ON -DENABLE_WS281XPWM=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev ..
|
cmake -DENABLE_WS2812BPWM=ON -DENABLE_WS281XPWM=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev ..
|
||||||
# or if you are not compiling on the raspberry pi and need to disable the Dispmanx grabber and support for spi devices
|
# or if you are not compiling on the raspberry pi (e.g. OrangePi) and need to disable the Dispmanx grabber and support for spi devices
|
||||||
cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_X11=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev ..
|
cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_X11=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev ..
|
||||||
# as an alternative for the dispmanx grabber on non-rpi devices (e.g. cubox-i) you could try the framebuffer grabber
|
# as an alternative for the dispmanx grabber on non-rpi devices (e.g. cubox-i) you could try the framebuffer grabber
|
||||||
cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_FB=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev ..
|
cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_FB=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev ..
|
||||||
|
@ -30,3 +30,4 @@
|
|||||||
// Define to enable the osx grabber
|
// Define to enable the osx grabber
|
||||||
#cmakedefine ENABLE_OSX
|
#cmakedefine ENABLE_OSX
|
||||||
|
|
||||||
|
#define HYPERION_VERSION_ID "${HYPERION_VERSION_ID}"
|
||||||
|
@ -4,5 +4,5 @@ Please check the wiki in case your problem is already known/feature requested.**
|
|||||||
**1.** Used hardware and sofware (Wetek,RPi1,Rpi2,... Ubuntu 14.04(64bit),OSX,OpenELEC,OSMC,XBian,...)
|
**1.** Used hardware and sofware (Wetek,RPi1,Rpi2,... Ubuntu 14.04(64bit),OSX,OpenELEC,OSMC,XBian,...)
|
||||||
**2.** Your LED device and additional hardware (if used) (WS2801,APA102,WS2812B,... connected through (direct,arduino uno,...))
|
**2.** Your LED device and additional hardware (if used) (WS2801,APA102,WS2812B,... connected through (direct,arduino uno,...))
|
||||||
**3.** Please upload your Hyperion log to pastebin.com and insert the link. Have a look at the wiki how you get one.
|
**3.** Please upload your Hyperion log to pastebin.com and insert the link. Have a look at the wiki how you get one.
|
||||||
**4.** Please upload your "Hyperion Configuration File" to www.jsoneditoronline.org and insert the link.
|
**4.** Please upload your "Hyperion Configuration File" to pastebin.com and insert the link.
|
||||||
|
|
||||||
|
@ -23,5 +23,6 @@ tar --create --verbose --gzip --absolute-names --show-transformed-names --derefe
|
|||||||
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXrender.so.1" \
|
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXrender.so.1" \
|
||||||
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXt.so.6" \
|
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXt.so.6" \
|
||||||
"./openelec/hyperiond.sh" \
|
"./openelec/hyperiond.sh" \
|
||||||
|
"./openelec/hyperion-v4l2.sh" \
|
||||||
"./openelec/hyperion-remote.sh"
|
"./openelec/hyperion-remote.sh"
|
||||||
|
|
||||||
|
@ -4,8 +4,18 @@
|
|||||||
# Make sure /sbin is on the path (for service to find sub scripts)
|
# Make sure /sbin is on the path (for service to find sub scripts)
|
||||||
PATH="/sbin:$PATH"
|
PATH="/sbin:$PATH"
|
||||||
|
|
||||||
|
#Check which arguments are used
|
||||||
|
if [ "$1" = "HyperConInstall" ] || [ "$2" = "HyperConInstall" ]; then
|
||||||
|
HCInstall=1
|
||||||
|
else HCInstall=0
|
||||||
|
fi
|
||||||
|
if [ "$1" = "WS281X" ] || [ "$2" = "WS281X" ]; then
|
||||||
|
PWM=1
|
||||||
|
else PWM=0
|
||||||
|
fi
|
||||||
|
|
||||||
#Check if HyperCon is logged in as root
|
#Check if HyperCon is logged in as root
|
||||||
if [ $(id -u) != 0 ] && [ "$1" = "HyperConInstall" ]; then
|
if [ $(id -u) != 0 ] && [ $HCInstall -eq 1 ]; then
|
||||||
echo '---> Critical Error: Please connect as user "root" through HyperCon'
|
echo '---> Critical Error: Please connect as user "root" through HyperCon'
|
||||||
echo '---> We need admin privileges to install/update your Hyperion! -> abort'
|
echo '---> We need admin privileges to install/update your Hyperion! -> abort'
|
||||||
exit 1
|
exit 1
|
||||||
@ -78,7 +88,7 @@ if [ $OS_OPENELEC -ne 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#Check, if dtparam=spi=on is in place (not for OPENELEC)
|
#Check, if dtparam=spi=on is in place (not for OPENELEC)
|
||||||
if [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -ne 1 ]; then
|
if [ $PWM -ne 1 ] && [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -ne 1 ]; then
|
||||||
SPIOK=`grep '^\dtparam=spi=on' /boot/config.txt | wc -l`
|
SPIOK=`grep '^\dtparam=spi=on' /boot/config.txt | wc -l`
|
||||||
if [ $SPIOK -ne 1 ]; then
|
if [ $SPIOK -ne 1 ]; then
|
||||||
echo '---> Raspberry Pi found, but SPI is not ready, we write "dtparam=spi=on" to /boot/config.txt'
|
echo '---> Raspberry Pi found, but SPI is not ready, we write "dtparam=spi=on" to /boot/config.txt'
|
||||||
@ -88,7 +98,7 @@ if [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -ne 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#Check, if dtparam=spi=on is in place (just for OPENELEC)
|
#Check, if dtparam=spi=on is in place (just for OPENELEC)
|
||||||
if [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -eq 1 ]; then
|
if [ $PWM -ne 1 ] && [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -eq 1 ]; then
|
||||||
SPIOK=`grep '^\dtparam=spi=on' /flash/config.txt | wc -l`
|
SPIOK=`grep '^\dtparam=spi=on' /flash/config.txt | wc -l`
|
||||||
if [ $SPIOK -ne 1 ]; then
|
if [ $SPIOK -ne 1 ]; then
|
||||||
mount -o remount,rw /flash
|
mount -o remount,rw /flash
|
||||||
@ -98,6 +108,28 @@ if [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -eq 1 ]; then
|
|||||||
REBOOTMESSAGE="echo Please reboot your OpenELEC, we inserted dtparam=spi=on to /flash/config.txt"
|
REBOOTMESSAGE="echo Please reboot your OpenELEC, we inserted dtparam=spi=on to /flash/config.txt"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#Check, if dtoverlay=pwm is in place (not for OPENELEC)
|
||||||
|
#if [ $PWM -eq 1 ] && [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -ne 1 ]; then
|
||||||
|
# PWMOK=`grep '^\dtoverlay=pwm' /boot/config.txt | wc -l`
|
||||||
|
# if [ $PWMOK -ne 1 ]; then
|
||||||
|
# echo '---> Raspberry Pi found, but PWM is not ready, we write "dtoverlay=pwm" to /boot/config.txt'
|
||||||
|
# sed -i '$a dtoverlay=pwm' /boot/config.txt
|
||||||
|
# PWMREBOOTMESSAGE="echo Please reboot your Raspberry Pi, we inserted dtoverlay=pwm to /boot/config.txt"
|
||||||
|
# fi
|
||||||
|
#fi
|
||||||
|
|
||||||
|
#Check, if dtoverlay=pwm is in place (just for OPENELEC)
|
||||||
|
if [ $PWM -eq 1 ] && [ $CPU_RPI -eq 1 ] && [ $OS_OPENELEC -eq 1 ]; then
|
||||||
|
PWMOK=`grep '^\dtoverlay=pwm' /flash/config.txt | wc -l`
|
||||||
|
if [ $PWMOK -ne 1 ]; then
|
||||||
|
mount -o remount,rw /flash
|
||||||
|
echo '---> Raspberry Pi with OpenELEC found, but PWM is not ready, we write "dtoverlay=pwm" to /flash/config.txt'
|
||||||
|
sed -i '$a dtoverlay=pwm' /flash/config.txt
|
||||||
|
mount -o remount,ro /flash
|
||||||
|
PWMREBOOTMESSAGE="echo Please reboot your OpenELEC, we inserted dtoverlay=pwm to /flash/config.txt"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
#Backup the .conf files, if present
|
#Backup the .conf files, if present
|
||||||
echo '---> Backup Hyperion configuration(s), if present'
|
echo '---> Backup Hyperion configuration(s), if present'
|
||||||
rm -f /tmp/*.json 2>/dev/null
|
rm -f /tmp/*.json 2>/dev/null
|
||||||
@ -177,16 +209,29 @@ elif [ $OS_OPENELEC -eq 1 ]; then
|
|||||||
echo "/storage/hyperion/bin/hyperiond.sh /storage/.config/hyperion.config.json > /dev/null 2>&1 &" >> /storage/.config/autostart.sh
|
echo "/storage/hyperion/bin/hyperiond.sh /storage/.config/hyperion.config.json > /dev/null 2>&1 &" >> /storage/.config/autostart.sh
|
||||||
chmod +x /storage/.config/autostart.sh
|
chmod +x /storage/.config/autostart.sh
|
||||||
fi
|
fi
|
||||||
|
# only add hyperion-x11 to startup, if not found and x32x64 detected
|
||||||
|
if [ $CPU_X32X64 -eq 1 ] && [ `cat /storage/.config/autostart.sh 2>/dev/null | grep hyperion-x11 | wc -l` -eq 0 ]; then
|
||||||
|
echo '---> Adding Hyperion-x11 to OpenELEC autostart.sh'
|
||||||
|
echo "DISPLAY=:0.0 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/storage/hyperion/bin /storage/hyperion/bin/hyperion-x11 </dev/null >/dev/null 2>&1 &" >> /storage/.config/autostart.sh
|
||||||
|
fi
|
||||||
elif [ $USE_SYSTEMD -eq 1 ]; then
|
elif [ $USE_SYSTEMD -eq 1 ]; then
|
||||||
echo '---> Installing systemd script'
|
echo '---> Installing systemd script'
|
||||||
#place startup script for systemd and activate
|
#place startup script for systemd and activate
|
||||||
#Problem with systemd to enable symlinks - Bug? Workaround cp -n (overwrite never)
|
#Problem with systemd to enable symlinks - Bug? Workaround cp -n (overwrite never)
|
||||||
#Bad workaround for Jessie users that used the official script for install
|
#Bad workaround for Jessie (systemd) users that used the official script for install
|
||||||
update-rc.d -f hyperion remove 2>/dev/null
|
update-rc.d -f hyperion remove 2>/dev/null
|
||||||
rm /etc/init.d/hyperion 2>/dev/null
|
rm /etc/init.d/hyperion 2>/dev/null
|
||||||
cp -n /opt/hyperion/init.d/hyperion.systemd.sh /etc/systemd/system/hyperion.service
|
cp -n /opt/hyperion/init.d/hyperion.systemd.sh /etc/systemd/system/hyperion.service
|
||||||
systemctl -q enable hyperion.service
|
systemctl -q enable hyperion.service
|
||||||
if [ $OS_OSMC -eq 1 ]; then
|
if [ $PWM -eq 1 ] && [ $OS_OSMC -eq 1 ]; then
|
||||||
|
echo '---> Modify systemd script for OSMC usage (PWM Support)'
|
||||||
|
# Wait until kodi is sarted (for xbmc checker) and FIX user in case it is wrong (need root for access to pwm!)!
|
||||||
|
sed -i '/After = mediacenter.service/d' /etc/systemd/system/hyperion.service
|
||||||
|
sed -i '/Unit/a After = mediacenter.service' /etc/systemd/system/hyperion.service
|
||||||
|
sed -i 's/User=osmc/User=root/g' /etc/systemd/system/hyperion.service
|
||||||
|
sed -i 's/Group=osmc/Group=root/g' /etc/systemd/system/hyperion.service
|
||||||
|
systemctl -q daemon-reload
|
||||||
|
elif [ $OS_OSMC -eq 1 ]; then
|
||||||
echo '---> Modify systemd script for OSMC usage'
|
echo '---> Modify systemd script for OSMC usage'
|
||||||
# Wait until kodi is sarted (for xbmc checker) and replace user (for remote control through osmc)
|
# Wait until kodi is sarted (for xbmc checker) and replace user (for remote control through osmc)
|
||||||
sed -i '/After = mediacenter.service/d' /etc/systemd/system/hyperion.service
|
sed -i '/After = mediacenter.service/d' /etc/systemd/system/hyperion.service
|
||||||
@ -226,15 +271,16 @@ echo 'Please get a new HyperCon version to benefit from the latest features!'
|
|||||||
echo 'Create a new config file, if you encounter problems!'
|
echo 'Create a new config file, if you encounter problems!'
|
||||||
$HINTMESSAGE
|
$HINTMESSAGE
|
||||||
$REBOOTMESSAGE
|
$REBOOTMESSAGE
|
||||||
|
$PWMREBOOTMESSAGE
|
||||||
echo '*******************************************************************************'
|
echo '*******************************************************************************'
|
||||||
## Force reboot and prevent prompt if spi is added during a HyperCon Install
|
## Force reboot and prevent prompt if spi is added during a HyperCon Install
|
||||||
if [ "$1" = "HyperConInstall" ] && [ $CPU_RPI -eq 1 ] && [ $SPIOK -ne 1 ]; then
|
if ( [ "$HCInstall" = "1" ] && [ "$CPU_RPI" = "1" ] ) && ( [ "$SPIOK" = "0" ] || [ "$PWMOK" = "0" ] ); then
|
||||||
echo "Rebooting now, we added dtparam=spi=on to config.txt"
|
echo "Rebooting now, we added dtparam=spi=on and/or dtoverlay=pwm to config.txt"
|
||||||
reboot
|
reboot
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
#Prompt for reboot, if spi added to config.txt
|
#Prompt for reboot, if spi added to config.txt
|
||||||
if [ $CPU_RPI -eq 1 ] && [ $SPIOK -ne 1 ];then
|
if ( [ "$CPU_RPI" = "1" ] ) && ( [ "$SPIOK" = "0" ] || [ "$PWMOK" = "0" ] ); then
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
echo -n "---> Do you want to reboot your Raspberry Pi now? (y or n) :"
|
echo -n "---> Do you want to reboot your Raspberry Pi now? (y or n) :"
|
||||||
|
@ -70,6 +70,7 @@ elif [ $OS_OPENELEC -eq 1 ]; then
|
|||||||
# Remove Hyperion from OpenELEC autostart.sh
|
# Remove Hyperion from OpenELEC autostart.sh
|
||||||
echo "---> Remove Hyperion from OpenELEC autostart.sh"
|
echo "---> Remove Hyperion from OpenELEC autostart.sh"
|
||||||
sed -i "/hyperiond/d" /storage/.config/autostart.sh 2>/dev/null
|
sed -i "/hyperiond/d" /storage/.config/autostart.sh 2>/dev/null
|
||||||
|
sed -i "/hyperion-x11/d" /storage/.config/autostart.sh 2>/dev/null
|
||||||
elif [ $USE_SYSTEMD -eq 1 ]; then
|
elif [ $USE_SYSTEMD -eq 1 ]; then
|
||||||
# Delete and disable Hyperion systemd script
|
# Delete and disable Hyperion systemd script
|
||||||
echo '---> Delete and disable Hyperion systemd script'
|
echo '---> Delete and disable Hyperion systemd script'
|
||||||
|
9
cmake/FindGitVersion.cmake
Normal file
9
cmake/FindGitVersion.cmake
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
execute_process( COMMAND git log -1 --format=%cn-%t/%h-%ct WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE BUILD_ID ERROR_QUIET )
|
||||||
|
execute_process( COMMAND sh -c "git branch | grep '^*' | sed 's;^*;;g' " WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE VERSION_ID ERROR_QUIET )
|
||||||
|
|
||||||
|
STRING ( STRIP "${BUILD_ID}" BUILD_ID )
|
||||||
|
STRING ( STRIP "${VERSION_ID}" VERSION_ID )
|
||||||
|
SET ( HYPERION_VERSION_ID "${VERSION_ID} (${BUILD_ID}" )
|
||||||
|
message ( STATUS "Current Version: ${HYPERION_VERSION_ID})" )
|
||||||
|
|
@ -42,6 +42,32 @@
|
|||||||
/// - 'updateDelay' The delay of the output to leds (in periods of smoothing)
|
/// - 'updateDelay' The delay of the output to leds (in periods of smoothing)
|
||||||
"color" :
|
"color" :
|
||||||
{
|
{
|
||||||
|
"correction" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id" : "default",
|
||||||
|
"leds" : "*",
|
||||||
|
"correctionValues" :
|
||||||
|
{
|
||||||
|
"red" : 255,
|
||||||
|
"green" : 255,
|
||||||
|
"blue" : 255
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"temperature" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id" : "default",
|
||||||
|
"leds" : "*",
|
||||||
|
"temperatureValues" :
|
||||||
|
{
|
||||||
|
"red" : 255,
|
||||||
|
"green" : 255,
|
||||||
|
"blue" : 255
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"transform" :
|
"transform" :
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -52,6 +78,11 @@
|
|||||||
"saturationGain" : 1.0000,
|
"saturationGain" : 1.0000,
|
||||||
"valueGain" : 1.0000
|
"valueGain" : 1.0000
|
||||||
},
|
},
|
||||||
|
"hsl" :
|
||||||
|
{
|
||||||
|
"saturationGain" : 1.0000,
|
||||||
|
"luminanceGain" : 1.0000
|
||||||
|
},
|
||||||
"red" :
|
"red" :
|
||||||
{
|
{
|
||||||
"threshold" : 0.0000,
|
"threshold" : 0.0000,
|
||||||
|
@ -1 +1 @@
|
|||||||
63bda72fdb3fb504564f067795f74e9b45eb99ba
|
bc3bead4aa43a0f90fb15fb300e63eb6ba6885bf
|
@ -1 +1 @@
|
|||||||
03e78585af86a18889ecd1d8b910d76155608cd6
|
e3cbd5bb82a29a50ee85a2fab6a1a0d610938f37
|
@ -1 +1 @@
|
|||||||
9a00f3dc5684cab0fede56348df91c046634ff11
|
dc2a99908af86a6e3a2b81721bc69e7d614623c3
|
18
include/hyperion/ColorCorrection.h
Normal file
18
include/hyperion/ColorCorrection.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// Utils includes
|
||||||
|
#include <utils/RgbChannelCorrection.h>
|
||||||
|
|
||||||
|
class ColorCorrection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// Unique identifier for this color correction
|
||||||
|
std::string _id;
|
||||||
|
|
||||||
|
/// The RGB correction
|
||||||
|
RgbChannelCorrection _rgbCorrection;
|
||||||
|
};
|
@ -6,6 +6,7 @@
|
|||||||
// Utils includes
|
// Utils includes
|
||||||
#include <utils/RgbChannelTransform.h>
|
#include <utils/RgbChannelTransform.h>
|
||||||
#include <utils/HsvTransform.h>
|
#include <utils/HsvTransform.h>
|
||||||
|
#include <utils/HslTransform.h>
|
||||||
|
|
||||||
class ColorTransform
|
class ColorTransform
|
||||||
{
|
{
|
||||||
@ -23,4 +24,7 @@ public:
|
|||||||
|
|
||||||
/// The HSV Transform for applying Saturation and Value transforms
|
/// The HSV Transform for applying Saturation and Value transforms
|
||||||
HsvTransform _hsvTransform;
|
HsvTransform _hsvTransform;
|
||||||
|
|
||||||
|
/// The HSL Transform for applying Saturation and Value transforms
|
||||||
|
HslTransform _hslTransform;
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
// Hyperion includes
|
// Hyperion includes
|
||||||
#include <hyperion/LedString.h>
|
#include <hyperion/LedString.h>
|
||||||
#include <hyperion/PriorityMuxer.h>
|
#include <hyperion/PriorityMuxer.h>
|
||||||
|
#include <hyperion/ColorTransform.h>
|
||||||
|
#include <hyperion/ColorCorrection.h>
|
||||||
#include <hyperion/MessageForwarder.h>
|
#include <hyperion/MessageForwarder.h>
|
||||||
|
|
||||||
// Effect engine includes
|
// Effect engine includes
|
||||||
@ -23,8 +25,12 @@ class LedDevice;
|
|||||||
class ColorTransform;
|
class ColorTransform;
|
||||||
class EffectEngine;
|
class EffectEngine;
|
||||||
class HsvTransform;
|
class HsvTransform;
|
||||||
|
class HslTransform;
|
||||||
class RgbChannelTransform;
|
class RgbChannelTransform;
|
||||||
|
class RgbChannelCorrection;
|
||||||
class MultiColorTransform;
|
class MultiColorTransform;
|
||||||
|
class MultiColorCorrection;
|
||||||
|
class MultiColorTemperature;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The main class of Hyperion. This gives other 'users' access to the attached LedDevice through
|
/// The main class of Hyperion. This gives other 'users' access to the attached LedDevice through
|
||||||
@ -117,18 +123,50 @@ public slots:
|
|||||||
///
|
///
|
||||||
const std::vector<std::string> & getTransformIds() const;
|
const std::vector<std::string> & getTransformIds() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns the list with unique correction identifiers
|
||||||
|
/// @return The list with correction identifiers
|
||||||
|
///
|
||||||
|
const std::vector<std::string> & getCorrectionIds() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns the list with unique correction identifiers
|
||||||
|
/// @return The list with correction identifiers
|
||||||
|
///
|
||||||
|
const std::vector<std::string> & getTemperatureIds() const;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Returns the ColorTransform with the given identifier
|
/// Returns the ColorTransform with the given identifier
|
||||||
/// @return The transform with the given identifier (or nullptr if the identifier does not exist)
|
/// @return The transform with the given identifier (or nullptr if the identifier does not exist)
|
||||||
///
|
///
|
||||||
ColorTransform * getTransform(const std::string& id);
|
ColorTransform * getTransform(const std::string& id);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns the ColorCorrection with the given identifier
|
||||||
|
/// @return The correction with the given identifier (or nullptr if the identifier does not exist)
|
||||||
|
///
|
||||||
|
ColorCorrection * getCorrection(const std::string& id);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns the ColorCorrection with the given identifier
|
||||||
|
/// @return The correction with the given identifier (or nullptr if the identifier does not exist)
|
||||||
|
///
|
||||||
|
ColorCorrection * getTemperature(const std::string& id);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns MessageForwarder Object
|
||||||
|
/// @return instance of message forwarder object
|
||||||
|
///
|
||||||
|
MessageForwarder * getForwarder();
|
||||||
|
|
||||||
/// Tell Hyperion that the transforms have changed and the leds need to be updated
|
/// Tell Hyperion that the transforms have changed and the leds need to be updated
|
||||||
void transformsUpdated();
|
void transformsUpdated();
|
||||||
|
|
||||||
/// Returns MessageForwarder Object
|
/// Tell Hyperion that the corrections have changed and the leds need to be updated
|
||||||
/// @return instance of message forwarder object
|
void correctionsUpdated();
|
||||||
MessageForwarder * getForwarder();
|
|
||||||
|
/// Tell Hyperion that the corrections have changed and the leds need to be updated
|
||||||
|
void temperaturesUpdated();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Clears the given priority channel. This will switch the led-colors to the colors of the next
|
/// Clears the given priority channel. This will switch the led-colors to the colors of the next
|
||||||
@ -168,9 +206,14 @@ public:
|
|||||||
static LedString createLedString(const Json::Value & ledsConfig, const ColorOrder deviceOrder);
|
static LedString createLedString(const Json::Value & ledsConfig, const ColorOrder deviceOrder);
|
||||||
|
|
||||||
static MultiColorTransform * createLedColorsTransform(const unsigned ledCnt, const Json::Value & colorTransformConfig);
|
static MultiColorTransform * createLedColorsTransform(const unsigned ledCnt, const Json::Value & colorTransformConfig);
|
||||||
|
static MultiColorCorrection * createLedColorsCorrection(const unsigned ledCnt, const Json::Value & colorCorrectionConfig);
|
||||||
|
static MultiColorCorrection * createLedColorsTemperature(const unsigned ledCnt, const Json::Value & colorTemperatureConfig);
|
||||||
static ColorTransform * createColorTransform(const Json::Value & transformConfig);
|
static ColorTransform * createColorTransform(const Json::Value & transformConfig);
|
||||||
|
static ColorCorrection * createColorCorrection(const Json::Value & correctionConfig);
|
||||||
static HsvTransform * createHsvTransform(const Json::Value & hsvConfig);
|
static HsvTransform * createHsvTransform(const Json::Value & hsvConfig);
|
||||||
|
static HslTransform * createHslTransform(const Json::Value & hslConfig);
|
||||||
static RgbChannelTransform * createRgbChannelTransform(const Json::Value& colorConfig);
|
static RgbChannelTransform * createRgbChannelTransform(const Json::Value& colorConfig);
|
||||||
|
static RgbChannelCorrection * createRgbChannelCorrection(const Json::Value& colorConfig);
|
||||||
|
|
||||||
static LedDevice * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice);
|
static LedDevice * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice);
|
||||||
static MessageForwarder * createMessageForwarder(const Json::Value & forwarderConfig);
|
static MessageForwarder * createMessageForwarder(const Json::Value & forwarderConfig);
|
||||||
@ -198,9 +241,15 @@ private:
|
|||||||
/// The priority muxer
|
/// The priority muxer
|
||||||
PriorityMuxer _muxer;
|
PriorityMuxer _muxer;
|
||||||
|
|
||||||
/// The transformation from raw colors to led colors
|
/// The transformation from corrected colors to led colors
|
||||||
MultiColorTransform * _raw2ledTransform;
|
MultiColorTransform * _raw2ledTransform;
|
||||||
|
|
||||||
|
/// The correction from raw colors to led colors
|
||||||
|
MultiColorCorrection * _raw2ledCorrection;
|
||||||
|
|
||||||
|
/// The temperature from corrected colors to led colors
|
||||||
|
MultiColorCorrection * _raw2ledTemperature;
|
||||||
|
|
||||||
/// The actual LedDevice
|
/// The actual LedDevice
|
||||||
LedDevice * _device;
|
LedDevice * _device;
|
||||||
|
|
||||||
|
100
include/utils/HslTransform.h
Normal file
100
include/utils/HslTransform.h
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Color transformation to adjust the saturation and luminance of a RGB color value
|
||||||
|
///
|
||||||
|
class HslTransform
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Default constructor
|
||||||
|
///
|
||||||
|
HslTransform();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructor
|
||||||
|
///
|
||||||
|
/// @param saturationGain The used saturation gain
|
||||||
|
/// @param luminanceGain The used luminance gain
|
||||||
|
///
|
||||||
|
HslTransform(double saturationGain, double luminanceGain);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Destructor
|
||||||
|
///
|
||||||
|
~HslTransform();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Updates the saturation gain
|
||||||
|
///
|
||||||
|
/// @param saturationGain New saturationGain
|
||||||
|
///
|
||||||
|
void setSaturationGain(double saturationGain);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns the saturation gain
|
||||||
|
///
|
||||||
|
/// @return The current Saturation gain
|
||||||
|
///
|
||||||
|
double getSaturationGain() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Updates the luminance gain
|
||||||
|
///
|
||||||
|
/// @param luminanceGain New luminance gain
|
||||||
|
///
|
||||||
|
void setLuminanceGain(double luminanceGain);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns the luminance gain
|
||||||
|
///
|
||||||
|
/// @return The current luminance gain
|
||||||
|
///
|
||||||
|
double getLuminanceGain() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Apply the transform the the given RGB values.
|
||||||
|
///
|
||||||
|
/// @param red The red color component
|
||||||
|
/// @param green The green color component
|
||||||
|
/// @param blue The blue color component
|
||||||
|
///
|
||||||
|
/// @note The values are updated in place.
|
||||||
|
///
|
||||||
|
void transform(uint8_t & red, uint8_t & green, uint8_t & blue) const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Translates an RGB (red, green, blue) color to an HSL (hue, saturation, luminance) color
|
||||||
|
///
|
||||||
|
/// @param[in] red The red RGB-component
|
||||||
|
/// @param[in] green The green RGB-component
|
||||||
|
/// @param[in] blue The blue RGB-component
|
||||||
|
/// @param[out] hue The hue HSL-component
|
||||||
|
/// @param[out] saturation The saturation HSL-component
|
||||||
|
/// @param[out] luminance The luminance HSL-component
|
||||||
|
///
|
||||||
|
|
||||||
|
static void rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, float & saturation, float & luminance);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Translates an HSL (hue, saturation, luminance) color to an RGB (red, green, blue) color
|
||||||
|
///
|
||||||
|
/// @param[in] hue The hue HSL-component
|
||||||
|
/// @param[in] saturation The saturation HSL-component
|
||||||
|
/// @param[in] luminance The luminance HSL-component
|
||||||
|
/// @param[out] red The red RGB-component
|
||||||
|
/// @param[out] green The green RGB-component
|
||||||
|
/// @param[out] blue The blue RGB-component
|
||||||
|
///
|
||||||
|
|
||||||
|
static void hsl2rgb(uint16_t hue, float saturation, float luminance, uint8_t & red, uint8_t & green, uint8_t & blue);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// The saturation gain
|
||||||
|
double _saturationGain;
|
||||||
|
/// The luminance gain
|
||||||
|
double _luminanceGain;
|
||||||
|
};
|
66
include/utils/RgbChannelCorrection.h
Normal file
66
include/utils/RgbChannelCorrection.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
/// Correction for a single color byte value
|
||||||
|
/// All configuration values are unsigned int and assume the color value to be between 0 and 255
|
||||||
|
class RgbChannelCorrection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// Default constructor
|
||||||
|
RgbChannelCorrection();
|
||||||
|
|
||||||
|
/// Constructor
|
||||||
|
/// @param correctionR
|
||||||
|
/// @param correctionG
|
||||||
|
/// @param correctionB
|
||||||
|
|
||||||
|
RgbChannelCorrection(int correctionR, int correctionG, int correctionB);
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
~RgbChannelCorrection();
|
||||||
|
|
||||||
|
/// @return The current correctionR value
|
||||||
|
uint8_t getcorrectionR() const;
|
||||||
|
|
||||||
|
/// @param threshold New correctionR value
|
||||||
|
void setcorrectionR(uint8_t correctionR);
|
||||||
|
|
||||||
|
/// @return The current correctionG value
|
||||||
|
uint8_t getcorrectionG() const;
|
||||||
|
|
||||||
|
/// @param gamma New correctionG value
|
||||||
|
void setcorrectionG(uint8_t correctionG);
|
||||||
|
|
||||||
|
/// @return The current correctionB value
|
||||||
|
uint8_t getcorrectionB() const;
|
||||||
|
|
||||||
|
/// @param blacklevel New correctionB value
|
||||||
|
void setcorrectionB(uint8_t correctionB);
|
||||||
|
|
||||||
|
/// Transform the given array value
|
||||||
|
/// @param input The input color bytes
|
||||||
|
/// @return The corrected byte value
|
||||||
|
uint8_t correctionR(uint8_t inputR) const;
|
||||||
|
uint8_t correctionG(uint8_t inputG) const;
|
||||||
|
uint8_t correctionB(uint8_t inputB) const;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// (re)-initilize the color mapping
|
||||||
|
void initializeMapping();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// The correction of R channel
|
||||||
|
int _correctionR;
|
||||||
|
/// The correction of G channel
|
||||||
|
int _correctionG;
|
||||||
|
/// The correction of B channel
|
||||||
|
int _correctionB;
|
||||||
|
|
||||||
|
/// The mapping from input color to output color
|
||||||
|
int _mappingR[256];
|
||||||
|
int _mappingG[256];
|
||||||
|
int _mappingB[256];
|
||||||
|
};
|
@ -18,6 +18,7 @@ SET(Hyperion_HEADERS
|
|||||||
${CURRENT_HEADER_DIR}/PriorityMuxer.h
|
${CURRENT_HEADER_DIR}/PriorityMuxer.h
|
||||||
|
|
||||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.h
|
${CURRENT_SOURCE_DIR}/MultiColorTransform.h
|
||||||
|
${CURRENT_SOURCE_DIR}/MultiColorCorrection.h
|
||||||
${CURRENT_HEADER_DIR}/MessageForwarder.h
|
${CURRENT_HEADER_DIR}/MessageForwarder.h
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ SET(Hyperion_SOURCES
|
|||||||
|
|
||||||
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
|
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
|
||||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp
|
${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp
|
||||||
|
${CURRENT_SOURCE_DIR}/MultiColorCorrection.cpp
|
||||||
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp
|
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp
|
||||||
${CURRENT_SOURCE_DIR}/MessageForwarder.cpp
|
${CURRENT_SOURCE_DIR}/MessageForwarder.cpp
|
||||||
)
|
)
|
||||||
|
@ -15,12 +15,15 @@
|
|||||||
// hyperion include
|
// hyperion include
|
||||||
#include <hyperion/Hyperion.h>
|
#include <hyperion/Hyperion.h>
|
||||||
#include <hyperion/ImageProcessorFactory.h>
|
#include <hyperion/ImageProcessorFactory.h>
|
||||||
|
#include <hyperion/ColorTransform.h>
|
||||||
|
#include <hyperion/ColorCorrection.h>
|
||||||
|
|
||||||
// Leddevice includes
|
// Leddevice includes
|
||||||
#include <leddevice/LedDevice.h>
|
#include <leddevice/LedDevice.h>
|
||||||
#include <leddevice/LedDeviceFactory.h>
|
#include <leddevice/LedDeviceFactory.h>
|
||||||
|
|
||||||
#include "MultiColorTransform.h"
|
#include "MultiColorTransform.h"
|
||||||
|
#include "MultiColorCorrection.h"
|
||||||
#include "LinearColorSmoothing.h"
|
#include "LinearColorSmoothing.h"
|
||||||
|
|
||||||
// effect engine includes
|
// effect engine includes
|
||||||
@ -77,6 +80,7 @@ ColorTransform * Hyperion::createColorTransform(const Json::Value & transformCon
|
|||||||
RgbChannelTransform * blueTransform = createRgbChannelTransform(transformConfig["blue"]);
|
RgbChannelTransform * blueTransform = createRgbChannelTransform(transformConfig["blue"]);
|
||||||
|
|
||||||
HsvTransform * hsvTransform = createHsvTransform(transformConfig["hsv"]);
|
HsvTransform * hsvTransform = createHsvTransform(transformConfig["hsv"]);
|
||||||
|
HslTransform * hslTransform = createHslTransform(transformConfig["hsl"]);
|
||||||
|
|
||||||
ColorTransform * transform = new ColorTransform();
|
ColorTransform * transform = new ColorTransform();
|
||||||
transform->_id = id;
|
transform->_id = id;
|
||||||
@ -84,16 +88,35 @@ ColorTransform * Hyperion::createColorTransform(const Json::Value & transformCon
|
|||||||
transform->_rgbGreenTransform = *greenTransform;
|
transform->_rgbGreenTransform = *greenTransform;
|
||||||
transform->_rgbBlueTransform = *blueTransform;
|
transform->_rgbBlueTransform = *blueTransform;
|
||||||
transform->_hsvTransform = *hsvTransform;
|
transform->_hsvTransform = *hsvTransform;
|
||||||
|
transform->_hslTransform = *hslTransform;
|
||||||
|
|
||||||
|
|
||||||
// Cleanup the allocated individual transforms
|
// Cleanup the allocated individual transforms
|
||||||
delete redTransform;
|
delete redTransform;
|
||||||
delete greenTransform;
|
delete greenTransform;
|
||||||
delete blueTransform;
|
delete blueTransform;
|
||||||
delete hsvTransform;
|
delete hsvTransform;
|
||||||
|
delete hslTransform;
|
||||||
|
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColorCorrection * Hyperion::createColorCorrection(const Json::Value & correctionConfig)
|
||||||
|
{
|
||||||
|
const std::string id = correctionConfig.get("id", "default").asString();
|
||||||
|
|
||||||
|
RgbChannelCorrection * rgbCorrection = createRgbChannelCorrection(correctionConfig["correctionValues"]);
|
||||||
|
|
||||||
|
ColorCorrection * correction = new ColorCorrection();
|
||||||
|
correction->_id = id;
|
||||||
|
correction->_rgbCorrection = *rgbCorrection;
|
||||||
|
|
||||||
|
// Cleanup the allocated individual transforms
|
||||||
|
delete rgbCorrection;
|
||||||
|
|
||||||
|
return correction;
|
||||||
|
}
|
||||||
|
|
||||||
MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt, const Json::Value & colorConfig)
|
MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt, const Json::Value & colorConfig)
|
||||||
{
|
{
|
||||||
// Create the result, the transforms are added to this
|
// Create the result, the transforms are added to this
|
||||||
@ -168,6 +191,154 @@ MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt,
|
|||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MultiColorCorrection * Hyperion::createLedColorsCorrection(const unsigned ledCnt, const Json::Value & colorConfig)
|
||||||
|
{
|
||||||
|
// Create the result, the corrections are added to this
|
||||||
|
MultiColorCorrection * correction = new MultiColorCorrection(ledCnt);
|
||||||
|
|
||||||
|
const Json::Value correctionConfig = colorConfig.get("correction", Json::nullValue);
|
||||||
|
if (correctionConfig.isNull())
|
||||||
|
{
|
||||||
|
// Old style color correction config (just one for all leds)
|
||||||
|
ColorCorrection * colorCorrection = createColorCorrection(colorConfig);
|
||||||
|
correction->addCorrection(colorCorrection);
|
||||||
|
correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1);
|
||||||
|
}
|
||||||
|
else if (!correctionConfig.isArray())
|
||||||
|
{
|
||||||
|
ColorCorrection * colorCorrection = createColorCorrection(colorConfig);
|
||||||
|
correction->addCorrection(colorCorrection);
|
||||||
|
correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*");
|
||||||
|
|
||||||
|
for (Json::UInt i = 0; i < correctionConfig.size(); ++i)
|
||||||
|
{
|
||||||
|
const Json::Value & config = correctionConfig[i];
|
||||||
|
ColorCorrection * colorCorrection = createColorCorrection(config);
|
||||||
|
correction->addCorrection(colorCorrection);
|
||||||
|
|
||||||
|
const QString ledIndicesStr = QString(config.get("leds", "").asCString()).trimmed();
|
||||||
|
if (ledIndicesStr.compare("*") == 0)
|
||||||
|
{
|
||||||
|
// Special case for indices '*' => all leds
|
||||||
|
correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1);
|
||||||
|
std::cout << "ColorCorrection '" << colorCorrection->_id << "' => [0; "<< ledCnt-1 << "]" << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!overallExp.exactMatch(ledIndicesStr))
|
||||||
|
{
|
||||||
|
std::cerr << "Given led indices " << i << " not correct format: " << ledIndicesStr.toStdString() << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "ColorCorrection '" << colorCorrection->_id << "' => [";
|
||||||
|
|
||||||
|
const QStringList ledIndexList = ledIndicesStr.split(",");
|
||||||
|
for (int i=0; i<ledIndexList.size(); ++i) {
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
std::cout << ", ";
|
||||||
|
}
|
||||||
|
if (ledIndexList[i].contains("-"))
|
||||||
|
{
|
||||||
|
QStringList ledIndices = ledIndexList[i].split("-");
|
||||||
|
int startInd = ledIndices[0].toInt();
|
||||||
|
int endInd = ledIndices[1].toInt();
|
||||||
|
|
||||||
|
correction->setCorrectionForLed(colorCorrection->_id, startInd, endInd);
|
||||||
|
std::cout << startInd << "-" << endInd;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int index = ledIndexList[i].toInt();
|
||||||
|
correction->setCorrectionForLed(colorCorrection->_id, index, index);
|
||||||
|
std::cout << index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << "]" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return correction;
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiColorCorrection * Hyperion::createLedColorsTemperature(const unsigned ledCnt, const Json::Value & colorConfig)
|
||||||
|
{
|
||||||
|
// Create the result, the corrections are added to this
|
||||||
|
MultiColorCorrection * correction = new MultiColorCorrection(ledCnt);
|
||||||
|
|
||||||
|
const Json::Value correctionConfig = colorConfig.get("temperature", Json::nullValue);
|
||||||
|
if (correctionConfig.isNull())
|
||||||
|
{
|
||||||
|
// Old style color correction config (just one for all leds)
|
||||||
|
ColorCorrection * colorCorrection = createColorCorrection(colorConfig);
|
||||||
|
correction->addCorrection(colorCorrection);
|
||||||
|
correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1);
|
||||||
|
}
|
||||||
|
else if (!correctionConfig.isArray())
|
||||||
|
{
|
||||||
|
ColorCorrection * colorCorrection = createColorCorrection(colorConfig);
|
||||||
|
correction->addCorrection(colorCorrection);
|
||||||
|
correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*");
|
||||||
|
|
||||||
|
for (Json::UInt i = 0; i < correctionConfig.size(); ++i)
|
||||||
|
{
|
||||||
|
const Json::Value & config = correctionConfig[i];
|
||||||
|
ColorCorrection * colorCorrection = createColorCorrection(config);
|
||||||
|
correction->addCorrection(colorCorrection);
|
||||||
|
|
||||||
|
const QString ledIndicesStr = QString(config.get("leds", "").asCString()).trimmed();
|
||||||
|
if (ledIndicesStr.compare("*") == 0)
|
||||||
|
{
|
||||||
|
// Special case for indices '*' => all leds
|
||||||
|
correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1);
|
||||||
|
std::cout << "ColorCorrection '" << colorCorrection->_id << "' => [0; "<< ledCnt-1 << "]" << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!overallExp.exactMatch(ledIndicesStr))
|
||||||
|
{
|
||||||
|
std::cerr << "Given led indices " << i << " not correct format: " << ledIndicesStr.toStdString() << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "ColorCorrection '" << colorCorrection->_id << "' => [";
|
||||||
|
|
||||||
|
const QStringList ledIndexList = ledIndicesStr.split(",");
|
||||||
|
for (int i=0; i<ledIndexList.size(); ++i) {
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
std::cout << ", ";
|
||||||
|
}
|
||||||
|
if (ledIndexList[i].contains("-"))
|
||||||
|
{
|
||||||
|
QStringList ledIndices = ledIndexList[i].split("-");
|
||||||
|
int startInd = ledIndices[0].toInt();
|
||||||
|
int endInd = ledIndices[1].toInt();
|
||||||
|
|
||||||
|
correction->setCorrectionForLed(colorCorrection->_id, startInd, endInd);
|
||||||
|
std::cout << startInd << "-" << endInd;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int index = ledIndexList[i].toInt();
|
||||||
|
correction->setCorrectionForLed(colorCorrection->_id, index, index);
|
||||||
|
std::cout << index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::cout << "]" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return correction;
|
||||||
|
}
|
||||||
|
|
||||||
HsvTransform * Hyperion::createHsvTransform(const Json::Value & hsvConfig)
|
HsvTransform * Hyperion::createHsvTransform(const Json::Value & hsvConfig)
|
||||||
{
|
{
|
||||||
const double saturationGain = hsvConfig.get("saturationGain", 1.0).asDouble();
|
const double saturationGain = hsvConfig.get("saturationGain", 1.0).asDouble();
|
||||||
@ -176,6 +347,14 @@ HsvTransform * Hyperion::createHsvTransform(const Json::Value & hsvConfig)
|
|||||||
return new HsvTransform(saturationGain, valueGain);
|
return new HsvTransform(saturationGain, valueGain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HslTransform * Hyperion::createHslTransform(const Json::Value & hslConfig)
|
||||||
|
{
|
||||||
|
const double saturationGain = hslConfig.get("saturationGain", 1.0).asDouble();
|
||||||
|
const double luminanceGain = hslConfig.get("luminanceGain", 1.0).asDouble();
|
||||||
|
|
||||||
|
return new HslTransform(saturationGain, luminanceGain);
|
||||||
|
}
|
||||||
|
|
||||||
RgbChannelTransform* Hyperion::createRgbChannelTransform(const Json::Value& colorConfig)
|
RgbChannelTransform* Hyperion::createRgbChannelTransform(const Json::Value& colorConfig)
|
||||||
{
|
{
|
||||||
const double threshold = colorConfig.get("threshold", 0.0).asDouble();
|
const double threshold = colorConfig.get("threshold", 0.0).asDouble();
|
||||||
@ -187,6 +366,16 @@ RgbChannelTransform* Hyperion::createRgbChannelTransform(const Json::Value& colo
|
|||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RgbChannelCorrection* Hyperion::createRgbChannelCorrection(const Json::Value& colorConfig)
|
||||||
|
{
|
||||||
|
const int varR = colorConfig.get("red", 255).asInt();
|
||||||
|
const int varG = colorConfig.get("green", 255).asInt();
|
||||||
|
const int varB = colorConfig.get("blue", 255).asInt();
|
||||||
|
|
||||||
|
RgbChannelCorrection* correction = new RgbChannelCorrection(varR, varG, varB);
|
||||||
|
return correction;
|
||||||
|
}
|
||||||
|
|
||||||
LedString Hyperion::createLedString(const Json::Value& ledsConfig, const ColorOrder deviceOrder)
|
LedString Hyperion::createLedString(const Json::Value& ledsConfig, const ColorOrder deviceOrder)
|
||||||
{
|
{
|
||||||
LedString ledString;
|
LedString ledString;
|
||||||
@ -266,7 +455,6 @@ LedDevice * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig,
|
|||||||
return ledDevice;
|
return ledDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MessageForwarder * Hyperion::createMessageForwarder(const Json::Value & forwarderConfig)
|
MessageForwarder * Hyperion::createMessageForwarder(const Json::Value & forwarderConfig)
|
||||||
{
|
{
|
||||||
MessageForwarder * forwarder = new MessageForwarder();
|
MessageForwarder * forwarder = new MessageForwarder();
|
||||||
@ -302,12 +490,22 @@ MessageForwarder * Hyperion::getForwarder()
|
|||||||
Hyperion::Hyperion(const Json::Value &jsonConfig) :
|
Hyperion::Hyperion(const Json::Value &jsonConfig) :
|
||||||
_ledString(createLedString(jsonConfig["leds"], createColorOrder(jsonConfig["device"]))),
|
_ledString(createLedString(jsonConfig["leds"], createColorOrder(jsonConfig["device"]))),
|
||||||
_muxer(_ledString.leds().size()),
|
_muxer(_ledString.leds().size()),
|
||||||
|
_raw2ledCorrection(createLedColorsCorrection(_ledString.leds().size(), jsonConfig["color"])),
|
||||||
|
_raw2ledTemperature(createLedColorsTemperature(_ledString.leds().size(), jsonConfig["color"])),
|
||||||
_raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])),
|
_raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])),
|
||||||
_device(LedDeviceFactory::construct(jsonConfig["device"])),
|
_device(LedDeviceFactory::construct(jsonConfig["device"])),
|
||||||
_effectEngine(nullptr),
|
_effectEngine(nullptr),
|
||||||
_messageForwarder(createMessageForwarder(jsonConfig["forwarder"])),
|
_messageForwarder(createMessageForwarder(jsonConfig["forwarder"])),
|
||||||
_timer()
|
_timer()
|
||||||
{
|
{
|
||||||
|
if (!_raw2ledCorrection->verifyCorrections())
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Color correction incorrectly set");
|
||||||
|
}
|
||||||
|
if (!_raw2ledTemperature->verifyCorrections())
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Color temperature incorrectly set");
|
||||||
|
}
|
||||||
if (!_raw2ledTransform->verifyTransforms())
|
if (!_raw2ledTransform->verifyTransforms())
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Color transformation incorrectly set");
|
throw std::runtime_error("Color transformation incorrectly set");
|
||||||
@ -348,6 +546,12 @@ Hyperion::~Hyperion()
|
|||||||
// delete the color transform
|
// delete the color transform
|
||||||
delete _raw2ledTransform;
|
delete _raw2ledTransform;
|
||||||
|
|
||||||
|
// delete the color correction
|
||||||
|
delete _raw2ledCorrection;
|
||||||
|
|
||||||
|
// delete the color temperature correction
|
||||||
|
delete _raw2ledTemperature;
|
||||||
|
|
||||||
// delete the message forwarder
|
// delete the message forwarder
|
||||||
delete _messageForwarder;
|
delete _messageForwarder;
|
||||||
}
|
}
|
||||||
@ -395,16 +599,46 @@ const std::vector<std::string> & Hyperion::getTransformIds() const
|
|||||||
return _raw2ledTransform->getTransformIds();
|
return _raw2ledTransform->getTransformIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string> & Hyperion::getCorrectionIds() const
|
||||||
|
{
|
||||||
|
return _raw2ledCorrection->getCorrectionIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string> & Hyperion::getTemperatureIds() const
|
||||||
|
{
|
||||||
|
return _raw2ledTemperature->getCorrectionIds();
|
||||||
|
}
|
||||||
|
|
||||||
ColorTransform * Hyperion::getTransform(const std::string& id)
|
ColorTransform * Hyperion::getTransform(const std::string& id)
|
||||||
{
|
{
|
||||||
return _raw2ledTransform->getTransform(id);
|
return _raw2ledTransform->getTransform(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColorCorrection * Hyperion::getCorrection(const std::string& id)
|
||||||
|
{
|
||||||
|
return _raw2ledCorrection->getCorrection(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorCorrection * Hyperion::getTemperature(const std::string& id)
|
||||||
|
{
|
||||||
|
return _raw2ledTemperature->getCorrection(id);
|
||||||
|
}
|
||||||
|
|
||||||
void Hyperion::transformsUpdated()
|
void Hyperion::transformsUpdated()
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Hyperion::correctionsUpdated()
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Hyperion::temperaturesUpdated()
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void Hyperion::clear(int priority)
|
void Hyperion::clear(int priority)
|
||||||
{
|
{
|
||||||
if (_muxer.hasPriority(priority))
|
if (_muxer.hasPriority(priority))
|
||||||
@ -468,8 +702,10 @@ void Hyperion::update()
|
|||||||
int priority = _muxer.getCurrentPriority();
|
int priority = _muxer.getCurrentPriority();
|
||||||
const PriorityMuxer::InputInfo & priorityInfo = _muxer.getInputInfo(priority);
|
const PriorityMuxer::InputInfo & priorityInfo = _muxer.getInputInfo(priority);
|
||||||
|
|
||||||
// Apply the transform to each led and color-channel
|
// Apply the correction and the transform to each led and color-channel
|
||||||
std::vector<ColorRgb> ledColors = _raw2ledTransform->applyTransform(priorityInfo.ledColors);
|
std::vector<ColorRgb> correctedColors = _raw2ledCorrection->applyCorrection(priorityInfo.ledColors);
|
||||||
|
std::vector<ColorRgb> temperatureColors = _raw2ledTemperature->applyCorrection(correctedColors);
|
||||||
|
std::vector<ColorRgb> ledColors =_raw2ledTransform->applyTransform(temperatureColors);
|
||||||
const std::vector<Led>& leds = _ledString.leds();
|
const std::vector<Led>& leds = _ledString.leds();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ColorRgb& color : ledColors)
|
for (ColorRgb& color : ledColors)
|
||||||
|
96
libsrc/hyperion/MultiColorCorrection.cpp
Normal file
96
libsrc/hyperion/MultiColorCorrection.cpp
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
// Hyperion includes
|
||||||
|
#include "MultiColorCorrection.h"
|
||||||
|
|
||||||
|
MultiColorCorrection::MultiColorCorrection(const unsigned ledCnt) :
|
||||||
|
_ledCorrections(ledCnt, nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiColorCorrection::~MultiColorCorrection()
|
||||||
|
{
|
||||||
|
// Clean up all the correctinos
|
||||||
|
for (ColorCorrection * correction : _correction)
|
||||||
|
{
|
||||||
|
delete correction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultiColorCorrection::addCorrection(ColorCorrection * correction)
|
||||||
|
{
|
||||||
|
_correctionIds.push_back(correction->_id);
|
||||||
|
_correction.push_back(correction);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MultiColorCorrection::setCorrectionForLed(const std::string& id, const unsigned startLed, const unsigned endLed)
|
||||||
|
{
|
||||||
|
assert(startLed <= endLed);
|
||||||
|
assert(endLed < _ledCorrections.size());
|
||||||
|
|
||||||
|
// Get the identified correction (don't care if is nullptr)
|
||||||
|
ColorCorrection * correction = getCorrection(id);
|
||||||
|
for (unsigned iLed=startLed; iLed<=endLed; ++iLed)
|
||||||
|
{
|
||||||
|
_ledCorrections[iLed] = correction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MultiColorCorrection::verifyCorrections() const
|
||||||
|
{
|
||||||
|
bool allLedsSet = true;
|
||||||
|
for (unsigned iLed=0; iLed<_ledCorrections.size(); ++iLed)
|
||||||
|
{
|
||||||
|
if (_ledCorrections[iLed] == nullptr)
|
||||||
|
{
|
||||||
|
std::cerr << "No correction set for " << iLed << std::endl;
|
||||||
|
allLedsSet = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return allLedsSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string> & MultiColorCorrection::getCorrectionIds()
|
||||||
|
{
|
||||||
|
return _correctionIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorCorrection* MultiColorCorrection::getCorrection(const std::string& id)
|
||||||
|
{
|
||||||
|
// Iterate through the unique corrections until we find the one with the given id
|
||||||
|
for (ColorCorrection * correction : _correction)
|
||||||
|
{
|
||||||
|
if (correction->_id == id)
|
||||||
|
{
|
||||||
|
return correction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The ColorCorrection was not found
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<ColorRgb> MultiColorCorrection::applyCorrection(const std::vector<ColorRgb>& rawColors)
|
||||||
|
{
|
||||||
|
// Create a copy, as we will do the rest of the correction in place
|
||||||
|
std::vector<ColorRgb> ledColors(rawColors);
|
||||||
|
|
||||||
|
const size_t itCnt = std::min(_ledCorrections.size(), rawColors.size());
|
||||||
|
for (size_t i=0; i<itCnt; ++i)
|
||||||
|
{
|
||||||
|
ColorCorrection * correction = _ledCorrections[i];
|
||||||
|
if (correction == nullptr)
|
||||||
|
{
|
||||||
|
// No correction set for this led (do nothing)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ColorRgb& color = ledColors[i];
|
||||||
|
|
||||||
|
color.red = correction->_rgbCorrection.correctionR(color.red);
|
||||||
|
color.green = correction->_rgbCorrection.correctionG(color.green);
|
||||||
|
color.blue = correction->_rgbCorrection.correctionB(color.blue);
|
||||||
|
}
|
||||||
|
return ledColors;
|
||||||
|
}
|
66
libsrc/hyperion/MultiColorCorrection.h
Normal file
66
libsrc/hyperion/MultiColorCorrection.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// STL includes
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// Utils includes
|
||||||
|
#include <utils/ColorRgb.h>
|
||||||
|
|
||||||
|
// Hyperion includes
|
||||||
|
#include <hyperion/ColorCorrection.h>
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The LedColorCorrection is responsible for performing color correction from 'raw' colors
|
||||||
|
/// received as input to colors mapped to match the color-properties of the leds.
|
||||||
|
///
|
||||||
|
class MultiColorCorrection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MultiColorCorrection(const unsigned ledCnt);
|
||||||
|
~MultiColorCorrection();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new ColorCorrection to this MultiColorCorrection
|
||||||
|
*
|
||||||
|
* @param Correction The new ColorCorrection (ownership is transfered)
|
||||||
|
*/
|
||||||
|
void addCorrection(ColorCorrection * correction);
|
||||||
|
|
||||||
|
void setCorrectionForLed(const std::string& id, const unsigned startLed, const unsigned endLed);
|
||||||
|
|
||||||
|
bool verifyCorrections() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns the identifier of all the unique ColorCorrection
|
||||||
|
///
|
||||||
|
/// @return The list with unique id's of the ColorCorrections
|
||||||
|
const std::vector<std::string> & getCorrectionIds();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns the pointer to the ColorCorrection with the given id
|
||||||
|
///
|
||||||
|
/// @param id The identifier of the ColorCorrection
|
||||||
|
///
|
||||||
|
/// @return The ColorCorrection with the given id (or nullptr if it does not exist)
|
||||||
|
///
|
||||||
|
ColorCorrection* getCorrection(const std::string& id);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Performs the color transoformation from raw-color to led-color
|
||||||
|
///
|
||||||
|
/// @param rawColors The list with raw colors
|
||||||
|
///
|
||||||
|
/// @return The list with led-colors
|
||||||
|
///
|
||||||
|
std::vector<ColorRgb> applyCorrection(const std::vector<ColorRgb>& rawColors);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// List with Correction ids
|
||||||
|
std::vector<std::string> _correctionIds;
|
||||||
|
|
||||||
|
/// List with unique ColorCorrections
|
||||||
|
std::vector<ColorCorrection*> _correction;
|
||||||
|
|
||||||
|
/// List with a pointer to the ColorCorrection for each individual led
|
||||||
|
std::vector<ColorCorrection*> _ledCorrections;
|
||||||
|
};
|
@ -89,6 +89,7 @@ std::vector<ColorRgb> MultiColorTransform::applyTransform(const std::vector<Colo
|
|||||||
ColorRgb& color = ledColors[i];
|
ColorRgb& color = ledColors[i];
|
||||||
|
|
||||||
transform->_hsvTransform.transform(color.red, color.green, color.blue);
|
transform->_hsvTransform.transform(color.red, color.green, color.blue);
|
||||||
|
transform->_hslTransform.transform(color.red, color.green, color.blue);
|
||||||
color.red = transform->_rgbRedTransform.transform(color.red);
|
color.red = transform->_rgbRedTransform.transform(color.red);
|
||||||
color.green = transform->_rgbGreenTransform.transform(color.green);
|
color.green = transform->_rgbGreenTransform.transform(color.green);
|
||||||
color.blue = transform->_rgbBlueTransform.transform(color.blue);
|
color.blue = transform->_rgbBlueTransform.transform(color.blue);
|
||||||
|
@ -54,6 +54,23 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties" : false
|
"additionalProperties" : false
|
||||||
|
},
|
||||||
|
"hsl" : {
|
||||||
|
"type" : "object",
|
||||||
|
"required" : false,
|
||||||
|
"properties" : {
|
||||||
|
"saturationGain" : {
|
||||||
|
"type" : "number",
|
||||||
|
"required" : false,
|
||||||
|
"minimum" : 0.0
|
||||||
|
},
|
||||||
|
"luminanceGain" : {
|
||||||
|
"type" : "number",
|
||||||
|
"required" : false,
|
||||||
|
"minimum" : 0.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties" : false
|
||||||
},
|
},
|
||||||
"red": {
|
"red": {
|
||||||
"type":"object",
|
"type":"object",
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <hyperion/ImageProcessor.h>
|
#include <hyperion/ImageProcessor.h>
|
||||||
#include <hyperion/MessageForwarder.h>
|
#include <hyperion/MessageForwarder.h>
|
||||||
#include <hyperion/ColorTransform.h>
|
#include <hyperion/ColorTransform.h>
|
||||||
|
#include <hyperion/ColorCorrection.h>
|
||||||
#include <utils/ColorRgb.h>
|
#include <utils/ColorRgb.h>
|
||||||
|
|
||||||
// project includes
|
// project includes
|
||||||
@ -247,6 +248,10 @@ void JsonClientConnection::handleMessage(const std::string &messageString)
|
|||||||
handleClearallCommand(message);
|
handleClearallCommand(message);
|
||||||
else if (command == "transform")
|
else if (command == "transform")
|
||||||
handleTransformCommand(message);
|
handleTransformCommand(message);
|
||||||
|
else if (command == "correction")
|
||||||
|
handleCorrectionCommand(message);
|
||||||
|
else if (command == "temperature")
|
||||||
|
handleTemperatureCommand(message);
|
||||||
else
|
else
|
||||||
handleNotImplemented();
|
handleNotImplemented();
|
||||||
}
|
}
|
||||||
@ -388,6 +393,47 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// collect correction information
|
||||||
|
Json::Value & correctionArray = info["correction"];
|
||||||
|
for (const std::string& correctionId : _hyperion->getCorrectionIds())
|
||||||
|
{
|
||||||
|
const ColorCorrection * colorCorrection = _hyperion->getCorrection(correctionId);
|
||||||
|
if (colorCorrection == nullptr)
|
||||||
|
{
|
||||||
|
std::cerr << "Incorrect color correction id: " << correctionId << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Json::Value & correction = correctionArray.append(Json::Value());
|
||||||
|
correction["id"] = correctionId;
|
||||||
|
|
||||||
|
Json::Value & corrValues = correction["correctionValues"];
|
||||||
|
corrValues.append(colorCorrection->_rgbCorrection.getcorrectionR());
|
||||||
|
corrValues.append(colorCorrection->_rgbCorrection.getcorrectionG());
|
||||||
|
corrValues.append(colorCorrection->_rgbCorrection.getcorrectionB());
|
||||||
|
}
|
||||||
|
|
||||||
|
// collect temperature correction information
|
||||||
|
Json::Value & temperatureArray = info["temperature"];
|
||||||
|
for (const std::string& tempId : _hyperion->getTemperatureIds())
|
||||||
|
{
|
||||||
|
const ColorCorrection * colorTemp = _hyperion->getTemperature(tempId);
|
||||||
|
if (colorTemp == nullptr)
|
||||||
|
{
|
||||||
|
std::cerr << "Incorrect color temperature correction id: " << tempId << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Json::Value & temperature = temperatureArray.append(Json::Value());
|
||||||
|
temperature["id"] = tempId;
|
||||||
|
|
||||||
|
Json::Value & tempValues = temperature["correctionValues"];
|
||||||
|
tempValues.append(colorTemp->_rgbCorrection.getcorrectionR());
|
||||||
|
tempValues.append(colorTemp->_rgbCorrection.getcorrectionG());
|
||||||
|
tempValues.append(colorTemp->_rgbCorrection.getcorrectionB());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// collect transform information
|
// collect transform information
|
||||||
Json::Value & transformArray = info["transform"];
|
Json::Value & transformArray = info["transform"];
|
||||||
for (const std::string& transformId : _hyperion->getTransformIds())
|
for (const std::string& transformId : _hyperion->getTransformIds())
|
||||||
@ -404,6 +450,8 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
|
|||||||
|
|
||||||
transform["saturationGain"] = colorTransform->_hsvTransform.getSaturationGain();
|
transform["saturationGain"] = colorTransform->_hsvTransform.getSaturationGain();
|
||||||
transform["valueGain"] = colorTransform->_hsvTransform.getValueGain();
|
transform["valueGain"] = colorTransform->_hsvTransform.getValueGain();
|
||||||
|
transform["saturationLGain"] = colorTransform->_hslTransform.getSaturationGain();
|
||||||
|
transform["luminanceGain"] = colorTransform->_hslTransform.getLuminanceGain();
|
||||||
|
|
||||||
Json::Value & threshold = transform["threshold"];
|
Json::Value & threshold = transform["threshold"];
|
||||||
threshold.append(colorTransform->_rgbRedTransform.getThreshold());
|
threshold.append(colorTransform->_rgbRedTransform.getThreshold());
|
||||||
@ -487,6 +535,16 @@ void JsonClientConnection::handleTransformCommand(const Json::Value &message)
|
|||||||
colorTransform->_hsvTransform.setValueGain(transform["valueGain"].asDouble());
|
colorTransform->_hsvTransform.setValueGain(transform["valueGain"].asDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (transform.isMember("saturationLGain"))
|
||||||
|
{
|
||||||
|
colorTransform->_hslTransform.setSaturationGain(transform["saturationLGain"].asDouble());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transform.isMember("luminanceGain"))
|
||||||
|
{
|
||||||
|
colorTransform->_hslTransform.setLuminanceGain(transform["luminanceGain"].asDouble());
|
||||||
|
}
|
||||||
|
|
||||||
if (transform.isMember("threshold"))
|
if (transform.isMember("threshold"))
|
||||||
{
|
{
|
||||||
const Json::Value & values = transform["threshold"];
|
const Json::Value & values = transform["threshold"];
|
||||||
@ -525,6 +583,58 @@ void JsonClientConnection::handleTransformCommand(const Json::Value &message)
|
|||||||
sendSuccessReply();
|
sendSuccessReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsonClientConnection::handleCorrectionCommand(const Json::Value &message)
|
||||||
|
{
|
||||||
|
const Json::Value & correction = message["correction"];
|
||||||
|
|
||||||
|
const std::string correctionId = correction.get("id", _hyperion->getCorrectionIds().front()).asString();
|
||||||
|
ColorCorrection * colorCorrection = _hyperion->getCorrection(correctionId);
|
||||||
|
if (colorCorrection == nullptr)
|
||||||
|
{
|
||||||
|
//sendErrorReply(std::string("Incorrect correction identifier: ") + correctionId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (correction.isMember("correctionValues"))
|
||||||
|
{
|
||||||
|
const Json::Value & values = correction["correctionValues"];
|
||||||
|
colorCorrection->_rgbCorrection.setcorrectionR(values[0u].asInt());
|
||||||
|
colorCorrection->_rgbCorrection.setcorrectionG(values[1u].asInt());
|
||||||
|
colorCorrection->_rgbCorrection.setcorrectionB(values[2u].asInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit the changes
|
||||||
|
_hyperion->correctionsUpdated();
|
||||||
|
|
||||||
|
sendSuccessReply();
|
||||||
|
}
|
||||||
|
|
||||||
|
void JsonClientConnection::handleTemperatureCommand(const Json::Value &message)
|
||||||
|
{
|
||||||
|
const Json::Value & temperature = message["temperature"];
|
||||||
|
|
||||||
|
const std::string tempId = temperature.get("id", _hyperion->getTemperatureIds().front()).asString();
|
||||||
|
ColorCorrection * colorTemperature = _hyperion->getTemperature(tempId);
|
||||||
|
if (colorTemperature == nullptr)
|
||||||
|
{
|
||||||
|
//sendErrorReply(std::string("Incorrect temperature identifier: ") + tempId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (temperature.isMember("correctionValues"))
|
||||||
|
{
|
||||||
|
const Json::Value & values = temperature["correctionValues"];
|
||||||
|
colorTemperature->_rgbCorrection.setcorrectionR(values[0u].asInt());
|
||||||
|
colorTemperature->_rgbCorrection.setcorrectionG(values[1u].asInt());
|
||||||
|
colorTemperature->_rgbCorrection.setcorrectionB(values[2u].asInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit the changes
|
||||||
|
_hyperion->temperaturesUpdated();
|
||||||
|
|
||||||
|
sendSuccessReply();
|
||||||
|
}
|
||||||
|
|
||||||
void JsonClientConnection::handleNotImplemented()
|
void JsonClientConnection::handleNotImplemented()
|
||||||
{
|
{
|
||||||
sendErrorReply("Command not implemented");
|
sendErrorReply("Command not implemented");
|
||||||
|
@ -113,6 +113,20 @@ private:
|
|||||||
///
|
///
|
||||||
void handleTransformCommand(const Json::Value & message);
|
void handleTransformCommand(const Json::Value & message);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Handle an incoming JSON Correction message
|
||||||
|
///
|
||||||
|
/// @param message the incoming message
|
||||||
|
///
|
||||||
|
void handleCorrectionCommand(const Json::Value & message);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Handle an incoming JSON Temperature message
|
||||||
|
///
|
||||||
|
/// @param message the incoming message
|
||||||
|
///
|
||||||
|
void handleTemperatureCommand(const Json::Value & message);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Handle an incoming JSON message of unknown type
|
/// Handle an incoming JSON message of unknown type
|
||||||
///
|
///
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
<file alias="schema-clear">schema/schema-clear.json</file>
|
<file alias="schema-clear">schema/schema-clear.json</file>
|
||||||
<file alias="schema-clearall">schema/schema-clearall.json</file>
|
<file alias="schema-clearall">schema/schema-clearall.json</file>
|
||||||
<file alias="schema-transform">schema/schema-transform.json</file>
|
<file alias="schema-transform">schema/schema-transform.json</file>
|
||||||
|
<file alias="schema-correction">schema/schema-correction.json</file>
|
||||||
|
<file alias="schema-temperature">schema/schema-temperature.json</file>
|
||||||
<file alias="schema-effect">schema/schema-effect.json</file>
|
<file alias="schema-effect">schema/schema-effect.json</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
34
libsrc/jsonserver/schema/schema-correction.json
Normal file
34
libsrc/jsonserver/schema/schema-correction.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"type":"object",
|
||||||
|
"required":true,
|
||||||
|
"properties":{
|
||||||
|
"command": {
|
||||||
|
"type" : "string",
|
||||||
|
"required" : true,
|
||||||
|
"enum" : ["correction"]
|
||||||
|
},
|
||||||
|
"correction": {
|
||||||
|
"type": "object",
|
||||||
|
"required": true,
|
||||||
|
"properties": {
|
||||||
|
"id" : {
|
||||||
|
"type" : "string",
|
||||||
|
"required" : false
|
||||||
|
},
|
||||||
|
"correctionValues" : {
|
||||||
|
"type": "array",
|
||||||
|
"required": false,
|
||||||
|
"items" : {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 255
|
||||||
|
},
|
||||||
|
"minItems": 3,
|
||||||
|
"maxItems": 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
34
libsrc/jsonserver/schema/schema-temperature.json
Normal file
34
libsrc/jsonserver/schema/schema-temperature.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"type":"object",
|
||||||
|
"required":true,
|
||||||
|
"properties":{
|
||||||
|
"command": {
|
||||||
|
"type" : "string",
|
||||||
|
"required" : true,
|
||||||
|
"enum" : ["temperature"]
|
||||||
|
},
|
||||||
|
"temperature": {
|
||||||
|
"type": "object",
|
||||||
|
"required": true,
|
||||||
|
"properties": {
|
||||||
|
"id" : {
|
||||||
|
"type" : "string",
|
||||||
|
"required" : false
|
||||||
|
},
|
||||||
|
"correctionValues" : {
|
||||||
|
"type": "array",
|
||||||
|
"required": false,
|
||||||
|
"items" : {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 255
|
||||||
|
},
|
||||||
|
"minItems": 3,
|
||||||
|
"maxItems": 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
@ -25,6 +25,16 @@
|
|||||||
"required" : false,
|
"required" : false,
|
||||||
"minimum" : 0.0
|
"minimum" : 0.0
|
||||||
},
|
},
|
||||||
|
"saturationLGain" : {
|
||||||
|
"type" : "number",
|
||||||
|
"required" : false,
|
||||||
|
"minimum" : 0.0
|
||||||
|
},
|
||||||
|
"luminanceGain" : {
|
||||||
|
"type" : "number",
|
||||||
|
"required" : false,
|
||||||
|
"minimum" : 0.0
|
||||||
|
},
|
||||||
"threshold": {
|
"threshold": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"required": false,
|
"required": false,
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"command": {
|
"command": {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform"]
|
"enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform", "correction", "temperature"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
|
|||||||
|
|
||||||
device = deviceLightpack;
|
device = deviceLightpack;
|
||||||
}
|
}
|
||||||
else if (type == "multi-lightpack" || type == "multi_lightpack")
|
else if (type == "multi-lightpack")
|
||||||
{
|
{
|
||||||
LedDeviceMultiLightpack* deviceLightpack = new LedDeviceMultiLightpack();
|
LedDeviceMultiLightpack* deviceLightpack = new LedDeviceMultiLightpack();
|
||||||
deviceLightpack->open();
|
deviceLightpack->open();
|
||||||
@ -327,8 +327,9 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
|
|||||||
const int leds = deviceConfig.get("leds", 12).asInt();
|
const int leds = deviceConfig.get("leds", 12).asInt();
|
||||||
const uint32_t freq = deviceConfig.get("freq", (Json::UInt)800000ul).asInt();
|
const uint32_t freq = deviceConfig.get("freq", (Json::UInt)800000ul).asInt();
|
||||||
const int dmanum = deviceConfig.get("dmanum", 5).asInt();
|
const int dmanum = deviceConfig.get("dmanum", 5).asInt();
|
||||||
|
const int pwmchannel = deviceConfig.get("pwmchannel", 0).asInt();
|
||||||
|
|
||||||
LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum);
|
LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum, pwmchannel);
|
||||||
device = ledDeviceWS281x;
|
device = ledDeviceWS281x;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
0
libsrc/leddevice/LedDeviceFadeCandy.cpp
Executable file → Normal file
0
libsrc/leddevice/LedDeviceFadeCandy.cpp
Executable file → Normal file
0
libsrc/leddevice/LedDeviceFadeCandy.h
Executable file → Normal file
0
libsrc/leddevice/LedDeviceFadeCandy.h
Executable file → Normal file
@ -216,7 +216,7 @@ int LedDevicePhilipsHue::switchOff() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LedDevicePhilipsHue::put(QString route, QString content) {
|
void LedDevicePhilipsHue::put(QString route, QString content) {
|
||||||
QString url = QString("http://%1/api/%2/%3").arg(host).arg(username).arg(route);
|
QString url = getUrl(route);
|
||||||
// Perfrom request
|
// Perfrom request
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
QNetworkReply* reply = manager->put(request, content.toLatin1());
|
QNetworkReply* reply = manager->put(request, content.toLatin1());
|
||||||
@ -225,10 +225,12 @@ void LedDevicePhilipsHue::put(QString route, QString content) {
|
|||||||
loop.connect(reply, SIGNAL(finished()), SLOT(quit()));
|
loop.connect(reply, SIGNAL(finished()), SLOT(quit()));
|
||||||
// Go into the loop until the request is finished.
|
// Go into the loop until the request is finished.
|
||||||
loop.exec();
|
loop.exec();
|
||||||
|
// Free space.
|
||||||
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray LedDevicePhilipsHue::get(QString route) {
|
QByteArray LedDevicePhilipsHue::get(QString route) {
|
||||||
QString url = QString("http://%1/api/%2/%3").arg(host).arg(username).arg(route);
|
QString url = getUrl(route);
|
||||||
// Perfrom request
|
// Perfrom request
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
QNetworkReply* reply = manager->get(request);
|
QNetworkReply* reply = manager->get(request);
|
||||||
@ -238,7 +240,11 @@ QByteArray LedDevicePhilipsHue::get(QString route) {
|
|||||||
// Go into the loop until the request is finished.
|
// Go into the loop until the request is finished.
|
||||||
loop.exec();
|
loop.exec();
|
||||||
// Read all data of the response.
|
// Read all data of the response.
|
||||||
return reply->readAll();
|
QByteArray response = reply->readAll();
|
||||||
|
// Free space.
|
||||||
|
reply->deleteLater();
|
||||||
|
// Return response
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LedDevicePhilipsHue::getStateRoute(unsigned int lightId) {
|
QString LedDevicePhilipsHue::getStateRoute(unsigned int lightId) {
|
||||||
@ -249,6 +255,10 @@ QString LedDevicePhilipsHue::getRoute(unsigned int lightId) {
|
|||||||
return QString("lights/%1").arg(lightId);
|
return QString("lights/%1").arg(lightId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString LedDevicePhilipsHue::getUrl(QString route) {
|
||||||
|
return QString("http://%1/api/%2/%3").arg(host).arg(username).arg(route);
|
||||||
|
}
|
||||||
|
|
||||||
void LedDevicePhilipsHue::saveStates(unsigned int nLights) {
|
void LedDevicePhilipsHue::saveStates(unsigned int nLights) {
|
||||||
// Clear saved lamps.
|
// Clear saved lamps.
|
||||||
lights.clear();
|
lights.clear();
|
||||||
@ -257,18 +267,24 @@ void LedDevicePhilipsHue::saveStates(unsigned int nLights) {
|
|||||||
Json::FastWriter writer;
|
Json::FastWriter writer;
|
||||||
// Read light ids if none have been supplied by the user.
|
// Read light ids if none have been supplied by the user.
|
||||||
if (lightIds.size() != nLights) {
|
if (lightIds.size() != nLights) {
|
||||||
|
lightIds.clear();
|
||||||
|
//
|
||||||
QByteArray response = get("lights");
|
QByteArray response = get("lights");
|
||||||
Json::Value json;
|
Json::Value json;
|
||||||
if (!reader.parse(QString(response).toStdString(), json)) {
|
if (!reader.parse(QString(response).toStdString(), json)) {
|
||||||
throw std::runtime_error("No lights found");
|
throw std::runtime_error(("No lights found at " + getUrl("lights")).toStdString());
|
||||||
}
|
}
|
||||||
// Loop over all children.
|
// Loop over all children.
|
||||||
for (Json::ValueIterator it = json.begin(); it != json.end() && lightIds.size() <= nLights; it++) {
|
for (Json::ValueIterator it = json.begin(); it != json.end() && lightIds.size() < nLights; it++) {
|
||||||
int lightId = atoi(it.key().asCString());
|
int lightId = atoi(it.key().asCString());
|
||||||
lightIds.push_back(lightId);
|
lightIds.push_back(lightId);
|
||||||
std::cout << "LedDevicePhilipsHue::saveStates(nLights=" << nLights << "): found light with id " << lightId
|
std::cout << "LedDevicePhilipsHue::saveStates(nLights=" << nLights << "): found light with id " << lightId
|
||||||
<< "." << std::endl;
|
<< "." << std::endl;
|
||||||
}
|
}
|
||||||
|
// Check if we found enough lights.
|
||||||
|
if (lightIds.size() != nLights) {
|
||||||
|
throw std::runtime_error(("Not enough lights found at " + getUrl("lights")).toStdString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Iterate lights.
|
// Iterate lights.
|
||||||
for (unsigned int i = 0; i < nLights; i++) {
|
for (unsigned int i = 0; i < nLights; i++) {
|
||||||
@ -278,12 +294,22 @@ void LedDevicePhilipsHue::saveStates(unsigned int nLights) {
|
|||||||
Json::Value json;
|
Json::Value json;
|
||||||
if (!reader.parse(QString(response).toStdString(), json)) {
|
if (!reader.parse(QString(response).toStdString(), json)) {
|
||||||
// Error occured, break loop.
|
// Error occured, break loop.
|
||||||
std::cerr << "LedDevicePhilipsHue::saveStates(nLights=" << nLights
|
std::cerr << "LedDevicePhilipsHue::saveStates(nLights=" << nLights << "): got invalid response from light "
|
||||||
<< "): got invalid response from light with id " << lightIds.at(i) << "." << std::endl;
|
<< getUrl(getRoute(lightIds.at(i))).toStdString() << "." << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Get state object values which are subject to change.
|
// Get state object values which are subject to change.
|
||||||
Json::Value state(Json::objectValue);
|
Json::Value state(Json::objectValue);
|
||||||
|
if (!json.isMember("state")) {
|
||||||
|
std::cerr << "LedDevicePhilipsHue::saveStates(nLights=" << nLights << "): got no state for light from "
|
||||||
|
<< getUrl(getRoute(lightIds.at(i))).toStdString() << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!json["state"].isMember("on")) {
|
||||||
|
std::cerr << "LedDevicePhilipsHue::saveStates(nLights=" << nLights << "): got no valid state from light "
|
||||||
|
<< getUrl(getRoute(lightIds.at(i))).toStdString() << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
state["on"] = json["state"]["on"];
|
state["on"] = json["state"]["on"];
|
||||||
if (json["state"]["on"] == true) {
|
if (json["state"]["on"] == true) {
|
||||||
state["xy"] = json["state"]["xy"];
|
state["xy"] = json["state"]["xy"];
|
||||||
|
@ -207,6 +207,13 @@ private:
|
|||||||
///
|
///
|
||||||
QString getRoute(unsigned int lightId);
|
QString getRoute(unsigned int lightId);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @param route
|
||||||
|
///
|
||||||
|
/// @return the full URL of the request.
|
||||||
|
///
|
||||||
|
QString getUrl(QString route);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Queries the status of all lights and saves it.
|
/// Queries the status of all lights and saves it.
|
||||||
///
|
///
|
||||||
|
@ -3,22 +3,27 @@
|
|||||||
#include "LedDeviceWS281x.h"
|
#include "LedDeviceWS281x.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum)
|
LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int pwmchannel)
|
||||||
{
|
{
|
||||||
initialized = false;
|
initialized = false;
|
||||||
led_string.freq = freq;
|
led_string.freq = freq;
|
||||||
led_string.dmanum = dmanum;
|
led_string.dmanum = dmanum;
|
||||||
led_string.channel[0].gpionum = gpio;
|
if (pwmchannel != 0 && pwmchannel != 1) {
|
||||||
led_string.channel[0].invert = 0;
|
std::cout << "WS281x: invalid PWM channel; must be 0 or 1." << std::endl;
|
||||||
led_string.channel[0].count = leds;
|
throw -1;
|
||||||
led_string.channel[0].brightness = 255;
|
}
|
||||||
led_string.channel[0].strip_type = WS2811_STRIP_RGB;
|
chan = pwmchannel;
|
||||||
|
led_string.channel[chan].gpionum = gpio;
|
||||||
|
led_string.channel[chan].invert = 0;
|
||||||
|
led_string.channel[chan].count = leds;
|
||||||
|
led_string.channel[chan].brightness = 255;
|
||||||
|
led_string.channel[chan].strip_type = WS2811_STRIP_RGB;
|
||||||
|
|
||||||
led_string.channel[1].gpionum = 0;
|
led_string.channel[!chan].gpionum = 0;
|
||||||
led_string.channel[1].invert = 0;
|
led_string.channel[!chan].invert = 0;
|
||||||
led_string.channel[1].count = 0;
|
led_string.channel[!chan].count = 0;
|
||||||
led_string.channel[1].brightness = 0;
|
led_string.channel[!chan].brightness = 0;
|
||||||
led_string.channel[0].strip_type = WS2811_STRIP_RGB;
|
led_string.channel[!chan].strip_type = WS2811_STRIP_RGB;
|
||||||
if (ws2811_init(&led_string) < 0) {
|
if (ws2811_init(&led_string) < 0) {
|
||||||
std::cout << "Unable to initialize ws281x library." << std::endl;
|
std::cout << "Unable to initialize ws281x library." << std::endl;
|
||||||
throw -1;
|
throw -1;
|
||||||
@ -35,12 +40,12 @@ int LedDeviceWS281x::write(const std::vector<ColorRgb> &ledValues)
|
|||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (const ColorRgb& color : ledValues)
|
for (const ColorRgb& color : ledValues)
|
||||||
{
|
{
|
||||||
if (idx >= led_string.channel[0].count)
|
if (idx >= led_string.channel[chan].count)
|
||||||
break;
|
break;
|
||||||
led_string.channel[0].leds[idx++] = ((uint32_t)color.red << 16) + ((uint32_t)color.green << 8) + color.blue;
|
led_string.channel[chan].leds[idx++] = ((uint32_t)color.red << 16) + ((uint32_t)color.green << 8) + color.blue;
|
||||||
}
|
}
|
||||||
while (idx < led_string.channel[0].count)
|
while (idx < led_string.channel[chan].count)
|
||||||
led_string.channel[0].leds[idx++] = 0;
|
led_string.channel[chan].leds[idx++] = 0;
|
||||||
|
|
||||||
if (ws2811_render(&led_string))
|
if (ws2811_render(&led_string))
|
||||||
return -1;
|
return -1;
|
||||||
@ -57,8 +62,8 @@ int LedDeviceWS281x::switchOff()
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
while (idx < led_string.channel[0].count)
|
while (idx < led_string.channel[chan].count)
|
||||||
led_string.channel[0].leds[idx++] = 0;
|
led_string.channel[chan].leds[idx++] = 0;
|
||||||
|
|
||||||
if (ws2811_render(&led_string))
|
if (ws2811_render(&led_string))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
/// @param freq The target frequency for the data line, default is 800000
|
/// @param freq The target frequency for the data line, default is 800000
|
||||||
/// @param dmanum The DMA channel to use, default is 5
|
/// @param dmanum The DMA channel to use, default is 5
|
||||||
///
|
///
|
||||||
LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum);
|
LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum, int pwmchannel);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor of the LedDevice, waits for DMA to complete and then cleans up
|
/// Destructor of the LedDevice, waits for DMA to complete and then cleans up
|
||||||
@ -37,6 +37,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ws2811_t led_string;
|
ws2811_t led_string;
|
||||||
|
int chan;
|
||||||
bool initialized;
|
bool initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,8 +23,12 @@ add_library(hyperion-utils
|
|||||||
|
|
||||||
${CURRENT_HEADER_DIR}/HsvTransform.h
|
${CURRENT_HEADER_DIR}/HsvTransform.h
|
||||||
${CURRENT_SOURCE_DIR}/HsvTransform.cpp
|
${CURRENT_SOURCE_DIR}/HsvTransform.cpp
|
||||||
|
${CURRENT_HEADER_DIR}/HslTransform.h
|
||||||
|
${CURRENT_SOURCE_DIR}/HslTransform.cpp
|
||||||
${CURRENT_HEADER_DIR}/RgbChannelTransform.h
|
${CURRENT_HEADER_DIR}/RgbChannelTransform.h
|
||||||
${CURRENT_SOURCE_DIR}/RgbChannelTransform.cpp
|
${CURRENT_SOURCE_DIR}/RgbChannelTransform.cpp
|
||||||
|
${CURRENT_HEADER_DIR}/RgbChannelCorrection.h
|
||||||
|
${CURRENT_SOURCE_DIR}/RgbChannelCorrection.cpp
|
||||||
|
|
||||||
${CURRENT_HEADER_DIR}/jsonschema/JsonFactory.h
|
${CURRENT_HEADER_DIR}/jsonschema/JsonFactory.h
|
||||||
${CURRENT_HEADER_DIR}/jsonschema/JsonSchemaChecker.h
|
${CURRENT_HEADER_DIR}/jsonschema/JsonSchemaChecker.h
|
||||||
|
158
libsrc/utils/HslTransform.cpp
Normal file
158
libsrc/utils/HslTransform.cpp
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
#include <utils/HslTransform.h>
|
||||||
|
|
||||||
|
HslTransform::HslTransform() :
|
||||||
|
_saturationGain(1.0),
|
||||||
|
_luminanceGain(1.0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HslTransform::HslTransform(double saturationGain, double luminanceGain) :
|
||||||
|
_saturationGain(saturationGain),
|
||||||
|
_luminanceGain(luminanceGain)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HslTransform::~HslTransform()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void HslTransform::setSaturationGain(double saturationGain)
|
||||||
|
{
|
||||||
|
_saturationGain = saturationGain;
|
||||||
|
}
|
||||||
|
|
||||||
|
double HslTransform::getSaturationGain() const
|
||||||
|
{
|
||||||
|
return _saturationGain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HslTransform::setLuminanceGain(double luminanceGain)
|
||||||
|
{
|
||||||
|
_luminanceGain = luminanceGain;
|
||||||
|
}
|
||||||
|
|
||||||
|
double HslTransform::getLuminanceGain() const
|
||||||
|
{
|
||||||
|
return _luminanceGain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HslTransform::transform(uint8_t & red, uint8_t & green, uint8_t & blue) const
|
||||||
|
{
|
||||||
|
if (_saturationGain != 1.0 || _luminanceGain != 1.0)
|
||||||
|
{
|
||||||
|
uint16_t hue;
|
||||||
|
float saturation, luminance;
|
||||||
|
rgb2hsl(red, green, blue, hue, saturation, luminance);
|
||||||
|
|
||||||
|
float s = saturation * _saturationGain;
|
||||||
|
if (s > 1.0f)
|
||||||
|
saturation = 1.0f;
|
||||||
|
else
|
||||||
|
saturation = s;
|
||||||
|
|
||||||
|
float l = luminance * _luminanceGain;
|
||||||
|
if (l > 1.0f)
|
||||||
|
luminance = 1.0f;
|
||||||
|
else
|
||||||
|
luminance = l;
|
||||||
|
|
||||||
|
hsl2rgb(hue, saturation, luminance, red, green, blue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HslTransform::rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, float & saturation, float & luminance)
|
||||||
|
{
|
||||||
|
float r = red / 255.0f;
|
||||||
|
float g = green / 255.0f;
|
||||||
|
float b = blue / 255.0f;
|
||||||
|
|
||||||
|
float rgbMin = r < g ? (r < b ? r : b) : (g < b ? g : b);
|
||||||
|
float rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b);
|
||||||
|
float diff = rgbMax - rgbMin;
|
||||||
|
|
||||||
|
//luminance
|
||||||
|
luminance = (rgbMin + rgbMax) / 2.0f;
|
||||||
|
|
||||||
|
if (diff == 0.0f) {
|
||||||
|
saturation = 0.0f;
|
||||||
|
hue = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//saturation
|
||||||
|
if (luminance < 0.5f)
|
||||||
|
saturation = diff / (rgbMin + rgbMax);
|
||||||
|
else
|
||||||
|
saturation = diff / (2.0f - rgbMin - rgbMax);
|
||||||
|
|
||||||
|
if (rgbMax == r)
|
||||||
|
{
|
||||||
|
// start from 360 to be sure that we won't assign a negative number to the unsigned hue value
|
||||||
|
hue = 360 + 60 * (g - b) / (rgbMax - rgbMin);
|
||||||
|
|
||||||
|
if (hue > 359)
|
||||||
|
hue -= 360;
|
||||||
|
}
|
||||||
|
else if (rgbMax == g)
|
||||||
|
{
|
||||||
|
hue = 120 + 60 * (b - r) / (rgbMax - rgbMin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hue = 240 + 60 * (r - g) / (rgbMax - rgbMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HslTransform::hsl2rgb(uint16_t hue, float saturation, float luminance, uint8_t & red, uint8_t & green, uint8_t & blue)
|
||||||
|
{
|
||||||
|
if (saturation == 0.0f){
|
||||||
|
red = (uint8_t)(luminance * 255.0f);
|
||||||
|
green = (uint8_t)(luminance * 255.0f);
|
||||||
|
blue = (uint8_t)(luminance * 255.0f);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float q;
|
||||||
|
|
||||||
|
if (luminance < 0.5f)
|
||||||
|
q = luminance * (1.0f + saturation);
|
||||||
|
else
|
||||||
|
q = (luminance + saturation) - (luminance * saturation);
|
||||||
|
|
||||||
|
float p = (2.0f * luminance) - q;
|
||||||
|
float h = hue / 360.0f;
|
||||||
|
|
||||||
|
float t[3];
|
||||||
|
|
||||||
|
t[0] = h + (1.0f / 3.0f);
|
||||||
|
t[1] = h;
|
||||||
|
t[2] = h - (1.0f / 3.0f);
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
if (t[i] < 0.0f)
|
||||||
|
t[i] += 1.0f;
|
||||||
|
if (t[i] > 1.0f)
|
||||||
|
t[i] -= 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float out[3];
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
if (t[i] * 6.0f < 1.0f)
|
||||||
|
out[i] = p + (q - p) * 6.0f * t[i];
|
||||||
|
else if (t[i] * 2.0f < 1.0f)
|
||||||
|
out[i] = q;
|
||||||
|
else if (t[i] * 3.0f < 2.0f)
|
||||||
|
out[i] = p + (q - p) * ((2.0f / 3.0f) - t[i]) * 6.0f;
|
||||||
|
else out[i] = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
//convert back to 0...255 range
|
||||||
|
red = (uint8_t)(out[0] * 255.0f);
|
||||||
|
green = (uint8_t)(out[1] * 255.0f);
|
||||||
|
blue = (uint8_t)(out[2] * 255.0f);
|
||||||
|
|
||||||
|
}
|
120
libsrc/utils/RgbChannelCorrection.cpp
Normal file
120
libsrc/utils/RgbChannelCorrection.cpp
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
// STL includes
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
// Utils includes
|
||||||
|
#include <utils/RgbChannelCorrection.h>
|
||||||
|
|
||||||
|
RgbChannelCorrection::RgbChannelCorrection() :
|
||||||
|
_correctionR(255),
|
||||||
|
_correctionB(255),
|
||||||
|
_correctionG(255)
|
||||||
|
{
|
||||||
|
initializeMapping();
|
||||||
|
}
|
||||||
|
|
||||||
|
RgbChannelCorrection::RgbChannelCorrection(int correctionR, int correctionG, int correctionB) :
|
||||||
|
_correctionR(correctionR),
|
||||||
|
_correctionG(correctionG),
|
||||||
|
_correctionB(correctionB)
|
||||||
|
{
|
||||||
|
initializeMapping();
|
||||||
|
}
|
||||||
|
|
||||||
|
RgbChannelCorrection::~RgbChannelCorrection()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t RgbChannelCorrection::getcorrectionR() const
|
||||||
|
{
|
||||||
|
return _correctionR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RgbChannelCorrection::setcorrectionR(uint8_t correctionR)
|
||||||
|
{
|
||||||
|
_correctionR = correctionR;
|
||||||
|
initializeMapping();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t RgbChannelCorrection::getcorrectionG() const
|
||||||
|
{
|
||||||
|
return _correctionG;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RgbChannelCorrection::setcorrectionG(uint8_t correctionG)
|
||||||
|
{
|
||||||
|
_correctionG = correctionG;
|
||||||
|
initializeMapping();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t RgbChannelCorrection::getcorrectionB() const
|
||||||
|
{
|
||||||
|
return _correctionB;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RgbChannelCorrection::setcorrectionB(uint8_t correctionB)
|
||||||
|
{
|
||||||
|
_correctionB = correctionB;
|
||||||
|
initializeMapping();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t RgbChannelCorrection::correctionR(uint8_t inputR) const
|
||||||
|
{
|
||||||
|
return _mappingR[inputR];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t RgbChannelCorrection::correctionG(uint8_t inputG) const
|
||||||
|
{
|
||||||
|
return _mappingG[inputG];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t RgbChannelCorrection::correctionB(uint8_t inputB) const
|
||||||
|
{
|
||||||
|
return _mappingB[inputB];
|
||||||
|
}
|
||||||
|
|
||||||
|
void RgbChannelCorrection::initializeMapping()
|
||||||
|
{
|
||||||
|
// initialize the mapping
|
||||||
|
for (int i = 0; i < 256; ++i)
|
||||||
|
{
|
||||||
|
int outputR = (i * _correctionR) / 255;
|
||||||
|
if (outputR < -255)
|
||||||
|
{
|
||||||
|
outputR = -255;
|
||||||
|
}
|
||||||
|
else if (outputR > 255)
|
||||||
|
{
|
||||||
|
outputR = 255;
|
||||||
|
}
|
||||||
|
_mappingR[i] = outputR;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 256; ++i)
|
||||||
|
{
|
||||||
|
int outputG = (i * _correctionG) / 255;
|
||||||
|
if (outputG < -255)
|
||||||
|
{
|
||||||
|
outputG = -255;
|
||||||
|
}
|
||||||
|
else if (outputG > 255)
|
||||||
|
{
|
||||||
|
outputG = 255;
|
||||||
|
}
|
||||||
|
_mappingG[i] = outputG;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 256; ++i)
|
||||||
|
{
|
||||||
|
int outputB = (i * _correctionB) / 255;
|
||||||
|
if (outputB < -255)
|
||||||
|
{
|
||||||
|
outputB = -255;
|
||||||
|
}
|
||||||
|
else if (outputB > 255)
|
||||||
|
{
|
||||||
|
outputB = 255;
|
||||||
|
}
|
||||||
|
_mappingB[i] = outputB;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -50,8 +50,15 @@ target_link_libraries(${PROJECT_NAME}
|
|||||||
pthread
|
pthread
|
||||||
)
|
)
|
||||||
|
|
||||||
|
qt4_use_modules(${PROJECT_NAME}
|
||||||
|
Core
|
||||||
|
Gui
|
||||||
|
Network)
|
||||||
|
|
||||||
if(ENABLE_QT5)
|
if(ENABLE_QT5)
|
||||||
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
|
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
|
||||||
else(ENABLE_QT5)
|
else(ENABLE_QT5)
|
||||||
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
|
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
|
||||||
endif(ENABLE_QT5)
|
endif(ENABLE_QT5)
|
||||||
|
|
||||||
|
install ( TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" )
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
#include <protoserver/ProtoConnectionWrapper.h>
|
#include <protoserver/ProtoConnectionWrapper.h>
|
||||||
#include "AmlogicWrapper.h"
|
#include "AmlogicWrapper.h"
|
||||||
|
|
||||||
|
#include "HyperionConfig.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace vlofgren;
|
using namespace vlofgren;
|
||||||
|
|
||||||
// save the image as screenshot
|
// save the image as screenshot
|
||||||
@ -22,6 +25,11 @@ void saveScreenshot(const char * filename, const Image<ColorRgb> & image)
|
|||||||
|
|
||||||
int main(int argc, char ** argv)
|
int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
|
std::cout
|
||||||
|
<< "hyperion-aml:" << std::endl
|
||||||
|
<< "\tversion : " << HYPERION_VERSION_ID << std::endl
|
||||||
|
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
|
||||||
|
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -59,3 +59,6 @@ if(ENABLE_QT5)
|
|||||||
else(ENABLE_QT5)
|
else(ENABLE_QT5)
|
||||||
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
|
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
|
||||||
endif(ENABLE_QT5)
|
endif(ENABLE_QT5)
|
||||||
|
|
||||||
|
|
||||||
|
install ( TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" )
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <protoserver/ProtoConnectionWrapper.h>
|
#include <protoserver/ProtoConnectionWrapper.h>
|
||||||
#include "DispmanxWrapper.h"
|
#include "DispmanxWrapper.h"
|
||||||
|
|
||||||
|
#include "HyperionConfig.h"
|
||||||
|
|
||||||
using namespace vlofgren;
|
using namespace vlofgren;
|
||||||
|
|
||||||
// save the image as screenshot
|
// save the image as screenshot
|
||||||
@ -21,6 +23,11 @@ void saveScreenshot(const char * filename, const Image<ColorRgb> & image)
|
|||||||
|
|
||||||
int main(int argc, char ** argv)
|
int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
|
std::cout
|
||||||
|
<< "hyperion-dispmanx:" << std::endl
|
||||||
|
<< "\tversion : " << HYPERION_VERSION_ID << std::endl
|
||||||
|
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
|
||||||
|
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -41,3 +41,6 @@ if(ENABLE_QT5)
|
|||||||
else(ENABLE_QT5)
|
else(ENABLE_QT5)
|
||||||
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
|
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
|
||||||
endif(ENABLE_QT5)
|
endif(ENABLE_QT5)
|
||||||
|
|
||||||
|
install ( TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" )
|
||||||
|
|
||||||
|
12
src/hyperion-remote/ColorCorrectionValues.h
Normal file
12
src/hyperion-remote/ColorCorrectionValues.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/// Simple structure to contain the values of a color transformation
|
||||||
|
struct ColorCorrectionValues
|
||||||
|
{
|
||||||
|
/// The value for the red color-channel
|
||||||
|
int valueRed;
|
||||||
|
/// The value for the green color-channel
|
||||||
|
int valueGreen;
|
||||||
|
/// The value for the blue color-channel
|
||||||
|
int valueBlue;
|
||||||
|
};
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
// hyperion-remote includes
|
// hyperion-remote includes
|
||||||
#include "ColorTransformValues.h"
|
#include "ColorTransformValues.h"
|
||||||
|
#include "ColorCorrectionValues.h"
|
||||||
|
|
||||||
/// Data parameter for a color
|
/// Data parameter for a color
|
||||||
typedef vlofgren::PODParameter<std::vector<QColor>> ColorParameter;
|
typedef vlofgren::PODParameter<std::vector<QColor>> ColorParameter;
|
||||||
@ -22,6 +23,9 @@ typedef vlofgren::PODParameter<QImage> ImageParameter;
|
|||||||
/// Data parameter for color transform values (list of three values)
|
/// Data parameter for color transform values (list of three values)
|
||||||
typedef vlofgren::PODParameter<ColorTransformValues> TransformParameter;
|
typedef vlofgren::PODParameter<ColorTransformValues> TransformParameter;
|
||||||
|
|
||||||
|
/// Data parameter for color correction values (list of three values)
|
||||||
|
typedef vlofgren::PODParameter<ColorCorrectionValues> CorrectionParameter;
|
||||||
|
|
||||||
namespace vlofgren {
|
namespace vlofgren {
|
||||||
///
|
///
|
||||||
/// Translates a string (as passed on the commandline) to a vector of colors
|
/// Translates a string (as passed on the commandline) to a vector of colors
|
||||||
@ -128,4 +132,33 @@ namespace vlofgren {
|
|||||||
|
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
ColorCorrectionValues CorrectionParameter::validate(const std::string& s) throw (Parameter::ParameterRejected)
|
||||||
|
{
|
||||||
|
ColorCorrectionValues correction;
|
||||||
|
|
||||||
|
// s should be split in 3 parts
|
||||||
|
// seperators are either a ',' or a space
|
||||||
|
QStringList components = QString(s.c_str()).split(" ", QString::SkipEmptyParts);
|
||||||
|
|
||||||
|
if (components.size() == 3)
|
||||||
|
{
|
||||||
|
bool ok1, ok2, ok3;
|
||||||
|
correction.valueRed = components[0].toInt(&ok1);
|
||||||
|
correction.valueGreen = components[1].toInt(&ok2);
|
||||||
|
correction.valueBlue = components[2].toInt(&ok3);
|
||||||
|
|
||||||
|
if (ok1 && ok2 && ok3)
|
||||||
|
{
|
||||||
|
return correction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::stringstream errorMessage;
|
||||||
|
errorMessage << "Argument " << s << " can not be parsed to 3 integer values";
|
||||||
|
throw Parameter::ParameterRejected(errorMessage.str());
|
||||||
|
|
||||||
|
return correction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ void JsonConnection::clearAll()
|
|||||||
parseReply(reply);
|
parseReply(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonConnection::setTransform(std::string * transformId, double * saturation, double * value, ColorTransformValues *threshold, ColorTransformValues *gamma, ColorTransformValues *blacklevel, ColorTransformValues *whitelevel)
|
void JsonConnection::setTransform(std::string * transformId, double * saturation, double * value, double * saturationL, double * luminance, ColorTransformValues *threshold, ColorTransformValues *gamma, ColorTransformValues *blacklevel, ColorTransformValues *whitelevel)
|
||||||
{
|
{
|
||||||
std::cout << "Set color transforms" << std::endl;
|
std::cout << "Set color transforms" << std::endl;
|
||||||
|
|
||||||
@ -216,6 +216,15 @@ void JsonConnection::setTransform(std::string * transformId, double * saturation
|
|||||||
transform["valueGain"] = *value;
|
transform["valueGain"] = *value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (saturationL != nullptr)
|
||||||
|
{
|
||||||
|
transform["saturationLGain"] = *saturationL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (luminance != nullptr)
|
||||||
|
{
|
||||||
|
transform["luminanceGain"] = *luminance;
|
||||||
|
}
|
||||||
if (threshold != nullptr)
|
if (threshold != nullptr)
|
||||||
{
|
{
|
||||||
Json::Value & v = transform["threshold"];
|
Json::Value & v = transform["threshold"];
|
||||||
@ -255,6 +264,64 @@ void JsonConnection::setTransform(std::string * transformId, double * saturation
|
|||||||
parseReply(reply);
|
parseReply(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsonConnection::setCorrection(std::string * correctionId, ColorCorrectionValues *correction)
|
||||||
|
{
|
||||||
|
std::cout << "Set color corrections" << std::endl;
|
||||||
|
|
||||||
|
// create command
|
||||||
|
Json::Value command;
|
||||||
|
command["command"] = "correction";
|
||||||
|
Json::Value & correct = command["correction"];
|
||||||
|
|
||||||
|
if (correctionId != nullptr)
|
||||||
|
{
|
||||||
|
correct["id"] = *correctionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (correction != nullptr)
|
||||||
|
{
|
||||||
|
Json::Value & v = correct["correctionValues"];
|
||||||
|
v.append(correction->valueRed);
|
||||||
|
v.append(correction->valueGreen);
|
||||||
|
v.append(correction->valueBlue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// send command message
|
||||||
|
Json::Value reply = sendMessage(command);
|
||||||
|
|
||||||
|
// parse reply message
|
||||||
|
parseReply(reply);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JsonConnection::setTemperature(std::string * temperatureId, ColorCorrectionValues *temperature)
|
||||||
|
{
|
||||||
|
std::cout << "Set color temperature corrections" << std::endl;
|
||||||
|
|
||||||
|
// create command
|
||||||
|
Json::Value command;
|
||||||
|
command["command"] = "temperature";
|
||||||
|
Json::Value & temp = command["temperature"];
|
||||||
|
|
||||||
|
if (temperatureId != nullptr)
|
||||||
|
{
|
||||||
|
temp["id"] = *temperatureId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (temperature != nullptr)
|
||||||
|
{
|
||||||
|
Json::Value & v = temp["correctionValues"];
|
||||||
|
v.append(temperature->valueRed);
|
||||||
|
v.append(temperature->valueGreen);
|
||||||
|
v.append(temperature->valueBlue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// send command message
|
||||||
|
Json::Value reply = sendMessage(command);
|
||||||
|
|
||||||
|
// parse reply message
|
||||||
|
parseReply(reply);
|
||||||
|
}
|
||||||
|
|
||||||
Json::Value JsonConnection::sendMessage(const Json::Value & message)
|
Json::Value JsonConnection::sendMessage(const Json::Value & message)
|
||||||
{
|
{
|
||||||
// serialize message (FastWriter already appends a newline)
|
// serialize message (FastWriter already appends a newline)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
// hyperion-remote includes
|
// hyperion-remote includes
|
||||||
#include "ColorTransformValues.h"
|
#include "ColorTransformValues.h"
|
||||||
|
#include "ColorCorrectionValues.h"
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Connection class to setup an connection to the hyperion server and execute commands
|
/// Connection class to setup an connection to the hyperion server and execute commands
|
||||||
@ -89,6 +90,8 @@ public:
|
|||||||
/// @param transformId The identifier of the transform to set
|
/// @param transformId The identifier of the transform to set
|
||||||
/// @param saturation The HSV saturation gain
|
/// @param saturation The HSV saturation gain
|
||||||
/// @param value The HSV value gain
|
/// @param value The HSV value gain
|
||||||
|
/// @param saturationL The HSL saturation gain
|
||||||
|
/// @param luminance The HSL luminance gain
|
||||||
/// @param threshold The threshold
|
/// @param threshold The threshold
|
||||||
/// @param gamma The gamma value
|
/// @param gamma The gamma value
|
||||||
/// @param blacklevel The blacklevel
|
/// @param blacklevel The blacklevel
|
||||||
@ -98,11 +101,35 @@ public:
|
|||||||
std::string * transformId,
|
std::string * transformId,
|
||||||
double * saturation,
|
double * saturation,
|
||||||
double * value,
|
double * value,
|
||||||
|
double * saturationL,
|
||||||
|
double * luminance,
|
||||||
ColorTransformValues * threshold,
|
ColorTransformValues * threshold,
|
||||||
ColorTransformValues * gamma,
|
ColorTransformValues * gamma,
|
||||||
ColorTransformValues * blacklevel,
|
ColorTransformValues * blacklevel,
|
||||||
ColorTransformValues * whitelevel);
|
ColorTransformValues * whitelevel);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the color correction of the leds
|
||||||
|
///
|
||||||
|
/// @note Note that providing a NULL will leave the settings on the server unchanged
|
||||||
|
///
|
||||||
|
/// @param correctionId The identifier of the correction to set
|
||||||
|
/// @param correction The correction values
|
||||||
|
void setCorrection(
|
||||||
|
std::string * correctionId,
|
||||||
|
ColorCorrectionValues * correction);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the color temperature of the leds
|
||||||
|
///
|
||||||
|
/// @note Note that providing a NULL will leave the settings on the server unchanged
|
||||||
|
///
|
||||||
|
/// @param temperatureId The identifier of the correction to set
|
||||||
|
/// @param temperature The temperature correction values
|
||||||
|
void setTemperature(
|
||||||
|
std::string * temperatureId,
|
||||||
|
ColorCorrectionValues * temperature);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
/// Send a json command message and receive its reply
|
/// Send a json command message and receive its reply
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
#include "CustomParameter.h"
|
#include "CustomParameter.h"
|
||||||
#include "JsonConnection.h"
|
#include "JsonConnection.h"
|
||||||
|
|
||||||
|
#include "HyperionConfig.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace vlofgren;
|
using namespace vlofgren;
|
||||||
|
|
||||||
/// Count the number of true values in a list of booleans
|
/// Count the number of true values in a list of booleans
|
||||||
@ -28,6 +31,11 @@ int count(std::initializer_list<bool> values)
|
|||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
|
std::cout
|
||||||
|
<< "hyperion-remote:" << std::endl
|
||||||
|
<< "\tversion : " << HYPERION_VERSION_ID << std::endl
|
||||||
|
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
|
||||||
|
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
// force the locale
|
// force the locale
|
||||||
@ -61,12 +69,18 @@ int main(int argc, char * argv[])
|
|||||||
StringParameter & argId = parameters.add<StringParameter> ('q', "qualifier" , "Identifier(qualifier) of the transform to set");
|
StringParameter & argId = parameters.add<StringParameter> ('q', "qualifier" , "Identifier(qualifier) of the transform to set");
|
||||||
DoubleParameter & argSaturation = parameters.add<DoubleParameter> ('s', "saturation", "Set the HSV saturation gain of the leds");
|
DoubleParameter & argSaturation = parameters.add<DoubleParameter> ('s', "saturation", "Set the HSV saturation gain of the leds");
|
||||||
DoubleParameter & argValue = parameters.add<DoubleParameter> ('v', "value" , "Set the HSV value gain of the leds");
|
DoubleParameter & argValue = parameters.add<DoubleParameter> ('v', "value" , "Set the HSV value gain of the leds");
|
||||||
|
DoubleParameter & argSaturationL = parameters.add<DoubleParameter> ('u', "saturationL", "Set the HSL saturation gain of the leds");
|
||||||
|
DoubleParameter & argLuminance = parameters.add<DoubleParameter> ('m', "luminance" , "Set the HSL luminance gain of the leds");
|
||||||
TransformParameter & argGamma = parameters.add<TransformParameter>('g', "gamma" , "Set the gamma of the leds (requires 3 space seperated values)");
|
TransformParameter & argGamma = parameters.add<TransformParameter>('g', "gamma" , "Set the gamma of the leds (requires 3 space seperated values)");
|
||||||
TransformParameter & argThreshold = parameters.add<TransformParameter>('t', "threshold" , "Set the threshold of the leds (requires 3 space seperated values between 0.0 and 1.0)");
|
TransformParameter & argThreshold = parameters.add<TransformParameter>('t', "threshold" , "Set the threshold of the leds (requires 3 space seperated values between 0.0 and 1.0)");
|
||||||
TransformParameter & argBlacklevel = parameters.add<TransformParameter>('b', "blacklevel", "Set the blacklevel of the leds (requires 3 space seperated values which are normally between 0.0 and 1.0)");
|
TransformParameter & argBlacklevel = parameters.add<TransformParameter>('b', "blacklevel", "Set the blacklevel of the leds (requires 3 space seperated values which are normally between 0.0 and 1.0)");
|
||||||
TransformParameter & argWhitelevel = parameters.add<TransformParameter>('w', "whitelevel", "Set the whitelevel of the leds (requires 3 space seperated values which are normally between 0.0 and 1.0)");
|
TransformParameter & argWhitelevel = parameters.add<TransformParameter>('w', "whitelevel", "Set the whitelevel of the leds (requires 3 space seperated values which are normally between 0.0 and 1.0)");
|
||||||
SwitchParameter<> & argPrint = parameters.add<SwitchParameter<> >(0x0, "print" , "Print the json input and output messages on stdout");
|
SwitchParameter<> & argPrint = parameters.add<SwitchParameter<> >(0x0, "print" , "Print the json input and output messages on stdout");
|
||||||
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<> >('h', "help" , "Show this help message and exit");
|
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<> >('h', "help" , "Show this help message and exit");
|
||||||
|
StringParameter & argIdC = parameters.add<StringParameter> ('y', "qualifier" , "Identifier(qualifier) of the correction to set");
|
||||||
|
CorrectionParameter & argCorrection = parameters.add<CorrectionParameter>('Y', "correction" , "Set the correction of the leds (requires 3 space seperated values between 0 and 255)");
|
||||||
|
StringParameter & argIdT = parameters.add<StringParameter> ('z', "qualifier" , "Identifier(qualifier) of the temperature to set");
|
||||||
|
CorrectionParameter & argTemperature = parameters.add<CorrectionParameter>('Z', "temperature" , "Set the temperature correction of the leds (requires 3 space seperated values between 0 and 255)");
|
||||||
|
|
||||||
// set the default values
|
// set the default values
|
||||||
argAddress.setDefault(defaultServerAddress.toStdString());
|
argAddress.setDefault(defaultServerAddress.toStdString());
|
||||||
@ -85,10 +99,10 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if at least one of the available color transforms is set
|
// check if at least one of the available color transforms is set
|
||||||
bool colorTransform = argSaturation.isSet() || argValue.isSet() || argThreshold.isSet() || argGamma.isSet() || argBlacklevel.isSet() || argWhitelevel.isSet();
|
bool colorTransform = argSaturation.isSet() || argValue.isSet() || argSaturationL.isSet() || argLuminance.isSet() || argThreshold.isSet() || argGamma.isSet() || argBlacklevel.isSet() || argWhitelevel.isSet();
|
||||||
|
|
||||||
// check that exactly one command was given
|
// check that exactly one command was given
|
||||||
int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform});
|
int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform, argCorrection.isSet(), argTemperature.isSet()});
|
||||||
if (commandCount != 1)
|
if (commandCount != 1)
|
||||||
{
|
{
|
||||||
std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl;
|
std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl;
|
||||||
@ -98,14 +112,22 @@ int main(int argc, char * argv[])
|
|||||||
std::cerr << " " << argServerInfo.usageLine() << std::endl;
|
std::cerr << " " << argServerInfo.usageLine() << std::endl;
|
||||||
std::cerr << " " << argClear.usageLine() << std::endl;
|
std::cerr << " " << argClear.usageLine() << std::endl;
|
||||||
std::cerr << " " << argClearAll.usageLine() << std::endl;
|
std::cerr << " " << argClearAll.usageLine() << std::endl;
|
||||||
std::cerr << "or one or more of the available color transformations:" << std::endl;
|
std::cerr << "one or more of the available color transformations:" << std::endl;
|
||||||
std::cerr << " " << argId.usageLine() << std::endl;
|
std::cerr << " " << argId.usageLine() << std::endl;
|
||||||
std::cerr << " " << argSaturation.usageLine() << std::endl;
|
std::cerr << " " << argSaturation.usageLine() << std::endl;
|
||||||
std::cerr << " " << argValue.usageLine() << std::endl;
|
std::cerr << " " << argValue.usageLine() << std::endl;
|
||||||
|
std::cerr << " " << argSaturationL.usageLine() << std::endl;
|
||||||
|
std::cerr << " " << argLuminance.usageLine() << std::endl;
|
||||||
std::cerr << " " << argThreshold.usageLine() << std::endl;
|
std::cerr << " " << argThreshold.usageLine() << std::endl;
|
||||||
std::cerr << " " << argGamma.usageLine() << std::endl;
|
std::cerr << " " << argGamma.usageLine() << std::endl;
|
||||||
std::cerr << " " << argBlacklevel.usageLine() << std::endl;
|
std::cerr << " " << argBlacklevel.usageLine() << std::endl;
|
||||||
std::cerr << " " << argWhitelevel.usageLine() << std::endl;
|
std::cerr << " " << argWhitelevel.usageLine() << std::endl;
|
||||||
|
std::cerr << "one or more of the available color corrections:" << std::endl;
|
||||||
|
std::cerr << " " << argIdC.usageLine() << std::endl;
|
||||||
|
std::cerr << " " << argCorrection.usageLine() << std::endl;
|
||||||
|
std::cerr << "or one or more of the available color temperature adjustment:" << std::endl;
|
||||||
|
std::cerr << " " << argIdT.usageLine() << std::endl;
|
||||||
|
std::cerr << " " << argTemperature.usageLine() << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,12 +163,14 @@ int main(int argc, char * argv[])
|
|||||||
else if (colorTransform)
|
else if (colorTransform)
|
||||||
{
|
{
|
||||||
std::string transId;
|
std::string transId;
|
||||||
double saturation, value;
|
double saturation, value, saturationL, luminance;
|
||||||
ColorTransformValues threshold, gamma, blacklevel, whitelevel;
|
ColorTransformValues threshold, gamma, blacklevel, whitelevel;
|
||||||
|
|
||||||
if (argId.isSet()) transId = argId.getValue();
|
if (argId.isSet()) transId = argId.getValue();
|
||||||
if (argSaturation.isSet()) saturation = argSaturation.getValue();
|
if (argSaturation.isSet()) saturation = argSaturation.getValue();
|
||||||
if (argValue.isSet()) value = argValue.getValue();
|
if (argValue.isSet()) value = argValue.getValue();
|
||||||
|
if (argSaturationL.isSet()) saturationL = argSaturationL.getValue();
|
||||||
|
if (argLuminance.isSet()) luminance = argLuminance.getValue();
|
||||||
if (argThreshold.isSet()) threshold = argThreshold.getValue();
|
if (argThreshold.isSet()) threshold = argThreshold.getValue();
|
||||||
if (argGamma.isSet()) gamma = argGamma.getValue();
|
if (argGamma.isSet()) gamma = argGamma.getValue();
|
||||||
if (argBlacklevel.isSet()) blacklevel = argBlacklevel.getValue();
|
if (argBlacklevel.isSet()) blacklevel = argBlacklevel.getValue();
|
||||||
@ -156,11 +180,37 @@ int main(int argc, char * argv[])
|
|||||||
argId.isSet() ? &transId : nullptr,
|
argId.isSet() ? &transId : nullptr,
|
||||||
argSaturation.isSet() ? &saturation : nullptr,
|
argSaturation.isSet() ? &saturation : nullptr,
|
||||||
argValue.isSet() ? &value : nullptr,
|
argValue.isSet() ? &value : nullptr,
|
||||||
|
argSaturationL.isSet() ? &saturationL : nullptr,
|
||||||
|
argLuminance.isSet() ? &luminance : nullptr,
|
||||||
argThreshold.isSet() ? &threshold : nullptr,
|
argThreshold.isSet() ? &threshold : nullptr,
|
||||||
argGamma.isSet() ? &gamma : nullptr,
|
argGamma.isSet() ? &gamma : nullptr,
|
||||||
argBlacklevel.isSet() ? &blacklevel : nullptr,
|
argBlacklevel.isSet() ? &blacklevel : nullptr,
|
||||||
argWhitelevel.isSet() ? &whitelevel : nullptr);
|
argWhitelevel.isSet() ? &whitelevel : nullptr);
|
||||||
}
|
}
|
||||||
|
else if (argCorrection.isSet())
|
||||||
|
{
|
||||||
|
std::string corrId;
|
||||||
|
ColorCorrectionValues correction;
|
||||||
|
|
||||||
|
if (argIdC.isSet()) corrId = argIdC.getValue();
|
||||||
|
if (argCorrection.isSet()) correction = argCorrection.getValue();
|
||||||
|
|
||||||
|
connection.setCorrection(
|
||||||
|
argIdC.isSet() ? &corrId : nullptr,
|
||||||
|
argCorrection.isSet() ? &correction : nullptr);
|
||||||
|
}
|
||||||
|
else if (argTemperature.isSet())
|
||||||
|
{
|
||||||
|
std::string tempId;
|
||||||
|
ColorCorrectionValues temperature;
|
||||||
|
|
||||||
|
if (argIdT.isSet()) tempId = argIdT.getValue();
|
||||||
|
if (argTemperature.isSet()) temperature = argTemperature.getValue();
|
||||||
|
|
||||||
|
connection.setTemperature(
|
||||||
|
argIdT.isSet() ? &tempId : nullptr,
|
||||||
|
argTemperature.isSet() ? &temperature : nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (const std::runtime_error & e)
|
catch (const std::runtime_error & e)
|
||||||
{
|
{
|
||||||
|
@ -59,3 +59,6 @@ if(ENABLE_QT5)
|
|||||||
else(ENABLE_QT5)
|
else(ENABLE_QT5)
|
||||||
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
|
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
|
||||||
endif(ENABLE_QT5)
|
endif(ENABLE_QT5)
|
||||||
|
|
||||||
|
|
||||||
|
install ( TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" )
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "PixelFormatParameter.h"
|
#include "PixelFormatParameter.h"
|
||||||
#include "ScreenshotHandler.h"
|
#include "ScreenshotHandler.h"
|
||||||
|
|
||||||
|
#include "HyperionConfig.h"
|
||||||
|
|
||||||
using namespace vlofgren;
|
using namespace vlofgren;
|
||||||
|
|
||||||
// save the image as screenshot
|
// save the image as screenshot
|
||||||
@ -36,6 +38,11 @@ void saveScreenshot(void *, const Image<ColorRgb> & image)
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
std::cout
|
||||||
|
<< "hyperion-v4l2:" << std::endl
|
||||||
|
<< "\tversion : " << HYPERION_VERSION_ID << std::endl
|
||||||
|
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
|
||||||
|
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
// force the locale
|
// force the locale
|
||||||
|
@ -60,3 +60,5 @@ if(ENABLE_QT5)
|
|||||||
else(ENABLE_QT5)
|
else(ENABLE_QT5)
|
||||||
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
|
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
|
||||||
endif(ENABLE_QT5)
|
endif(ENABLE_QT5)
|
||||||
|
|
||||||
|
install ( TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" )
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "protoserver/ProtoConnectionWrapper.h"
|
#include "protoserver/ProtoConnectionWrapper.h"
|
||||||
#include "X11Wrapper.h"
|
#include "X11Wrapper.h"
|
||||||
|
#include "HyperionConfig.h"
|
||||||
|
|
||||||
using namespace vlofgren;
|
using namespace vlofgren;
|
||||||
|
|
||||||
@ -21,6 +22,11 @@ void saveScreenshot(const char * filename, const Image<ColorRgb> & image)
|
|||||||
|
|
||||||
int main(int argc, char ** argv)
|
int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
|
std::cout
|
||||||
|
<< "hyperion-x11:" << std::endl
|
||||||
|
<< "\tversion : " << HYPERION_VERSION_ID << std::endl
|
||||||
|
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
|
||||||
|
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -33,3 +33,5 @@ endif (ENABLE_AMLOGIC)
|
|||||||
if (ENABLE_PROTOBUF)
|
if (ENABLE_PROTOBUF)
|
||||||
target_link_libraries(hyperiond protoserver)
|
target_link_libraries(hyperiond protoserver)
|
||||||
endif (ENABLE_PROTOBUF)
|
endif (ENABLE_PROTOBUF)
|
||||||
|
|
||||||
|
install ( TARGETS hyperiond DESTINATION "${CMAKE_SOURCE_DIR}/deploy/bin" )
|
||||||
|
@ -92,11 +92,13 @@ Json::Value loadConfig(const std::string & configFile)
|
|||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
std::cout << "Application build time: " << __DATE__ << " " << __TIME__ << std::endl;
|
std::cout
|
||||||
|
<< "Hyperiond:" << std::endl
|
||||||
|
<< "\tversion : " << HYPERION_VERSION_ID << std::endl
|
||||||
|
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
|
||||||
|
|
||||||
// Initialising QCoreApplication
|
// Initialising QCoreApplication
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
std::cout << "QCoreApplication initialised" << std::endl;
|
|
||||||
|
|
||||||
signal(SIGINT, signal_handler);
|
signal(SIGINT, signal_handler);
|
||||||
signal(SIGTERM, signal_handler);
|
signal(SIGTERM, signal_handler);
|
||||||
|
Loading…
Reference in New Issue
Block a user