From e352dea7a6228dd7b008765917f227d7387ab409 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 21 Mar 2016 15:43:30 +1100 Subject: [PATCH 1/5] Added support to invert the WS281x LED data. This supports level shifters that invert the data Config option - "invert" (integer) if omitted, do not invert if == 0, do not invert if !=0, invert Former-commit-id: 44ab64329641f0e1450174314a955d241641d149 --- libsrc/leddevice/LedDeviceFactory.cpp | 5 +++-- libsrc/leddevice/LedDeviceWS281x.cpp | 4 ++-- libsrc/leddevice/LedDeviceWS281x.h | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index 49b197f6..8ba6a9d3 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -324,11 +324,12 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) else if (type == "ws281x") { const int gpio = deviceConfig.get("gpio", 18).asInt(); - const int leds = deviceConfig.get("leds", 12).asInt(); + const int leds = deviceConfig.get("leds", 256).asInt(); const uint32_t freq = deviceConfig.get("freq", (Json::UInt)800000ul).asInt(); const int dmanum = deviceConfig.get("dmanum", 5).asInt(); + const int invert = deviceConfig.get("invert", 0).asInt(); - LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum); + LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum, invert); device = ledDeviceWS281x; } #endif diff --git a/libsrc/leddevice/LedDeviceWS281x.cpp b/libsrc/leddevice/LedDeviceWS281x.cpp index 10b5d2e0..b8ea8822 100644 --- a/libsrc/leddevice/LedDeviceWS281x.cpp +++ b/libsrc/leddevice/LedDeviceWS281x.cpp @@ -3,13 +3,13 @@ #include "LedDeviceWS281x.h" // 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 invert) { initialized = false; led_string.freq = freq; led_string.dmanum = dmanum; led_string.channel[0].gpionum = gpio; - led_string.channel[0].invert = 0; + led_string.channel[0].invert = invert; led_string.channel[0].count = leds; led_string.channel[0].brightness = 255; led_string.channel[0].strip_type = WS2811_STRIP_RGB; diff --git a/libsrc/leddevice/LedDeviceWS281x.h b/libsrc/leddevice/LedDeviceWS281x.h index 429a092f..df8b1082 100644 --- a/libsrc/leddevice/LedDeviceWS281x.h +++ b/libsrc/leddevice/LedDeviceWS281x.h @@ -16,8 +16,9 @@ public: /// @param leds The number of leds attached to the gpio pin /// @param freq The target frequency for the data line, default is 800000 /// @param dmanum The DMA channel to use, default is 5 + /// @param invert Invert the output line to support an inverting level shifter /// - LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum); + LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int invert); /// /// Destructor of the LedDevice, waits for DMA to complete and then cleans up From 9280078cf007c3cd09aa30e50d3a9510bfb7895d Mon Sep 17 00:00:00 2001 From: penfold42 Date: Tue, 22 Mar 2016 23:24:34 +1100 Subject: [PATCH 2/5] Revert "Merge pull request #7 from tvdzwan/master" This reverts commit ae218b85ff084ce0f5a49f69e3684c486ad6bb42 [formerly b57904d64f0fbdd2e97f0326de4378489206e357], reversing changes made to cda2232080d6eefb0b2fa3c9e028c50023bac6b7 [formerly 6949fe847d9c4181c924a13ed0715ecd71b98499]. Former-commit-id: 0261bc7735663dba45681a5c0e4026b4c1fddeba --- CompileHowto.txt | 6 +- bin/create_all_releases.sh | 34 ++-- bin/create_oe_depedencies.sh | 4 +- bin/create_release.sh | 18 +- bin/{openelec => }/hyperion-remote.sh | 0 bin/{service => }/hyperion.init.sh | 0 bin/{service => }/hyperion.initctl.sh | 0 bin/{service => }/hyperion.systemd.sh | 0 bin/{openelec => }/hyperiond.sh | 0 bin/install_hyperion.sh | 18 +- bin/remove_hyperion.sh | 4 +- ...deps.openelec-x32x64.tar.gz.REMOVED.git-id | 1 - 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 | 1 + deploy/hyperion_x32x64.tar.gz.REMOVED.git-id | 1 - deploy/hyperion_x64.tar.gz.REMOVED.git-id | 1 + doc/datasheets/AtmoOrb_sample_config.json | 165 ------------------ libsrc/leddevice/CMakeLists.txt | 2 - libsrc/leddevice/LedDeviceAtmoOrb.cpp | 131 -------------- libsrc/leddevice/LedDeviceAtmoOrb.h | 129 -------------- libsrc/leddevice/LedDeviceFactory.cpp | 30 ---- 22 files changed, 44 insertions(+), 505 deletions(-) rename bin/{openelec => }/hyperion-remote.sh (100%) rename bin/{service => }/hyperion.init.sh (100%) rename bin/{service => }/hyperion.initctl.sh (100%) rename bin/{service => }/hyperion.systemd.sh (100%) rename bin/{openelec => }/hyperiond.sh (100%) delete mode 100644 deploy/hyperion.deps.openelec-x32x64.tar.gz.REMOVED.git-id create mode 100644 deploy/hyperion_x32.tar.gz.REMOVED.git-id delete mode 100644 deploy/hyperion_x32x64.tar.gz.REMOVED.git-id create mode 100644 deploy/hyperion_x64.tar.gz.REMOVED.git-id delete mode 100644 doc/datasheets/AtmoOrb_sample_config.json delete mode 100644 libsrc/leddevice/LedDeviceAtmoOrb.cpp delete mode 100644 libsrc/leddevice/LedDeviceAtmoOrb.h diff --git a/CompileHowto.txt b/CompileHowto.txt index da8f38c9..86ca1405 100644 --- a/CompileHowto.txt +++ b/CompileHowto.txt @@ -23,10 +23,8 @@ git submodule update mkdir "$HYPERION_DIR/build" cd "$HYPERION_DIR/build" -# run cmake to generate make files on the raspberry pi WITHOUT PWM SUPPORT +# run cmake to generate make files on the raspberry pi cmake -DCMAKE_BUILD_TYPE=Release -Wno-dev .. -# 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 .. # 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 -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 @@ -46,7 +44,7 @@ cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_V4L2=OFF -DENABLE_OSX=O make # or if you have a system with more then 1 cpu core make -j 4 -# "4" is the number of cpu cores (e.g. 4 on RPi2 and RPi3), this makes compile faster +# "4" is the number of cpu cores (e.g. 4 on RPi2), this makes compile faster #after compile, to remove any stuff not needed for a release version. strip bin/* diff --git a/bin/create_all_releases.sh b/bin/create_all_releases.sh index 9f969cef..99aba774 100644 --- a/bin/create_all_releases.sh +++ b/bin/create_all_releases.sh @@ -1,43 +1,43 @@ #!/bin/sh # create all directly for release with -DCMAKE_BUILD_TYPE=Release -Wno-dev # Create the x64 build -mkdir build-x32x64 -cd build-x32x64 +mkdir build-x64 +cd build-x64 cmake -DENABLE_DISPMANX=OFF -DENABLE_X11=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. 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 -DCMAKE_BUILD_TYPE=Release -Wno-dev .. -#make -j 4 -#cd .. +mkdir build-x32 +cd build-x32 +cmake -DIMPORT_PROTOC=../build-x64/protoc_export.cmake -DENABLE_DISPMANX=OFF -DENABLE_X11=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. +make -j 4 +cd .. # Create the RPI build mkdir build-rpi cd build-rpi -cmake -DCMAKE_TOOLCHAIN_FILE="../Toolchain-rpi.cmake" -DIMPORT_PROTOC=../build-x32x64/protoc_export.cmake -DENABLE_WS2812BPWM=ON -DENABLE_WS281XPWM=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. +cmake -DCMAKE_TOOLCHAIN_FILE="../Toolchain-rpi.cmake" -DIMPORT_PROTOC=../build-x64/protoc_export.cmake -DCMAKE_BUILD_TYPE=Release -Wno-dev .. make -j 4 cd .. # Create the WETEK build mkdir build-wetek cd build-wetek -cmake -DCMAKE_TOOLCHAIN_FILE="../Toolchain-rpi.cmake" -DIMPORT_PROTOC=../build-x32x64/protoc_export.cmake -DENABLE_DISPMANX=OFF -DENABLE_FB=ON -DENABLE_AMLOGIC=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. +cmake -DCMAKE_TOOLCHAIN_FILE="../Toolchain-rpi.cmake" -DIMPORT_PROTOC=../build-x64/protoc_export.cmake -DENABLE_DISPMANX=OFF -DENABLE_FB=ON -DENABLE_AMLOGIC=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. make -j 4 cd .. # Create the IMX6 build -#mkdir build-imx6 -#cd build-imx6 -#cmake -DCMAKE_TOOLCHAIN_FILE="../Toolchain-imx6.cmake" -DIMPORT_PROTOC=../build-x32x64/protoc_export.cmake -DENABLE_DISPMANX=OFF -DENABLE_FB=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. -#make -j 4 -#cd .. +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 -DCMAKE_BUILD_TYPE=Release -Wno-dev .. +make -j 4 +cd .. -bin/create_release.sh . x32x64 -#bin/create_release.sh . x32 +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 +bin/create_release.sh . imx6 diff --git a/bin/create_oe_depedencies.sh b/bin/create_oe_depedencies.sh index dd2883e4..288c5ee9 100644 --- a/bin/create_oe_depedencies.sh +++ b/bin/create_oe_depedencies.sh @@ -22,6 +22,6 @@ tar --create --verbose --gzip --absolute-names --show-transformed-names --derefe "$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" \ - "./openelec/hyperiond.sh" \ - "./openelec/hyperion-remote.sh" + "./hyperiond.sh" \ + "./hyperion-remote.sh" diff --git a/bin/create_release.sh b/bin/create_release.sh index 7eb07bb8..c44fb5c5 100644 --- a/bin/create_release.sh +++ b/bin/create_release.sh @@ -18,23 +18,23 @@ fi outfile="$repodir/deploy/hyperion_$buildid.tar.gz" echo create $outfile -tar --create --gzip --absolute-names --show-transformed-names --ignore-failed-read\ +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/service/hyperion.init.sh:hyperion/init.d/hyperion.init.sh:" \ - --transform "s:$repodir/bin/service/hyperion.systemd.sh:hyperion/init.d/hyperion.systemd.sh:" \ - --transform "s:$repodir/bin/service/hyperion.initctl.sh:hyperion/init.d/hyperion.initctl.sh:" \ + --transform "s:$repodir/bin/hyperion.init.sh:hyperion/init.d/hyperion.init.sh:" \ + --transform "s:$repodir/bin/hyperion.systemd.sh:hyperion/init.d/hyperion.systemd.sh:" \ + --transform "s:$repodir/bin/hyperion.initctl.sh:hyperion/init.d/hyperion.initctl.sh:" \ --transform "s://:/:g" \ "$builddir/bin/hyperiond" \ "$builddir/bin/hyperion-remote" \ "$builddir/bin/hyperion-v4l2" \ - "$builddir/bin/hyperion-x11" \ - "$builddir/bin/hyperion-dispmanx" \ + "$builddir/bin/gpio2spi" \ + "$builddir/bin/dispmanx2png" \ "$repodir/effects/"* \ - "$repodir/bin/service/hyperion.init.sh" \ - "$repodir/bin/service/hyperion.systemd.sh" \ - "$repodir/bin/service/hyperion.initctl.sh" \ + "$repodir/bin/hyperion.init.sh" \ + "$repodir/bin/hyperion.systemd.sh" \ + "$repodir/bin/hyperion.initctl.sh" \ "$repodir/config/hyperion.config.json" diff --git a/bin/openelec/hyperion-remote.sh b/bin/hyperion-remote.sh similarity index 100% rename from bin/openelec/hyperion-remote.sh rename to bin/hyperion-remote.sh diff --git a/bin/service/hyperion.init.sh b/bin/hyperion.init.sh similarity index 100% rename from bin/service/hyperion.init.sh rename to bin/hyperion.init.sh diff --git a/bin/service/hyperion.initctl.sh b/bin/hyperion.initctl.sh similarity index 100% rename from bin/service/hyperion.initctl.sh rename to bin/hyperion.initctl.sh diff --git a/bin/service/hyperion.systemd.sh b/bin/hyperion.systemd.sh similarity index 100% rename from bin/service/hyperion.systemd.sh rename to bin/hyperion.systemd.sh diff --git a/bin/openelec/hyperiond.sh b/bin/hyperiond.sh similarity index 100% rename from bin/openelec/hyperiond.sh rename to bin/hyperiond.sh diff --git a/bin/install_hyperion.sh b/bin/install_hyperion.sh index 5bdc5c2a..0dbd2de1 100755 --- a/bin/install_hyperion.sh +++ b/bin/install_hyperion.sh @@ -31,10 +31,10 @@ OS_OSMC=`grep -m1 -c OSMC /etc/issue` CPU_RPI=`grep -m1 -c 'BCM2708\|BCM2709\|BCM2710' /proc/cpuinfo` CPU_IMX6=`grep -m1 -c i.MX6 /proc/cpuinfo` CPU_WETEK=`grep -m1 -c Amlogic /proc/cpuinfo` -CPU_X32X64=`uname -m | grep 'x86_32\|i686\|x86_64' | wc -l` -#CPU_X32=`uname -m | grep 'x86_32\|i686' | wc -l` +CPU_X64=`uname -m | grep x86_64 | wc -l` +CPU_X32=`uname -m | grep 'x86_32\|i686' | wc -l` # Check that we have a known configuration -if [ $CPU_RPI -ne 1 ] && [ $CPU_IMX6 -ne 1 ] && [ $CPU_WETEK -ne 1 ] && [ $CPU_X32X64 -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 '---> Critical Error: CPU information does not match any known releases -> abort' exit 1 fi @@ -117,12 +117,12 @@ elif [ $CPU_IMX6 -eq 1 ]; then 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_X32X64 -eq 1 ]; then - HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_x32x64.tar.gz - OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-x32x64.tar.gz -#elif [ $CPU_X32 -eq 1 ]; then -# HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_x32.tar.gz -# OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-x32x64.tar.gz +elif [ $CPU_X64 -eq 1 ]; then + HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_x64.tar.gz + OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-rpi.tar.gz +elif [ $CPU_X32 -eq 1 ]; then + HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_x32.tar.gz + OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-rpi.tar.gz else echo "---> Critical Error: Target platform unknown -> abort" exit 1 diff --git a/bin/remove_hyperion.sh b/bin/remove_hyperion.sh index 1b56b84c..2b0c2788 100644 --- a/bin/remove_hyperion.sh +++ b/bin/remove_hyperion.sh @@ -64,7 +64,7 @@ fi #Disabling and delete service files if [ $USE_INITCTL -eq 1 ]; then echo '---> Delete and disable Hyperion initctl script' - rm -v /etc/init/hyperion.conf 2>/dev/null + rm -v /etc/init/hyperion 2>/dev/null initctl reload-configuration elif [ $OS_OPENELEC -eq 1 ]; then # Remove Hyperion from OpenELEC autostart.sh @@ -94,8 +94,6 @@ else rm -v /usr/bin/hyperiond 2>/dev/null rm -v /usr/bin/hyperion-remote 2>/dev/null rm -v /usr/bin/hyperion-v4l2 2>/dev/null - rm -v /usr/bin/hyperion-dispmanx 2>/dev/null - rm -v /usr/bin/hyperion-x11 2>/dev/null rm -v /etc/hyperion.config.json 2>/dev/null echo "---> Remove binaries" rm -rv /opt/hyperion 2>/dev/null diff --git a/deploy/hyperion.deps.openelec-x32x64.tar.gz.REMOVED.git-id b/deploy/hyperion.deps.openelec-x32x64.tar.gz.REMOVED.git-id deleted file mode 100644 index 2a663519..00000000 --- a/deploy/hyperion.deps.openelec-x32x64.tar.gz.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -e55dbd6444d070f519115e83e4fda96b6911e5db \ 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 df62cd1b..eee1ea4c 100644 --- a/deploy/hyperion_rpi.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_rpi.tar.gz.REMOVED.git-id @@ -1 +1 @@ -63bda72fdb3fb504564f067795f74e9b45eb99ba \ No newline at end of file +6465f4220aa1a8b4bdfed82492bf3ed079f586c4 \ 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 9cc7dee0..01df1168 100644 --- a/deploy/hyperion_wetek.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_wetek.tar.gz.REMOVED.git-id @@ -1 +1 @@ -03e78585af86a18889ecd1d8b910d76155608cd6 \ No newline at end of file +752ebb4ffc19892d1c99af0993913eb922195e38 \ 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..cb027877 --- /dev/null +++ b/deploy/hyperion_x32.tar.gz.REMOVED.git-id @@ -0,0 +1 @@ +f7b19344829d6df11bd624bbf722a5d8ec6b1dbe \ No newline at end of file diff --git a/deploy/hyperion_x32x64.tar.gz.REMOVED.git-id b/deploy/hyperion_x32x64.tar.gz.REMOVED.git-id deleted file mode 100644 index d2485017..00000000 --- a/deploy/hyperion_x32x64.tar.gz.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -9a00f3dc5684cab0fede56348df91c046634ff11 \ 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..0f7275da --- /dev/null +++ b/deploy/hyperion_x64.tar.gz.REMOVED.git-id @@ -0,0 +1 @@ +294f14bdc79d9d8306432681bf3c8468a4097a48 \ No newline at end of file diff --git a/doc/datasheets/AtmoOrb_sample_config.json b/doc/datasheets/AtmoOrb_sample_config.json deleted file mode 100644 index 1c81790a..00000000 --- a/doc/datasheets/AtmoOrb_sample_config.json +++ /dev/null @@ -1,165 +0,0 @@ -// Automatically generated configuration file for 'Hyperion daemon' -// Generated by: HyperCon (The Hyperion deamon configuration file builder) -// Created with HyperCon V1.00.0 (11.03.2016) - -{ - /// Device configuration contains the following fields: - /// * 'name' : The user friendly name of the device (only used for display purposes) - /// * 'type' : The type of the device or leds (known types for now are - /// APA102, Adalight, AdalightAPA102, AmbiLed, Atmo, Hyperion-USBASP-WS2801, Hyperion-USBASP-WS2812, Lightberry, Lightpack, LPD6803, LPD8806, Multi-Lightpack, P9813, Paintpack, PhilipsHUE, PiBlaster, SEDU, Test, ThinkerForge, TPM2, WS2801, WS2812b, None) - /// * [device type specific configuration] - /// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.). - /// - /// * 'Specific for AtmoOrb: - /// * 'transitiontime' : Set the time of transition between color of Orb (not implemented) - /// * 'port' : Multicast UDP port - /// * 'numLeds' : Number of leds in Orb - /// * 'orbIds' : The Orb ids to use - /// * 'switchOffOnBlack': Define if Orb is to switch off when black is detected - "device" : - { - "name" : "MyPi", - "type" : "atmoorb", - "output" : "239.15.18.2", - "transitiontime" : 0, - "port" : 49692, - "numLeds" : 24, - "orbIds" : "1", - "switchOffOnBlack" : true, - "colorOrder" : "rgb" - }, - - /// Color manipulation configuration used to tune the output colors to specific surroundings. - /// The configuration contains a list of color-transforms. Each transform contains the - /// following fields: - /// * 'id' : The unique identifier of the color transformation (eg 'device_1') /// * 'leds' : The indices (or index ranges) of the leds to which this color transform applies - /// (eg '0-5, 9, 11, 12-17'). The indices are zero based. /// * 'hsv' : The manipulation in the Hue-Saturation-Value color domain with the following - /// tuning parameters: - /// - 'saturationGain' The gain adjustement of the saturation - /// - 'valueGain' The gain adjustement of the value - /// * 'red'/'green'/'blue' : The manipulation in the Red-Green-Blue color domain with the - /// following tuning parameters for each channel: - /// - 'threshold' The minimum required input value for the channel to be on - /// (else zero) - /// - 'gamma' The gamma-curve correction factor - /// - 'blacklevel' The lowest possible value (when the channel is black) - /// - 'whitelevel' The highest possible value (when the channel is white) - /// - /// Next to the list with color transforms there is also a smoothing option. - /// * 'smoothing' : Smoothing of the colors in the time-domain with the following tuning - /// parameters: - /// - 'type' The type of smoothing algorithm ('linear' or 'none') - /// - 'time_ms' The time constant for smoothing algorithm in milliseconds - /// - 'updateFrequency' The update frequency of the leds in Hz - /// - 'updateDelay' The delay of the output to leds (in periods of smoothing) - "color" : - { - "transform" : - [ - { - "id" : "default", - "leds" : "*", - "hsv" : - { - "saturationGain" : 1.0000, - "valueGain" : 1.0000 - }, - "red" : - { - "threshold" : 0.0000, - "gamma" : 2.2000, - "blacklevel" : 0.0000, - "whitelevel" : 1.0000 - }, - "green" : - { - "threshold" : 0.0000, - "gamma" : 2.2000, - "blacklevel" : 0.0000, - "whitelevel" : 1.0000 - }, - "blue" : - { - "threshold" : 0.0000, - "gamma" : 2.2000, - "blacklevel" : 0.0000, - "whitelevel" : 1.0000 - } - } - ], - "smoothing" : - { - "type" : "linear", - "time_ms" : 100, - "updateFrequency" : 60.0000, - "updateDelay" : 0 - } - }, - - /// The black border configuration, contains the following items: - /// * enable : true if the detector should be activated - /// * threshold : Value below which a pixel is regarded as black (value between 0.0 and 1.0) - /// * unknownFrameCnt : Number of frames without any detection before the border is set to 0 (default 600) - /// * borderFrameCnt : Number of frames before a consistent detected border gets set (default 50) - /// * maxInconsistentCnt : Number of inconsistent frames that are ignored before a new border gets a chance to proof consistency - /// * blurRemoveCnt : Number of pixels that get removed from the detected border to cut away blur (default 1) - /// * mode : Border detection mode (values=default,classic,osd) - "blackborderdetector" : - { - "enable" : false, - "threshold" : 0.01, - "unknownFrameCnt" : 600, - "borderFrameCnt" : 50, - "maxInconsistentCnt" : 10, - "blurRemoveCnt" : 1, - "mode" : "default" - }, - - /// The configuration of the effect engine, contains the following items: - /// * paths : An array with absolute location(s) of directories with effects - /// * color : Set static color after boot -> set effect to "" (empty) and input the values [R,G,B] and set duration_ms NOT to 0 (use 1) instead - /// * effect : The effect selected as 'boot sequence' - /// * duration_ms : The duration of the selected effect (0=endless) - /// * priority : The priority of the selected effect/static color (default=990) HINT: lower value result in HIGHER priority! - "effects" : - { - "paths" : - [ - "/opt/hyperion/effects" - ] - }, - - /// The configuration of the Json server which enables the json remote interface - /// * port : Port at which the json server is started - "jsonServer" : - { - "port" : 19446 - }, - - /// The configuration of the Proto server which enables the protobuffer remote interface - /// * port : Port at which the protobuffer server is started - "protoServer" : - { - "port" : 19447 - }, - - /// The configuration for each individual led. This contains the specification of the area - /// averaged of an input image for each led to determine its color. Each item in the list - /// contains the following fields: - /// * index: The index of the led. This determines its location in the string of leds; zero - /// being the first led. - /// * hscan: The fractional part of the image along the horizontal used for the averaging - /// (minimum and maximum inclusive) - /// * vscan: The fractional part of the image along the vertical used for the averaging - /// (minimum and maximum inclusive) - "leds" : - [ - { - "index" : 0, - "hscan" : { "minimum" : 0.0000, "maximum" : 1.0000 }, - "vscan" : { "minimum" : 0.0000, "maximum" : 1.0000 } - } - ], - - "endOfJson" : "endOfJson" -} \ No newline at end of file diff --git a/libsrc/leddevice/CMakeLists.txt b/libsrc/leddevice/CMakeLists.txt index 66d61efd..da1251ca 100755 --- a/libsrc/leddevice/CMakeLists.txt +++ b/libsrc/leddevice/CMakeLists.txt @@ -17,7 +17,6 @@ SET(Leddevice_QT_HEADERS ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.h ${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.h - ${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.h ${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h ${CURRENT_SOURCE_DIR}/LedHIDDevice.h ${CURRENT_SOURCE_DIR}/LedDeviceRawHID.h @@ -51,7 +50,6 @@ SET(Leddevice_SOURCES ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.cpp - ${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.cpp ${CURRENT_SOURCE_DIR}/LedDeviceRawHID.cpp ${CURRENT_SOURCE_DIR}/LedDeviceLightpack.cpp ${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.cpp diff --git a/libsrc/leddevice/LedDeviceAtmoOrb.cpp b/libsrc/leddevice/LedDeviceAtmoOrb.cpp deleted file mode 100644 index 4ef3486d..00000000 --- a/libsrc/leddevice/LedDeviceAtmoOrb.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Local-Hyperion includes -#include "LedDeviceAtmoOrb.h" - -// qt includes -#include -#include -#include -#include - -#include -#include -#include - -AtmoOrbLight::AtmoOrbLight(unsigned int id) { - // Not implemented -} - -LedDeviceAtmoOrb::LedDeviceAtmoOrb(const std::string &output, bool switchOffOnBlack, - int transitiontime, int port, int numLeds, std::vector orbIds) : - multicastGroup(output.c_str()), switchOffOnBlack(switchOffOnBlack), transitiontime(transitiontime), - multiCastGroupPort(port), numLeds(numLeds), orbIds(orbIds) { - manager = new QNetworkAccessManager(); - groupAddress = QHostAddress(multicastGroup); - - udpSocket = new QUdpSocket(this); - udpSocket->bind(multiCastGroupPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); - - joinedMulticastgroup = udpSocket->joinMulticastGroup(groupAddress); -} - -int LedDeviceAtmoOrb::write(const std::vector &ledValues) { - - // If not in multicast group return - if (!joinedMulticastgroup) { - return 0; - } - - // Iterate through colors and set Orb color - // Start off with idx 1 as 0 is reserved for controlling all orbs at once - unsigned int idx = 1; - for (const ColorRgb &color : ledValues) { - // Options parameter: - // - // 1 = force off - // 2 = use lamp smoothing and validate by Orb ID - // 4 = validate by Orb ID - // - - if (switchOffOnBlack && color.red == 0 && color.green == 0 && color.blue == 0) { - // Force to black - for (unsigned int i = 0; i < orbIds.size(); i++) { - if (orbIds[i] == idx) { - setColor(idx, color, 1); - } - } - } - else { - // Default send color - for (unsigned int i = 0; i < orbIds.size(); i++) { - if (orbIds[i] == idx) { - setColor(idx, color, 4); - } - } - } - - // Next light id. - idx++; - } - return 0; -} - -void LedDeviceAtmoOrb::setColor(unsigned int orbId, const ColorRgb &color, int commandType) { - QByteArray bytes; - bytes.resize(5 + numLeds * 3); - bytes.fill('\0'); - - // Command identifier: C0FFEE - bytes[0] = 0xC0; - bytes[1] = 0xFF; - bytes[2] = 0xEE; - - // Command type - bytes[3] = 2; - - // Orb ID - bytes[4] = orbId; - - // RED / GREEN / BLUE - bytes[5] = color.red; - bytes[6] = color.green; - bytes[7] = color.blue; - - sendCommand(bytes); -} - -void LedDeviceAtmoOrb::sendCommand(const QByteArray &bytes) { - QByteArray datagram = bytes; - udpSocket->writeDatagram(datagram.data(), datagram.size(), - groupAddress, multiCastGroupPort); -} - -int LedDeviceAtmoOrb::switchOff() { - for (unsigned int i = 0; i < orbIds.size(); i++) { - QByteArray bytes; - bytes.resize(5 + numLeds * 3); - bytes.fill('\0'); - - // Command identifier: C0FFEE - bytes[0] = 0xC0; - bytes[1] = 0xFF; - bytes[2] = 0xEE; - - // Command type - bytes[3] = 1; - - // Orb ID - bytes[4] = orbIds[i]; - - // RED / GREEN / BLUE - bytes[5] = 0; - bytes[6] = 0; - bytes[7] = 0; - - sendCommand(bytes); - } - return 0; -} - -LedDeviceAtmoOrb::~LedDeviceAtmoOrb() { - delete manager; -} \ No newline at end of file diff --git a/libsrc/leddevice/LedDeviceAtmoOrb.h b/libsrc/leddevice/LedDeviceAtmoOrb.h deleted file mode 100644 index d425b06a..00000000 --- a/libsrc/leddevice/LedDeviceAtmoOrb.h +++ /dev/null @@ -1,129 +0,0 @@ -#pragma once - -// STL includes -#include - -// Qt includes -#include -#include -#include -#include - -// Leddevice includes -#include - -class QUdpSocket; - -class AtmoOrbLight { -public: - unsigned int id; - - /// - /// Constructs the light. - /// - /// @param id the orb id - AtmoOrbLight(unsigned int id); -}; - -/** - * Implementation for the AtmoOrb - * - * To use set the device to "atmoorb". - * - * @author RickDB (github) - */ -class LedDeviceAtmoOrb : public QObject, public LedDevice { - Q_OBJECT -public: - // Last color sent - int lastRed; - int lastGreen; - int lastBlue; - - // Multicast status - bool joinedMulticastgroup; - - /// - /// Constructs the device. - /// - /// @param output is the multicast address of Orbs - /// - /// @param switchOffOnBlack turn off Orbs on black (default: false) - /// - /// @param transitiontime is optional and not used at the moment - /// - /// @param port is the multicast port. - /// - /// @param numLeds is the total amount of leds per Orb - /// - /// @param array containing orb ids - /// - LedDeviceAtmoOrb(const std::string &output, bool switchOffOnBlack = - false, int transitiontime = 0, int port = 49692, int numLeds = 24, - std::vector orbIds = std::vector < unsigned int - - >()); - - /// - /// Destructor of this device - /// - virtual ~LedDeviceAtmoOrb(); - - /// - /// Sends the given led-color values to the Orbs - /// - /// @param ledValues The color-value per led - /// - /// @return Zero on success else negative - /// - virtual int write(const std::vector &ledValues); - - virtual int switchOff(); - -private: - /// QNetworkAccessManager object for sending requests. - QNetworkAccessManager *manager; - - /// String containing multicast group IP address - QString multicastGroup; - - /// Switch off when detecting black - bool switchOffOnBlack; - - /// Transition time between colors (not implemented) - int transitiontime; - - /// Multicast port to send data to - int multiCastGroupPort; - - /// Number of leds in Orb, used to determine buffer size - int numLeds; - - /// QHostAddress object of multicast group IP address - QHostAddress groupAddress; - - /// QUdpSocket object used to send data over - QUdpSocket *udpSocket; - - /// Array of the orb ids. - std::vector orbIds; - - /// - /// Set Orbcolor - /// - /// @param orbId the orb id - /// - /// @param color which color to set - /// - /// - /// @param commandType which type of command to send (off / smoothing / etc..) - /// - void setColor(unsigned int orbId, const ColorRgb &color, int commandType); - - /// - /// Send Orb command - /// - /// @param bytes the byte array containing command to send over multicast - /// - void sendCommand(const QByteArray &bytes); -}; diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index 8ba6a9d3..f3c2f4e5 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -37,7 +37,6 @@ #include "LedDeviceTpm2.h" #include "LedDeviceAtmo.h" #include "LedDeviceAdalightApa102.h" -#include "LedDeviceAtmoOrb.h" #ifdef ENABLE_WS2812BPWM #include "LedDeviceWS2812b.h" @@ -246,35 +245,6 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) } device = new LedDevicePhilipsHue(output, username, switchOffOnBlack, transitiontime, lightIds); } - else if (type == "atmoorb") - { - const std::string output = deviceConfig["output"].asString(); - const bool switchOffOnBlack = deviceConfig.get("switchOffOnBlack", true).asBool(); - const int transitiontime = deviceConfig.get("transitiontime", 1).asInt(); - const int port = deviceConfig.get("port", 1).asInt(); - const int numLeds = deviceConfig.get("numLeds", 1).asInt(); - const std::string orbId = deviceConfig["orbIds"].asString(); - std::vector orbIds; - - // If we find multiple Orb ids separate them and add to list - const std::string separator (","); - if (orbId.find(separator) != std::string::npos) { - std::stringstream ss(orbId); - std::vector output; - unsigned int i; - while (ss >> i) { - orbIds.push_back(i); - if (ss.peek() == ',' || ss.peek() == ' ') - ss.ignore(); - } - } - else - { - orbIds.push_back(atoi(orbId.c_str())); - } - - device = new LedDeviceAtmoOrb(output, switchOffOnBlack, transitiontime, port, numLeds, orbIds); - } else if (type == "test") { const std::string output = deviceConfig["output"].asString(); From ff2a1038a0462c476a86afb3a26022c6596854ab Mon Sep 17 00:00:00 2001 From: penfold42 Date: Tue, 22 Mar 2016 23:28:04 +1100 Subject: [PATCH 3/5] Revert "Revert "Merge pull request #7 from tvdzwan/master"" This reverts commit 9280078cf007c3cd09aa30e50d3a9510bfb7895d [formerly 0261bc7735663dba45681a5c0e4026b4c1fddeba]. Former-commit-id: e2850cd34a48bcccaa887a33ff7bf06e0a25c904 --- CompileHowto.txt | 6 +- bin/create_all_releases.sh | 34 ++-- bin/create_oe_depedencies.sh | 4 +- bin/create_release.sh | 18 +- bin/install_hyperion.sh | 18 +- bin/{ => openelec}/hyperion-remote.sh | 0 bin/{ => openelec}/hyperiond.sh | 0 bin/remove_hyperion.sh | 4 +- bin/{ => service}/hyperion.init.sh | 0 bin/{ => service}/hyperion.initctl.sh | 0 bin/{ => service}/hyperion.systemd.sh | 0 ...deps.openelec-x32x64.tar.gz.REMOVED.git-id | 1 + 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 | 1 - deploy/hyperion_x32x64.tar.gz.REMOVED.git-id | 1 + deploy/hyperion_x64.tar.gz.REMOVED.git-id | 1 - doc/datasheets/AtmoOrb_sample_config.json | 165 ++++++++++++++++++ libsrc/leddevice/CMakeLists.txt | 2 + libsrc/leddevice/LedDeviceAtmoOrb.cpp | 131 ++++++++++++++ libsrc/leddevice/LedDeviceAtmoOrb.h | 129 ++++++++++++++ libsrc/leddevice/LedDeviceFactory.cpp | 30 ++++ 22 files changed, 505 insertions(+), 44 deletions(-) rename bin/{ => openelec}/hyperion-remote.sh (100%) rename bin/{ => openelec}/hyperiond.sh (100%) rename bin/{ => service}/hyperion.init.sh (100%) rename bin/{ => service}/hyperion.initctl.sh (100%) rename bin/{ => service}/hyperion.systemd.sh (100%) create mode 100644 deploy/hyperion.deps.openelec-x32x64.tar.gz.REMOVED.git-id delete mode 100644 deploy/hyperion_x32.tar.gz.REMOVED.git-id create mode 100644 deploy/hyperion_x32x64.tar.gz.REMOVED.git-id delete mode 100644 deploy/hyperion_x64.tar.gz.REMOVED.git-id create mode 100644 doc/datasheets/AtmoOrb_sample_config.json create mode 100644 libsrc/leddevice/LedDeviceAtmoOrb.cpp create mode 100644 libsrc/leddevice/LedDeviceAtmoOrb.h diff --git a/CompileHowto.txt b/CompileHowto.txt index 86ca1405..da8f38c9 100644 --- a/CompileHowto.txt +++ b/CompileHowto.txt @@ -23,8 +23,10 @@ git submodule update mkdir "$HYPERION_DIR/build" cd "$HYPERION_DIR/build" -# run cmake to generate make files on the raspberry pi +# run cmake to generate make files on the raspberry pi WITHOUT PWM SUPPORT cmake -DCMAKE_BUILD_TYPE=Release -Wno-dev .. +# 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 .. # 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 -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 @@ -44,7 +46,7 @@ cmake -DENABLE_DISPMANX=OFF -DENABLE_SPIDEV=OFF -DENABLE_V4L2=OFF -DENABLE_OSX=O make # or if you have a system with more then 1 cpu core make -j 4 -# "4" is the number of cpu cores (e.g. 4 on RPi2), this makes compile faster +# "4" is the number of cpu cores (e.g. 4 on RPi2 and RPi3), this makes compile faster #after compile, to remove any stuff not needed for a release version. strip bin/* diff --git a/bin/create_all_releases.sh b/bin/create_all_releases.sh index 99aba774..9f969cef 100644 --- a/bin/create_all_releases.sh +++ b/bin/create_all_releases.sh @@ -1,43 +1,43 @@ #!/bin/sh # create all directly for release with -DCMAKE_BUILD_TYPE=Release -Wno-dev # Create the x64 build -mkdir build-x64 -cd build-x64 +mkdir build-x32x64 +cd build-x32x64 cmake -DENABLE_DISPMANX=OFF -DENABLE_X11=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. 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 -DCMAKE_BUILD_TYPE=Release -Wno-dev .. -make -j 4 -cd .. +#mkdir build-x32 +#cd build-x32 +#cmake -DIMPORT_PROTOC=../build-x64/protoc_export.cmake -DENABLE_DISPMANX=OFF -DENABLE_X11=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. +#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 -DCMAKE_BUILD_TYPE=Release -Wno-dev .. +cmake -DCMAKE_TOOLCHAIN_FILE="../Toolchain-rpi.cmake" -DIMPORT_PROTOC=../build-x32x64/protoc_export.cmake -DENABLE_WS2812BPWM=ON -DENABLE_WS281XPWM=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. 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 -DCMAKE_BUILD_TYPE=Release -Wno-dev .. +cmake -DCMAKE_TOOLCHAIN_FILE="../Toolchain-rpi.cmake" -DIMPORT_PROTOC=../build-x32x64/protoc_export.cmake -DENABLE_DISPMANX=OFF -DENABLE_FB=ON -DENABLE_AMLOGIC=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. 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 -DCMAKE_BUILD_TYPE=Release -Wno-dev .. -make -j 4 -cd .. +#mkdir build-imx6 +#cd build-imx6 +#cmake -DCMAKE_TOOLCHAIN_FILE="../Toolchain-imx6.cmake" -DIMPORT_PROTOC=../build-x32x64/protoc_export.cmake -DENABLE_DISPMANX=OFF -DENABLE_FB=ON -DCMAKE_BUILD_TYPE=Release -Wno-dev .. +#make -j 4 +#cd .. -bin/create_release.sh . x64 -bin/create_release.sh . x32 +bin/create_release.sh . x32x64 +#bin/create_release.sh . x32 bin/create_release.sh . rpi bin/create_release.sh . wetek -bin/create_release.sh . imx6 +#bin/create_release.sh . imx6 diff --git a/bin/create_oe_depedencies.sh b/bin/create_oe_depedencies.sh index 288c5ee9..dd2883e4 100644 --- a/bin/create_oe_depedencies.sh +++ b/bin/create_oe_depedencies.sh @@ -22,6 +22,6 @@ tar --create --verbose --gzip --absolute-names --show-transformed-names --derefe "$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" + "./openelec/hyperiond.sh" \ + "./openelec/hyperion-remote.sh" diff --git a/bin/create_release.sh b/bin/create_release.sh index c44fb5c5..7eb07bb8 100644 --- a/bin/create_release.sh +++ b/bin/create_release.sh @@ -18,23 +18,23 @@ fi outfile="$repodir/deploy/hyperion_$buildid.tar.gz" echo create $outfile -tar --create --verbose --gzip --absolute-names --show-transformed-names --ignore-failed-read\ +tar --create --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:$repodir/bin/hyperion.systemd.sh:hyperion/init.d/hyperion.systemd.sh:" \ - --transform "s:$repodir/bin/hyperion.initctl.sh:hyperion/init.d/hyperion.initctl.sh:" \ + --transform "s:$repodir/bin/service/hyperion.init.sh:hyperion/init.d/hyperion.init.sh:" \ + --transform "s:$repodir/bin/service/hyperion.systemd.sh:hyperion/init.d/hyperion.systemd.sh:" \ + --transform "s:$repodir/bin/service/hyperion.initctl.sh:hyperion/init.d/hyperion.initctl.sh:" \ --transform "s://:/:g" \ "$builddir/bin/hyperiond" \ "$builddir/bin/hyperion-remote" \ "$builddir/bin/hyperion-v4l2" \ - "$builddir/bin/gpio2spi" \ - "$builddir/bin/dispmanx2png" \ + "$builddir/bin/hyperion-x11" \ + "$builddir/bin/hyperion-dispmanx" \ "$repodir/effects/"* \ - "$repodir/bin/hyperion.init.sh" \ - "$repodir/bin/hyperion.systemd.sh" \ - "$repodir/bin/hyperion.initctl.sh" \ + "$repodir/bin/service/hyperion.init.sh" \ + "$repodir/bin/service/hyperion.systemd.sh" \ + "$repodir/bin/service/hyperion.initctl.sh" \ "$repodir/config/hyperion.config.json" diff --git a/bin/install_hyperion.sh b/bin/install_hyperion.sh index 0dbd2de1..5bdc5c2a 100755 --- a/bin/install_hyperion.sh +++ b/bin/install_hyperion.sh @@ -31,10 +31,10 @@ OS_OSMC=`grep -m1 -c OSMC /etc/issue` CPU_RPI=`grep -m1 -c 'BCM2708\|BCM2709\|BCM2710' /proc/cpuinfo` CPU_IMX6=`grep -m1 -c i.MX6 /proc/cpuinfo` CPU_WETEK=`grep -m1 -c Amlogic /proc/cpuinfo` -CPU_X64=`uname -m | grep x86_64 | wc -l` -CPU_X32=`uname -m | grep 'x86_32\|i686' | wc -l` +CPU_X32X64=`uname -m | grep 'x86_32\|i686\|x86_64' | wc -l` +#CPU_X32=`uname -m | grep 'x86_32\|i686' | 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_X32X64 -ne 1 ]; then echo '---> Critical Error: CPU information does not match any known releases -> abort' exit 1 fi @@ -117,12 +117,12 @@ elif [ $CPU_IMX6 -eq 1 ]; then 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-rpi.tar.gz -elif [ $CPU_X32 -eq 1 ]; then - HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_x32.tar.gz - OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-rpi.tar.gz +elif [ $CPU_X32X64 -eq 1 ]; then + HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_x32x64.tar.gz + OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-x32x64.tar.gz +#elif [ $CPU_X32 -eq 1 ]; then +# HYPERION_RELEASE=$HYPERION_ADDRESS/hyperion_x32.tar.gz +# OE_DEPENDECIES=$HYPERION_ADDRESS/hyperion.deps.openelec-x32x64.tar.gz else echo "---> Critical Error: Target platform unknown -> abort" exit 1 diff --git a/bin/hyperion-remote.sh b/bin/openelec/hyperion-remote.sh similarity index 100% rename from bin/hyperion-remote.sh rename to bin/openelec/hyperion-remote.sh diff --git a/bin/hyperiond.sh b/bin/openelec/hyperiond.sh similarity index 100% rename from bin/hyperiond.sh rename to bin/openelec/hyperiond.sh diff --git a/bin/remove_hyperion.sh b/bin/remove_hyperion.sh index 2b0c2788..1b56b84c 100644 --- a/bin/remove_hyperion.sh +++ b/bin/remove_hyperion.sh @@ -64,7 +64,7 @@ fi #Disabling and delete service files if [ $USE_INITCTL -eq 1 ]; then echo '---> Delete and disable Hyperion initctl script' - rm -v /etc/init/hyperion 2>/dev/null + rm -v /etc/init/hyperion.conf 2>/dev/null initctl reload-configuration elif [ $OS_OPENELEC -eq 1 ]; then # Remove Hyperion from OpenELEC autostart.sh @@ -94,6 +94,8 @@ else rm -v /usr/bin/hyperiond 2>/dev/null rm -v /usr/bin/hyperion-remote 2>/dev/null rm -v /usr/bin/hyperion-v4l2 2>/dev/null + rm -v /usr/bin/hyperion-dispmanx 2>/dev/null + rm -v /usr/bin/hyperion-x11 2>/dev/null rm -v /etc/hyperion.config.json 2>/dev/null echo "---> Remove binaries" rm -rv /opt/hyperion 2>/dev/null diff --git a/bin/hyperion.init.sh b/bin/service/hyperion.init.sh similarity index 100% rename from bin/hyperion.init.sh rename to bin/service/hyperion.init.sh diff --git a/bin/hyperion.initctl.sh b/bin/service/hyperion.initctl.sh similarity index 100% rename from bin/hyperion.initctl.sh rename to bin/service/hyperion.initctl.sh diff --git a/bin/hyperion.systemd.sh b/bin/service/hyperion.systemd.sh similarity index 100% rename from bin/hyperion.systemd.sh rename to bin/service/hyperion.systemd.sh diff --git a/deploy/hyperion.deps.openelec-x32x64.tar.gz.REMOVED.git-id b/deploy/hyperion.deps.openelec-x32x64.tar.gz.REMOVED.git-id new file mode 100644 index 00000000..2a663519 --- /dev/null +++ b/deploy/hyperion.deps.openelec-x32x64.tar.gz.REMOVED.git-id @@ -0,0 +1 @@ +e55dbd6444d070f519115e83e4fda96b6911e5db \ 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 eee1ea4c..df62cd1b 100644 --- a/deploy/hyperion_rpi.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_rpi.tar.gz.REMOVED.git-id @@ -1 +1 @@ -6465f4220aa1a8b4bdfed82492bf3ed079f586c4 \ No newline at end of file +63bda72fdb3fb504564f067795f74e9b45eb99ba \ 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 01df1168..9cc7dee0 100644 --- a/deploy/hyperion_wetek.tar.gz.REMOVED.git-id +++ b/deploy/hyperion_wetek.tar.gz.REMOVED.git-id @@ -1 +1 @@ -752ebb4ffc19892d1c99af0993913eb922195e38 \ No newline at end of file +03e78585af86a18889ecd1d8b910d76155608cd6 \ 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 deleted file mode 100644 index cb027877..00000000 --- a/deploy/hyperion_x32.tar.gz.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -f7b19344829d6df11bd624bbf722a5d8ec6b1dbe \ No newline at end of file diff --git a/deploy/hyperion_x32x64.tar.gz.REMOVED.git-id b/deploy/hyperion_x32x64.tar.gz.REMOVED.git-id new file mode 100644 index 00000000..d2485017 --- /dev/null +++ b/deploy/hyperion_x32x64.tar.gz.REMOVED.git-id @@ -0,0 +1 @@ +9a00f3dc5684cab0fede56348df91c046634ff11 \ 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 deleted file mode 100644 index 0f7275da..00000000 --- a/deploy/hyperion_x64.tar.gz.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -294f14bdc79d9d8306432681bf3c8468a4097a48 \ No newline at end of file diff --git a/doc/datasheets/AtmoOrb_sample_config.json b/doc/datasheets/AtmoOrb_sample_config.json new file mode 100644 index 00000000..1c81790a --- /dev/null +++ b/doc/datasheets/AtmoOrb_sample_config.json @@ -0,0 +1,165 @@ +// Automatically generated configuration file for 'Hyperion daemon' +// Generated by: HyperCon (The Hyperion deamon configuration file builder) +// Created with HyperCon V1.00.0 (11.03.2016) + +{ + /// Device configuration contains the following fields: + /// * 'name' : The user friendly name of the device (only used for display purposes) + /// * 'type' : The type of the device or leds (known types for now are + /// APA102, Adalight, AdalightAPA102, AmbiLed, Atmo, Hyperion-USBASP-WS2801, Hyperion-USBASP-WS2812, Lightberry, Lightpack, LPD6803, LPD8806, Multi-Lightpack, P9813, Paintpack, PhilipsHUE, PiBlaster, SEDU, Test, ThinkerForge, TPM2, WS2801, WS2812b, None) + /// * [device type specific configuration] + /// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.). + /// + /// * 'Specific for AtmoOrb: + /// * 'transitiontime' : Set the time of transition between color of Orb (not implemented) + /// * 'port' : Multicast UDP port + /// * 'numLeds' : Number of leds in Orb + /// * 'orbIds' : The Orb ids to use + /// * 'switchOffOnBlack': Define if Orb is to switch off when black is detected + "device" : + { + "name" : "MyPi", + "type" : "atmoorb", + "output" : "239.15.18.2", + "transitiontime" : 0, + "port" : 49692, + "numLeds" : 24, + "orbIds" : "1", + "switchOffOnBlack" : true, + "colorOrder" : "rgb" + }, + + /// Color manipulation configuration used to tune the output colors to specific surroundings. + /// The configuration contains a list of color-transforms. Each transform contains the + /// following fields: + /// * 'id' : The unique identifier of the color transformation (eg 'device_1') /// * 'leds' : The indices (or index ranges) of the leds to which this color transform applies + /// (eg '0-5, 9, 11, 12-17'). The indices are zero based. /// * 'hsv' : The manipulation in the Hue-Saturation-Value color domain with the following + /// tuning parameters: + /// - 'saturationGain' The gain adjustement of the saturation + /// - 'valueGain' The gain adjustement of the value + /// * 'red'/'green'/'blue' : The manipulation in the Red-Green-Blue color domain with the + /// following tuning parameters for each channel: + /// - 'threshold' The minimum required input value for the channel to be on + /// (else zero) + /// - 'gamma' The gamma-curve correction factor + /// - 'blacklevel' The lowest possible value (when the channel is black) + /// - 'whitelevel' The highest possible value (when the channel is white) + /// + /// Next to the list with color transforms there is also a smoothing option. + /// * 'smoothing' : Smoothing of the colors in the time-domain with the following tuning + /// parameters: + /// - 'type' The type of smoothing algorithm ('linear' or 'none') + /// - 'time_ms' The time constant for smoothing algorithm in milliseconds + /// - 'updateFrequency' The update frequency of the leds in Hz + /// - 'updateDelay' The delay of the output to leds (in periods of smoothing) + "color" : + { + "transform" : + [ + { + "id" : "default", + "leds" : "*", + "hsv" : + { + "saturationGain" : 1.0000, + "valueGain" : 1.0000 + }, + "red" : + { + "threshold" : 0.0000, + "gamma" : 2.2000, + "blacklevel" : 0.0000, + "whitelevel" : 1.0000 + }, + "green" : + { + "threshold" : 0.0000, + "gamma" : 2.2000, + "blacklevel" : 0.0000, + "whitelevel" : 1.0000 + }, + "blue" : + { + "threshold" : 0.0000, + "gamma" : 2.2000, + "blacklevel" : 0.0000, + "whitelevel" : 1.0000 + } + } + ], + "smoothing" : + { + "type" : "linear", + "time_ms" : 100, + "updateFrequency" : 60.0000, + "updateDelay" : 0 + } + }, + + /// The black border configuration, contains the following items: + /// * enable : true if the detector should be activated + /// * threshold : Value below which a pixel is regarded as black (value between 0.0 and 1.0) + /// * unknownFrameCnt : Number of frames without any detection before the border is set to 0 (default 600) + /// * borderFrameCnt : Number of frames before a consistent detected border gets set (default 50) + /// * maxInconsistentCnt : Number of inconsistent frames that are ignored before a new border gets a chance to proof consistency + /// * blurRemoveCnt : Number of pixels that get removed from the detected border to cut away blur (default 1) + /// * mode : Border detection mode (values=default,classic,osd) + "blackborderdetector" : + { + "enable" : false, + "threshold" : 0.01, + "unknownFrameCnt" : 600, + "borderFrameCnt" : 50, + "maxInconsistentCnt" : 10, + "blurRemoveCnt" : 1, + "mode" : "default" + }, + + /// The configuration of the effect engine, contains the following items: + /// * paths : An array with absolute location(s) of directories with effects + /// * color : Set static color after boot -> set effect to "" (empty) and input the values [R,G,B] and set duration_ms NOT to 0 (use 1) instead + /// * effect : The effect selected as 'boot sequence' + /// * duration_ms : The duration of the selected effect (0=endless) + /// * priority : The priority of the selected effect/static color (default=990) HINT: lower value result in HIGHER priority! + "effects" : + { + "paths" : + [ + "/opt/hyperion/effects" + ] + }, + + /// The configuration of the Json server which enables the json remote interface + /// * port : Port at which the json server is started + "jsonServer" : + { + "port" : 19446 + }, + + /// The configuration of the Proto server which enables the protobuffer remote interface + /// * port : Port at which the protobuffer server is started + "protoServer" : + { + "port" : 19447 + }, + + /// The configuration for each individual led. This contains the specification of the area + /// averaged of an input image for each led to determine its color. Each item in the list + /// contains the following fields: + /// * index: The index of the led. This determines its location in the string of leds; zero + /// being the first led. + /// * hscan: The fractional part of the image along the horizontal used for the averaging + /// (minimum and maximum inclusive) + /// * vscan: The fractional part of the image along the vertical used for the averaging + /// (minimum and maximum inclusive) + "leds" : + [ + { + "index" : 0, + "hscan" : { "minimum" : 0.0000, "maximum" : 1.0000 }, + "vscan" : { "minimum" : 0.0000, "maximum" : 1.0000 } + } + ], + + "endOfJson" : "endOfJson" +} \ No newline at end of file diff --git a/libsrc/leddevice/CMakeLists.txt b/libsrc/leddevice/CMakeLists.txt index da1251ca..66d61efd 100755 --- a/libsrc/leddevice/CMakeLists.txt +++ b/libsrc/leddevice/CMakeLists.txt @@ -17,6 +17,7 @@ SET(Leddevice_QT_HEADERS ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.h ${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.h + ${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.h ${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h ${CURRENT_SOURCE_DIR}/LedHIDDevice.h ${CURRENT_SOURCE_DIR}/LedDeviceRawHID.h @@ -50,6 +51,7 @@ SET(Leddevice_SOURCES ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.cpp + ${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.cpp ${CURRENT_SOURCE_DIR}/LedDeviceRawHID.cpp ${CURRENT_SOURCE_DIR}/LedDeviceLightpack.cpp ${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.cpp diff --git a/libsrc/leddevice/LedDeviceAtmoOrb.cpp b/libsrc/leddevice/LedDeviceAtmoOrb.cpp new file mode 100644 index 00000000..4ef3486d --- /dev/null +++ b/libsrc/leddevice/LedDeviceAtmoOrb.cpp @@ -0,0 +1,131 @@ +// Local-Hyperion includes +#include "LedDeviceAtmoOrb.h" + +// qt includes +#include +#include +#include +#include + +#include +#include +#include + +AtmoOrbLight::AtmoOrbLight(unsigned int id) { + // Not implemented +} + +LedDeviceAtmoOrb::LedDeviceAtmoOrb(const std::string &output, bool switchOffOnBlack, + int transitiontime, int port, int numLeds, std::vector orbIds) : + multicastGroup(output.c_str()), switchOffOnBlack(switchOffOnBlack), transitiontime(transitiontime), + multiCastGroupPort(port), numLeds(numLeds), orbIds(orbIds) { + manager = new QNetworkAccessManager(); + groupAddress = QHostAddress(multicastGroup); + + udpSocket = new QUdpSocket(this); + udpSocket->bind(multiCastGroupPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); + + joinedMulticastgroup = udpSocket->joinMulticastGroup(groupAddress); +} + +int LedDeviceAtmoOrb::write(const std::vector &ledValues) { + + // If not in multicast group return + if (!joinedMulticastgroup) { + return 0; + } + + // Iterate through colors and set Orb color + // Start off with idx 1 as 0 is reserved for controlling all orbs at once + unsigned int idx = 1; + for (const ColorRgb &color : ledValues) { + // Options parameter: + // + // 1 = force off + // 2 = use lamp smoothing and validate by Orb ID + // 4 = validate by Orb ID + // + + if (switchOffOnBlack && color.red == 0 && color.green == 0 && color.blue == 0) { + // Force to black + for (unsigned int i = 0; i < orbIds.size(); i++) { + if (orbIds[i] == idx) { + setColor(idx, color, 1); + } + } + } + else { + // Default send color + for (unsigned int i = 0; i < orbIds.size(); i++) { + if (orbIds[i] == idx) { + setColor(idx, color, 4); + } + } + } + + // Next light id. + idx++; + } + return 0; +} + +void LedDeviceAtmoOrb::setColor(unsigned int orbId, const ColorRgb &color, int commandType) { + QByteArray bytes; + bytes.resize(5 + numLeds * 3); + bytes.fill('\0'); + + // Command identifier: C0FFEE + bytes[0] = 0xC0; + bytes[1] = 0xFF; + bytes[2] = 0xEE; + + // Command type + bytes[3] = 2; + + // Orb ID + bytes[4] = orbId; + + // RED / GREEN / BLUE + bytes[5] = color.red; + bytes[6] = color.green; + bytes[7] = color.blue; + + sendCommand(bytes); +} + +void LedDeviceAtmoOrb::sendCommand(const QByteArray &bytes) { + QByteArray datagram = bytes; + udpSocket->writeDatagram(datagram.data(), datagram.size(), + groupAddress, multiCastGroupPort); +} + +int LedDeviceAtmoOrb::switchOff() { + for (unsigned int i = 0; i < orbIds.size(); i++) { + QByteArray bytes; + bytes.resize(5 + numLeds * 3); + bytes.fill('\0'); + + // Command identifier: C0FFEE + bytes[0] = 0xC0; + bytes[1] = 0xFF; + bytes[2] = 0xEE; + + // Command type + bytes[3] = 1; + + // Orb ID + bytes[4] = orbIds[i]; + + // RED / GREEN / BLUE + bytes[5] = 0; + bytes[6] = 0; + bytes[7] = 0; + + sendCommand(bytes); + } + return 0; +} + +LedDeviceAtmoOrb::~LedDeviceAtmoOrb() { + delete manager; +} \ No newline at end of file diff --git a/libsrc/leddevice/LedDeviceAtmoOrb.h b/libsrc/leddevice/LedDeviceAtmoOrb.h new file mode 100644 index 00000000..d425b06a --- /dev/null +++ b/libsrc/leddevice/LedDeviceAtmoOrb.h @@ -0,0 +1,129 @@ +#pragma once + +// STL includes +#include + +// Qt includes +#include +#include +#include +#include + +// Leddevice includes +#include + +class QUdpSocket; + +class AtmoOrbLight { +public: + unsigned int id; + + /// + /// Constructs the light. + /// + /// @param id the orb id + AtmoOrbLight(unsigned int id); +}; + +/** + * Implementation for the AtmoOrb + * + * To use set the device to "atmoorb". + * + * @author RickDB (github) + */ +class LedDeviceAtmoOrb : public QObject, public LedDevice { + Q_OBJECT +public: + // Last color sent + int lastRed; + int lastGreen; + int lastBlue; + + // Multicast status + bool joinedMulticastgroup; + + /// + /// Constructs the device. + /// + /// @param output is the multicast address of Orbs + /// + /// @param switchOffOnBlack turn off Orbs on black (default: false) + /// + /// @param transitiontime is optional and not used at the moment + /// + /// @param port is the multicast port. + /// + /// @param numLeds is the total amount of leds per Orb + /// + /// @param array containing orb ids + /// + LedDeviceAtmoOrb(const std::string &output, bool switchOffOnBlack = + false, int transitiontime = 0, int port = 49692, int numLeds = 24, + std::vector orbIds = std::vector < unsigned int + + >()); + + /// + /// Destructor of this device + /// + virtual ~LedDeviceAtmoOrb(); + + /// + /// Sends the given led-color values to the Orbs + /// + /// @param ledValues The color-value per led + /// + /// @return Zero on success else negative + /// + virtual int write(const std::vector &ledValues); + + virtual int switchOff(); + +private: + /// QNetworkAccessManager object for sending requests. + QNetworkAccessManager *manager; + + /// String containing multicast group IP address + QString multicastGroup; + + /// Switch off when detecting black + bool switchOffOnBlack; + + /// Transition time between colors (not implemented) + int transitiontime; + + /// Multicast port to send data to + int multiCastGroupPort; + + /// Number of leds in Orb, used to determine buffer size + int numLeds; + + /// QHostAddress object of multicast group IP address + QHostAddress groupAddress; + + /// QUdpSocket object used to send data over + QUdpSocket *udpSocket; + + /// Array of the orb ids. + std::vector orbIds; + + /// + /// Set Orbcolor + /// + /// @param orbId the orb id + /// + /// @param color which color to set + /// + /// + /// @param commandType which type of command to send (off / smoothing / etc..) + /// + void setColor(unsigned int orbId, const ColorRgb &color, int commandType); + + /// + /// Send Orb command + /// + /// @param bytes the byte array containing command to send over multicast + /// + void sendCommand(const QByteArray &bytes); +}; diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index f3c2f4e5..8ba6a9d3 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -37,6 +37,7 @@ #include "LedDeviceTpm2.h" #include "LedDeviceAtmo.h" #include "LedDeviceAdalightApa102.h" +#include "LedDeviceAtmoOrb.h" #ifdef ENABLE_WS2812BPWM #include "LedDeviceWS2812b.h" @@ -245,6 +246,35 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) } device = new LedDevicePhilipsHue(output, username, switchOffOnBlack, transitiontime, lightIds); } + else if (type == "atmoorb") + { + const std::string output = deviceConfig["output"].asString(); + const bool switchOffOnBlack = deviceConfig.get("switchOffOnBlack", true).asBool(); + const int transitiontime = deviceConfig.get("transitiontime", 1).asInt(); + const int port = deviceConfig.get("port", 1).asInt(); + const int numLeds = deviceConfig.get("numLeds", 1).asInt(); + const std::string orbId = deviceConfig["orbIds"].asString(); + std::vector orbIds; + + // If we find multiple Orb ids separate them and add to list + const std::string separator (","); + if (orbId.find(separator) != std::string::npos) { + std::stringstream ss(orbId); + std::vector output; + unsigned int i; + while (ss >> i) { + orbIds.push_back(i); + if (ss.peek() == ',' || ss.peek() == ' ') + ss.ignore(); + } + } + else + { + orbIds.push_back(atoi(orbId.c_str())); + } + + device = new LedDeviceAtmoOrb(output, switchOffOnBlack, transitiontime, port, numLeds, orbIds); + } else if (type == "test") { const std::string output = deviceConfig["output"].asString(); From ac3e7efceee20af7d943bce3fc594e487f139e39 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Tue, 22 Mar 2016 23:28:41 +1100 Subject: [PATCH 4/5] Revert "Added support to invert the WS281x LED data." This reverts commit e352dea7a6228dd7b008765917f227d7387ab409 [formerly 44ab64329641f0e1450174314a955d241641d149]. Former-commit-id: d8cc750d60ac642cbdb611cd925252f09cb907db --- libsrc/leddevice/LedDeviceFactory.cpp | 5 ++--- libsrc/leddevice/LedDeviceWS281x.cpp | 4 ++-- libsrc/leddevice/LedDeviceWS281x.h | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index 8ba6a9d3..49b197f6 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -324,12 +324,11 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) else if (type == "ws281x") { const int gpio = deviceConfig.get("gpio", 18).asInt(); - const int leds = deviceConfig.get("leds", 256).asInt(); + const int leds = deviceConfig.get("leds", 12).asInt(); const uint32_t freq = deviceConfig.get("freq", (Json::UInt)800000ul).asInt(); const int dmanum = deviceConfig.get("dmanum", 5).asInt(); - const int invert = deviceConfig.get("invert", 0).asInt(); - LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum, invert); + LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum); device = ledDeviceWS281x; } #endif diff --git a/libsrc/leddevice/LedDeviceWS281x.cpp b/libsrc/leddevice/LedDeviceWS281x.cpp index b8ea8822..10b5d2e0 100644 --- a/libsrc/leddevice/LedDeviceWS281x.cpp +++ b/libsrc/leddevice/LedDeviceWS281x.cpp @@ -3,13 +3,13 @@ #include "LedDeviceWS281x.h" // Constructor -LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int invert) +LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum) { initialized = false; led_string.freq = freq; led_string.dmanum = dmanum; led_string.channel[0].gpionum = gpio; - led_string.channel[0].invert = invert; + led_string.channel[0].invert = 0; led_string.channel[0].count = leds; led_string.channel[0].brightness = 255; led_string.channel[0].strip_type = WS2811_STRIP_RGB; diff --git a/libsrc/leddevice/LedDeviceWS281x.h b/libsrc/leddevice/LedDeviceWS281x.h index df8b1082..429a092f 100644 --- a/libsrc/leddevice/LedDeviceWS281x.h +++ b/libsrc/leddevice/LedDeviceWS281x.h @@ -16,9 +16,8 @@ public: /// @param leds The number of leds attached to the gpio pin /// @param freq The target frequency for the data line, default is 800000 /// @param dmanum The DMA channel to use, default is 5 - /// @param invert Invert the output line to support an inverting level shifter /// - LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int invert); + LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum); /// /// Destructor of the LedDevice, waits for DMA to complete and then cleans up From 61430753650ab8888510af7e7f17e56d693841bd Mon Sep 17 00:00:00 2001 From: penfold42 Date: Tue, 22 Mar 2016 23:50:14 +1100 Subject: [PATCH 5/5] 1. changed default number of pwm LEDs to 256 2. Adds support for level shifters that invert the data Config option - "invert" (integer) if omitted, do not invert if == 0, do not invert if !=0, invert Former-commit-id: fd5b2863a85b11ac3a8444d1e02822f852feb556 --- libsrc/leddevice/LedDeviceFactory.cpp | 5 +++-- libsrc/leddevice/LedDeviceWS281x.cpp | 6 +++--- libsrc/leddevice/LedDeviceWS281x.h | 5 ++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index 3c925e8d..a3dd87af 100755 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -324,12 +324,13 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig) else if (type == "ws281x") { const int gpio = deviceConfig.get("gpio", 18).asInt(); - const int leds = deviceConfig.get("leds", 12).asInt(); + const int leds = deviceConfig.get("leds", 256).asInt(); const uint32_t freq = deviceConfig.get("freq", (Json::UInt)800000ul).asInt(); const int dmanum = deviceConfig.get("dmanum", 5).asInt(); const int pwmchannel = deviceConfig.get("pwmchannel", 0).asInt(); + const int invert = deviceConfig.get("invert", 0).asInt(); - LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum, pwmchannel); + LedDeviceWS281x * ledDeviceWS281x = new LedDeviceWS281x(gpio, leds, freq, dmanum, pwmchannel, invert); device = ledDeviceWS281x; } #endif diff --git a/libsrc/leddevice/LedDeviceWS281x.cpp b/libsrc/leddevice/LedDeviceWS281x.cpp index 3871b553..542ff80c 100644 --- a/libsrc/leddevice/LedDeviceWS281x.cpp +++ b/libsrc/leddevice/LedDeviceWS281x.cpp @@ -3,7 +3,7 @@ #include "LedDeviceWS281x.h" // Constructor -LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int pwmchannel) +LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, const int dmanum, const int pwmchannel, const int invert) { initialized = false; led_string.freq = freq; @@ -14,13 +14,13 @@ LedDeviceWS281x::LedDeviceWS281x(const int gpio, const int leds, const uint32_t } chan = pwmchannel; led_string.channel[chan].gpionum = gpio; - led_string.channel[chan].invert = 0; + led_string.channel[chan].invert = invert; led_string.channel[chan].count = leds; led_string.channel[chan].brightness = 255; led_string.channel[chan].strip_type = WS2811_STRIP_RGB; led_string.channel[!chan].gpionum = 0; - led_string.channel[!chan].invert = 0; + led_string.channel[!chan].invert = invert; led_string.channel[!chan].count = 0; led_string.channel[!chan].brightness = 0; led_string.channel[!chan].strip_type = WS2811_STRIP_RGB; diff --git a/libsrc/leddevice/LedDeviceWS281x.h b/libsrc/leddevice/LedDeviceWS281x.h index 61a58800..29209016 100644 --- a/libsrc/leddevice/LedDeviceWS281x.h +++ b/libsrc/leddevice/LedDeviceWS281x.h @@ -16,8 +16,11 @@ public: /// @param leds The number of leds attached to the gpio pin /// @param freq The target frequency for the data line, default is 800000 /// @param dmanum The DMA channel to use, default is 5 + /// @param pwmchannel The pwm channel to use + /// @param invert Invert the output line to support an inverting level shifter + /// - LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum, int pwmchannel); + LedDeviceWS281x(const int gpio, const int leds, const uint32_t freq, int dmanum, int pwmchannel, int invert); /// /// Destructor of the LedDevice, waits for DMA to complete and then cleans up