From 712d5043d25e8fec8636287ec96d509de2bfe336 Mon Sep 17 00:00:00 2001 From: bpohvoodoo Date: Wed, 26 Feb 2020 12:25:13 +0100 Subject: [PATCH] Version Bump to 3.1.0 * bugfixes * E1.31 is now working for multi segments --- Arduino/McLighting/McLighting.ino | 8 ++--- Arduino/McLighting/WS2812FX.cpp | 6 ++-- Arduino/McLighting/WS2812FX.h | 2 +- Arduino/McLighting/definitions.h | 6 ++-- Arduino/McLighting/helper_functions.h | 4 +-- .../mode_custom_ws2812fx_animations.h | 35 +++++++++++-------- Arduino/McLighting/request_handlers.h | 4 +-- Arduino/McLighting/version.h | 2 +- Arduino/McLighting/version_info.ino | 7 +++- 9 files changed, 42 insertions(+), 32 deletions(-) diff --git a/Arduino/McLighting/McLighting.ino b/Arduino/McLighting/McLighting.ino index 52a3bbc..ad2cd04 100644 --- a/Arduino/McLighting/McLighting.ino +++ b/Arduino/McLighting/McLighting.ino @@ -718,14 +718,12 @@ void loop() { if ((State.mode == HOLD) || ((State.mode == OFF) && (strip->getBrightness() > 0) && Config.transEffect)) { if(!strip->isRunning()) strip->start(); strip->service(); + bool playE131 = false; for (uint8_t i = 0; i < Config.segments; i++) { if (segState.mode[i] == FX_MODE_CUSTOM_0) { handleAutoPlay(i); } - if (segState.mode[i] == FX_MODE_CUSTOM_3) { - if (strip->getSpeed(i) > SPEED_MIN) { - strip->setSpeed(i, SPEED_MIN); - } - } + if (segState.mode[i] == FX_MODE_CUSTOM_3) { playE131 = true; } } + if (playE131 == true) { handleE131Play(); } } if (prevmode != State.mode) { diff --git a/Arduino/McLighting/WS2812FX.cpp b/Arduino/McLighting/WS2812FX.cpp index d64ba6d..dad49ac 100644 --- a/Arduino/McLighting/WS2812FX.cpp +++ b/Arduino/McLighting/WS2812FX.cpp @@ -781,7 +781,7 @@ uint16_t WS2812FX::scan(uint32_t color1, uint32_t color2, bool dual) { SEGMENT_RUNTIME.counter_mode_step += dir; if(SEGMENT_RUNTIME.counter_mode_step == 0) SEGMENT_RUNTIME.aux_param = 0; - if(SEGMENT_RUNTIME.counter_mode_step >= (SEGMENT_LENGTH - size)) SEGMENT_RUNTIME.aux_param = 1; + if(SEGMENT_RUNTIME.counter_mode_step >= (uint16_t)(SEGMENT_LENGTH - size)) SEGMENT_RUNTIME.aux_param = 1; return (SEGMENT.speed / (SEGMENT_LENGTH * 2)); } @@ -1388,7 +1388,7 @@ uint16_t WS2812FX::mode_larson_scanner(void) { else CLR_CYCLE; SEGMENT_RUNTIME.counter_mode_step++; - if(SEGMENT_RUNTIME.counter_mode_step >= ((SEGMENT_LENGTH * 2) - 2)) { + if(SEGMENT_RUNTIME.counter_mode_step >= (uint16_t)((SEGMENT_LENGTH * 2) - 2)) { SEGMENT_RUNTIME.counter_mode_step = 0; } @@ -1630,7 +1630,7 @@ uint8_t WS2812FX::setCustomMode(const __FlashStringHelper* name, uint16_t (*p)() } uint8_t WS2812FX::setCustomMode(uint8_t index, const __FlashStringHelper* name, uint16_t (*p)()) { - if((FX_MODE_CUSTOM_0 + index) < MODE_COUNT) { + if((uint8_t)(FX_MODE_CUSTOM_0 + index) < MODE_COUNT) { _names[FX_MODE_CUSTOM_0 + index] = name; // store the custom mode name customModes[index] = p; // store the custom mode diff --git a/Arduino/McLighting/WS2812FX.h b/Arduino/McLighting/WS2812FX.h index 115fee9..5405457 100644 --- a/Arduino/McLighting/WS2812FX.h +++ b/Arduino/McLighting/WS2812FX.h @@ -65,7 +65,7 @@ #define MAX_CUSTOM_MODES 10 #define SEGMENT _segments[_segment_index] #define SEGMENT_RUNTIME _segment_runtimes[_segment_index] -#define SEGMENT_LENGTH (SEGMENT.stop - SEGMENT.start + 1) +#define SEGMENT_LENGTH (uint16_t)(SEGMENT.stop - SEGMENT.start + 1) // some common colors #define RED (uint32_t)0xFF0000 diff --git a/Arduino/McLighting/definitions.h b/Arduino/McLighting/definitions.h index 8aa8c20..285fff9 100644 --- a/Arduino/McLighting/definitions.h +++ b/Arduino/McLighting/definitions.h @@ -1,4 +1,4 @@ -#define USE_WS2812FX_DMA 0 // 0 = Used PIN is ignored & set to RX/GPIO3; 1 = Used PIN is ignored & set to TX/GPIO1; 2 = Uses PIN is ignored & set to D4/GPIO2; Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX +#define USE_WS2812FX_DMA 0 // 0 = Used PIN is ignored & set to RX/GPIO3; 1 = Used PIN is ignored & set to TX/GPIO1; 2 = Used PIN is ignored & set to D4/GPIO2; Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX // or comment it out #if defined(USE_WS2812FX_DMA) #define MAXLEDS 384 // due to memory limit of esp8266 at the moment only 384 leds are supported in DMA Mode. More can crash if mqtt is used. @@ -22,13 +22,13 @@ char HOSTNAME[65] = "McLightingRGBW"; // Friedly hostname is configurable just #define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth //#define DISABLE_MQTT_OUT_ON_MQTT_IN // If defined, McLighting will not send back MQTT-out on MQTT-in regarding issue #67, does not change anything at the moment -#define ENABLE_BUTTON 14 // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control, the value defines the input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button. +//#define ENABLE_BUTTON 14 // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control, the value defines the input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button. //#define ENABLE_BUTTON_GY33 12 // If defined, enable button handling code for GY-33 color sensor to scan color. The value defines the input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button. //#define POWER_SUPPLY 12 // PIN (12 / D6) If defined, enable output to control external power supply #if defined(POWER_SUPPLY) #define POWER_ON HIGH // Define the output state to turn on the power supply, either HIGH or LOW. Opposite will be uses for power off. #endif -//#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out +#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out #if defined(ENABLE_BUTTON_GY33) #define GAMMA 2.5 // Gamma correction for GY-33 sensor diff --git a/Arduino/McLighting/helper_functions.h b/Arduino/McLighting/helper_functions.h index 3527d66..70a5150 100644 --- a/Arduino/McLighting/helper_functions.h +++ b/Arduino/McLighting/helper_functions.h @@ -250,8 +250,8 @@ void initStrip(uint16_t _stripSize = Config.stripSize, uint8_t _num_segments = C } void getSegmentParams(uint8_t _seg) { - segState.start = strip->getSegment(_seg)->start;; - segState.stop = strip->getSegment(_seg)->stop;; + segState.start = strip->getSegment(_seg)->start; + segState.stop = strip->getSegment(_seg)->stop; //segState.mode[_seg] = strip->getMode(_seg); //segState.speed[_seg] = unconvertSpeed(strip->getSpeed(_seg)); //fx_mode = segState.mode[_seg]; diff --git a/Arduino/McLighting/mode_custom_ws2812fx_animations.h b/Arduino/McLighting/mode_custom_ws2812fx_animations.h index d72d475..52be436 100644 --- a/Arduino/McLighting/mode_custom_ws2812fx_animations.h +++ b/Arduino/McLighting/mode_custom_ws2812fx_animations.h @@ -101,7 +101,7 @@ uint16_t handleCustomWS(void) { } } else { if (millis() - dipStartTime[_seg_num] < darkTime[_seg_num]) { - for (uint16_t i=(_seg->start + 3); i<= _seg->stop; i++) { + for (uint16_t i = _seg->start; i <= _seg->stop; i++) { ledstates[i] = 0; for (uint16_t j=_seg->start; j<=_seg->stop; j++) { uint16_t index = (j%3 == 0) ? 400 : random(0,767); @@ -118,15 +118,19 @@ uint16_t handleCustomWS(void) { // E1.31 mode // *************************************************************************** uint16_t handleE131(void) { - WS2812FX::Segment* _seg = strip->getSegment(); + WS2812FX::Segment* _seg = strip->getSegment(); + return _seg->speed/(_seg->stop - _seg->start); + } + + void handleE131Play(void) { if (!e131->isEmpty()) { e131_packet_t packet; e131->pull(&packet); // Pull packet from ring buffer - + uint16_t universe = htons(packet.universe); uint8_t *data = packet.property_values + 1; - if (universe < START_UNIVERSE || universe > END_UNIVERSE) return _seg->speed/(_seg->stop - _seg->start); //async will take care about filling the buffer + if (universe < START_UNIVERSE || universe > END_UNIVERSE) return; //async will take care about filling the buffer // Serial.printf("Universe %u / %u Channels | Packet#: %u / Errors: %u / CH1: %u\n", // htons(packet.universe), // The Universe for this packet @@ -140,21 +144,24 @@ uint16_t handleCustomWS(void) { uint16_t len = (128 + multipacketOffset > Config.stripSize) ? (Config.stripSize - multipacketOffset) : 128; #else*/ uint16_t multipacketOffset = (universe - START_UNIVERSE) * 170; //if more than 170 LEDs * 3 colors = 510 channels, client will send in next higher universe - if (Config.stripSize <= multipacketOffset) return _seg->speed/(_seg->stop - _seg->start); + if (Config.stripSize <= multipacketOffset) return; uint16_t len = (170 + multipacketOffset > Config.stripSize) ? (Config.stripSize - multipacketOffset) : 170; /* #endif */ - for (uint16_t i = 0; i < len; i++){ - if ((i >= _seg->start) && (i <= _seg->stop)) { - uint16_t j = i * 3; - /* #if defined(RGBW) - strip->setPixelColor(i + multipacketOffset, data[j], data[j + 1], data[j + 2], data[j + 3]); - #else */ - strip->setPixelColor(i + multipacketOffset, data[j], data[j + 1], data[j + 2], 0); - /* #endif */ + for (uint8_t k = 0; k < Config.segments; k++) { + if (segState.mode[k] == FX_MODE_CUSTOM_3) { + for (uint16_t i = 0; i < len; i++){ + if ((i >= strip->getSegment(k)->start) && (i <= strip->getSegment(k)->stop)) { + uint16_t j = i * 3; + /* #if defined(RGBW) + strip->setPixelColor(i + multipacketOffset, data[j], data[j + 1], data[j + 2], data[j + 3]); + #else */ + strip->setPixelColor(i + multipacketOffset, data[j], data[j + 1], data[j + 2], 0); + /* #endif */ + } + } } } } - return _seg->speed/(_seg->stop - _seg->start); } /* diff --git a/Arduino/McLighting/request_handlers.h b/Arduino/McLighting/request_handlers.h index e734e32..b95e466 100644 --- a/Arduino/McLighting/request_handlers.h +++ b/Arduino/McLighting/request_handlers.h @@ -1244,7 +1244,7 @@ void handleRemote() { _updateState = true; } else { State.mode = OFF; - _updateState = true;; + _updateState = true; } } if (State.mode == HOLD) { @@ -1348,7 +1348,7 @@ void handleRemote() { last_remote_cmd = results.value; if (selected_color == 1) { if (main_color.green - chng >= 0) { - main_color.green = main_color.green - chng;; + main_color.green = main_color.green - chng; _updateSegState = true; } } diff --git a/Arduino/McLighting/version.h b/Arduino/McLighting/version.h index e41f3a6..d375a80 100644 --- a/Arduino/McLighting/version.h +++ b/Arduino/McLighting/version.h @@ -1 +1 @@ -#define SKETCH_VERSION "3.1.0.BETA7" +#define SKETCH_VERSION "3.1.0" diff --git a/Arduino/McLighting/version_info.ino b/Arduino/McLighting/version_info.ino index ba01809..bc1e5d0 100644 --- a/Arduino/McLighting/version_info.ino +++ b/Arduino/McLighting/version_info.ino @@ -248,8 +248,13 @@ * Homeassistant will allways use active segment * E1.31 is only working for one segment at the moment * - * 27 January + * 27 January 2020 * Version Bump to 3.1.0.BETA7 * small API changes * work to solve heap problems + * + * 23 February 2020 + * Version Bump to 3.1.0 + * bugfixes + * E1.31 is now working for multi segments */