Merge pull request #18 from Aircoookie/master

Update
This commit is contained in:
srg74 2020-01-28 22:43:03 -05:00 committed by GitHub
commit e610a1ffe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 138 additions and 37 deletions

View File

@ -1025,15 +1025,22 @@ uint16_t WS2812FX::larson_scanner(bool dual) {
/*
* Firing comets from one end.
* Firing comets from one end. "Lighthouse"
*/
uint16_t WS2812FX::mode_comet(void) {
uint16_t counter = now * (SEGMENT.speed >>3) +1;
uint16_t counter = now * ((SEGMENT.speed >>2) +1);
uint16_t index = counter * SEGLEN >> 16;
if (SEGENV.call == 0) SEGENV.aux0 = index;
fade_out(SEGMENT.intensity);
setPixelColor( index, color_from_palette(index, true, PALETTE_SOLID_WRAP, 0));
if (index > SEGENV.aux0) {
for (uint16_t i = SEGENV.aux0; i < index ; i++) {
setPixelColor( i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
}
}
SEGENV.aux0 = index++;
return FRAMETIME;
}
@ -1172,19 +1179,26 @@ uint16_t WS2812FX::mode_loading(void) {
//American Police Light with all LEDs Red and Blue
uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2)
{
uint16_t counter = now * ((SEGMENT.speed >> 3) +1);
uint16_t counter = now * ((SEGMENT.speed >> 2) +1);
uint16_t idexR = (counter * SEGLEN) >> 16;
if (idexR >= SEGLEN) idexR = 0;
uint16_t topindex = SEGLEN >> 1;
uint16_t idexB = idexR + topindex;
if (SEGENV.call == 0) SEGENV.aux0 = idexR;
if (idexR > topindex) idexB -= SEGLEN;
if (idexB >= SEGLEN) idexB = 0; //otherwise overflow on odd number of LEDs
setPixelColor(idexR, color1);
setPixelColor(idexB, color2);
uint8_t gap = (SEGENV.aux0 < idexR)? idexR - SEGENV.aux0:SEGLEN - SEGENV.aux0 + idexR;
for (uint8_t i = 0; i < gap ; i++) {
if ((idexR - i) < 0) idexR = SEGLEN-1 + i;
if ((idexB - i) < 0) idexB = SEGLEN-1 + i;
setPixelColor(idexR-i, color1);
setPixelColor(idexB-i, color2);
}
SEGENV.aux0 = idexR;
return FRAMETIME;
}
@ -2486,22 +2500,33 @@ uint16_t WS2812FX::mode_bouncing_balls(void) {
*/
uint16_t WS2812FX::sinelon_base(bool dual, bool rainbow=false) {
fade_out(SEGMENT.intensity);
int pos = beatsin16(SEGMENT.speed/10,0,SEGLEN-1);
uint16_t pos = beatsin16(SEGMENT.speed/10,0,SEGLEN-1);
if (SEGENV.call == 0) SEGENV.aux0 = pos;
uint32_t color1 = color_from_palette(pos, true, false, 0);
uint32_t color2 = SEGCOLOR(2);
if (rainbow) {
color1 = color_wheel((pos & 0x07) * 32);
}
setPixelColor(pos, color1);
if (dual) {
uint32_t color2 = SEGCOLOR(2);
if (!color2) color2 = color_from_palette(pos, true, false, 0);
if (rainbow) color2 = color1; //rainbow
setPixelColor(SEGLEN-1-pos, color2);
}
if (SEGENV.aux0 != pos) {
if (SEGENV.aux0 < pos) {
for (uint16_t i = SEGENV.aux0; i < pos ; i++) {
setPixelColor(i, color1);
if (dual) setPixelColor(SEGLEN-1-i, color2);
}
} else {
for (uint16_t i = SEGENV.aux0; i > pos ; i--) {
setPixelColor(i, color1);
if (dual) setPixelColor(SEGLEN-1-i, color2);
}
}
SEGENV.aux0 = pos;
}
return FRAMETIME;
}
@ -2985,23 +3010,26 @@ uint16_t WS2812FX::mode_plasma(void) {
uint16_t WS2812FX::mode_percent(void) {
uint8_t percent = max(0, min(100, SEGMENT.intensity));
float active_float = SEGLEN * percent / 100.0;
uint16_t active_leds = active_float;
uint16_t active_part = (active_float - active_leds) * 255;
CRGB color;
for (uint16_t i = 0; i < SEGLEN; i++) {
if (i < active_leds) {
uint16_t active_leds = SEGLEN * percent / 100.0;
if (SEGENV.call == 0) SEGENV.step = 0;
uint8_t size = (1 + ((SEGMENT.speed * SEGLEN) >> 11)) & 0xFF ;
for (uint16_t i = 0; i < SEGLEN; i++) {
if (i < SEGENV.step) {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
}
else if (i == active_leds) {
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0, active_part));
}
else {
setPixelColor(i, SEGCOLOR(1));
}
}
}
if(active_leds > SEGENV.step) {
SEGENV.step += size;
if (SEGENV.step > active_leds) SEGENV.step = active_leds;
} else if (active_leds < SEGENV.step) {
SEGENV.step -= size;
if (SEGENV.step < active_leds) SEGENV.step = active_leds;
}
return FRAMETIME;
return FRAMETIME;
}

View File

@ -469,7 +469,19 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping,
if (seg.stop) setRange(seg.start, seg.stop -1, 0); //turn old segment range off
if (i2 <= i1) //disable segment
{
seg.stop = 0; return;
seg.stop = 0;
if (n == mainSegment) //if main segment is deleted, set first active as main segment
{
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (_segments[i].isActive()) {
mainSegment = i;
return;
}
}
mainSegment = 0; //should not happen (always at least one active segment)
}
return;
}
if (i1 < _length) seg.start = i1;
seg.stop = i2;
@ -482,6 +494,7 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping,
}
void WS2812FX::resetSegments() {
mainSegment = 0;
memset(_segments, 0, sizeof(_segments));
//memset(_segment_runtimes, 0, sizeof(_segment_runtimes));
_segment_index = 0;

View File

@ -9,7 +9,7 @@
//#define USE_LPD8806 // Uncomment for using LPD8806
//#define WLED_USE_ANALOG_LEDS //Uncomment for using "dumb" PWM controlled LEDs (see pins below, default R: gpio5, G: 12, B: 15, W: 13)
//#define WLED_USE_H801 //H801 controller. Please uncomment #define WLED_USE_ANALOG_LEDS as well
//#define WLED_USE_5CH //5 Channel H801 for cold and warm white
//#define WLED_USE_5CH_LEDS //5 Channel H801 for cold and warm white
#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended)
#define IR_PIN 4 //infrared pin (-1 to disable) MagicHome: 4, H801 Wifi: 0
@ -34,7 +34,7 @@
#define RPIN 15 //R pin for analog LED strip
#define GPIN 13 //G pin for analog LED strip
#define BPIN 12 //B pin for analog LED strip
#define WPIN 14 //W pin for analog LED strip (W1: 14, W2: 04)
#define WPIN 14 //W pin for analog LED strip
#define W2PIN 04 //W2 pin for analog LED strip
#undef BTNPIN
#undef IR_PIN
@ -44,7 +44,7 @@
#define RPIN 5 //R pin for analog LED strip
#define GPIN 12 //G pin for analog LED strip
#define BPIN 15 //B pin for analog LED strip
#define WPIN 13 //W pin for analog LED strip (W1: 14, W2: 04)
#define WPIN 13 //W pin for analog LED strip
#endif
#undef RLYPIN
#define RLYPIN -1 //disable as pin 12 is used by analog LEDs

View File

@ -189,7 +189,7 @@ const char PAGE_settings_sync[] PROGMEM = R"=====(<!DOCTYPE html>
<h2>Sync setup</h2>
<h3>Button setup</h3>
On/Off button enabled: <input type="checkbox" name="BT"><br>
Infrared receiver type (0 = disabled): <input name="IR" type="number" min="0" max="5" required><br>
Infrared receiver type (0 = disabled): <input name="IR" type="number" min="0" max="6" required><br>
<a href="https://github.com/Aircoookie/WLED/wiki/Infrared-Control" target="_blank">IR info</a>
<h3>WLED Broadcast</h3>
UDP Port: <input name="UP" type="number" min="1" max="65535" required><br>
@ -234,13 +234,13 @@ Group Topic: <input name="MG" maxlength="32"><br>
<i>Reboot required to apply changes. </i><a href="https://github.com/Aircoookie/WLED/wiki/MQTT" target="_blank">MQTT info</a>
<h3>Philips Hue</h3>
<i>You can find the bridge IP and the light number in the 'About' section of the hue app.</i><br>
Poll Hue light <input name="HL" type="number" min="1" max="99" required> every <input name="HI" type="number" min="100" max="65000" required> ms: <input type="checkbox" name="HP"><br>
Poll Hue light <input name="HL" type="number" min="1" max="99" > every <input name="HI" type="number" min="100" max="65000"> ms: <input type="checkbox" name="HP"><br>
Then, receive <input type="checkbox" name="HO"> On/Off, <input type="checkbox" name="HB"> Brightness, and <input type="checkbox" name="HC"> Color<br>
Hue Bridge IP:<br>
<input name="H0" type="number" min="0" max="255" required> .
<input name="H1" type="number" min="0" max="255" required> .
<input name="H2" type="number" min="0" max="255" required> .
<input name="H3" type="number" min="0" max="255" required><br>
<input name="H0" type="number" min="0" max="255" > .
<input name="H1" type="number" min="0" max="255" > .
<input name="H2" type="number" min="0" max="255" > .
<input name="H3" type="number" min="0" max="255" ><br>
<b>Press the pushlink button on the bridge, after that save this page!</b><br>
(when first connecting)<br>
Hue status: <span class="hms"> Internal ESP Error! </span><hr>

View File

@ -4,6 +4,16 @@
#define IRCUSTOM_ONOFF 0xA55AEA15 //Pioneer RC-975R "+FAV" button (example)
#define IRCUSTOM_MACRO1 0xFFFFFFFF //placeholder, will never be checked for
// Default IR codes for 6-key learning remote https://www.aliexpress.com/item/4000307837886.html
// This cheap remote has the advantage of being more powerful (longer range) than cheap credit-card remotes
#define IR6_POWER 0xFF0FF0
#define IR6_CHANNEL_UP 0xFF8F70
#define IR6_CHANNEL_DOWN 0xFF4FB0
#define IR6_VOLUME_UP 0xFFCF30
#define IR6_VOLUME_DOWN 0xFF2FD0
#define IR6_MUTE 0xFFAF50
//Infrared codes for 24-key remote from http://woodsgood.ca/projects/2015/02/13/rgb-led-strip-controllers-ir-codes/
#define IR24_BRIGHTER 0xF700FF
#define IR24_DARKER 0xF7807F

View File

@ -90,7 +90,7 @@
#endif
//version code in format yymmddb (b = daily build)
#define VERSION 2001191
#define VERSION 2001281
char versionString[] = "0.9.0-b2";
@ -535,6 +535,9 @@ void loop() {
if (!offMode) strip.service();
}
yield();
#ifdef ESP8266
MDNS.update();
#endif
if (millis() - lastMqttReconnectAttempt > 30000) initMqtt();
//DEBUG serial logging

View File

@ -14,6 +14,7 @@ decode_results results;
unsigned long irCheckedTime = 0;
uint32_t lastValidCode = 0;
uint16_t irTimesRepeated = 0;
uint8_t lastIR6ColourIdx = 0;
//Add what your custom IR codes should trigger here. Guide: https://github.com/Aircoookie/WLED/wiki/Infrared-Control
@ -84,6 +85,9 @@ void decodeIR(uint32_t code)
case 3: decodeIR40(code); break; // blue 40-key remote with 25%, 50%, 75% and 100% keys
case 4: decodeIR44(code); break; // white 44-key remote with color-up/down keys and DIY1 to 6 keys
case 5: decodeIR21(code); break; // white 21-key remote
case 6: decodeIR6(code); break; // black 6-key learning remote defaults: "CH" controls brightness,
// "VOL +" controls effect, "VOL -" controls colour/palette, "MUTE"
// sets bright plain white
default: return;
}
}
@ -346,6 +350,49 @@ void decodeIR21(uint32_t code)
colorUpdated(2); //for notifier, IR is considered a button input
}
void decodeIR6(uint32_t code)
{
switch (code) {
case IR6_POWER: toggleOnOff(); break;
case IR6_CHANNEL_UP: relativeChange(&bri, 10); break;
case IR6_CHANNEL_DOWN: relativeChange(&bri, -10, 5); break;
case IR6_VOLUME_UP: /* next effect */ relativeChange(&effectCurrent, 1); break;
case IR6_VOLUME_DOWN:
/* next palette */
relativeChange(&effectPalette, 1);
switch(lastIR6ColourIdx)
{
case 0: colorFromUint32(COLOR_RED); break;
case 1: colorFromUint32(COLOR_REDDISH); break;
case 2:colorFromUint32(COLOR_ORANGE); break;
case 3:colorFromUint32(COLOR_YELLOWISH); break;
case 4:colorFromUint32(COLOR_GREEN); break;
case 5:colorFromUint32(COLOR_GREENISH); break;
case 6:colorFromUint32(COLOR_TURQUOISE); break;
case 7: colorFromUint32(COLOR_CYAN); break;
case 8:colorFromUint32(COLOR_BLUE); break;
case 9:colorFromUint32(COLOR_DEEPBLUE); break;
case 10:colorFromUint32(COLOR_PURPLE); break;
case 11:colorFromUint32(COLOR_PINK); break;
case 12:colorFromUint32(COLOR_WHITE); break;
default:break;
}
lastIR6ColourIdx++;
if(lastIR6ColourIdx > 12) lastIR6ColourIdx = 0;
break;
case IR6_MUTE: effectCurrent = 0; effectPalette = 0; colorFromUint32(COLOR_WHITE); bri=255; break;
}
lastValidCode = code;
colorUpdated(2); //for notifier, IR is considered a button input
}
void initIR()
{
if (irEnabled > 0)