From c0c8490b95f58e5105d0285bc675ba158f2e798c Mon Sep 17 00:00:00 2001 From: mrgreywater Date: Tue, 11 Aug 2015 12:47:44 +0200 Subject: [PATCH 01/22] Maintain compatibility with gcc 4.6 This fixes a compatibility issue when compiling with gcc 4.6 (which is the version distributed with raspbian by default) Former-commit-id: ff8518cbc0627049526138b67f4965cedfdfd4be --- libsrc/leddevice/LedDevicePhilipsHue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/leddevice/LedDevicePhilipsHue.h b/libsrc/leddevice/LedDevicePhilipsHue.h index 17d78618..59c0383d 100755 --- a/libsrc/leddevice/LedDevicePhilipsHue.h +++ b/libsrc/leddevice/LedDevicePhilipsHue.h @@ -134,7 +134,7 @@ public: /// @param lightIds light ids of the lights to control if not starting at one in ascending order. /// LedDevicePhilipsHue(const std::string& output, const std::string& username = "newdeveloper", bool switchOffOnBlack = - false, int transitiontime = 1, std::vector lightIds = {}); + false, int transitiontime = 1, std::vector lightIds = std::vector()); /// /// Destructor of this device From ad876b0d8c960eac96278528b08d8d78dfb27562 Mon Sep 17 00:00:00 2001 From: "T.van der Zwan" Date: Thu, 3 Sep 2015 21:37:49 +0200 Subject: [PATCH 02/22] Fixed json value lookup Only close the amlogic device every 20th succesfull reads. Former-commit-id: 46c0cf1465b8c8b33d696bb2aeac5cabb1cb2819 --- libsrc/grabber/amlogic/AmlogicGrabber.cpp | 19 +++++++++++++++---- src/hyperiond/hyperiond.cpp | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libsrc/grabber/amlogic/AmlogicGrabber.cpp b/libsrc/grabber/amlogic/AmlogicGrabber.cpp index dd727217..8eaa9799 100644 --- a/libsrc/grabber/amlogic/AmlogicGrabber.cpp +++ b/libsrc/grabber/amlogic/AmlogicGrabber.cpp @@ -122,6 +122,8 @@ int AmlogicGrabber::grabFrame(Image & image) { // Failed to configure frame width std::cerr << "[" << __PRETTY_FUNCTION__ << "] Failed to configure capture size (" << errno << "): " << strerror(errno) << std::endl; + close(_amlogicCaptureDev); + _amlogicCaptureDev = -1; return -1; } @@ -133,18 +135,27 @@ int AmlogicGrabber::grabFrame(Image & image) if (bytesRead == -1) { std::cerr << "[" << __PRETTY_FUNCTION__ << "] Read of device failed (erno=" << errno << "): " << strerror(errno) << std::endl; + close(_amlogicCaptureDev); + _amlogicCaptureDev = -1; return -1; } else if (bytesToRead != bytesRead) { // Read of snapshot failed std::cerr << "[" << __PRETTY_FUNCTION__ << "] Capture failed to grab entire image [bytesToRead(" << bytesToRead << ") != bytesRead(" << bytesRead << ")]" << std::endl; + close(_amlogicCaptureDev); + _amlogicCaptureDev = -1; return -1; } - // For now we always close the device again - close(_amlogicCaptureDev); - _amlogicCaptureDev = -1; - + // For now we always close the device now and again + static int readCnt = 0; + ++readCnt; + if (readCnt > 20) + { + close(_amlogicCaptureDev); + _amlogicCaptureDev = -1; + readCnt = 0; + } return 0; } diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index 7fccc2e6..7357d55f 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -274,7 +274,7 @@ int main(int argc, char** argv) FramebufferWrapper * fbGrabber = nullptr; if (config.isMember("framebuffergrabber") || config.isMember("framegrabber")) { - const Json::Value & grabberConfig = config.isMember("framebuffergrabber")? config["framebuffergrabber"] : config.isMember("framegrabber"); + const Json::Value & grabberConfig = config.isMember("framebuffergrabber")? config["framebuffergrabber"] : config["framegrabber"]; fbGrabber = new FramebufferWrapper( grabberConfig.get("device", "/dev/fb0").asString(), grabberConfig["width"].asUInt(), From f7bce46f349c2855c372d631f49f795c4a8f4149 Mon Sep 17 00:00:00 2001 From: "T.van der Zwan" Date: Wed, 9 Sep 2015 22:21:51 +0200 Subject: [PATCH 03/22] Update install/update script Added build scripts for building different releases (in cross-compile) Added new releases for rpi/imx6/wetek/x32/x64 Former-commit-id: 2025f1e3e8663d733b60a18944c6097da4ee371b --- CrossCompileHowto.txt | 3 + Toolchain-imx6.cmake | 22 ++++ ...n-RaspberryPi.cmake => Toolchain-rpi.cmake | 0 Toolchain-x32.cmake | 12 ++ bin/create_all_releases.sh | 43 +++++++ bin/create_oe_depedencies.sh | 27 +++++ bin/create_release.sh | 35 ++++++ deploy/hyperion-remote.sh | 2 + ...n.deps.openelec-imx6.tar.gz.REMOVED.git-id | 1 + deploy/hyperion_imx6.tar.gz.REMOVED.git-id | 2 +- deploy/hyperion_rpi.tar.gz.REMOVED.git-id | 1 + deploy/hyperion_wetek.tar.gz.REMOVED.git-id | 1 + deploy/hyperion_x32.tar.gz.REMOVED.git-id | 1 + deploy/hyperion_x64.tar.gz.REMOVED.git-id | 1 + deploy/hyperiond.sh | 2 + deploy/update_hyperion.sh | 114 ++++++++++++++++++ 16 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 Toolchain-imx6.cmake rename Toolchain-RaspberryPi.cmake => Toolchain-rpi.cmake (100%) create mode 100644 Toolchain-x32.cmake create mode 100644 bin/create_all_releases.sh create mode 100644 bin/create_oe_depedencies.sh create mode 100644 bin/create_release.sh create mode 100644 deploy/hyperion-remote.sh create mode 100644 deploy/hyperion.deps.openelec-imx6.tar.gz.REMOVED.git-id create mode 100644 deploy/hyperion_rpi.tar.gz.REMOVED.git-id create mode 100644 deploy/hyperion_wetek.tar.gz.REMOVED.git-id create mode 100644 deploy/hyperion_x32.tar.gz.REMOVED.git-id create mode 100644 deploy/hyperion_x64.tar.gz.REMOVED.git-id create mode 100644 deploy/hyperiond.sh create mode 100644 deploy/update_hyperion.sh diff --git a/CrossCompileHowto.txt b/CrossCompileHowto.txt index 1f793b6f..97e9db7c 100644 --- a/CrossCompileHowto.txt +++ b/CrossCompileHowto.txt @@ -55,6 +55,9 @@ cmake -DENABLE_DISPMANX=OFF --build "$NATIVE_BUILD_DIR" "$HYPERION_DIR" mkdir -p "$TARGET_BUILD_DIR" cmake -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" -DIMPORT_PROTOC=$NATIVE_BUILD_DIR/protoc_export.cmake --build "$TARGET_BUILD_DIR" "$HYPERION_DIR" +# For hummingboard (imx6) the following package is required +sudo apt-get install lib32z1 + ------------------------------------------------------------------------------ These instructions are based on the guide given by: http://airwiki.ws.dei.polimi.it/index.php/Cross-compiling_for_the_RaspberryPi diff --git a/Toolchain-imx6.cmake b/Toolchain-imx6.cmake new file mode 100644 index 00000000..6ca757a7 --- /dev/null +++ b/Toolchain-imx6.cmake @@ -0,0 +1,22 @@ +SET(CUBIXCROSS_DIR $ENV{HOME}/hummingboard) + +SET(CMAKE_SYSTEM_NAME Linux) +SET(CMAKE_SYSTEM_VERSION 1) + +# specify the cross compiler +SET(CMAKE_C_COMPILER ${CUBIXCROSS_DIR}/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc) +SET(CMAKE_CXX_COMPILER ${CUBIXCROSS_DIR}/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-g++) +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=vfpv3 -mfloat-abi=softfp") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=vfpv3 -mfloat-abi=softfp") + +# where is the target environment +SET(CMAKE_FIND_ROOT_PATH ${CUBIXCROSS_DIR}/rootfs) + +# search for programs in the build host directories +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + +# for libraries and headers in the target directories +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +include_directories(${CMAKE_FIND_ROOT_PATH}/usr/include) diff --git a/Toolchain-RaspberryPi.cmake b/Toolchain-rpi.cmake similarity index 100% rename from Toolchain-RaspberryPi.cmake rename to Toolchain-rpi.cmake diff --git a/Toolchain-x32.cmake b/Toolchain-x32.cmake new file mode 100644 index 00000000..2304edc6 --- /dev/null +++ b/Toolchain-x32.cmake @@ -0,0 +1,12 @@ +# toolchain file for building a 32bit version on a 64bit host + +# use it like this: +# cmake -DCMAKE_TOOLCHAIN_FILE=Toolchain-x32.cmake + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_SYSTEM_PROCESSOR "i686") + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags") + diff --git a/bin/create_all_releases.sh b/bin/create_all_releases.sh new file mode 100644 index 00000000..c284f207 --- /dev/null +++ b/bin/create_all_releases.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# Create the x64 build +mkdir build-x64 +cd build-x64 +cmake -DENABLE_DISPMANX=OFF -DENABLE_X11=ON .. +make -j 4 +cd .. + +# Create the x32 build +mkdir build-x32 +cd build-x32 +cmake -DIMPORT_PROTOC=../build-x64/protoc_export.cmake -DENABLE_DISPMANX=OFF -DENABLE_X11=ON .. +make -j 4 +cd .. + +# Create the RPI build +mkdir build-rpi +cd build-rpi +cmake -DCMAKE_TOOLCHAIN_FILE="../Toolchain-rpi.cmake" -DIMPORT_PROTOC=../build-x64/protoc_export.cmake .. +make -j 4 +cd .. + +# Create the WETEK build +mkdir build-wetek +cd build-wetek +cmake -DCMAKE_TOOLCHAIN_FILE="../Toolchain-rpi.cmake" -DIMPORT_PROTOC=../build-x64/protoc_export.cmake -DENABLE_DISPMANX=OFF -DENABLE_FB=ON -DENABLE_AMLOGIC=ON .. +make -j 4 +cd .. + +# Create the IMX6 build +mkdir build-imx6 +cd build-imx6 +cmake -DCMAKE_TOOLCHAIN_FILE="../Toolchain-imx6.cmake" -DIMPORT_PROTOC=../build-x64/protoc_export.cmake -DENABLE_DISPMANX=OFF -DENABLE_FB=ON .. +make -j 4 +cd .. + +bin/create_release.sh . x64 +bin/create_release.sh . x32 +bin/create_release.sh . rpi +bin/create_release.sh . wetek +bin/create_release.sh . imx6 + diff --git a/bin/create_oe_depedencies.sh b/bin/create_oe_depedencies.sh new file mode 100644 index 00000000..288c5ee9 --- /dev/null +++ b/bin/create_oe_depedencies.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +RPI_ROOTFS=/home/tvdzwan/hummingboard/rootfs +IMX6_ROOTFS=/home/tvdzwan/hummingboard/rootfs +outfile=hyperion.deps.openelec-imx6.tar.gz + +tar --create --verbose --gzip --absolute-names --show-transformed-names --dereference \ + --file "$outfile" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libaudio.so.2" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libffi.so.6" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libICE.so.6" \ + "$IMX6_ROOTFS/lib/arm-linux-gnueabihf/libpcre.so.3" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libpng12.so.0" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libQtCore.so.4" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libQtGui.so.4" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libQtNetwork.so.4" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libSM.so.6" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libX11.so.6" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXau.so.6" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libxcb.so.1" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXdmcp.so.6" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXext.so.6" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXrender.so.1" \ + "$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXt.so.6" \ + "./hyperiond.sh" \ + "./hyperion-remote.sh" + diff --git a/bin/create_release.sh b/bin/create_release.sh new file mode 100644 index 00000000..625ff0e1 --- /dev/null +++ b/bin/create_release.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +if [ "$#" -ne 2 ] || ! [ -d "$1" ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +repodir="$1" +buildid="$2" +builddir=$repodir/build-$buildid +echo build directory = $builddir +echo repository root dirrectory = $repodir +if ! [ -d "$builddir" ]; then + echo "Could not find build director" + exit 1 +fi + +outfile="$repodir/deploy/hyperion_$buildid.tar.gz" +echo create $outfile + +tar --create --verbose --gzip --absolute-names --show-transformed-names --ignore-failed-read\ + --file "$outfile" \ + --transform "s:$builddir/bin/:hyperion/bin/:" \ + --transform "s:$repodir/effects/:hyperion/effects/:" \ + --transform "s:$repodir/config/:hyperion/config/:" \ + --transform "s:$repodir/bin/hyperion.init.sh:hyperion/init.d/hyperion.init.sh:" \ + --transform "s://:/:g" \ + "$builddir/bin/hyperiond" \ + "$builddir/bin/hyperion-remote" \ + "$builddir/bin/hyperion-v4l2" \ + "$builddir/bin/dispmanx2png" \ + "$repodir/effects/"* \ + "$repodir/bin/hyperion.init.sh" \ + "$repodir/config/hyperion.config.json" + diff --git a/deploy/hyperion-remote.sh b/deploy/hyperion-remote.sh new file mode 100644 index 00000000..b9a58d14 --- /dev/null +++ b/deploy/hyperion-remote.sh @@ -0,0 +1,2 @@ +#!/bin/sh +LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/storage/hyperion/bin /storage/hyperion/bin/hyperion-remote "$@" diff --git a/deploy/hyperion.deps.openelec-imx6.tar.gz.REMOVED.git-id b/deploy/hyperion.deps.openelec-imx6.tar.gz.REMOVED.git-id new file mode 100644 index 00000000..bebbc1ba --- /dev/null +++ b/deploy/hyperion.deps.openelec-imx6.tar.gz.REMOVED.git-id @@ -0,0 +1 @@ +198ac3d44bac13ba993069454397ad8c201d37b9 \ No newline at end of file diff --git a/deploy/hyperion_imx6.tar.gz.REMOVED.git-id b/deploy/hyperion_imx6.tar.gz.REMOVED.git-id index e8868c08..1243e5d8 100644 --- a/deploy/hyperion_imx6.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_imx6.tar.gz.REMOVED.git-id @@ -1 +1 @@ -8708dec3801868f8710e06bd9186fc520f7e639f \ No newline at end of file +9a4c5499f7191aad3e23e0e3be806861a3ec1c02 \ No newline at end of file diff --git a/deploy/hyperion_rpi.tar.gz.REMOVED.git-id b/deploy/hyperion_rpi.tar.gz.REMOVED.git-id new file mode 100644 index 00000000..a429abf8 --- /dev/null +++ b/deploy/hyperion_rpi.tar.gz.REMOVED.git-id @@ -0,0 +1 @@ +3a346e54f8958f87ae7f4e8804f6afdec33aa9fc \ No newline at end of file diff --git a/deploy/hyperion_wetek.tar.gz.REMOVED.git-id b/deploy/hyperion_wetek.tar.gz.REMOVED.git-id new file mode 100644 index 00000000..e38beaa9 --- /dev/null +++ b/deploy/hyperion_wetek.tar.gz.REMOVED.git-id @@ -0,0 +1 @@ +05227980ea998eeeecda03cefe090b5f55ff8ee0 \ No newline at end of file diff --git a/deploy/hyperion_x32.tar.gz.REMOVED.git-id b/deploy/hyperion_x32.tar.gz.REMOVED.git-id new file mode 100644 index 00000000..c189c367 --- /dev/null +++ b/deploy/hyperion_x32.tar.gz.REMOVED.git-id @@ -0,0 +1 @@ +f3e3f4a3a8e52e4bfaf9a0337cb364da841e150b \ No newline at end of file diff --git a/deploy/hyperion_x64.tar.gz.REMOVED.git-id b/deploy/hyperion_x64.tar.gz.REMOVED.git-id new file mode 100644 index 00000000..ca1bf5dd --- /dev/null +++ b/deploy/hyperion_x64.tar.gz.REMOVED.git-id @@ -0,0 +1 @@ +9342bb64479ea4d5554f301b905a0a830e330635 \ No newline at end of file diff --git a/deploy/hyperiond.sh b/deploy/hyperiond.sh new file mode 100644 index 00000000..ea9909db --- /dev/null +++ b/deploy/hyperiond.sh @@ -0,0 +1,2 @@ +#!/bin/sh +LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/storage/hyperion/bin /storage/hyperion/bin/hyperiond "$@" diff --git a/deploy/update_hyperion.sh b/deploy/update_hyperion.sh new file mode 100644 index 00000000..2a310f51 --- /dev/null +++ b/deploy/update_hyperion.sh @@ -0,0 +1,114 @@ +#!/bin/sh + +# Script for downloading and installing the latest Hyperion release + +# Make sure /sbin is on the path (for service to find sub scripts) +PATH="/sbin:$PATH" + +# Find out if we are on OpenElec +OS_OPENELEC=`cat /etc/issue | grep -m 1 OpenELEC | wc -l` + +# Find out if its an imx6 device +CPU_RPI=`cat /proc/cpuinfo | grep RPI | wc -l` +CPU_IMX6=`cat /proc/cpuinfo | grep i.MX6 | wc -l` +CPU_WETEK=`cat /proc/cpyinfo | grep wetek | wc -l` +CPU_X64=`uname -m | grep x86_64 | wc -l` +CPU_X32=`uname -m | grep x86_32 | wc -l` +# Check that we have a known configuration +if [ $CPU_RPI -ne 1 ] & [ $CPU_IMX6 -ne 1 ] & [ $CPU_WETEK -ne 1 ] & [ $CPU_X64 -ne 1 ] & [ $CPU_X32 -ne 1 ]; then + echo 'CPU information does not match any known releases' + exit +fi + +# check which init script we should use +USE_INITCTL=`which /sbin/initctl | wc -l` +USE_SERVICE=`which /usr/sbin/service | wc -l` + +# Make sure that the boblight daemon is no longer running +BOBLIGHT_PROCNR=$(pidof boblightd | wc -l) +if [ $BOBLIGHT_PROCNR -eq 1 ]; then + echo 'Found running instance of boblight. Please stop boblight via XBMC menu before installing hyperion' + exit +fi + +# Stop hyperion daemon if it is running +# Start the hyperion daemon +if [ $USE_INITCTL -eq 1 ]; then + /sbin/initctl stop hyperion +elif [ $USE_SERVICE -eq 1 ]; then + /usr/sbin/service hyperion stop +fi + +# Select the appropriate release +HYPERION_ADDRESS=https://raw.githubusercontent.com/tvdzwan/hyperion/master/deploy +if [ $CPU_RPI -eq 1 ]; then + HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_rpi.tar.gz + OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-rpi.tar.gz +elif [ $CPU_IMX6 -eq 1 ]; then + HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_imx6.tar.gz + OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-imx6.tar.gz +elif [ $CPU_WETEK -eq 1 ]; then + HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_wetek.tar.gz + OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-rpi.tar.gz +elif [ $CPU_X64 -eq 1 ]; then + HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_x64.tar.gz + OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-x64.tar.gz +elif [ $CPU_X32 -eq 1 ]; then + HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_x32.tar.gz + OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-x32.tar.gz +else + echo "Target platform unknown" + exit +fi + +# Get and extract the Hyperion binaries and effects +echo 'Downloading hyperion' +if [ $OS_OPENELEC -eq 1 ]; then + # OpenELEC has a readonly file system. Use alternative location + curl -L --get $HYPERION_RELEASE | tar -C /storage -xz + curl -L --get $OE_DEPENDECIES | tar -C /storage/hyperion/bin -xz + + # modify the default config to have a correct effect path + sed -i 's:/opt:/storage:g' /storage/hyperion/config/hyperion.config.json + + # /storage/.config is available as samba share. A symbolic link would not be working + false | cp -i /storage/hyperion/config/hyperion.config.json /storage/.config/hyperion.config.json 2>/dev/null +else + wget $HYPERION_RELEASE -O - | tar -C /opt -xz + + # create links to the binaries + ln -fs /opt/hyperion/bin/hyperiond /usr/bin/hyperiond + ln -fs /opt/hyperion/bin/hyperion-remote /usr/bin/hyperion-remote + ln -fs /opt/hyperion/bin/hyperion-v4l2 /usr/bin/hyperion-v4l2 + +# Copy a link to the hyperion configuration file to /etc + ln -s /opt/hyperion/config/hyperion.config.json /etc/hyperion.config.json +fi + +# Copy the service control configuration to /etc/int +if [ $USE_INITCTL -eq 1 ]; then + echo 'Installing initctl script' + wget -N https://raw.githubusercontent.com/tvdzwan/hyperion/master/deploy/hyperion.conf -P /etc/init/ + initctl reload-configuration +elif [ $USE_SERVICE -eq 1 ]; then + echo 'Installing startup script in init.d' + # place startup script in init.d and add it to upstart + ln -fs /opt/hyperion/init.d/hyperion.init.sh /etc/init.d/hyperion + chmod +x /etc/init.d/hyperion + update-rc.d hyperion defaults 98 02 +elif [ $IS_OPENELEC -eq 1 ]; then + # only add to start script if hyperion is not present yet + if [ `cat /storage/.config/autostart.sh 2>/dev/null | grep hyperiond | wc -l` -eq 0 ]; then + echo 'Adding Hyperion to autostart script' + 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 + fi +fi + +# Start the hyperion daemon +if [ $USE_INITCTL -eq 1 ]; then + /sbin/initctl start hyperion +elif [ $USE_SERVICE -eq 1 ]; then + /usr/sbin/service hyperion start +fi + From 41b4d3dfe2edf76b4b9d6a04d20175a7428631c2 Mon Sep 17 00:00:00 2001 From: poljvd Date: Tue, 29 Sep 2015 16:39:29 +0200 Subject: [PATCH 04/22] Update update_hyperion.sh Fixed check for wetek (amlogic) device Former-commit-id: bedd8945265d0a72ebcf934dd26aadc38d036b92 --- deploy/update_hyperion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/update_hyperion.sh b/deploy/update_hyperion.sh index 2a310f51..acfcdd99 100644 --- a/deploy/update_hyperion.sh +++ b/deploy/update_hyperion.sh @@ -11,7 +11,7 @@ OS_OPENELEC=`cat /etc/issue | grep -m 1 OpenELEC | wc -l` # Find out if its an imx6 device CPU_RPI=`cat /proc/cpuinfo | grep RPI | wc -l` CPU_IMX6=`cat /proc/cpuinfo | grep i.MX6 | wc -l` -CPU_WETEK=`cat /proc/cpyinfo | grep wetek | wc -l` +CPU_WETEK=`cat /proc/cpuinfo | grep Amlogic | wc -l` CPU_X64=`uname -m | grep x86_64 | wc -l` CPU_X32=`uname -m | grep x86_32 | wc -l` # Check that we have a known configuration From 4fe01a6613af6c7ffd381d026af59c870a8b9dd8 Mon Sep 17 00:00:00 2001 From: poljvd Date: Tue, 29 Sep 2015 17:06:06 +0200 Subject: [PATCH 05/22] Update update_hyperion.sh Fixed incorrect openelec variable reference Former-commit-id: f594935c9a6a2f1818dd3acfdb0fddfac6ad76cb --- deploy/update_hyperion.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/update_hyperion.sh b/deploy/update_hyperion.sh index acfcdd99..ff7494f6 100644 --- a/deploy/update_hyperion.sh +++ b/deploy/update_hyperion.sh @@ -15,7 +15,7 @@ CPU_WETEK=`cat /proc/cpuinfo | grep Amlogic | wc -l` CPU_X64=`uname -m | grep x86_64 | wc -l` CPU_X32=`uname -m | grep x86_32 | wc -l` # Check that we have a known configuration -if [ $CPU_RPI -ne 1 ] & [ $CPU_IMX6 -ne 1 ] & [ $CPU_WETEK -ne 1 ] & [ $CPU_X64 -ne 1 ] & [ $CPU_X32 -ne 1 ]; then +if [[ $CPU_RPI -ne 1 && $CPU_IMX6 -ne 1 && $CPU_WETEK -ne 1 && $CPU_X64 -ne 1 && $CPU_X32 -ne 1 ]]; then echo 'CPU information does not match any known releases' exit fi @@ -96,7 +96,7 @@ elif [ $USE_SERVICE -eq 1 ]; then ln -fs /opt/hyperion/init.d/hyperion.init.sh /etc/init.d/hyperion chmod +x /etc/init.d/hyperion update-rc.d hyperion defaults 98 02 -elif [ $IS_OPENELEC -eq 1 ]; then +elif [ $OS_OPENELEC -eq 1 ]; then # only add to start script if hyperion is not present yet if [ `cat /storage/.config/autostart.sh 2>/dev/null | grep hyperiond | wc -l` -eq 0 ]; then echo 'Adding Hyperion to autostart script' From 33edcddb1b6af087164d5837d72668b184be1983 Mon Sep 17 00:00:00 2001 From: tociek Date: Tue, 13 Oct 2015 19:11:01 +0200 Subject: [PATCH 06/22] APA102 device for use with Adalight (nominaly for ws2801) Former-commit-id: 7fb9e8e84518be9387ea9feca11e93a8a5389e4f --- libsrc/leddevice/CMakeLists.txt | 2 ++ libsrc/leddevice/LedDeviceAdalight.h | 2 +- libsrc/leddevice/LedDeviceAdalightApa102.h | 36 ++++++++++++++++++++++ libsrc/leddevice/LedDeviceFactory.cpp | 12 ++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 libsrc/leddevice/LedDeviceAdalightApa102.h diff --git a/libsrc/leddevice/CMakeLists.txt b/libsrc/leddevice/CMakeLists.txt index 06e13278..16463fb5 100755 --- a/libsrc/leddevice/CMakeLists.txt +++ b/libsrc/leddevice/CMakeLists.txt @@ -15,6 +15,7 @@ include_directories( SET(Leddevice_QT_HEADERS ${CURRENT_SOURCE_DIR}/LedRs232Device.h ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h + ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.h ${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.h ${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h ) @@ -40,6 +41,7 @@ SET(Leddevice_SOURCES ${CURRENT_SOURCE_DIR}/LedRs232Device.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.cpp ${CURRENT_SOURCE_DIR}/LedDeviceLightpack.cpp ${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.cpp diff --git a/libsrc/leddevice/LedDeviceAdalight.h b/libsrc/leddevice/LedDeviceAdalight.h index bc08200b..66d299d1 100644 --- a/libsrc/leddevice/LedDeviceAdalight.h +++ b/libsrc/leddevice/LedDeviceAdalight.h @@ -40,7 +40,7 @@ private slots: /// Write the last data to the leds again void rewriteLeds(); -private: +protected: /// The buffer containing the packed RGB values std::vector _ledBuffer; diff --git a/libsrc/leddevice/LedDeviceAdalightApa102.h b/libsrc/leddevice/LedDeviceAdalightApa102.h new file mode 100644 index 00000000..63e39c59 --- /dev/null +++ b/libsrc/leddevice/LedDeviceAdalightApa102.h @@ -0,0 +1,36 @@ +#pragma once + +// STL includes +#include + +// Qt includes +#include + +// hyperion incluse +#include "LedDeviceAdalight.h" + +/// +/// Implementation of the LedDevice interface for writing to an Adalight led device for APA102 led strips. +/// +class LedDeviceAdalightApa102 : public LedDeviceAdalight +{ + Q_OBJECT + +public: + /// + /// Constructs the LedDevice for attached Adalight device + /// + /// @param outputDevice The name of the output device (eg '/dev/ttyS0') + /// @param baudrate The used baudrate for writing to the output device + /// + LedDeviceAdalightApa102(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms); + + /// + /// Writes the led color values to the led-device + /// + /// @param ledValues The color-value per led + /// @return Zero on succes else negative + /// + virtual int write(const std::vector & ledValues); + +}; diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index 55028fde..ce8cb835 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -33,6 +33,7 @@ #include "LedDevicePhilipsHue.h" #include "LedDeviceTpm2.h" #include "LedDeviceAtmo.h" +#include "LedDeviceAdalightApa102.h" #ifdef ENABLE_WS2812BPWM #include "LedDeviceWS2812b.h" @@ -58,6 +59,17 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) device = deviceAdalight; } + else if (type == "adalightapa102") + { + const std::string output = deviceConfig["output"].asString(); + const unsigned rate = deviceConfig["rate"].asInt(); + const int delay_ms = deviceConfig["delayAfterConnect"].asInt(); + + LedDeviceAdalightApa102* deviceAdalightApa102 = new LedDeviceAdalightApa102(output, rate, delay_ms); + deviceAdalightApa102->open(); + + device = deviceAdalightApa102; + } else if (type == "ambiled") { const std::string output = deviceConfig["output"].asString(); From 3f6c00966e377e371d52c11923ba042fd4787275 Mon Sep 17 00:00:00 2001 From: tociek Date: Tue, 13 Oct 2015 23:35:27 +0200 Subject: [PATCH 07/22] Final adjustments for APA102 via Adalight Former-commit-id: ba786d5c4165c992ce4671e487294547c8dae8c6 --- libsrc/leddevice/LedDeviceAdalightApa102.cpp | 53 ++++++++++++++++++++ libsrc/leddevice/LedDeviceAdalightApa102.h | 12 ++++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 libsrc/leddevice/LedDeviceAdalightApa102.cpp diff --git a/libsrc/leddevice/LedDeviceAdalightApa102.cpp b/libsrc/leddevice/LedDeviceAdalightApa102.cpp new file mode 100644 index 00000000..172e76de --- /dev/null +++ b/libsrc/leddevice/LedDeviceAdalightApa102.cpp @@ -0,0 +1,53 @@ + +// STL includes +#include +#include +#include + +// Linux includes +#include +#include + +// hyperion local includes +#include "LedDeviceAdalightApa102.h" + +LedDeviceAdalightApa102::LedDeviceAdalightApa102(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms) : + LedDeviceAdalight(outputDevice, baudrate, delayAfterConnect_ms), + _ledBuffer(0), + _timer() +{ +} +//comparing to ws2801 adalight, the following changes were needed: +// 1- differnt data frame (4 bytes instead of 3) +// 2 - in order to accomodate point 1 above, number of leds sent to adalight is increased by 1/3rd +int LedDeviceAdalightApa102::write(const std::vector & ledValues) +{ + const unsigned int startFrameSize = 4; + const unsigned int endFrameSize = (ledValues.size() + 63) / 64 * 4; + const unsigned int mLedCount = (ledValues.size() * 4) + startFrameSize + endFrameSize; + if(_ledBuffer.size() != mLedCount){ + _ledBuffer.resize(mLedCount, 0x00); + _ledBuffer[0] = 'A'; + _ledBuffer[1] = 'd'; + _ledBuffer[2] = 'a'; + _ledBuffer[3] = (((unsigned int)(ledValues.size() * 1.33) - 1) >> 8) & 0xFF; // LED count high byte + _ledBuffer[4] = ((unsigned int)(ledValues.size() * 1.33) - 1) & 0xFF; // LED count low byte + _ledBuffer[5] = _ledBuffer[3] ^ _ledBuffer[4] ^ 0x55; // Checksum + } + + for (unsigned iLed=1; iLed<=ledValues.size(); iLed++) { + const ColorRgb& rgb = ledValues[iLed]; + _ledBuffer[iLed*4+6] = 0xFF; + _ledBuffer[iLed*4+1+6] = rgb.red; + _ledBuffer[iLed*4+2+6] = rgb.green; + _ledBuffer[iLed*4+3+6] = rgb.blue; + } + + // restart the timer + _timer.start(); + + // write data + return writeBytes(_ledBuffer.size(), _ledBuffer.data()); +} + + diff --git a/libsrc/leddevice/LedDeviceAdalightApa102.h b/libsrc/leddevice/LedDeviceAdalightApa102.h index 63e39c59..a0a7c89c 100644 --- a/libsrc/leddevice/LedDeviceAdalightApa102.h +++ b/libsrc/leddevice/LedDeviceAdalightApa102.h @@ -10,7 +10,7 @@ #include "LedDeviceAdalight.h" /// -/// Implementation of the LedDevice interface for writing to an Adalight led device for APA102 led strips. +/// Implementation of the LedDevice interface for writing to an Adalight led device for APA102. /// class LedDeviceAdalightApa102 : public LedDeviceAdalight { @@ -33,4 +33,14 @@ public: /// virtual int write(const std::vector & ledValues); + + +private: + /// The buffer containing the packed RGB values + std::vector _ledBuffer; + + /// Timer object which makes sure that led data is written at a minimum rate + /// The Adalight device will switch off when it does not receive data at least + /// every 15 seconds + QTimer _timer; }; From 6230f1dfe7d7c359be724af97fb4366b9673b3c7 Mon Sep 17 00:00:00 2001 From: "T.van der Zwan" Date: Tue, 20 Oct 2015 21:02:09 +0200 Subject: [PATCH 08/22] Updated releases with APA102 fix Former-commit-id: 2125e182e31c667b66ec176ae302514742114914 --- deploy/hyperion_imx6.tar.gz.REMOVED.git-id | 2 +- deploy/hyperion_rpi.tar.gz.REMOVED.git-id | 2 +- deploy/hyperion_wetek.tar.gz.REMOVED.git-id | 2 +- deploy/hyperion_x32.tar.gz.REMOVED.git-id | 2 +- deploy/hyperion_x64.tar.gz.REMOVED.git-id | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deploy/hyperion_imx6.tar.gz.REMOVED.git-id b/deploy/hyperion_imx6.tar.gz.REMOVED.git-id index 1243e5d8..294f2909 100644 --- a/deploy/hyperion_imx6.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_imx6.tar.gz.REMOVED.git-id @@ -1 +1 @@ -9a4c5499f7191aad3e23e0e3be806861a3ec1c02 \ No newline at end of file +3785db40d7232275fbc00b20e627280e0e057f99 \ No newline at end of file diff --git a/deploy/hyperion_rpi.tar.gz.REMOVED.git-id b/deploy/hyperion_rpi.tar.gz.REMOVED.git-id index a429abf8..0f6903ba 100644 --- a/deploy/hyperion_rpi.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_rpi.tar.gz.REMOVED.git-id @@ -1 +1 @@ -3a346e54f8958f87ae7f4e8804f6afdec33aa9fc \ No newline at end of file +0769228a95e4a0d4b2ed6649f21ddf70b43773d6 \ No newline at end of file diff --git a/deploy/hyperion_wetek.tar.gz.REMOVED.git-id b/deploy/hyperion_wetek.tar.gz.REMOVED.git-id index e38beaa9..4a4621a7 100644 --- a/deploy/hyperion_wetek.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_wetek.tar.gz.REMOVED.git-id @@ -1 +1 @@ -05227980ea998eeeecda03cefe090b5f55ff8ee0 \ No newline at end of file +7e53ee35b7258e7d58d96514701a50014a98da31 \ No newline at end of file diff --git a/deploy/hyperion_x32.tar.gz.REMOVED.git-id b/deploy/hyperion_x32.tar.gz.REMOVED.git-id index c189c367..24239241 100644 --- a/deploy/hyperion_x32.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_x32.tar.gz.REMOVED.git-id @@ -1 +1 @@ -f3e3f4a3a8e52e4bfaf9a0337cb364da841e150b \ No newline at end of file +36d03bb18626fa0faea8aabf6426e571eab4f719 \ No newline at end of file diff --git a/deploy/hyperion_x64.tar.gz.REMOVED.git-id b/deploy/hyperion_x64.tar.gz.REMOVED.git-id index ca1bf5dd..f6368736 100644 --- a/deploy/hyperion_x64.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_x64.tar.gz.REMOVED.git-id @@ -1 +1 @@ -9342bb64479ea4d5554f301b905a0a830e330635 \ No newline at end of file +6f86ceeb6650e527d179cf7153e0beada3b73889 \ No newline at end of file From acc1a1b397e69f4f9ee69777848867cdc3636dd8 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Fri, 30 Oct 2015 20:07:21 +0100 Subject: [PATCH 09/22] Update LedDeviceAPA102.cpp Problem with endFrame was not only endFrameSize, but ledValue index too Former-commit-id: cc14e9d440a1d27f6a51c18f92aeba1f438c9c01 --- libsrc/leddevice/LedDeviceAPA102.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libsrc/leddevice/LedDeviceAPA102.cpp b/libsrc/leddevice/LedDeviceAPA102.cpp index 2af01acf..fa224a9a 100644 --- a/libsrc/leddevice/LedDeviceAPA102.cpp +++ b/libsrc/leddevice/LedDeviceAPA102.cpp @@ -3,6 +3,7 @@ #include #include #include +#include // Linux includes #include @@ -21,14 +22,14 @@ LedDeviceAPA102::LedDeviceAPA102(const std::string& outputDevice, const unsigned int LedDeviceAPA102::write(const std::vector &ledValues) { const unsigned int startFrameSize = 4; - const unsigned int endFrameSize = (ledValues.size() + 63) / 64 * 4; + const unsigned int endFrameSize = std::max(((ledValues.size() + 15) / 16), 4); const unsigned int mLedCount = (ledValues.size() * 4) + startFrameSize + endFrameSize; if(_ledBuffer.size() != mLedCount){ _ledBuffer.resize(mLedCount, 0x00); } for (unsigned iLed=1; iLed<=ledValues.size(); ++iLed) { - const ColorRgb& rgb = ledValues[iLed]; + const ColorRgb& rgb = ledValues[iLed-1]; _ledBuffer[iLed*4] = 0xFF; _ledBuffer[iLed*4+1] = rgb.red; _ledBuffer[iLed*4+2] = rgb.green; From 9d004fa36e835268480c72041253b2cba8adf631 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Fri, 30 Oct 2015 20:08:16 +0100 Subject: [PATCH 10/22] Update LedDeviceAdalightApa102.cpp Former-commit-id: 2bbbb4756e6c3f8fe070ba73e63ce327e3f75ff4 --- libsrc/leddevice/LedDeviceAdalightApa102.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libsrc/leddevice/LedDeviceAdalightApa102.cpp b/libsrc/leddevice/LedDeviceAdalightApa102.cpp index 172e76de..d7bc355e 100644 --- a/libsrc/leddevice/LedDeviceAdalightApa102.cpp +++ b/libsrc/leddevice/LedDeviceAdalightApa102.cpp @@ -3,6 +3,7 @@ #include #include #include +#include // Linux includes #include @@ -23,7 +24,7 @@ LedDeviceAdalightApa102::LedDeviceAdalightApa102(const std::string& outputDevice int LedDeviceAdalightApa102::write(const std::vector & ledValues) { const unsigned int startFrameSize = 4; - const unsigned int endFrameSize = (ledValues.size() + 63) / 64 * 4; + const unsigned int endFrameSize = std::max(((ledValues.size() + 15) / 16), 4); const unsigned int mLedCount = (ledValues.size() * 4) + startFrameSize + endFrameSize; if(_ledBuffer.size() != mLedCount){ _ledBuffer.resize(mLedCount, 0x00); @@ -36,7 +37,7 @@ int LedDeviceAdalightApa102::write(const std::vector & ledValues) } for (unsigned iLed=1; iLed<=ledValues.size(); iLed++) { - const ColorRgb& rgb = ledValues[iLed]; + const ColorRgb& rgb = ledValues[iLed-1]; _ledBuffer[iLed*4+6] = 0xFF; _ledBuffer[iLed*4+1+6] = rgb.red; _ledBuffer[iLed*4+2+6] = rgb.green; From 958aa428a343c4be56717d20c93f9345cc355510 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Wed, 4 Nov 2015 14:05:09 +0100 Subject: [PATCH 11/22] Update LedDeviceAPA102.cpp Former-commit-id: 164b396f7d779d01e2fc1df80438ad817a0ac712 --- libsrc/leddevice/LedDeviceAPA102.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libsrc/leddevice/LedDeviceAPA102.cpp b/libsrc/leddevice/LedDeviceAPA102.cpp index fa224a9a..d7eb5828 100644 --- a/libsrc/leddevice/LedDeviceAPA102.cpp +++ b/libsrc/leddevice/LedDeviceAPA102.cpp @@ -25,7 +25,11 @@ int LedDeviceAPA102::write(const std::vector &ledValues) const unsigned int endFrameSize = std::max(((ledValues.size() + 15) / 16), 4); const unsigned int mLedCount = (ledValues.size() * 4) + startFrameSize + endFrameSize; if(_ledBuffer.size() != mLedCount){ - _ledBuffer.resize(mLedCount, 0x00); + _ledBuffer.resize(mLedCount, 0xFF); + } + + for (unsigned iLed=0; iLed Date: Wed, 4 Nov 2015 14:07:15 +0100 Subject: [PATCH 12/22] Update LedDeviceAdalightApa102.cpp Former-commit-id: fbf05206e681fc5979a7241bcb1ee716ec088757 --- libsrc/leddevice/LedDeviceAdalightApa102.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/leddevice/LedDeviceAdalightApa102.cpp b/libsrc/leddevice/LedDeviceAdalightApa102.cpp index d7bc355e..07732080 100644 --- a/libsrc/leddevice/LedDeviceAdalightApa102.cpp +++ b/libsrc/leddevice/LedDeviceAdalightApa102.cpp @@ -27,7 +27,7 @@ int LedDeviceAdalightApa102::write(const std::vector & ledValues) const unsigned int endFrameSize = std::max(((ledValues.size() + 15) / 16), 4); const unsigned int mLedCount = (ledValues.size() * 4) + startFrameSize + endFrameSize; if(_ledBuffer.size() != mLedCount){ - _ledBuffer.resize(mLedCount, 0x00); + _ledBuffer.resize(mLedCount, 0xFF); _ledBuffer[0] = 'A'; _ledBuffer[1] = 'd'; _ledBuffer[2] = 'a'; From 1c41919c08c5b9278a2d593526ae595082921b53 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Wed, 4 Nov 2015 14:08:33 +0100 Subject: [PATCH 13/22] Update LedDeviceAPA102.cpp Former-commit-id: f0b04ded96a9c9b99c2329e7889917645065382d --- libsrc/leddevice/LedDeviceAPA102.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libsrc/leddevice/LedDeviceAPA102.cpp b/libsrc/leddevice/LedDeviceAPA102.cpp index d7eb5828..26a21f72 100644 --- a/libsrc/leddevice/LedDeviceAPA102.cpp +++ b/libsrc/leddevice/LedDeviceAPA102.cpp @@ -26,12 +26,12 @@ int LedDeviceAPA102::write(const std::vector &ledValues) const unsigned int mLedCount = (ledValues.size() * 4) + startFrameSize + endFrameSize; if(_ledBuffer.size() != mLedCount){ _ledBuffer.resize(mLedCount, 0xFF); + _ledBuffer[0] = 0x00; + _ledBuffer[1] = 0x00; + _ledBuffer[2] = 0x00; + _ledBuffer[3] = 0x00; } - for (unsigned iLed=0; iLed Date: Sun, 8 Nov 2015 16:26:55 +0100 Subject: [PATCH 14/22] Added HID Device Former-commit-id: 6284152fd9ffdad69fa1bbd4490da9547c4dbe87 --- libsrc/leddevice/LedHIDDevice.cpp | 152 ++++++++++++++++++++++++++++++ libsrc/leddevice/LedHIDDevice.h | 66 +++++++++++++ 2 files changed, 218 insertions(+) create mode 100644 libsrc/leddevice/LedHIDDevice.cpp create mode 100644 libsrc/leddevice/LedHIDDevice.h diff --git a/libsrc/leddevice/LedHIDDevice.cpp b/libsrc/leddevice/LedHIDDevice.cpp new file mode 100644 index 00000000..e1506560 --- /dev/null +++ b/libsrc/leddevice/LedHIDDevice.cpp @@ -0,0 +1,152 @@ + +// STL includes +#include +#include + +// Qt includes +#include + +// Local Hyperion includes +#include "LedHIDDevice.h" + +LedHIDDevice::LedHIDDevice(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms, const bool useFeature) : + _VendorId(VendorId), + _ProductId(ProductId), + _useFeature(useFeature), + _deviceHandle(nullptr), + _delayAfterConnect_ms(delayAfterConnect_ms), + _blockedForDelay(false) +{ + // empty +} + +LedHIDDevice::~LedHIDDevice() +{ + if (_deviceHandle != nullptr) + { + hid_close(_deviceHandle); + _deviceHandle = nullptr; + } + + hid_exit(); +} + +int LedHIDDevice::open() +{ + // Initialize the usb context + int error = hid_init(); + if (error != 0) + { + std::cerr << "Error while initializing the hidapi context" << std::endl; + return -1; + } + std::cout << "Hidapi initialized" << std::endl; + + // Open the device + printf("Opening device: VID %04hx PID %04hx\n", _VendorId, _ProductId); + _deviceHandle = hid_open(_VendorId, _ProductId, nullptr); + + if (_deviceHandle == nullptr) + { + // Failed to open the device + std::cerr << "Failed to open HID device. Maybe your PID/VID setting is wrong?" << std::endl; + + // http://www.signal11.us/oss/hidapi/ + /* + std::cout << "Showing a list of all available HID devices:" << std::endl; + auto devs = hid_enumerate(0x00, 0x00); + auto cur_dev = devs; + while (cur_dev) { + printf("Device Found\n type: %04hx %04hx\n path: %s\n serial_number: %ls", + cur_dev->vendor_id, cur_dev->product_id, cur_dev->path, cur_dev->serial_number); + printf("\n"); + printf(" Manufacturer: %ls\n", cur_dev->manufacturer_string); + printf(" Product: %ls\n", cur_dev->product_string); + printf("\n"); + cur_dev = cur_dev->next; + } + hid_free_enumeration(devs); + */ + + return -1; + } + else{ + std::cout << "Opened HID device successful" << std::endl; + } + + // Wait after device got opened if enabled + if (_delayAfterConnect_ms > 0) + { + _blockedForDelay = true; + QTimer::singleShot(_delayAfterConnect_ms, this, SLOT(unblockAfterDelay())); + std::cout << "Device blocked for " << _delayAfterConnect_ms << " ms" << std::endl; + } + + return 0; +} + + +int LedHIDDevice::writeBytes(const unsigned size, const uint8_t * data) +{ + if (_blockedForDelay) { + return 0; + } + + if (_deviceHandle == nullptr) + { + // try to reopen + auto status = open(); + if(status < 0){ + // Try again in 3 seconds + int seconds = 3000; + _blockedForDelay = true; + QTimer::singleShot(seconds, this, SLOT(unblockAfterDelay())); + std::cout << "Device blocked for " << seconds << " ms" << std::endl; + } + // Return here, to not write led data if the device should be blocked after connect + return status; + } + + // Prepend report ID to the buffer + uint8_t ledData[size + 1]; + ledData[0] = 0; // Report ID + memcpy(ledData + 1, data, size_t(size)); + + // Send data via feature or out report + int ret; + if(_useFeature){ + ret = hid_send_feature_report(_deviceHandle, ledData, size + 1); + } + else{ + ret = hid_write(_deviceHandle, ledData, size + 1); + } + + // Handle first error + if(ret < 0){ + std::cerr << "Failed to write to HID device." << std::endl; + + // Try again + if(_useFeature){ + ret = hid_send_feature_report(_deviceHandle, ledData, size + 1); + } + else{ + ret = hid_write(_deviceHandle, ledData, size + 1); + } + + // Writing failed again, device might have disconnected + if(ret < 0){ + std::cerr << "Failed to write to HID device." << std::endl; + + hid_close(_deviceHandle); + _deviceHandle = nullptr; + } + } + + return ret; +} + +void LedHIDDevice::unblockAfterDelay() +{ + std::cout << "Device unblocked" << std::endl; + _blockedForDelay = false; +} diff --git a/libsrc/leddevice/LedHIDDevice.h b/libsrc/leddevice/LedHIDDevice.h new file mode 100644 index 00000000..fb4aa6b3 --- /dev/null +++ b/libsrc/leddevice/LedHIDDevice.h @@ -0,0 +1,66 @@ +#pragma once + +#include + +// libusb include +#include + +// Leddevice includes +#include + +/// +/// The LedHIDDevice implements an abstract base-class for LedDevices using an HID-device. +/// +class LedHIDDevice : public QObject, public LedDevice +{ + Q_OBJECT + +public: + /// + /// Constructs the LedDevice attached to an HID-device + /// + /// @param[in] VendorId The USB VID of the output device + /// @param[in] ProductId The USB PID of the output device + /// + LedHIDDevice(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms = 0, const bool useFeature = false); + + /// + /// Destructor of the LedDevice; closes the output device if it is open + /// + virtual ~LedHIDDevice(); + + /// + /// Opens and configures the output device + /// + /// @return Zero on succes else negative + /// + int open(); +protected: + /** + * Writes the given bytes to the HID-device and + * + * @param[in[ size The length of the data + * @param[in] data The data + * + * @return Zero on succes else negative + */ + int writeBytes(const unsigned size, const uint8_t *data); + +private slots: + /// Unblock the device after a connection delay + void unblockAfterDelay(); + +private: + // HID VID and PID + const unsigned short _VendorId; + const unsigned short _ProductId; + const bool _useFeature; + + /// libusb device handle + hid_device * _deviceHandle; + + /// Sleep after the connect before continuing + const int _delayAfterConnect_ms; + + bool _blockedForDelay; +}; From 29d3209d7de9b0e8ea5c08c94cc6298bf8d03fb9 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 8 Nov 2015 16:31:18 +0100 Subject: [PATCH 15/22] Added Raw HID device Former-commit-id: bd36530b6b63959ee4d83693e396cbb0af70ddb3 --- libsrc/leddevice/CMakeLists.txt | 4 ++ libsrc/leddevice/LedDeviceFactory.cpp | 16 ++++++++ libsrc/leddevice/LedDeviceRawHID.cpp | 57 +++++++++++++++++++++++++++ libsrc/leddevice/LedDeviceRawHID.h | 48 ++++++++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 libsrc/leddevice/LedDeviceRawHID.cpp create mode 100644 libsrc/leddevice/LedDeviceRawHID.h diff --git a/libsrc/leddevice/CMakeLists.txt b/libsrc/leddevice/CMakeLists.txt index 16463fb5..d6d4682c 100755 --- a/libsrc/leddevice/CMakeLists.txt +++ b/libsrc/leddevice/CMakeLists.txt @@ -18,6 +18,8 @@ SET(Leddevice_QT_HEADERS ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.h ${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.h ${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h + ${CURRENT_SOURCE_DIR}/LedHIDDevice.h + ${CURRENT_SOURCE_DIR}/LedDeviceRawHID.h ) SET(Leddevice_HEADERS @@ -39,10 +41,12 @@ SET(Leddevice_SOURCES ${CURRENT_SOURCE_DIR}/LedDeviceFactory.cpp ${CURRENT_SOURCE_DIR}/LedRs232Device.cpp + ${CURRENT_SOURCE_DIR}/LedHIDDevice.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceRawHID.cpp ${CURRENT_SOURCE_DIR}/LedDeviceLightpack.cpp ${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.cpp ${CURRENT_SOURCE_DIR}/LedDevicePaintpack.cpp diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index ce8cb835..d5d40611 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -23,6 +23,7 @@ #include "LedDeviceAdalight.h" #include "LedDeviceAmbiLed.h" +#include "LedDeviceRawHID.h" #include "LedDeviceLightpack.h" #include "LedDeviceMultiLightpack.h" #include "LedDevicePaintpack.h" @@ -147,6 +148,21 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) device = deviceTinkerforge; } #endif + else if (type == "rawhid") + { + const int delay_ms = deviceConfig["delayAfterConnect"].asInt(); + auto VendorIdString = deviceConfig.get("VID", "0x2341").asString(); + auto ProductIdString = deviceConfig.get("PID", "0x8036").asString(); + + // Convert HEX values to integer + auto VendorId = std::stoul(VendorIdString, nullptr, 16); + auto ProductId = std::stoul(ProductIdString, nullptr, 16); + + LedDeviceRawHID* deviceHID = new LedDeviceRawHID(VendorId, ProductId, delay_ms); + deviceHID->open(); + + device = deviceHID; + } else if (type == "lightpack") { const std::string output = deviceConfig.get("output", "").asString(); diff --git a/libsrc/leddevice/LedDeviceRawHID.cpp b/libsrc/leddevice/LedDeviceRawHID.cpp new file mode 100644 index 00000000..18d678c3 --- /dev/null +++ b/libsrc/leddevice/LedDeviceRawHID.cpp @@ -0,0 +1,57 @@ + +// STL includes +#include +#include +#include + +// Linux includes +#include +#include + +// hyperion local includes +#include "LedDeviceRawHID.h" + +// Use feature report HID device +LedDeviceRawHID::LedDeviceRawHID(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms) : + LedHIDDevice(VendorId, ProductId, delayAfterConnect_ms, true), + _ledBuffer(0), + _timer() +{ + // setup the timer + _timer.setSingleShot(false); + _timer.setInterval(5000); + connect(&_timer, SIGNAL(timeout()), this, SLOT(rewriteLeds())); + + // start the timer + _timer.start(); +} + +int LedDeviceRawHID::write(const std::vector & ledValues) +{ + // Resize buffer if required + if (_ledBuffer.size() < ledValues.size() * 3) { + _ledBuffer.resize(3 * ledValues.size()); + } + + // restart the timer + _timer.start(); + + // write data + memcpy(_ledBuffer.data(), ledValues.data(), ledValues.size() * 3); + return writeBytes(_ledBuffer.size(), _ledBuffer.data()); +} + +int LedDeviceRawHID::switchOff() +{ + // restart the timer + _timer.start(); + + // write data + std::fill(_ledBuffer.begin(), _ledBuffer.end(), uint8_t(0)); + return writeBytes(_ledBuffer.size(), _ledBuffer.data()); +} + +void LedDeviceRawHID::rewriteLeds() +{ + writeBytes(_ledBuffer.size(), _ledBuffer.data()); +} diff --git a/libsrc/leddevice/LedDeviceRawHID.h b/libsrc/leddevice/LedDeviceRawHID.h new file mode 100644 index 00000000..6e23fe02 --- /dev/null +++ b/libsrc/leddevice/LedDeviceRawHID.h @@ -0,0 +1,48 @@ +#pragma once + +// STL includes +#include + +// Qt includes +#include + +// hyperion include +#include "LedHIDDevice.h" + +/// +/// Implementation of the LedDevice interface for writing to an RawHID led device. +/// +class LedDeviceRawHID : public LedHIDDevice +{ + Q_OBJECT + +public: + /// + /// Constructs the LedDevice for attached RawHID device + /// + LedDeviceRawHID(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms); + + /// + /// Writes the led color values to the led-device + /// + /// @param ledValues The color-value per led + /// @return Zero on succes else negative + /// + virtual int write(const std::vector & ledValues); + + /// Switch the leds off + virtual int switchOff(); + +private slots: + /// Write the last data to the leds again + void rewriteLeds(); + +private: + /// The buffer containing the packed RGB values + std::vector _ledBuffer; + + /// Timer object which makes sure that led data is written at a minimum rate + /// The RawHID device will switch off when it does not receive data at least + /// every 15 seconds + QTimer _timer; +}; From a7d9a44dcc6088644dd50517525091ab1ec71d65 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 8 Nov 2015 16:31:41 +0100 Subject: [PATCH 16/22] Fixed adalight typos Former-commit-id: c4bccd1e6c036b244f69283d2edff41c618ffc1b --- libsrc/leddevice/LedDeviceAdalight.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/leddevice/LedDeviceAdalight.h b/libsrc/leddevice/LedDeviceAdalight.h index 66d299d1..650fdfb1 100644 --- a/libsrc/leddevice/LedDeviceAdalight.h +++ b/libsrc/leddevice/LedDeviceAdalight.h @@ -6,7 +6,7 @@ // Qt includes #include -// hyperion incluse +// hyperion include #include "LedRs232Device.h" /// From 3595709099397d8c72a16b973b17925262af248a Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 8 Nov 2015 16:32:53 +0100 Subject: [PATCH 17/22] Adapted Paintpack to HIDDevice API Former-commit-id: 06101f0e99fbe99f8994193cea337b400acbafe3 --- libsrc/leddevice/LedDeviceFactory.cpp | 10 +++- libsrc/leddevice/LedDevicePaintpack.cpp | 65 ++++++------------------- libsrc/leddevice/LedDevicePaintpack.h | 26 ++-------- 3 files changed, 27 insertions(+), 74 deletions(-) diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index d5d40611..85f665a5 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -181,7 +181,15 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) } else if (type == "paintpack") { - LedDevicePaintpack * devicePainLightpack = new LedDevicePaintpack(); + const int delay_ms = deviceConfig["delayAfterConnect"].asInt(); + auto VendorIdString = deviceConfig.get("VID", "0x0EBF").asString(); + auto ProductIdString = deviceConfig.get("PID", "0x0025").asString(); + + // Convert HEX values to integer + auto VendorId = std::stoul(VendorIdString, nullptr, 16); + auto ProductId = std::stoul(ProductIdString, nullptr, 16); + + LedDevicePaintpack * devicePainLightpack = new LedDevicePaintpack(VendorId, ProductId, delay_ms); devicePainLightpack->open(); device = devicePainLightpack; diff --git a/libsrc/leddevice/LedDevicePaintpack.cpp b/libsrc/leddevice/LedDevicePaintpack.cpp index 7ed0c847..db87bf49 100644 --- a/libsrc/leddevice/LedDevicePaintpack.cpp +++ b/libsrc/leddevice/LedDevicePaintpack.cpp @@ -2,61 +2,25 @@ // Hyperion includes #include "LedDevicePaintpack.h" -LedDevicePaintpack::LedDevicePaintpack() : - LedDevice(), - _deviceHandle(nullptr) +// Use out report HID device +LedDevicePaintpack::LedDevicePaintpack(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms) : + LedHIDDevice(VendorId, ProductId, delayAfterConnect_ms, false), + _ledBuffer(0) { // empty } -int LedDevicePaintpack::open() + +int LedDevicePaintpack::write(const std::vector & ledValues) { - // initialize the usb context - int error = hid_init(); - if (error != 0) + if (_ledBuffer.size() < 2 + ledValues.size()*3) { - std::cerr << "Error while initializing the hidapi context" << std::endl; - return -1; - } - std::cout << "Hidapi initialized" << std::endl; - - // Initialise the paintpack device - const unsigned short Paintpack_VendorId = 0x0ebf; - const unsigned short Paintpack_ProductId = 0x0025; - _deviceHandle = hid_open(Paintpack_VendorId, Paintpack_ProductId, nullptr); - if (_deviceHandle == nullptr) - { - // Failed to open the device - std::cerr << "Failed to open HID Paintpakc device " << std::endl; - return -1; + _ledBuffer.resize(2 + ledValues.size()*3, uint8_t(0)); + _ledBuffer[0] = 3; + _ledBuffer[1] = 0; } - return 0; -} - -LedDevicePaintpack::~LedDevicePaintpack() -{ - if (_deviceHandle != nullptr) - { - hid_close(_deviceHandle); - _deviceHandle = nullptr; - } - - hid_exit(); -} - -int LedDevicePaintpack::write(const std::vector& ledValues) -{ - if (_ledBuffer.size() < 3 + ledValues.size()*3) - { - _ledBuffer.resize(3 + ledValues.size()*3, uint8_t(0)); - - _ledBuffer[0] = 0; - _ledBuffer[1] = 3; - _ledBuffer[2] = 0; - } - - auto bufIt = _ledBuffer.begin()+3; + auto bufIt = _ledBuffer.begin()+2; for (const ColorRgb & ledValue : ledValues) { *bufIt = ledValue.red; @@ -67,11 +31,12 @@ int LedDevicePaintpack::write(const std::vector& ledValues) ++bufIt; } - return hid_write(_deviceHandle, _ledBuffer.data(), _ledBuffer.size()); + return writeBytes(_ledBuffer.size(), _ledBuffer.data()); } + int LedDevicePaintpack::switchOff() { - std::fill(_ledBuffer.begin()+3, _ledBuffer.end(), uint8_t(0)); - return hid_write(_deviceHandle, _ledBuffer.data(), _ledBuffer.size()); + std::fill(_ledBuffer.begin() + 2, _ledBuffer.end(), uint8_t(0)); + return writeBytes(_ledBuffer.size(), _ledBuffer.data()); } diff --git a/libsrc/leddevice/LedDevicePaintpack.h b/libsrc/leddevice/LedDevicePaintpack.h index 327dc123..3ed91eab 100644 --- a/libsrc/leddevice/LedDevicePaintpack.h +++ b/libsrc/leddevice/LedDevicePaintpack.h @@ -3,34 +3,19 @@ // STL includes #include -// libusb include -#include - // Hyperion includes -#include +#include "LedHIDDevice.h" /// /// LedDevice implementation for a paintpack device () /// -class LedDevicePaintpack : public LedDevice +class LedDevicePaintpack : public LedHIDDevice { public: /** * Constructs the paintpack device */ - LedDevicePaintpack(); - - /** - * Destructs the paintpack device, closes USB connection if open - */ - virtual ~LedDevicePaintpack(); - - /** - * Opens the Paintpack device - * - * @return Zero on succes else negative - */ - int open(); + LedDevicePaintpack(const unsigned short VendorId, const unsigned short ProductId, int delayAfterConnect_ms); /// /// Writes the RGB-Color values to the leds. @@ -49,11 +34,6 @@ public: virtual int switchOff(); private: - /// libusb device handle - hid_device * _deviceHandle; - /// buffer for led data std::vector _ledBuffer; - - }; From 1b2b3b3135ac0a57c59da136f2ef69bdcdb3420b Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 8 Nov 2015 21:05:12 +0100 Subject: [PATCH 18/22] Added udev/sudo note to HID Device Former-commit-id: 30e1524a5ca587cd5928aae028de868df2725aca --- libsrc/leddevice/LedHIDDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/leddevice/LedHIDDevice.cpp b/libsrc/leddevice/LedHIDDevice.cpp index e1506560..0ed53524 100644 --- a/libsrc/leddevice/LedHIDDevice.cpp +++ b/libsrc/leddevice/LedHIDDevice.cpp @@ -49,7 +49,7 @@ int LedHIDDevice::open() if (_deviceHandle == nullptr) { // Failed to open the device - std::cerr << "Failed to open HID device. Maybe your PID/VID setting is wrong?" << std::endl; + std::cerr << "Failed to open HID device. Maybe your PID/VID setting is wrong? Make sure to add a udev rule/use sudo." << std::endl; // http://www.signal11.us/oss/hidapi/ /* From 25c4322ff8a252eebac44f56dd17406b0cacda5d Mon Sep 17 00:00:00 2001 From: Nico Date: Sun, 15 Nov 2015 10:32:33 +0100 Subject: [PATCH 19/22] Typos in Compile Instructions + clone only latest git Former-commit-id: a259a1ee1de4b535e254a21721bffd582380b6b2 --- CompileHowto.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CompileHowto.txt b/CompileHowto.txt index df85dc5f..5154aabb 100644 --- a/CompileHowto.txt +++ b/CompileHowto.txt @@ -2,14 +2,15 @@ sudo apt-get update sudo apt-get install git cmake build-essential libQt4-dev libusb-1.0-0-dev python-dev -# RPI ONLY: when you build on the rapberry pi and inlcude the dispmanx grabber (which is the default) +# RPI ONLY: when you build on the rapberry pi and include the dispmanx grabber (which is the default) # you also need the firmware including headers installed. This downloads the firmware from the raspberrypi github # and copies the required files to the correct place. The firmware directory can be deleted afterwards if desired. export FIRMWARE_DIR="raspberrypi-firmware" -git clone https://github.com/raspberrypi/firmware.git "$FIRMWARE_DIR" -sudo cp -R "$FIRMWARE_DIR/hardfp/opt/*" /opt +git clone --depth 1 https://github.com/raspberrypi/firmware.git "$FIRMWARE_DIR" +sudo cp -R "$FIRMWARE_DIR/hardfp/opt/" /opt # create hyperion directory and checkout the code from github +# You might want to add "--depth 1" if you only want to recompile the current source or dont want to use git any further export HYPERION_DIR="hyperion" git clone --recursive https://github.com/tvdzwan/hyperion.git "$HYPERION_DIR" @@ -22,7 +23,7 @@ git submodule update mkdir "$HYPERION_DIR/build" cd "$HYPERION_DIR/build" -# run cmake to generate make files on the rsapberry pi +# run cmake to generate make files on the raspberry pi cmake .. # or if you are not compiling on the raspberry pi and need to disable the Dispmanx grabber and support for spi devices cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_X11=ON .. From 9b1b4d2aea970e13d3e0fb6688eddbf7743675bd Mon Sep 17 00:00:00 2001 From: Nico Date: Sun, 15 Nov 2015 11:14:44 +0100 Subject: [PATCH 20/22] Copy effects to /opt/hyperion/ on a manual compilation Former-commit-id: 49893ea8d35ee78f52fe8f95d841ed29dacc94ee --- CompileHowto.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CompileHowto.txt b/CompileHowto.txt index 5154aabb..621cf8fd 100644 --- a/CompileHowto.txt +++ b/CompileHowto.txt @@ -40,3 +40,6 @@ make # The binaries are build in "$HYPERION_DIR/build/bin". You could copy those to /usr/bin sudo cp ./bin/hyperion-remote /usr/bin/ sudo cp ./bin/hyperiond /usr/bin/ + +# Copy the effect folder (if you did not use the normal installation methode before) +sudo mkdir -p /opt/hyperion/effects && sudo cp -R ../effects/ /opt/hyperion/ From 8ffbc160904ee9420e483a9be6db194ea1aa7997 Mon Sep 17 00:00:00 2001 From: Matthias Grimm Date: Fri, 20 Nov 2015 18:47:00 +0100 Subject: [PATCH 21/22] Added some more hue devices and Gamut-Profile Added the new Lightstrip plus, hue go and Aura. The first two come with a new Gamut profile and the Aura is from Living Colors. Former-commit-id: 83b676bf136095f3069c219810ea361829d81558 --- libsrc/leddevice/LedDevicePhilipsHue.cpp | 40 ++++++++++++++---------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/libsrc/leddevice/LedDevicePhilipsHue.cpp b/libsrc/leddevice/LedDevicePhilipsHue.cpp index c65391f6..dd58e124 100755 --- a/libsrc/leddevice/LedDevicePhilipsHue.cpp +++ b/libsrc/leddevice/LedDevicePhilipsHue.cpp @@ -20,23 +20,29 @@ bool operator !=(CiColor p1, CiColor p2) { return !(p1 == p2); } -PhilipsHueLight::PhilipsHueLight(unsigned int id, QString originalState, QString modelId) : - id(id), originalState(originalState) { - // Hue system model ids (http://www.developers.meethue.com/documentation/supported-lights). - // Light strips, color iris, ... - const std::set GAMUT_A_MODEL_IDS = { "LLC001", "LLC005", "LLC006", "LLC007", "LLC010", "LLC011", "LLC012", - "LLC013", "LST001" }; - // Hue bulbs, spots, ... - const std::set GAMUT_B_MODEL_IDS = { "LCT001", "LCT002", "LCT003", "LLM001" }; - // Find id in the sets and set the appropiate color space. - if (GAMUT_A_MODEL_IDS.find(modelId) != GAMUT_A_MODEL_IDS.end()) { - colorSpace.red = {0.703f, 0.296f}; - colorSpace.green = {0.2151f, 0.7106f}; - colorSpace.blue = {0.138f, 0.08f}; - } else if (GAMUT_B_MODEL_IDS.find(modelId) != GAMUT_B_MODEL_IDS.end()) { - colorSpace.red = {0.675f, 0.322f}; - colorSpace.green = {0.4091f, 0.518f}; - colorSpace.blue = {0.167f, 0.04f}; +PPhilipsHueLight::PhilipsHueLight(unsigned int id, QString originalState, QString modelId) : + id(id), originalState(originalState) { + // Hue system model ids (http://www.developers.meethue.com/documentation/supported-lights). + // Light strips, color iris, ... + const std::set GAMUT_A_MODEL_IDS = { "LLC001", "LLC005", "LLC006", "LLC007", "LLC010", "LLC011", "LLC012", + "LLC013", "LLC014", "LST001" }; + // Hue bulbs, spots, ... + const std::set GAMUT_B_MODEL_IDS = { "LCT001", "LCT002", "LCT003", "LCT007", "LLM001" }; + // Hue Lightstrip plus, go ... + const std::set GAMUT_C_MODEL_IDS = { "LLC020", "LST002" }; + // Find id in the sets and set the appropiate color space. + if (GAMUT_A_MODEL_IDS.find(modelId) != GAMUT_A_MODEL_IDS.end()) { + colorSpace.red = {0.703f, 0.296f}; + colorSpace.green = {0.2151f, 0.7106f}; + colorSpace.blue = {0.138f, 0.08f}; + } else if (GAMUT_B_MODEL_IDS.find(modelId) != GAMUT_B_MODEL_IDS.end()) { + colorSpace.red = {0.675f, 0.322f}; + colorSpace.green = {0.4091f, 0.518f}; + colorSpace.blue = {0.167f, 0.04f}; + } else if (GAMUT_C_MODEL_IDS.find(modelId) != GAMUT_B_MODEL_IDS.end()) { + colorSpace.red = {0.675f, 0.322f}; + colorSpace.green = {0.2151f, 0.7106f}; + colorSpace.blue = {0.167f, 0.04f}; } else { colorSpace.red = {1.0f, 0.0f}; colorSpace.green = {0.0f, 1.0f}; From e76e41c04682819f15bd7dec8a9d25c527062dcc Mon Sep 17 00:00:00 2001 From: Matthias Grimm Date: Tue, 24 Nov 2015 19:37:52 +0100 Subject: [PATCH 22/22] fixed typo forgot to pull my local changes to Mac :-/ Former-commit-id: 8e57cad4af836746ba6442443ace8d4521202151 --- libsrc/leddevice/LedDevicePhilipsHue.cpp | 50 ++++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/libsrc/leddevice/LedDevicePhilipsHue.cpp b/libsrc/leddevice/LedDevicePhilipsHue.cpp index dd58e124..056e9ead 100755 --- a/libsrc/leddevice/LedDevicePhilipsHue.cpp +++ b/libsrc/leddevice/LedDevicePhilipsHue.cpp @@ -20,34 +20,34 @@ bool operator !=(CiColor p1, CiColor p2) { return !(p1 == p2); } -PPhilipsHueLight::PhilipsHueLight(unsigned int id, QString originalState, QString modelId) : - id(id), originalState(originalState) { +PhilipsHueLight::PhilipsHueLight(unsigned int id, QString originalState, QString modelId) : + id(id), originalState(originalState) { // Hue system model ids (http://www.developers.meethue.com/documentation/supported-lights). // Light strips, color iris, ... - const std::set GAMUT_A_MODEL_IDS = { "LLC001", "LLC005", "LLC006", "LLC007", "LLC010", "LLC011", "LLC012", + const std::set GAMUT_A_MODEL_IDS = { "LLC001", "LLC005", "LLC006", "LLC007", "LLC010", "LLC011", "LLC012", "LLC013", "LLC014", "LST001" }; - // Hue bulbs, spots, ... - const std::set GAMUT_B_MODEL_IDS = { "LCT001", "LCT002", "LCT003", "LCT007", "LLM001" }; - // Hue Lightstrip plus, go ... - const std::set GAMUT_C_MODEL_IDS = { "LLC020", "LST002" }; - // Find id in the sets and set the appropiate color space. - if (GAMUT_A_MODEL_IDS.find(modelId) != GAMUT_A_MODEL_IDS.end()) { - colorSpace.red = {0.703f, 0.296f}; - colorSpace.green = {0.2151f, 0.7106f}; - colorSpace.blue = {0.138f, 0.08f}; - } else if (GAMUT_B_MODEL_IDS.find(modelId) != GAMUT_B_MODEL_IDS.end()) { - colorSpace.red = {0.675f, 0.322f}; - colorSpace.green = {0.4091f, 0.518f}; - colorSpace.blue = {0.167f, 0.04f}; - } else if (GAMUT_C_MODEL_IDS.find(modelId) != GAMUT_B_MODEL_IDS.end()) { - colorSpace.red = {0.675f, 0.322f}; - colorSpace.green = {0.2151f, 0.7106f}; - colorSpace.blue = {0.167f, 0.04f}; - } else { - colorSpace.red = {1.0f, 0.0f}; - colorSpace.green = {0.0f, 1.0f}; - colorSpace.blue = {0.0f, 0.0f}; - } + // Hue bulbs, spots, ... + const std::set GAMUT_B_MODEL_IDS = { "LCT001", "LCT002", "LCT003", "LCT007", "LLM001" }; + // Hue Lightstrip plus, go ... + const std::set GAMUT_C_MODEL_IDS = { "LLC020", "LST002" }; + // Find id in the sets and set the appropiate color space. + if (GAMUT_A_MODEL_IDS.find(modelId) != GAMUT_A_MODEL_IDS.end()) { + colorSpace.red = {0.703f, 0.296f}; + colorSpace.green = {0.2151f, 0.7106f}; + colorSpace.blue = {0.138f, 0.08f}; + } else if (GAMUT_B_MODEL_IDS.find(modelId) != GAMUT_B_MODEL_IDS.end()) { + colorSpace.red = {0.675f, 0.322f}; + colorSpace.green = {0.4091f, 0.518f}; + colorSpace.blue = {0.167f, 0.04f}; + } else if (GAMUT_C_MODEL_IDS.find(modelId) != GAMUT_B_MODEL_IDS.end()) { + colorSpace.red = {0.675f, 0.322f}; + colorSpace.green = {0.2151f, 0.7106f}; + colorSpace.blue = {0.167f, 0.04f}; + } else { + colorSpace.red = {1.0f, 0.0f}; + colorSpace.green = {0.0f, 1.0f}; + colorSpace.blue = {0.0f, 0.0f}; + } // Initialize black color. black = rgbToCiColor(0.0f, 0.0f, 0.0f); // Initialize color with black