diff --git a/.travis/travis_build.sh b/.travis/travis_build.sh index 7788b430..3689d357 100644 --- a/.travis/travis_build.sh +++ b/.travis/travis_build.sh @@ -23,7 +23,7 @@ if [[ $TRAVIS_OS_NAME == 'linux' ]] then mkdir build || exit 1 cd build - cmake -DPLATFORM=x86 -DCMAKE_BUILD_TYPE=Release -DENABLE_AMLOGIC=ON -DENABLE_TESTS=ON -DENABLE_SPIDEV=ON -DENABLE_WS281XPWM=ON .. || exit 2 + cmake -DPLATFORM=x86-dev -DCMAKE_BUILD_TYPE=Release .. || exit 2 make -j$(nproc) || exit 3 make -j$(nproc) package || exit 4 fi diff --git a/CMakeLists.txt b/CMakeLists.txt index f4e17b06..750d280e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ SET ( DEFAULT_WS2812BPWM OFF ) SET ( DEFAULT_WS281XPWM OFF ) SET ( DEFAULT_V4L2 ON ) SET ( DEFAULT_USE_SHARED_AVAHI_LIBS OFF ) +SET ( DEFAULT_TESTS OFF ) if (APPLE) SET ( DEFAULT_OSX ON ) @@ -68,6 +69,14 @@ else () SET ( DEFAULT_X11 ON ) SET ( DEFAULT_FB ON ) SET ( DEFAULT_USE_SHARED_AVAHI_LIBS ON ) + elseif ( "${PLATFORM}" STREQUAL "x86-dev" ) + SET ( DEFAULT_X11 ON ) + SET ( DEFAULT_FB ON ) + SET ( DEFAULT_AMLOGIC ON) + SET ( DEFAULT_SPIDEV ON ) + SET ( DEFAULT_WS281XPWM ON ) + SET ( DEFAULT_USE_SHARED_AVAHI_LIBS ON ) + SET ( DEFAULT_TESTS ON ) elseif ( "${PLATFORM}" STREQUAL "imx6" ) SET ( DEFAULT_FB ON ) endif() @@ -106,7 +115,7 @@ message(STATUS "ENABLE_X11 = " ${ENABLE_X11}) SET(ENABLE_QT5 ON) -option(ENABLE_TESTS "Compile additional test applications" OFF) +option(ENABLE_TESTS "Compile additional test applications" ${DEFAULT_TESTS}) message(STATUS "ENABLE_TESTS = " ${ENABLE_TESTS}) option(ENABLE_PROFILER "enable profiler capabilities - not for release code" OFF) diff --git a/assets/firmware/arduino/adalight/adalight.ino b/assets/firmware/arduino/adalight/adalight.ino new file mode 100644 index 00000000..a204d67b --- /dev/null +++ b/assets/firmware/arduino/adalight/adalight.ino @@ -0,0 +1,102 @@ +#include "FastLED.h" + +// How many leds in your strip? +#define NUM_LEDS 240 + +// For led chips like Neopixels, which have a data line, ground, and power, you just +// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, +// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN +#define DATA_PIN 6 +#define CLOCK_PIN 13 + +#define COLOR_ORDER RGB + +// Adalight sends a "Magic Word" (defined in /etc/boblight.conf) before sending the pixel data +uint8_t prefix[] = {'A', 'd', 'a'}, hi, lo, chk, i; + +// Baudrate, higher rate allows faster refresh rate and more LEDs (defined in /etc/boblight.conf) +#define serialRate 460800 + +// Define the array of leds +CRGB leds[NUM_LEDS]; + +void setup() { + // Uncomment/edit one of the following lines for your leds arrangement. + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + // FastLED.addLeds(leds, NUM_LEDS); + + // initial RGB flash + LEDS.showColor(CRGB(255, 0, 0)); + delay(500); + LEDS.showColor(CRGB(0, 255, 0)); + delay(500); + LEDS.showColor(CRGB(0, 0, 255)); + delay(500); + LEDS.showColor(CRGB(0, 0, 0)); + + Serial.begin(serialRate); + Serial.print("Ada\n"); // Send "Magic Word" string to host + +} + +void loop() { + // wait for first byte of Magic Word + for (i = 0; i < sizeof prefix; ++i) { +waitLoop: while (!Serial.available()) ;; + // Check next byte in Magic Word + if (prefix[i] == Serial.read()) continue; + // otherwise, start over + i = 0; + goto waitLoop; + } + + // Hi, Lo, Checksum + + while (!Serial.available()) ;; + hi = Serial.read(); + while (!Serial.available()) ;; + lo = Serial.read(); + while (!Serial.available()) ;; + chk = Serial.read(); + + // if checksum does not match go back to wait + if (chk != (hi ^ lo ^ 0x55)) + { + i = 0; + goto waitLoop; + } + + memset(leds, 0, NUM_LEDS * sizeof(struct CRGB)); + // read the transmission data and set LED values + for (uint8_t i = 0; i < NUM_LEDS; i++) { + byte r, g, b; + while (!Serial.available()); + r = Serial.read(); + while (!Serial.available()); + g = Serial.read(); + while (!Serial.available()); + b = Serial.read(); + leds[i].r = r; + leds[i].g = g; + leds[i].b = b; + } + // shows new values + FastLED.show(); +} diff --git a/config/hyperion.config.json.commented b/config/hyperion.config.json.commented index 6342c0db..e5ade8ac 100644 --- a/config/hyperion.config.json.commented +++ b/config/hyperion.config.json.commented @@ -245,18 +245,18 @@ /// Initial Effect sets a "booteffect" or "color" (foreground-effect) and optional set a "effect" or "color" during inactive grabbers and network receivers (background-effect) /// * background-effect : 2 options: set a effect (example: "Rainbow swirl fast") or set a color (RGB) (example: [255,134,0]) - /// * background-effect-args : Set optional effect arguments (Have a look at the select effect to get the possible values) + /// * background-effect-args : Set optional effect arguments (Have a look at the select effect to get the possible values), define it only when needed /// * foreground-effect : 2 options: set a effect (example: "Rainbow swirl fast") or set a color (RGB) (example: [255,134,0]) - /// * foreground-effect-args : Set optional effect arguments (Have a look at the select effect to get the possible values) + /// * foreground-effect-args : Set optional effect arguments (Have a look at the select effect to get the possible values), define it only when needed /// * foreground-duration_ms : The duration of the selected foreground-effect or color (0=endless) /// HINT: "foreground-effect" starts always with priority 0, so it blocks all remotes and grabbers if the loop is endless /// HINT: Set a empty value if you want to disable a component (example: "") "initialEffect" : { "background-effect" : "Full color mood blobs", - "background-effect-args" : {}, + //"background-effect-args" : {}, "foreground-effect" : "Rainbow swirl fast", - "foreground-effect-args" : {}, + //"foreground-effect-args" : {}, "foreground-duration_ms" : 3000 }, diff --git a/libsrc/grabber/v4l2/V4L2Grabber.cpp b/libsrc/grabber/v4l2/V4L2Grabber.cpp index b933b19a..d6d944eb 100644 --- a/libsrc/grabber/v4l2/V4L2Grabber.cpp +++ b/libsrc/grabber/v4l2/V4L2Grabber.cpp @@ -77,22 +77,27 @@ void V4L2Grabber::uninit() bool V4L2Grabber::init() { - if ( _deviceName == "auto" ) - { - for (auto& dev: _v4lDevices) - { - Debug(_log, "check v4l2 device: %s (%s)",dev.first.c_str(), dev.second.c_str()); - _deviceName = dev.first; - if ( init() ) - { - Info(_log, "found usable v4l2 device: %s (%s)",dev.first.c_str(), dev.second.c_str()); - break; - } - } - } - if (! _initialized) { + getV4Ldevices(); + if ( _deviceName == "auto" ) + { + for (auto& dev: _v4lDevices) + { + Debug(_log, "check v4l2 device: %s (%s)",dev.first.c_str(), dev.second.c_str()); + _deviceName = dev.first; + if ( init() ) + { + Info(_log, "found usable v4l2 device: %s (%s)",dev.first.c_str(), dev.second.c_str()); + break; + } + } + } + else + { + Info(_log, "configured v4l device: %s", _deviceName.c_str()); + } + bool opened = false; try { diff --git a/libsrc/grabber/v4l2/V4L2Wrapper.cpp b/libsrc/grabber/v4l2/V4L2Wrapper.cpp index b685c962..bf1eb9cb 100644 --- a/libsrc/grabber/v4l2/V4L2Wrapper.cpp +++ b/libsrc/grabber/v4l2/V4L2Wrapper.cpp @@ -57,7 +57,6 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device, _timer.setInterval(500); _timer.setSingleShot(false); QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(checkSources())); - _timer.start(); } V4L2Wrapper::~V4L2Wrapper() @@ -67,6 +66,7 @@ V4L2Wrapper::~V4L2Wrapper() bool V4L2Wrapper::start() { + _timer.start(); bool grabber_started = _grabber.start(); if ( ! grabber_started ) { diff --git a/libsrc/leddevice/LedRs232Device.cpp b/libsrc/leddevice/LedRs232Device.cpp index 9030088a..08c2bc84 100644 --- a/libsrc/leddevice/LedRs232Device.cpp +++ b/libsrc/leddevice/LedRs232Device.cpp @@ -9,19 +9,23 @@ // Local Hyperion includes #include "LedRs232Device.h" -LedRs232Device::LedRs232Device(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms) : - _deviceName(outputDevice), - _baudRate_Hz(baudrate), - _delayAfterConnect_ms(delayAfterConnect_ms), - _rs232Port(this), - _blockedForDelay(false) +LedRs232Device::LedRs232Device(const std::string& outputDevice, const unsigned baudrate, int delayAfterConnect_ms) + : _deviceName(outputDevice) + , _baudRate_Hz(baudrate) + , _delayAfterConnect_ms(delayAfterConnect_ms) + , _rs232Port(this) + , _blockedForDelay(false) + , _stateChanged(true) { } LedRs232Device::~LedRs232Device() { if (_rs232Port.isOpen()) + { _rs232Port.close(); + Debug(_log,"Close UART: %s", _deviceName.c_str()); + } } @@ -40,12 +44,17 @@ bool LedRs232Device::tryOpen() { if ( ! _rs232Port.open(QIODevice::WriteOnly) ) { - Error(_log, "Unable to open RS232 device (%s)", _deviceName.c_str()); + if ( _stateChanged ) + { + Error(_log, "Unable to open RS232 device (%s)", _deviceName.c_str()); + _stateChanged = false; + } return false; } _rs232Port.setBaudRate(_baudRate_Hz); + _stateChanged = true; } - + if (_delayAfterConnect_ms > 0) { _blockedForDelay = true; diff --git a/libsrc/leddevice/LedRs232Device.h b/libsrc/leddevice/LedRs232Device.h index 0fdabda9..cf7c4e62 100644 --- a/libsrc/leddevice/LedRs232Device.h +++ b/libsrc/leddevice/LedRs232Device.h @@ -66,4 +66,6 @@ private: QSerialPort _rs232Port; bool _blockedForDelay; + + bool _stateChanged; };