GY-33
added changes from original repository. added support for color sensor GY-33.
This commit is contained in:
@@ -0,0 +1,240 @@
|
|||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@file GY33_MCU.h
|
||||||
|
@author BPoHVoodoo (FabLab Luenen)
|
||||||
|
|
||||||
|
@section LICENSE
|
||||||
|
|
||||||
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
|
Copyright (c) 2018,
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Driver for the GY-33 MCU digital color sensors.
|
||||||
|
|
||||||
|
@section HISTORY
|
||||||
|
|
||||||
|
v1.0 - First release
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
#ifdef __AVR
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#elif defined(ESP8266)
|
||||||
|
#include <pgmspace.h>
|
||||||
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "GY33_MCU.h"
|
||||||
|
|
||||||
|
/*========================================================================*/
|
||||||
|
/* PRIVATE FUNCTIONS */
|
||||||
|
/*========================================================================*/
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Implements missing powf function
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
float powf(const float x, const float y)
|
||||||
|
{
|
||||||
|
return (float)(pow((double)x, (double)y));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Writes a register and an 8 bit value over I2C
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
void GY33_MCU::write8 (uint8_t reg, uint32_t val)
|
||||||
|
{
|
||||||
|
uint8_t buf[2];
|
||||||
|
brzo_i2c_start_transaction(MCU_ADDRESS, SCL_SPEED);
|
||||||
|
buf[0]=reg;
|
||||||
|
buf[1]=val;
|
||||||
|
brzo_i2c_write(buf, 2, true);
|
||||||
|
brzo_i2c_end_transaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Reads an 8 bit value over I2C
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
uint8_t GY33_MCU::read8(uint8_t reg)
|
||||||
|
{
|
||||||
|
uint8_t buf[2];
|
||||||
|
brzo_i2c_start_transaction(MCU_ADDRESS, SCL_SPEED);
|
||||||
|
buf[0]=reg;
|
||||||
|
brzo_i2c_write(buf,1, true);
|
||||||
|
brzo_i2c_read(buf, 1, false);
|
||||||
|
brzo_i2c_end_transaction();
|
||||||
|
return buf[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Reads a 16 bit values over I2C
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
uint16_t GY33_MCU::read16(uint8_t reg)
|
||||||
|
{
|
||||||
|
uint16_t x; uint16_t t;
|
||||||
|
uint8_t buf[2];
|
||||||
|
brzo_i2c_start_transaction(MCU_ADDRESS, SCL_SPEED);
|
||||||
|
buf[0]=reg;
|
||||||
|
brzo_i2c_write(buf, 1, true);
|
||||||
|
brzo_i2c_read(buf, 2, false);
|
||||||
|
brzo_i2c_end_transaction();
|
||||||
|
x = buf[0];
|
||||||
|
t = buf[1];
|
||||||
|
x <<= 8;
|
||||||
|
x |= t;
|
||||||
|
return buf[0] << 8 | buf[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*========================================================================*/
|
||||||
|
/* CONSTRUCTORS */
|
||||||
|
/*========================================================================*/
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
Constructor
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
GY33_MCU::GY33_MCU()
|
||||||
|
{
|
||||||
|
_MCUInitialised = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*========================================================================*/
|
||||||
|
/* PUBLIC FUNCTIONS */
|
||||||
|
/*========================================================================*/
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
Initializes I2C and configures the sensor (call this function before
|
||||||
|
doing anything else)
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
boolean GY33_MCU::begin(void)
|
||||||
|
{
|
||||||
|
brzo_i2c_setup(SDA, SCL, SCL_STRETCH_TIMEOUT);
|
||||||
|
|
||||||
|
/* Make sure we're actually connected */
|
||||||
|
uint8_t x = read8(MCU_CONFIG);
|
||||||
|
Serial.println(x, HEX);
|
||||||
|
if ((x != 0x00) && (x != 0xFF))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_MCUInitialised = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Reads the raw red, green, blue and clear channel values
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
void GY33_MCU::getRawData (uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c, uint16_t *ct)
|
||||||
|
{
|
||||||
|
if (!_MCUInitialised) begin();
|
||||||
|
|
||||||
|
*r = read16(MCU_RDATAH);
|
||||||
|
*g = read16(MCU_GDATAH);
|
||||||
|
*b = read16(MCU_BDATAH);
|
||||||
|
*c = read16(MCU_CDATAH);
|
||||||
|
*ct = read16(MCU_CTDATAH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GY33_MCU::getData (uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *c)
|
||||||
|
{
|
||||||
|
if (!_MCUInitialised) begin();
|
||||||
|
|
||||||
|
*r = read8(MCU_RDATA);
|
||||||
|
*g = read8(MCU_GDATA);
|
||||||
|
*b = read8(MCU_BDATA);
|
||||||
|
*c = read8(MCU_COLDATA);
|
||||||
|
}
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Converts the raw R/G/B values to color temperature in degrees
|
||||||
|
Kelvin
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
uint16_t GY33_MCU::calculateColorTemperature(uint16_t r, uint16_t g, uint16_t b)
|
||||||
|
{
|
||||||
|
float X, Y, Z; /* RGB to XYZ correlation */
|
||||||
|
float xc, yc; /* Chromaticity co-ordinates */
|
||||||
|
float n; /* McCamy's formula */
|
||||||
|
float cct;
|
||||||
|
|
||||||
|
/* 1. Map RGB values to their XYZ counterparts. */
|
||||||
|
/* Based on 6500K fluorescent, 3000K fluorescent */
|
||||||
|
/* and 60W incandescent values for a wide range. */
|
||||||
|
/* Note: Y = Illuminance or lux */
|
||||||
|
X = (-0.14282F * r) + (1.54924F * g) + (-0.95641F * b);
|
||||||
|
Y = (-0.32466F * r) + (1.57837F * g) + (-0.73191F * b);
|
||||||
|
Z = (-0.68202F * r) + (0.77073F * g) + ( 0.56332F * b);
|
||||||
|
|
||||||
|
/* 2. Calculate the chromaticity co-ordinates */
|
||||||
|
xc = (X) / (X + Y + Z);
|
||||||
|
yc = (Y) / (X + Y + Z);
|
||||||
|
|
||||||
|
/* 3. Use McCamy's formula to determine the CCT */
|
||||||
|
n = (xc - 0.3320F) / (0.1858F - yc);
|
||||||
|
|
||||||
|
/* Calculate the final CCT */
|
||||||
|
cct = (449.0F * powf(n, 3)) + (3525.0F * powf(n, 2)) + (6823.3F * n) + 5520.33F;
|
||||||
|
|
||||||
|
/* Return the results in degrees Kelvin */
|
||||||
|
return (uint16_t)cct;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Converts the raw R/G/B values to lux
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
uint16_t GY33_MCU::calculateLux(uint16_t r, uint16_t g, uint16_t b)
|
||||||
|
{
|
||||||
|
float illuminance;
|
||||||
|
|
||||||
|
/* This only uses RGB ... how can we integrate clear or calculate lux */
|
||||||
|
/* based exclusively on clear since this might be more reliable? */
|
||||||
|
illuminance = (-0.32466F * r) + (1.57837F * g) + (-0.73191F * b);
|
||||||
|
|
||||||
|
return (uint16_t)illuminance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*void GY33_MCU::setInterrupt(boolean i) {
|
||||||
|
uint8_t r = read8(MCU_ENABLE);
|
||||||
|
if (i) {
|
||||||
|
r |= MCU_ENABLE_AIEN;
|
||||||
|
} else {
|
||||||
|
r &= ~MCU_ENABLE_AIEN;
|
||||||
|
}
|
||||||
|
write8(MCU_ENABLE, r);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GY33_MCU::clearInterrupt(void) {
|
||||||
|
Wire.beginTransmission(MCU_ADDRESS);
|
||||||
|
#if ARDUINO >= 100
|
||||||
|
Wire.write(MCU_COMMAND_BIT | 0x66);
|
||||||
|
#else
|
||||||
|
Wire.send(MCU_COMMAND_BIT | 0x66);
|
||||||
|
#endif
|
||||||
|
Wire.endTransmission();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void GY33_MCU::setConfig(uint8_t high, uint8_t low) {
|
||||||
|
// write8(MCU_CONFIG, high | low);
|
||||||
|
write8(MCU_CONFIG, 0x11);
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
#include <brzo_i2c.h>
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@file GY33_MCU.h
|
||||||
|
@author BPoHVoodoo (FabLab Luenen)
|
||||||
|
|
||||||
|
@section LICENSE
|
||||||
|
|
||||||
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
|
Copyright (c) 2018,
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the copyright holders nor the
|
||||||
|
names of its contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
#ifndef _MCU_H_
|
||||||
|
#define _MCU_H_
|
||||||
|
|
||||||
|
#if ARDUINO >= 100
|
||||||
|
#include <Arduino.h>
|
||||||
|
#else
|
||||||
|
#include <WProgram.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <brzo_i2c.h>
|
||||||
|
|
||||||
|
#define MCU_ADDRESS (0x5A)
|
||||||
|
|
||||||
|
#define SCL_SPEED 100
|
||||||
|
#define SCL_STRETCH_TIMEOUT 50000
|
||||||
|
|
||||||
|
#define MCU_LED_OFF (0x00)
|
||||||
|
#define MCU_LED_1 (0x10)
|
||||||
|
#define MCU_LED_2 (0x20)
|
||||||
|
#define MCU_LED_3 (0x30)
|
||||||
|
#define MCU_LED_4 (0x40)
|
||||||
|
#define MCU_LED_5 (0x50)
|
||||||
|
#define MCU_LED_6 (0x60)
|
||||||
|
#define MCU_LED_7 (0x70)
|
||||||
|
#define MCU_LED_8 (0x80)
|
||||||
|
#define MCU_LED_9 (0x90)
|
||||||
|
#define MCU_LED_10 (0xA0)
|
||||||
|
#define MCU_WHITE_OFF (0x00) /* No Whitebalance */
|
||||||
|
#define MCU_WHITE_ON (0x01) /* Whitebalance */
|
||||||
|
|
||||||
|
#define MCU_RDATAH (0x00) /* Raw Red channel data */
|
||||||
|
#define MCU_RDATAL (0x01)
|
||||||
|
#define MCU_GDATAH (0x02) /* Raw Green channel data */
|
||||||
|
#define MCU_GDATAL (0x03)
|
||||||
|
#define MCU_BDATAH (0x04) /* Raw Blue channel data */
|
||||||
|
#define MCU_BDATAL (0x05)
|
||||||
|
#define MCU_CDATAH (0x06) /* Clear channel data */
|
||||||
|
#define MCU_CDATAL (0x07)
|
||||||
|
#define MCU_LDATAH (0x08) /* Lux channel data */
|
||||||
|
#define MCU_LDATAL (0x09)
|
||||||
|
#define MCU_CTDATAH (0x0A) /* Colortemperature channel data */
|
||||||
|
#define MCU_CTDATAL (0x0B)
|
||||||
|
#define MCU_RDATA (0x0C) /* Red channel data */
|
||||||
|
#define MCU_GDATA (0x0D) /* Green channel data */
|
||||||
|
#define MCU_BDATA (0x0E) /* Blue channel data */
|
||||||
|
#define MCU_COLDATA (0x0F) /* Blue channel data */
|
||||||
|
#define MCU_CONFIG (0x10)
|
||||||
|
|
||||||
|
class GY33_MCU {
|
||||||
|
public:
|
||||||
|
GY33_MCU();
|
||||||
|
|
||||||
|
boolean begin(void);
|
||||||
|
void getRawData(uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c, uint16_t *ct);
|
||||||
|
void getData(uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *c);
|
||||||
|
uint16_t calculateColorTemperature(uint16_t r, uint16_t g, uint16_t b);
|
||||||
|
uint16_t calculateLux(uint16_t r, uint16_t g, uint16_t b);
|
||||||
|
void write8 (uint8_t reg, uint32_t val);
|
||||||
|
uint8_t read8 (uint8_t reg);
|
||||||
|
uint16_t read16 (uint8_t reg);
|
||||||
|
/* void setInterrupt(boolean flag);
|
||||||
|
void clearInterrupt(void);*/
|
||||||
|
void setConfig(uint8_t h, uint8_t l);
|
||||||
|
|
||||||
|
private:
|
||||||
|
boolean _MCUInitialised;
|
||||||
|
|
||||||
|
void disable(void);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
+556
-247
File diff suppressed because it is too large
Load Diff
+107
-101
@@ -7,10 +7,10 @@
|
|||||||
|
|
||||||
FEATURES
|
FEATURES
|
||||||
* A lot of blinken modes and counting
|
* A lot of blinken modes and counting
|
||||||
* WS2812FX can be used as drop-in replacement for Adafruit Neopixel Library
|
* WS2812FX can be used as drop-in replacement for Adafruit NeoPixel Library
|
||||||
|
|
||||||
NOTES
|
NOTES
|
||||||
* Uses the Adafruit Neopixel library. Get it here:
|
* Uses the Adafruit NeoPixel library. Get it here:
|
||||||
https://github.com/adafruit/Adafruit_NeoPixel
|
https://github.com/adafruit/Adafruit_NeoPixel
|
||||||
|
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ void WS2812FX::decreaseLength(uint16_t s) {
|
|||||||
s = _segments[0].stop - _segments[0].start + 1 - s;
|
s = _segments[0].stop - _segments[0].start + 1 - s;
|
||||||
|
|
||||||
for(uint16_t i=_segments[0].start + s; i <= (_segments[0].stop - _segments[0].start + 1); i++) {
|
for(uint16_t i=_segments[0].start + s; i <= (_segments[0].stop - _segments[0].start + 1); i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, 0);
|
this->setPixelColor(i, 0);
|
||||||
}
|
}
|
||||||
Adafruit_NeoPixel::show();
|
Adafruit_NeoPixel::show();
|
||||||
|
|
||||||
@@ -211,7 +211,15 @@ uint32_t WS2812FX::getColor(void) {
|
|||||||
return _segments[0].colors[0];
|
return _segments[0].colors[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
WS2812FX::segment* WS2812FX::getSegments(void) {
|
WS2812FX::Segment WS2812FX::getSegment(void) {
|
||||||
|
return SEGMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
WS2812FX::Segment_runtime WS2812FX::getSegmentRuntime(void) {
|
||||||
|
return SEGMENT_RUNTIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
WS2812FX::Segment* WS2812FX::getSegments(void) {
|
||||||
return _segments;
|
return _segments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +261,6 @@ void WS2812FX::setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t mode
|
|||||||
void WS2812FX::resetSegments() {
|
void WS2812FX::resetSegments() {
|
||||||
memset(_segments, 0, sizeof(_segments));
|
memset(_segments, 0, sizeof(_segments));
|
||||||
memset(_segment_runtimes, 0, sizeof(_segment_runtimes));
|
memset(_segment_runtimes, 0, sizeof(_segment_runtimes));
|
||||||
|
|
||||||
_segment_index = 0;
|
_segment_index = 0;
|
||||||
_num_segments = 1;
|
_num_segments = 1;
|
||||||
setSegment(0, 0, 7, FX_MODE_STATIC, DEFAULT_COLOR, DEFAULT_SPEED, false);
|
setSegment(0, 0, 7, FX_MODE_STATIC, DEFAULT_COLOR, DEFAULT_SPEED, false);
|
||||||
@@ -318,7 +325,7 @@ uint8_t WS2812FX::get_random_wheel_index(uint8_t pos) {
|
|||||||
*/
|
*/
|
||||||
uint16_t WS2812FX::mode_static(void) {
|
uint16_t WS2812FX::mode_static(void) {
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, SEGMENT.colors[0]);
|
this->setPixelColor(i, SEGMENT.colors[0]);
|
||||||
}
|
}
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
@@ -334,7 +341,7 @@ uint16_t WS2812FX::blink(uint32_t color1, uint32_t color2, bool strobe) {
|
|||||||
if(SEGMENT.reverse) color = (color == color1) ? color2 : color1;
|
if(SEGMENT.reverse) color = (color == color1) ? color2 : color1;
|
||||||
|
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, color);
|
this->setPixelColor(i, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((SEGMENT_RUNTIME.counter_mode_call & 1) == 0) {
|
if((SEGMENT_RUNTIME.counter_mode_call & 1) == 0) {
|
||||||
@@ -386,16 +393,16 @@ uint16_t WS2812FX::color_wipe(uint32_t color1, uint32_t color2, bool rev) {
|
|||||||
if(SEGMENT_RUNTIME.counter_mode_step < SEGMENT_LENGTH) {
|
if(SEGMENT_RUNTIME.counter_mode_step < SEGMENT_LENGTH) {
|
||||||
uint32_t led_offset = SEGMENT_RUNTIME.counter_mode_step;
|
uint32_t led_offset = SEGMENT_RUNTIME.counter_mode_step;
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - led_offset, color1);
|
this->setPixelColor(SEGMENT.stop - led_offset, color1);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + led_offset, color1);
|
this->setPixelColor(SEGMENT.start + led_offset, color1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uint32_t led_offset = SEGMENT_RUNTIME.counter_mode_step - SEGMENT_LENGTH;
|
uint32_t led_offset = SEGMENT_RUNTIME.counter_mode_step - SEGMENT_LENGTH;
|
||||||
if((SEGMENT.reverse && !rev) || (!SEGMENT.reverse && rev)) {
|
if((SEGMENT.reverse && !rev) || (!SEGMENT.reverse && rev)) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - led_offset, color2);
|
this->setPixelColor(SEGMENT.stop - led_offset, color2);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + led_offset, color2);
|
this->setPixelColor(SEGMENT.start + led_offset, color2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,7 +444,7 @@ uint16_t WS2812FX::mode_color_wipe_random(void) {
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Random color intruduced alternating from start and end of strip.
|
* Random color introduced alternating from start and end of strip.
|
||||||
*/
|
*/
|
||||||
uint16_t WS2812FX::mode_color_sweep_random(void) {
|
uint16_t WS2812FX::mode_color_sweep_random(void) {
|
||||||
if(SEGMENT_RUNTIME.counter_mode_step % SEGMENT_LENGTH == 0) { // aux_param will store our random color wheel index
|
if(SEGMENT_RUNTIME.counter_mode_step % SEGMENT_LENGTH == 0) { // aux_param will store our random color wheel index
|
||||||
@@ -457,7 +464,7 @@ uint16_t WS2812FX::mode_random_color(void) {
|
|||||||
uint32_t color = color_wheel(SEGMENT_RUNTIME.aux_param);
|
uint32_t color = color_wheel(SEGMENT_RUNTIME.aux_param);
|
||||||
|
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, color);
|
this->setPixelColor(i, color);
|
||||||
}
|
}
|
||||||
return (SEGMENT.speed);
|
return (SEGMENT.speed);
|
||||||
}
|
}
|
||||||
@@ -470,11 +477,11 @@ uint16_t WS2812FX::mode_random_color(void) {
|
|||||||
uint16_t WS2812FX::mode_single_dynamic(void) {
|
uint16_t WS2812FX::mode_single_dynamic(void) {
|
||||||
if(SEGMENT_RUNTIME.counter_mode_call == 0) {
|
if(SEGMENT_RUNTIME.counter_mode_call == 0) {
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, color_wheel(random(256)));
|
this->setPixelColor(i, color_wheel(random(256)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), color_wheel(random(256)));
|
this->setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), color_wheel(random(256)));
|
||||||
return (SEGMENT.speed);
|
return (SEGMENT.speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,7 +492,7 @@ uint16_t WS2812FX::mode_single_dynamic(void) {
|
|||||||
*/
|
*/
|
||||||
uint16_t WS2812FX::mode_multi_dynamic(void) {
|
uint16_t WS2812FX::mode_multi_dynamic(void) {
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, color_wheel(random(256)));
|
this->setPixelColor(i, color_wheel(random(256)));
|
||||||
}
|
}
|
||||||
return (SEGMENT.speed);
|
return (SEGMENT.speed);
|
||||||
}
|
}
|
||||||
@@ -523,7 +530,7 @@ uint16_t WS2812FX::mode_breath(void) {
|
|||||||
uint8_t g = (SEGMENT.colors[0] >> 8 & 0xFF) * lum / _brightness;
|
uint8_t g = (SEGMENT.colors[0] >> 8 & 0xFF) * lum / _brightness;
|
||||||
uint8_t b = (SEGMENT.colors[0] & 0xFF) * lum / _brightness;
|
uint8_t b = (SEGMENT.colors[0] & 0xFF) * lum / _brightness;
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, r, g, b, w);
|
this->setPixelColor(i, r, g, b, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
SEGMENT_RUNTIME.aux_param = breath_brightness;
|
SEGMENT_RUNTIME.aux_param = breath_brightness;
|
||||||
@@ -544,7 +551,7 @@ uint16_t WS2812FX::mode_fade(void) {
|
|||||||
uint8_t g = (SEGMENT.colors[0] >> 8 & 0xFF) * lum / _brightness;
|
uint8_t g = (SEGMENT.colors[0] >> 8 & 0xFF) * lum / _brightness;
|
||||||
uint8_t b = (SEGMENT.colors[0] & 0xFF) * lum / _brightness;
|
uint8_t b = (SEGMENT.colors[0] & 0xFF) * lum / _brightness;
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, r, g, b, w);
|
this->setPixelColor(i, r, g, b, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) % 64;
|
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) % 64;
|
||||||
@@ -561,16 +568,16 @@ uint16_t WS2812FX::mode_scan(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, BLACK);
|
this->setPixelColor(i, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int led_offset = SEGMENT_RUNTIME.counter_mode_step - (SEGMENT_LENGTH - 1);
|
int led_offset = SEGMENT_RUNTIME.counter_mode_step - (SEGMENT_LENGTH - 1);
|
||||||
led_offset = abs(led_offset);
|
led_offset = abs(led_offset);
|
||||||
|
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - led_offset, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.stop - led_offset, SEGMENT.colors[0]);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + led_offset, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + led_offset, SEGMENT.colors[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SEGMENT_RUNTIME.counter_mode_step++;
|
SEGMENT_RUNTIME.counter_mode_step++;
|
||||||
@@ -587,14 +594,14 @@ uint16_t WS2812FX::mode_dual_scan(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, BLACK);
|
this->setPixelColor(i, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
int led_offset = SEGMENT_RUNTIME.counter_mode_step - (SEGMENT_LENGTH - 1);
|
int led_offset = SEGMENT_RUNTIME.counter_mode_step - (SEGMENT_LENGTH - 1);
|
||||||
led_offset = abs(led_offset);
|
led_offset = abs(led_offset);
|
||||||
|
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + led_offset, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + led_offset, SEGMENT.colors[0]);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + SEGMENT_LENGTH - led_offset - 1, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + SEGMENT_LENGTH - led_offset - 1, SEGMENT.colors[0]);
|
||||||
|
|
||||||
SEGMENT_RUNTIME.counter_mode_step++;
|
SEGMENT_RUNTIME.counter_mode_step++;
|
||||||
return (SEGMENT.speed / (SEGMENT_LENGTH * 2));
|
return (SEGMENT.speed / (SEGMENT_LENGTH * 2));
|
||||||
@@ -607,7 +614,7 @@ uint16_t WS2812FX::mode_dual_scan(void) {
|
|||||||
uint16_t WS2812FX::mode_rainbow(void) {
|
uint16_t WS2812FX::mode_rainbow(void) {
|
||||||
uint32_t color = color_wheel(SEGMENT_RUNTIME.counter_mode_step);
|
uint32_t color = color_wheel(SEGMENT_RUNTIME.counter_mode_step);
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, color);
|
this->setPixelColor(i, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) & 0xFF;
|
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) & 0xFF;
|
||||||
@@ -621,7 +628,7 @@ uint16_t WS2812FX::mode_rainbow(void) {
|
|||||||
uint16_t WS2812FX::mode_rainbow_cycle(void) {
|
uint16_t WS2812FX::mode_rainbow_cycle(void) {
|
||||||
for(uint16_t i=0; i < SEGMENT_LENGTH; i++) {
|
for(uint16_t i=0; i < SEGMENT_LENGTH; i++) {
|
||||||
uint32_t color = color_wheel(((i * 256 / SEGMENT_LENGTH) + SEGMENT_RUNTIME.counter_mode_step) & 0xFF);
|
uint32_t color = color_wheel(((i * 256 / SEGMENT_LENGTH) + SEGMENT_RUNTIME.counter_mode_step) & 0xFF);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + i, color);
|
this->setPixelColor(SEGMENT.start + i, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) & 0xFF;
|
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) & 0xFF;
|
||||||
@@ -637,15 +644,15 @@ uint16_t WS2812FX::theater_chase(uint32_t color1, uint32_t color2) {
|
|||||||
for(uint16_t i=0; i < SEGMENT_LENGTH; i++) {
|
for(uint16_t i=0; i < SEGMENT_LENGTH; i++) {
|
||||||
if((i % 3) == SEGMENT_RUNTIME.counter_mode_call) {
|
if((i % 3) == SEGMENT_RUNTIME.counter_mode_call) {
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - i, color1);
|
this->setPixelColor(SEGMENT.stop - i, color1);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + i, color1);
|
this->setPixelColor(SEGMENT.start + i, color1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - i, color2);
|
this->setPixelColor(SEGMENT.stop - i, color2);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + i, color2);
|
this->setPixelColor(SEGMENT.start + i, color2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -686,9 +693,9 @@ uint16_t WS2812FX::mode_running_lights(void) {
|
|||||||
for(uint16_t i=0; i < SEGMENT_LENGTH; i++) {
|
for(uint16_t i=0; i < SEGMENT_LENGTH; i++) {
|
||||||
int lum = map((int)(sin((i + SEGMENT_RUNTIME.counter_mode_step) * radPerLed) * 128), -128, 128, 0, 255);
|
int lum = map((int)(sin((i + SEGMENT_RUNTIME.counter_mode_step) * radPerLed) * 128), -128, 128, 0, 255);
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + i, (r * lum) / 256, (g * lum) / 256, (b * lum) / 256, (w * lum) / 256);
|
this->setPixelColor(SEGMENT.start + i, (r * lum) / 256, (g * lum) / 256, (b * lum) / 256, (w * lum) / 256);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - i, (r * lum) / 256, (g * lum) / 256, (b * lum) / 256, (w * lum) / 256);
|
this->setPixelColor(SEGMENT.stop - i, (r * lum) / 256, (g * lum) / 256, (b * lum) / 256, (w * lum) / 256);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) % SEGMENT_LENGTH;
|
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) % SEGMENT_LENGTH;
|
||||||
@@ -702,14 +709,14 @@ uint16_t WS2812FX::mode_running_lights(void) {
|
|||||||
uint16_t WS2812FX::twinkle(uint32_t color) {
|
uint16_t WS2812FX::twinkle(uint32_t color) {
|
||||||
if(SEGMENT_RUNTIME.counter_mode_step == 0) {
|
if(SEGMENT_RUNTIME.counter_mode_step == 0) {
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, BLACK);
|
this->setPixelColor(i, BLACK);
|
||||||
}
|
}
|
||||||
uint16_t min_leds = max(1, SEGMENT_LENGTH / 5); // make sure, at least one LED is on
|
uint16_t min_leds = max(1, SEGMENT_LENGTH / 5); // make sure, at least one LED is on
|
||||||
uint16_t max_leds = max(1, SEGMENT_LENGTH / 2); // make sure, at least one LED is on
|
uint16_t max_leds = max(1, SEGMENT_LENGTH / 2); // make sure, at least one LED is on
|
||||||
SEGMENT_RUNTIME.counter_mode_step = random(min_leds, max_leds);
|
SEGMENT_RUNTIME.counter_mode_step = random(min_leds, max_leds);
|
||||||
}
|
}
|
||||||
|
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), color);
|
this->setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), color);
|
||||||
|
|
||||||
SEGMENT_RUNTIME.counter_mode_step--;
|
SEGMENT_RUNTIME.counter_mode_step--;
|
||||||
return (SEGMENT.speed / SEGMENT_LENGTH);
|
return (SEGMENT.speed / SEGMENT_LENGTH);
|
||||||
@@ -740,7 +747,7 @@ void WS2812FX::fade_out() {
|
|||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
uint32_t color = Adafruit_NeoPixel::getPixelColor(i);
|
uint32_t color = Adafruit_NeoPixel::getPixelColor(i);
|
||||||
color = (color >> 1) & 0x7F7F7F7F;
|
color = (color >> 1) & 0x7F7F7F7F;
|
||||||
Adafruit_NeoPixel::setPixelColor(i, color);
|
this->setPixelColor(i, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,7 +758,7 @@ uint16_t WS2812FX::twinkle_fade(uint32_t color) {
|
|||||||
fade_out();
|
fade_out();
|
||||||
|
|
||||||
if(random(3) == 0) {
|
if(random(3) == 0) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), color);
|
this->setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), color);
|
||||||
}
|
}
|
||||||
return (SEGMENT.speed / 8);
|
return (SEGMENT.speed / 8);
|
||||||
}
|
}
|
||||||
@@ -778,9 +785,9 @@ uint16_t WS2812FX::mode_twinkle_fade_random(void) {
|
|||||||
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
|
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
|
||||||
*/
|
*/
|
||||||
uint16_t WS2812FX::mode_sparkle(void) {
|
uint16_t WS2812FX::mode_sparkle(void) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param, BLACK);
|
this->setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param, BLACK);
|
||||||
SEGMENT_RUNTIME.aux_param = random(SEGMENT_LENGTH); // aux_param stores the random led index
|
SEGMENT_RUNTIME.aux_param = random(SEGMENT_LENGTH); // aux_param stores the random led index
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param, SEGMENT.colors[0]);
|
||||||
return (SEGMENT.speed / SEGMENT_LENGTH);
|
return (SEGMENT.speed / SEGMENT_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -792,15 +799,15 @@ uint16_t WS2812FX::mode_sparkle(void) {
|
|||||||
uint16_t WS2812FX::mode_flash_sparkle(void) {
|
uint16_t WS2812FX::mode_flash_sparkle(void) {
|
||||||
if(SEGMENT_RUNTIME.counter_mode_call == 0) {
|
if(SEGMENT_RUNTIME.counter_mode_call == 0) {
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, SEGMENT.colors[0]);
|
this->setPixelColor(i, SEGMENT.colors[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param, SEGMENT.colors[0]);
|
||||||
|
|
||||||
if(random(5) == 0) {
|
if(random(5) == 0) {
|
||||||
SEGMENT_RUNTIME.aux_param = random(SEGMENT_LENGTH); // aux_param stores the random led index
|
SEGMENT_RUNTIME.aux_param = random(SEGMENT_LENGTH); // aux_param stores the random led index
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param, WHITE);
|
this->setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.aux_param, WHITE);
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
return SEGMENT.speed;
|
return SEGMENT.speed;
|
||||||
@@ -813,12 +820,12 @@ uint16_t WS2812FX::mode_flash_sparkle(void) {
|
|||||||
*/
|
*/
|
||||||
uint16_t WS2812FX::mode_hyper_sparkle(void) {
|
uint16_t WS2812FX::mode_hyper_sparkle(void) {
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, SEGMENT.colors[0]);
|
this->setPixelColor(i, SEGMENT.colors[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(random(5) < 2) {
|
if(random(5) < 2) {
|
||||||
for(uint16_t i=0; i < max(1, SEGMENT_LENGTH/3); i++) {
|
for(uint16_t i=0; i < max(1, SEGMENT_LENGTH/3); i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), WHITE);
|
this->setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), WHITE);
|
||||||
}
|
}
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
@@ -831,14 +838,14 @@ uint16_t WS2812FX::mode_hyper_sparkle(void) {
|
|||||||
*/
|
*/
|
||||||
uint16_t WS2812FX::mode_multi_strobe(void) {
|
uint16_t WS2812FX::mode_multi_strobe(void) {
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, BLACK);
|
this->setPixelColor(i, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t delay = SEGMENT.speed / (2 * ((SEGMENT.speed / 10) + 1));
|
uint16_t delay = SEGMENT.speed / (2 * ((SEGMENT.speed / 10) + 1));
|
||||||
if(SEGMENT_RUNTIME.counter_mode_step < (2 * ((SEGMENT.speed / 10) + 1))) {
|
if(SEGMENT_RUNTIME.counter_mode_step < (2 * ((SEGMENT.speed / 10) + 1))) {
|
||||||
if((SEGMENT_RUNTIME.counter_mode_step & 1) == 0) {
|
if((SEGMENT_RUNTIME.counter_mode_step & 1) == 0) {
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, SEGMENT.colors[0]);
|
this->setPixelColor(i, SEGMENT.colors[0]);
|
||||||
}
|
}
|
||||||
delay = 20;
|
delay = 20;
|
||||||
} else {
|
} else {
|
||||||
@@ -861,13 +868,13 @@ uint16_t WS2812FX::chase(uint32_t color1, uint32_t color2, uint32_t color3) {
|
|||||||
uint16_t b = (a + 1) % SEGMENT_LENGTH;
|
uint16_t b = (a + 1) % SEGMENT_LENGTH;
|
||||||
uint16_t c = (b + 1) % SEGMENT_LENGTH;
|
uint16_t c = (b + 1) % SEGMENT_LENGTH;
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - a, color1);
|
this->setPixelColor(SEGMENT.stop - a, color1);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - b, color2);
|
this->setPixelColor(SEGMENT.stop - b, color2);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - c, color3);
|
this->setPixelColor(SEGMENT.stop - c, color3);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + a, color1);
|
this->setPixelColor(SEGMENT.start + a, color1);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + b, color2);
|
this->setPixelColor(SEGMENT.start + b, color2);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + c, color3);
|
this->setPixelColor(SEGMENT.start + c, color3);
|
||||||
}
|
}
|
||||||
|
|
||||||
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) % SEGMENT_LENGTH;
|
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) % SEGMENT_LENGTH;
|
||||||
@@ -963,7 +970,7 @@ uint16_t WS2812FX::mode_chase_flash(void) {
|
|||||||
uint8_t flash_step = SEGMENT_RUNTIME.counter_mode_call % ((flash_count * 2) + 1);
|
uint8_t flash_step = SEGMENT_RUNTIME.counter_mode_call % ((flash_count * 2) + 1);
|
||||||
|
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(i, SEGMENT.colors[0]);
|
this->setPixelColor(i, SEGMENT.colors[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t delay = (SEGMENT.speed / SEGMENT_LENGTH);
|
uint16_t delay = (SEGMENT.speed / SEGMENT_LENGTH);
|
||||||
@@ -972,11 +979,11 @@ uint16_t WS2812FX::mode_chase_flash(void) {
|
|||||||
uint16_t n = SEGMENT_RUNTIME.counter_mode_step;
|
uint16_t n = SEGMENT_RUNTIME.counter_mode_step;
|
||||||
uint16_t m = (SEGMENT_RUNTIME.counter_mode_step + 1) % SEGMENT_LENGTH;
|
uint16_t m = (SEGMENT_RUNTIME.counter_mode_step + 1) % SEGMENT_LENGTH;
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - n, WHITE);
|
this->setPixelColor(SEGMENT.stop - n, WHITE);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - m, WHITE);
|
this->setPixelColor(SEGMENT.stop - m, WHITE);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + n, WHITE);
|
this->setPixelColor(SEGMENT.start + n, WHITE);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + m, WHITE);
|
this->setPixelColor(SEGMENT.start + m, WHITE);
|
||||||
}
|
}
|
||||||
delay = 20;
|
delay = 20;
|
||||||
} else {
|
} else {
|
||||||
@@ -997,7 +1004,7 @@ uint16_t WS2812FX::mode_chase_flash_random(void) {
|
|||||||
uint8_t flash_step = SEGMENT_RUNTIME.counter_mode_call % ((flash_count * 2) + 1);
|
uint8_t flash_step = SEGMENT_RUNTIME.counter_mode_call % ((flash_count * 2) + 1);
|
||||||
|
|
||||||
for(uint16_t i=0; i < SEGMENT_RUNTIME.counter_mode_step; i++) {
|
for(uint16_t i=0; i < SEGMENT_RUNTIME.counter_mode_step; i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + i, color_wheel(SEGMENT_RUNTIME.aux_param));
|
this->setPixelColor(SEGMENT.start + i, color_wheel(SEGMENT_RUNTIME.aux_param));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t delay = (SEGMENT.speed / SEGMENT_LENGTH);
|
uint16_t delay = (SEGMENT.speed / SEGMENT_LENGTH);
|
||||||
@@ -1005,12 +1012,12 @@ uint16_t WS2812FX::mode_chase_flash_random(void) {
|
|||||||
uint16_t n = SEGMENT_RUNTIME.counter_mode_step;
|
uint16_t n = SEGMENT_RUNTIME.counter_mode_step;
|
||||||
uint16_t m = (SEGMENT_RUNTIME.counter_mode_step + 1) % SEGMENT_LENGTH;
|
uint16_t m = (SEGMENT_RUNTIME.counter_mode_step + 1) % SEGMENT_LENGTH;
|
||||||
if(flash_step % 2 == 0) {
|
if(flash_step % 2 == 0) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + n, WHITE);
|
this->setPixelColor(SEGMENT.start + n, WHITE);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + m, WHITE);
|
this->setPixelColor(SEGMENT.start + m, WHITE);
|
||||||
delay = 20;
|
delay = 20;
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + n, color_wheel(SEGMENT_RUNTIME.aux_param));
|
this->setPixelColor(SEGMENT.start + n, color_wheel(SEGMENT_RUNTIME.aux_param));
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + m, BLACK);
|
this->setPixelColor(SEGMENT.start + m, BLACK);
|
||||||
delay = 30;
|
delay = 30;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1031,15 +1038,15 @@ uint16_t WS2812FX::running(uint32_t color1, uint32_t color2) {
|
|||||||
for(uint16_t i=0; i < SEGMENT_LENGTH; i++) {
|
for(uint16_t i=0; i < SEGMENT_LENGTH; i++) {
|
||||||
if((i + SEGMENT_RUNTIME.counter_mode_step) % 4 < 2) {
|
if((i + SEGMENT_RUNTIME.counter_mode_step) % 4 < 2) {
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + i, color1);
|
this->setPixelColor(SEGMENT.start + i, color1);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - i, color1);
|
this->setPixelColor(SEGMENT.stop - i, color1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + i, color2);
|
this->setPixelColor(SEGMENT.start + i, color2);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - i, color2);
|
this->setPixelColor(SEGMENT.stop - i, color2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1085,18 +1092,18 @@ uint16_t WS2812FX::mode_halloween(void) {
|
|||||||
uint16_t WS2812FX::mode_running_random(void) {
|
uint16_t WS2812FX::mode_running_random(void) {
|
||||||
for(uint16_t i=SEGMENT_LENGTH-1; i > 0; i--) {
|
for(uint16_t i=SEGMENT_LENGTH-1; i > 0; i--) {
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - i, Adafruit_NeoPixel::getPixelColor(SEGMENT.stop - i + 1));
|
this->setPixelColor(SEGMENT.stop - i, Adafruit_NeoPixel::getPixelColor(SEGMENT.stop - i + 1));
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + i, Adafruit_NeoPixel::getPixelColor(SEGMENT.start + i - 1));
|
this->setPixelColor(SEGMENT.start + i, Adafruit_NeoPixel::getPixelColor(SEGMENT.start + i - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SEGMENT_RUNTIME.counter_mode_step == 0) {
|
if(SEGMENT_RUNTIME.counter_mode_step == 0) {
|
||||||
SEGMENT_RUNTIME.aux_param = get_random_wheel_index(SEGMENT_RUNTIME.aux_param);
|
SEGMENT_RUNTIME.aux_param = get_random_wheel_index(SEGMENT_RUNTIME.aux_param);
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop, color_wheel(SEGMENT_RUNTIME.aux_param));
|
this->setPixelColor(SEGMENT.stop, color_wheel(SEGMENT_RUNTIME.aux_param));
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start, color_wheel(SEGMENT_RUNTIME.aux_param));
|
this->setPixelColor(SEGMENT.start, color_wheel(SEGMENT_RUNTIME.aux_param));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1113,15 +1120,15 @@ uint16_t WS2812FX::mode_larson_scanner(void) {
|
|||||||
|
|
||||||
if(SEGMENT_RUNTIME.counter_mode_step < SEGMENT_LENGTH) {
|
if(SEGMENT_RUNTIME.counter_mode_step < SEGMENT_LENGTH) {
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - SEGMENT_RUNTIME.counter_mode_step, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.stop - SEGMENT_RUNTIME.counter_mode_step, SEGMENT.colors[0]);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.counter_mode_step, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.counter_mode_step, SEGMENT.colors[0]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - ((SEGMENT_LENGTH * 2) - SEGMENT_RUNTIME.counter_mode_step) + 2, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.stop - ((SEGMENT_LENGTH * 2) - SEGMENT_RUNTIME.counter_mode_step) + 2, SEGMENT.colors[0]);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + ((SEGMENT_LENGTH * 2) - SEGMENT_RUNTIME.counter_mode_step) - 2, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + ((SEGMENT_LENGTH * 2) - SEGMENT_RUNTIME.counter_mode_step) - 2, SEGMENT.colors[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1137,9 +1144,9 @@ uint16_t WS2812FX::mode_comet(void) {
|
|||||||
fade_out();
|
fade_out();
|
||||||
|
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - SEGMENT_RUNTIME.counter_mode_step, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.stop - SEGMENT_RUNTIME.counter_mode_step, SEGMENT.colors[0]);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.counter_mode_step, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + SEGMENT_RUNTIME.counter_mode_step, SEGMENT.colors[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) % SEGMENT_LENGTH;
|
SEGMENT_RUNTIME.counter_mode_step = (SEGMENT_RUNTIME.counter_mode_step + 1) % SEGMENT_LENGTH;
|
||||||
@@ -1166,7 +1173,7 @@ uint32_t prevLed, thisLed, nextLed;
|
|||||||
px_r = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.start+1) & 0xFF0000) >> 16) >> 1) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.start) & 0xFF0000) >> 16);
|
px_r = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.start+1) & 0xFF0000) >> 16) >> 1) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.start) & 0xFF0000) >> 16);
|
||||||
px_g = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.start+1) & 0x00FF00) >> 8) >> 1) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.start) & 0x00FF00) >> 8);
|
px_g = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.start+1) & 0x00FF00) >> 8) >> 1) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.start) & 0x00FF00) >> 8);
|
||||||
px_b = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.start+1) & 0x0000FF) ) >> 1) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.start) & 0x0000FF));
|
px_b = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.start+1) & 0x0000FF) ) >> 1) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.start) & 0x0000FF));
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start, px_r, px_g, px_b);
|
this->setPixelColor(SEGMENT.start, px_r, px_g, px_b);
|
||||||
*/
|
*/
|
||||||
// set brightness(i) = ((brightness(i-1)/2 + brightness(i+1)) / 2) + brightness(i)
|
// set brightness(i) = ((brightness(i-1)/2 + brightness(i+1)) / 2) + brightness(i)
|
||||||
for(uint16_t i=SEGMENT.start + 1; i <SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start + 1; i <SEGMENT.stop; i++) {
|
||||||
@@ -1174,7 +1181,7 @@ uint32_t prevLed, thisLed, nextLed;
|
|||||||
prevLed = (Adafruit_NeoPixel::getPixelColor(i-1) >> 2) & 0x3F3F3F3F;
|
prevLed = (Adafruit_NeoPixel::getPixelColor(i-1) >> 2) & 0x3F3F3F3F;
|
||||||
thisLed = Adafruit_NeoPixel::getPixelColor(i);
|
thisLed = Adafruit_NeoPixel::getPixelColor(i);
|
||||||
nextLed = (Adafruit_NeoPixel::getPixelColor(i+1) >> 2) & 0x3F3F3F3F;
|
nextLed = (Adafruit_NeoPixel::getPixelColor(i+1) >> 2) & 0x3F3F3F3F;
|
||||||
Adafruit_NeoPixel::setPixelColor(i, prevLed + thisLed + nextLed);
|
this->setPixelColor(i, prevLed + thisLed + nextLed);
|
||||||
|
|
||||||
/* the old way
|
/* the old way
|
||||||
px_r = ((
|
px_r = ((
|
||||||
@@ -1192,7 +1199,7 @@ uint32_t prevLed, thisLed, nextLed;
|
|||||||
(((Adafruit_NeoPixel::getPixelColor(i+1) & 0x0000FF) ) ) ) >> 1) +
|
(((Adafruit_NeoPixel::getPixelColor(i+1) & 0x0000FF) ) ) ) >> 1) +
|
||||||
(((Adafruit_NeoPixel::getPixelColor(i ) & 0x0000FF) ) );
|
(((Adafruit_NeoPixel::getPixelColor(i ) & 0x0000FF) ) );
|
||||||
|
|
||||||
Adafruit_NeoPixel::setPixelColor(i, px_r, px_g, px_b);
|
this->setPixelColor(i, px_r, px_g, px_b);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1201,17 +1208,17 @@ uint32_t prevLed, thisLed, nextLed;
|
|||||||
px_r = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop-1) & 0xFF0000) >> 16) >> 2) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop) & 0xFF0000) >> 16);
|
px_r = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop-1) & 0xFF0000) >> 16) >> 2) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop) & 0xFF0000) >> 16);
|
||||||
px_g = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop-1) & 0x00FF00) >> 8) >> 2) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop) & 0x00FF00) >> 8);
|
px_g = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop-1) & 0x00FF00) >> 8) >> 2) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop) & 0x00FF00) >> 8);
|
||||||
px_b = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop-1) & 0x0000FF) ) >> 2) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop) & 0x0000FF));
|
px_b = (((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop-1) & 0x0000FF) ) >> 2) + ((Adafruit_NeoPixel::getPixelColor(SEGMENT.stop) & 0x0000FF));
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop, px_r, px_g, px_b);
|
this->setPixelColor(SEGMENT.stop, px_r, px_g, px_b);
|
||||||
*/
|
*/
|
||||||
if(!_triggered) {
|
if(!_triggered) {
|
||||||
for(uint16_t i=0; i<max(1, SEGMENT_LENGTH/20); i++) {
|
for(uint16_t i=0; i<max(1, SEGMENT_LENGTH/20); i++) {
|
||||||
if(random(10) == 0) {
|
if(random(10) == 0) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), color);
|
this->setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(uint16_t i=0; i<max(1, SEGMENT_LENGTH/10); i++) {
|
for(uint16_t i=0; i<max(1, SEGMENT_LENGTH/10); i++) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), color);
|
this->setPixelColor(SEGMENT.start + random(SEGMENT_LENGTH), color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (SEGMENT.speed / SEGMENT_LENGTH);
|
return (SEGMENT.speed / SEGMENT_LENGTH);
|
||||||
@@ -1247,7 +1254,7 @@ uint16_t WS2812FX::fire_flicker(int rev_intensity) {
|
|||||||
byte lum = max(w, max(r, max(g, b))) / rev_intensity;
|
byte lum = max(w, max(r, max(g, b))) / rev_intensity;
|
||||||
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
for(uint16_t i=SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||||
int flicker = random(0, lum);
|
int flicker = random(0, lum);
|
||||||
Adafruit_NeoPixel::setPixelColor(i, max(r - flicker, 0), max(g - flicker, 0), max(b - flicker, 0), max(w - flicker, 0));
|
this->setPixelColor(i, max(r - flicker, 0), max(g - flicker, 0), max(b - flicker, 0), max(w - flicker, 0));
|
||||||
}
|
}
|
||||||
return (SEGMENT.speed / SEGMENT_LENGTH);
|
return (SEGMENT.speed / SEGMENT_LENGTH);
|
||||||
}
|
}
|
||||||
@@ -1260,14 +1267,14 @@ uint16_t WS2812FX::mode_fire_flicker(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Random flickering, less intesity.
|
* Random flickering, less intensity.
|
||||||
*/
|
*/
|
||||||
uint16_t WS2812FX::mode_fire_flicker_soft(void) {
|
uint16_t WS2812FX::mode_fire_flicker_soft(void) {
|
||||||
return fire_flicker(6);
|
return fire_flicker(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Random flickering, more intesity.
|
* Random flickering, more intensity.
|
||||||
*/
|
*/
|
||||||
uint16_t WS2812FX::mode_fire_flicker_intense(void) {
|
uint16_t WS2812FX::mode_fire_flicker_intense(void) {
|
||||||
return fire_flicker(1.7);
|
return fire_flicker(1.7);
|
||||||
@@ -1281,21 +1288,21 @@ uint16_t WS2812FX::tricolor_chase(uint32_t color1, uint32_t color2, uint32_t col
|
|||||||
for(uint16_t i=0; i < SEGMENT_LENGTH; i++) {
|
for(uint16_t i=0; i < SEGMENT_LENGTH; i++) {
|
||||||
if((i + SEGMENT_RUNTIME.counter_mode_step) % 6 < 2) {
|
if((i + SEGMENT_RUNTIME.counter_mode_step) % 6 < 2) {
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + i, color1);
|
this->setPixelColor(SEGMENT.start + i, color1);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - i, color1);
|
this->setPixelColor(SEGMENT.stop - i, color1);
|
||||||
}
|
}
|
||||||
} else if((i + SEGMENT_RUNTIME.counter_mode_step) % 6 < 4) {
|
} else if((i + SEGMENT_RUNTIME.counter_mode_step) % 6 < 4) {
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + i, color2);
|
this->setPixelColor(SEGMENT.start + i, color2);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - i, color2);
|
this->setPixelColor(SEGMENT.stop - i, color2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(SEGMENT.reverse) {
|
if(SEGMENT.reverse) {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + i, color3);
|
this->setPixelColor(SEGMENT.start + i, color3);
|
||||||
} else {
|
} else {
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.stop - i, color3);
|
this->setPixelColor(SEGMENT.stop - i, color3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1323,24 +1330,24 @@ uint16_t WS2812FX::mode_circus_combustus(void) {
|
|||||||
/*
|
/*
|
||||||
* ICU mode
|
* ICU mode
|
||||||
*/
|
*/
|
||||||
uint16_t WS2812FX::mode_icu() {
|
uint16_t WS2812FX::mode_icu(void) {
|
||||||
uint16_t dest = SEGMENT_RUNTIME.counter_mode_step & 0xFFFF;
|
uint16_t dest = SEGMENT_RUNTIME.counter_mode_step & 0xFFFF;
|
||||||
|
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + dest, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + dest, SEGMENT.colors[0]);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + dest + SEGMENT_LENGTH/2, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + dest + SEGMENT_LENGTH/2, SEGMENT.colors[0]);
|
||||||
|
|
||||||
if(SEGMENT_RUNTIME.aux_param == dest) { // pause between eye movements
|
if(SEGMENT_RUNTIME.aux_param == dest) { // pause between eye movements
|
||||||
if(random(6) == 0) { // blink once in a while
|
if(random(6) == 0) { // blink once in a while
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + dest, 0);
|
this->setPixelColor(SEGMENT.start + dest, 0);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + dest + SEGMENT_LENGTH/2, 0);
|
this->setPixelColor(SEGMENT.start + dest + SEGMENT_LENGTH/2, 0);
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
SEGMENT_RUNTIME.aux_param = random(SEGMENT_LENGTH/2);
|
SEGMENT_RUNTIME.aux_param = random(SEGMENT_LENGTH/2);
|
||||||
return 1000 + random(2000);
|
return 1000 + random(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + dest, 0);
|
this->setPixelColor(SEGMENT.start + dest, 0);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + dest + SEGMENT_LENGTH/2, 0);
|
this->setPixelColor(SEGMENT.start + dest + SEGMENT_LENGTH/2, 0);
|
||||||
|
|
||||||
if(SEGMENT_RUNTIME.aux_param > SEGMENT_RUNTIME.counter_mode_step) {
|
if(SEGMENT_RUNTIME.aux_param > SEGMENT_RUNTIME.counter_mode_step) {
|
||||||
SEGMENT_RUNTIME.counter_mode_step++;
|
SEGMENT_RUNTIME.counter_mode_step++;
|
||||||
@@ -1350,8 +1357,8 @@ uint16_t WS2812FX::mode_icu() {
|
|||||||
dest--;
|
dest--;
|
||||||
}
|
}
|
||||||
|
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + dest, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + dest, SEGMENT.colors[0]);
|
||||||
Adafruit_NeoPixel::setPixelColor(SEGMENT.start + dest + SEGMENT_LENGTH/2, SEGMENT.colors[0]);
|
this->setPixelColor(SEGMENT.start + dest + SEGMENT_LENGTH/2, SEGMENT.colors[0]);
|
||||||
|
|
||||||
return (SEGMENT.speed / SEGMENT_LENGTH);
|
return (SEGMENT.speed / SEGMENT_LENGTH);
|
||||||
}
|
}
|
||||||
@@ -1372,6 +1379,5 @@ uint16_t WS2812FX::mode_custom() {
|
|||||||
* Custom mode helper
|
* Custom mode helper
|
||||||
*/
|
*/
|
||||||
void WS2812FX::setCustomMode(uint16_t (*p)()) {
|
void WS2812FX::setCustomMode(uint16_t (*p)()) {
|
||||||
setMode(FX_MODE_CUSTOM);
|
|
||||||
customMode = p;
|
customMode = p;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
www.aldick.org
|
www.aldick.org
|
||||||
FEATURES
|
FEATURES
|
||||||
* A lot of blinken modes and counting
|
* A lot of blinken modes and counting
|
||||||
* WS2812FX can be used as drop-in replacement for Adafruit Neopixel Library
|
* WS2812FX can be used as drop-in replacement for Adafruit NeoPixel Library
|
||||||
NOTES
|
NOTES
|
||||||
* Uses the Adafruit Neopixel library. Get it here:
|
* Uses the Adafruit NeoPixel library. Get it here:
|
||||||
https://github.com/adafruit/Adafruit_NeoPixel
|
https://github.com/adafruit/Adafruit_NeoPixel
|
||||||
LICENSE
|
LICENSE
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
@@ -50,8 +50,8 @@
|
|||||||
#define BRIGHTNESS_MIN 0
|
#define BRIGHTNESS_MIN 0
|
||||||
#define BRIGHTNESS_MAX 255
|
#define BRIGHTNESS_MAX 255
|
||||||
|
|
||||||
|
/* each segment uses 36 bytes of SRAM memory, so if you're application fails because of
|
||||||
|
insufficient memory, decreasing MAX_NUM_SEGMENTS may help */
|
||||||
#define MAX_NUM_SEGMENTS 10
|
#define MAX_NUM_SEGMENTS 10
|
||||||
#define NUM_COLORS 4 /* number of colors per segment */
|
#define NUM_COLORS 4 /* number of colors per segment */
|
||||||
#define SEGMENT _segments[_segment_index]
|
#define SEGMENT _segments[_segment_index]
|
||||||
@@ -138,25 +138,26 @@ class WS2812FX : public Adafruit_NeoPixel {
|
|||||||
|
|
||||||
// segment parameters
|
// segment parameters
|
||||||
public:
|
public:
|
||||||
typedef struct segment {
|
typedef struct Segment { // 20 bytes
|
||||||
uint8_t mode;
|
|
||||||
uint32_t colors[NUM_COLORS];
|
|
||||||
uint16_t speed;
|
|
||||||
uint16_t start;
|
uint16_t start;
|
||||||
uint16_t stop;
|
uint16_t stop;
|
||||||
|
uint16_t speed;
|
||||||
|
uint8_t mode;
|
||||||
bool reverse;
|
bool reverse;
|
||||||
|
uint32_t colors[NUM_COLORS];
|
||||||
} segment;
|
} segment;
|
||||||
|
|
||||||
// segment runtime parameters
|
// segment runtime parameters
|
||||||
typedef struct segment_runtime {
|
public:
|
||||||
uint32_t counter_mode_step;
|
typedef struct Segment_runtime { // 16 bytes
|
||||||
uint32_t counter_mode_call;
|
unsigned long next_time;
|
||||||
unsigned long next_time;
|
uint32_t counter_mode_step;
|
||||||
uint16_t aux_param;
|
uint32_t counter_mode_call;
|
||||||
} segment_runtime;
|
uint16_t aux_param;
|
||||||
|
uint16_t aux_param2;
|
||||||
|
} segment_runtime;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WS2812FX(uint16_t n, uint8_t p, neoPixelType t) : Adafruit_NeoPixel(n, p, t) {
|
WS2812FX(uint16_t n, uint8_t p, neoPixelType t) : Adafruit_NeoPixel(n, p, t) {
|
||||||
_mode[FX_MODE_STATIC] = &WS2812FX::mode_static;
|
_mode[FX_MODE_STATIC] = &WS2812FX::mode_static;
|
||||||
_mode[FX_MODE_BLINK] = &WS2812FX::mode_blink;
|
_mode[FX_MODE_BLINK] = &WS2812FX::mode_blink;
|
||||||
@@ -211,7 +212,7 @@ class WS2812FX : public Adafruit_NeoPixel {
|
|||||||
_mode[FX_MODE_CIRCUS_COMBUSTUS] = &WS2812FX::mode_circus_combustus;
|
_mode[FX_MODE_CIRCUS_COMBUSTUS] = &WS2812FX::mode_circus_combustus;
|
||||||
_mode[FX_MODE_BICOLOR_CHASE] = &WS2812FX::mode_bicolor_chase;
|
_mode[FX_MODE_BICOLOR_CHASE] = &WS2812FX::mode_bicolor_chase;
|
||||||
_mode[FX_MODE_TRICOLOR_CHASE] = &WS2812FX::mode_tricolor_chase;
|
_mode[FX_MODE_TRICOLOR_CHASE] = &WS2812FX::mode_tricolor_chase;
|
||||||
// if flash memory is constrained (i'm looking at you Adruino Nano), replace modes
|
// if flash memory is constrained (I'm looking at you Arduino Nano), replace modes
|
||||||
// that use a lot of flash with mode_static (reduces flash footprint by about 3600 bytes)
|
// that use a lot of flash with mode_static (reduces flash footprint by about 3600 bytes)
|
||||||
#ifdef REDUCED_MODES
|
#ifdef REDUCED_MODES
|
||||||
_mode[FX_MODE_BREATH] = &WS2812FX::mode_static;
|
_mode[FX_MODE_BREATH] = &WS2812FX::mode_static;
|
||||||
@@ -337,7 +338,13 @@ class WS2812FX : public Adafruit_NeoPixel {
|
|||||||
const __FlashStringHelper*
|
const __FlashStringHelper*
|
||||||
getModeName(uint8_t m);
|
getModeName(uint8_t m);
|
||||||
|
|
||||||
WS2812FX::segment*
|
WS2812FX::Segment
|
||||||
|
getSegment(void);
|
||||||
|
|
||||||
|
WS2812FX::Segment_runtime
|
||||||
|
getSegmentRuntime(void);
|
||||||
|
|
||||||
|
WS2812FX::Segment*
|
||||||
getSegments(void);
|
getSegments(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -431,10 +438,10 @@ class WS2812FX : public Adafruit_NeoPixel {
|
|||||||
uint8_t _segment_index = 0;
|
uint8_t _segment_index = 0;
|
||||||
uint8_t _num_segments = 1;
|
uint8_t _num_segments = 1;
|
||||||
segment _segments[MAX_NUM_SEGMENTS] = { // SRAM footprint: 20 bytes per element
|
segment _segments[MAX_NUM_SEGMENTS] = { // SRAM footprint: 20 bytes per element
|
||||||
// mode, color[], speed, start, stop, reverse
|
// start, stop, speed, mode, reverse, color[]
|
||||||
{ FX_MODE_STATIC, {DEFAULT_COLOR}, DEFAULT_SPEED, 0, 7, false}
|
{ 0, 7, DEFAULT_SPEED, FX_MODE_STATIC, false, {DEFAULT_COLOR}}
|
||||||
};
|
};
|
||||||
segment_runtime _segment_runtimes[MAX_NUM_SEGMENTS]; // SRAM footprint: 14 bytes per element
|
segment_runtime _segment_runtimes[MAX_NUM_SEGMENTS]; // SRAM footprint: 16 bytes per element
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<!--
|
||||||
|
FSWebServer - Example Index Page
|
||||||
|
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
|
||||||
|
This file is part of the ESP8266WebServer library for Arduino environment.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
-->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||||
|
<title>ESP Monitor</title>
|
||||||
|
<script type="text/javascript" src="graphs.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var heap,temp,digi;
|
||||||
|
var reloadPeriod = 1000;
|
||||||
|
var running = false;
|
||||||
|
|
||||||
|
function loadValues(){
|
||||||
|
if(!running) return;
|
||||||
|
var xh = new XMLHttpRequest();
|
||||||
|
xh.onreadystatechange = function(){
|
||||||
|
if (xh.readyState == 4){
|
||||||
|
if(xh.status == 200) {
|
||||||
|
var res = JSON.parse(xh.responseText);
|
||||||
|
heap.add(res.heap);
|
||||||
|
temp.add(res.analog);
|
||||||
|
digi.add(res.gpio);
|
||||||
|
if(running) setTimeout(loadValues, reloadPeriod);
|
||||||
|
} else running = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xh.open("GET", "/status", true);
|
||||||
|
xh.send(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
function run(){
|
||||||
|
if(!running){
|
||||||
|
running = true;
|
||||||
|
loadValues();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onBodyLoad(){
|
||||||
|
var refreshInput = document.getElementById("refresh-rate");
|
||||||
|
refreshInput.value = reloadPeriod;
|
||||||
|
refreshInput.onchange = function(e){
|
||||||
|
var value = parseInt(e.target.value);
|
||||||
|
reloadPeriod = (value > 0)?value:0;
|
||||||
|
e.target.value = reloadPeriod;
|
||||||
|
}
|
||||||
|
var stopButton = document.getElementById("stop-button");
|
||||||
|
stopButton.onclick = function(e){
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
var startButton = document.getElementById("start-button");
|
||||||
|
startButton.onclick = function(e){
|
||||||
|
run();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Example with 10K thermistor
|
||||||
|
//function calcThermistor(v) {
|
||||||
|
// var t = Math.log(((10230000 / v) - 10000));
|
||||||
|
// t = (1/(0.001129148+(0.000234125*t)+(0.0000000876741*t*t*t)))-273.15;
|
||||||
|
// return (t>120)?0:Math.round(t*10)/10;
|
||||||
|
//}
|
||||||
|
//temp = createGraph(document.getElementById("analog"), "Temperature", 100, 128, 10, 40, false, "cyan", calcThermistor);
|
||||||
|
|
||||||
|
temp = createGraph(document.getElementById("analog"), "Analog Input", 100, 128, 0, 1023, false, "cyan");
|
||||||
|
heap = createGraph(document.getElementById("heap"), "Current Heap", 100, 125, 0, 30000, true, "orange");
|
||||||
|
digi = createDigiGraph(document.getElementById("digital"), "GPIO", 100, 146, [0, 4, 5, 16], "gold");
|
||||||
|
run();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body id="index" style="margin:0; padding:0;" onload="onBodyLoad()">
|
||||||
|
<div id="controls" style="display: block; border: 1px solid rgb(68, 68, 68); padding: 5px; margin: 5px; width: 362px; background-color: rgb(238, 238, 238);">
|
||||||
|
<label>Period (ms):</label>
|
||||||
|
<input type="number" id="refresh-rate"/>
|
||||||
|
<input type="button" id="start-button" value="Start"/>
|
||||||
|
<input type="button" id="stop-button" value="Stop"/>
|
||||||
|
</div>
|
||||||
|
<div id="heap"></div>
|
||||||
|
<div id="analog"></div>
|
||||||
|
<div id="digital"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,14 +1,37 @@
|
|||||||
|
//#define USE_NEOANIMATIONFX // Uses NeoAnimationFX, PIN is ignored & set to RX/GPIO3, see: https://github.com/debsahu/NeoAnimationFX
|
||||||
|
#define USE_WS2812FX // Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
||||||
|
|
||||||
// Neopixel
|
// Neopixel
|
||||||
#define PIN 2 // PIN (5 / D1) where neopixel / WS2811 strip is attached
|
#define PIN 15 // PIN (15 / D8) where neopixel / WS2811 strip is attached
|
||||||
#define NUMLEDS 144 // Number of leds in the strip
|
#define NUMLEDS 194 // Number of leds in the strip
|
||||||
//#define BUILTIN_LED 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
|
#define BUILTIN_LED 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
|
||||||
#define BUTTON 0 // Input pin (4 / D2) for switching the LED strip on / off, connect this PIN to ground to trigger button.
|
#define BUTTON 14 // Input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button.
|
||||||
|
#define BUTTON2 12 // Input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
|
||||||
|
|
||||||
const char HOSTNAME[] = "ESPLightRGBW01"; // Friedly hostname
|
const char HOSTNAME[] = "ESPLightRGBW02"; // Friedly hostname
|
||||||
|
|
||||||
#define ENABLE_OTA // If defined, enable Arduino OTA code.
|
#define HTTP_OTA // If defined, enable Added ESP8266HTTPUpdateServer
|
||||||
#define ENABLE_MQTT // If defined, enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API
|
//#define ENABLE_OTA // If defined, enable Arduino OTA code.
|
||||||
#define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
|
#define ENABLE_AMQTT // If defined, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client
|
||||||
|
//#define ENABLE_MQTT // If defined, enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API
|
||||||
|
#define ENABLE_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT must be active
|
||||||
|
#define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
|
||||||
|
#define ENABLE_BUTTON2 //
|
||||||
|
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(USE_NEOANIMATIONFX) and defined(USE_WS2812FX)
|
||||||
|
#error "Cant have both NeoAnimationFX and WS2812FX enabled. Choose either one."
|
||||||
|
#endif
|
||||||
|
#if !defined(USE_NEOANIMATIONFX) and !defined(USE_WS2812FX)
|
||||||
|
#error "Need to either use NeoAnimationFX and WS2812FX mode."
|
||||||
|
#endif
|
||||||
|
#if defined(ENABLE_MQTT) and defined(ENABLE_AMQTT)
|
||||||
|
#error "Cant have both PubSubClient and AsyncMQTT enabled. Choose either one."
|
||||||
|
#endif
|
||||||
|
#if ( (defined(ENABLE_HOMEASSISTANT) and !defined(ENABLE_MQTT)) and (defined(ENABLE_HOMEASSISTANT) and !defined(ENABLE_AMQTT)) )
|
||||||
|
#error "To use HA, you have to either enable PubCubClient or AsyncMQTT"
|
||||||
|
#endif
|
||||||
|
|
||||||
// parameters for automatically cycling favorite patterns
|
// parameters for automatically cycling favorite patterns
|
||||||
uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
|
uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
|
||||||
@@ -18,16 +41,39 @@ uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
|
|||||||
{0x000000ff, 200, 46, 15.0} // fireworks for 15 seconds
|
{0x000000ff, 200, 46, 15.0} // fireworks for 15 seconds
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ENABLE_MQTT
|
#if defined(ENABLE_MQTT) or defined(ENABLE_AMQTT)
|
||||||
#define MQTT_MAX_PACKET_SIZE 256
|
#ifdef ENABLE_MQTT
|
||||||
#define MQTT_MAX_RECONNECT_TRIES 4
|
#define MQTT_MAX_PACKET_SIZE 512
|
||||||
|
#define MQTT_MAX_RECONNECT_TRIES 4
|
||||||
int mqtt_reconnect_retries = 0;
|
|
||||||
char mqtt_intopic[strlen(HOSTNAME) + 4]; // Topic in will be: <HOSTNAME>/in
|
int mqtt_reconnect_retries = 0;
|
||||||
char mqtt_outtopic[strlen(HOSTNAME) + 5]; // Topic out will be: <HOSTNAME>/out
|
char mqtt_intopic[strlen(HOSTNAME) + 4 + 5]; // Topic in will be: <HOSTNAME>/in
|
||||||
|
char mqtt_outtopic[strlen(HOSTNAME) + 5 + 5]; // Topic out will be: <HOSTNAME>/out
|
||||||
const char mqtt_clientid[] = "ESPLightMax"; // MQTT ClientID
|
uint8_t qossub = 0; // PubSubClient can sub qos 0 or 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_AMQTT
|
||||||
|
String mqtt_intopic = String(HOSTNAME) + "/in";
|
||||||
|
String mqtt_outtopic = String(HOSTNAME) + "/out";
|
||||||
|
uint8_t qossub = 0; // AMQTT can sub qos 0 or 1 or 2
|
||||||
|
uint8_t qospub = 0; // AMQTT can pub qos 0 or 1 or 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_HOMEASSISTANT
|
||||||
|
String mqtt_ha = "home/" + String(HOSTNAME) + "_ha/";
|
||||||
|
String mqtt_ha_state_in = mqtt_ha + "state/in";
|
||||||
|
String mqtt_ha_state_out = mqtt_ha + "state/out";
|
||||||
|
|
||||||
|
const char* on_cmd = "ON";
|
||||||
|
const char* off_cmd = "OFF";
|
||||||
|
bool stateOn = false;
|
||||||
|
bool animation_on = false;
|
||||||
|
bool new_ha_mqtt_msg = false;
|
||||||
|
uint16_t color_temp = 327; // min is 154 and max is 500
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char mqtt_clientid[] = "NeoPixelsStrip"; // MQTT ClientID
|
||||||
|
|
||||||
char mqtt_host[64] = "";
|
char mqtt_host[64] = "";
|
||||||
char mqtt_port[6] = "";
|
char mqtt_port[6] = "";
|
||||||
char mqtt_user[32] = "";
|
char mqtt_user[32] = "";
|
||||||
@@ -41,7 +87,7 @@ uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
|
|||||||
#define DBG_OUTPUT_PORT Serial // Set debug output port
|
#define DBG_OUTPUT_PORT Serial // Set debug output port
|
||||||
|
|
||||||
// List of all color modes
|
// List of all color modes
|
||||||
enum MODE { SET_MODE, HOLD, OFF, ALL, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM, AUTO };
|
enum MODE { SET_MODE, HOLD, OFF, ALL, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW, TV, CUSTOM, AUTO };
|
||||||
|
|
||||||
MODE mode = RAINBOW; // Standard mode that is active when software starts
|
MODE mode = RAINBOW; // Standard mode that is active when software starts
|
||||||
|
|
||||||
@@ -66,7 +112,8 @@ typedef struct ledstate LEDState; // Define the datatype LEDState
|
|||||||
LEDState ledstates[NUMLEDS]; // Get an array of led states to store the state of the whole strip
|
LEDState ledstates[NUMLEDS]; // Get an array of led states to store the state of the whole strip
|
||||||
LEDState main_color = { 0, 255, 0, 0}; // Store the "main color" of the strip used in single color modes
|
LEDState main_color = { 0, 255, 0, 0}; // Store the "main color" of the strip used in single color modes
|
||||||
|
|
||||||
#define ENABLE_STATE_SAVE // If defined, save state on reboot
|
#define ENABLE_STATE_SAVE_SPIFFS // If defined, saves state on SPIFFS
|
||||||
|
//#define ENABLE_STATE_SAVE_EEPROM // If defined, save state on reboot
|
||||||
#ifdef ENABLE_STATE_SAVE
|
#ifdef ENABLE_STATE_SAVE
|
||||||
char current_state[36]; // Keeps the current state representation
|
char current_state[36]; // Keeps the current state representation
|
||||||
char last_state[36]; // Save the last state as string representation
|
char last_state[36]; // Save the last state as string representation
|
||||||
@@ -74,12 +121,20 @@ LEDState main_color = { 0, 255, 0, 0}; // Store the "main color" of the strip u
|
|||||||
int timeout_statechange_save = 5000; // Timeout in ms to wait before state is saved
|
int timeout_statechange_save = 5000; // Timeout in ms to wait before state is saved
|
||||||
bool state_save_requested = false; // State has to be saved after timeout
|
bool state_save_requested = false; // State has to be saved after timeout
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
||||||
|
bool updateStateFS = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Button handling
|
// Button handling
|
||||||
|
|
||||||
|
#ifdef ENABLE_BUTTON || ENABLE_BUTTON2
|
||||||
|
boolean buttonState = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_BUTTON
|
#ifdef ENABLE_BUTTON
|
||||||
#define BTN_MODE_SHORT "STA| 1| 0|245|196| 0|255|255|255" // Static white
|
#define BTN_MODE_SHORT "STA| 1| 0|245|196|255| 0| 0| 0" // Static white
|
||||||
#define BTN_MODE_MEDIUM "STA| 1| 48|245|196| 0|255|102| 0" // Fire flicker
|
#define BTN_MODE_MEDIUM "STA| 1| 48|245|196| 0|255|102| 0" // Fire flicker
|
||||||
#define BTN_MODE_LONG "STA| 1| 46|253|196| 0|255|102| 0" // Fireworks random
|
#define BTN_MODE_LONG "STA| 1| 46|253|196| 0|255|102| 0" // Fireworks random
|
||||||
|
|
||||||
unsigned long keyPrevMillis = 0;
|
unsigned long keyPrevMillis = 0;
|
||||||
const unsigned long keySampleIntervalMs = 25;
|
const unsigned long keySampleIntervalMs = 25;
|
||||||
@@ -87,5 +142,18 @@ LEDState main_color = { 0, 255, 0, 0}; // Store the "main color" of the strip u
|
|||||||
byte mediumKeyPressCountMin = 20; // 20 * 25 = 500 ms
|
byte mediumKeyPressCountMin = 20; // 20 * 25 = 500 ms
|
||||||
byte KeyPressCount = 0;
|
byte KeyPressCount = 0;
|
||||||
byte prevKeyState = HIGH; // button is active low
|
byte prevKeyState = HIGH; // button is active low
|
||||||
boolean buttonState = false;
|
#endif
|
||||||
#endif
|
|
||||||
|
#ifdef ENABLE_BUTTON2
|
||||||
|
#define BTN_MODE_SHORT "STA| 1| 0|245|196|255| 0| 0| 0" // Static white
|
||||||
|
#define BTN_MODE_MEDIUM "STA| 1| 48|245|196| 0|255|102| 0" // Fire flicker
|
||||||
|
#define BTN_MODE_LONG "STA| 1| 46|253|196| 0|255|102| 0" // Fireworks random
|
||||||
|
|
||||||
|
unsigned long keyPrevMillis2 = 0;
|
||||||
|
const unsigned long keySampleIntervalMs2 = 25;
|
||||||
|
byte longKeyPressCountMax2 = 80; // 80 * 25 = 2000 ms
|
||||||
|
byte mediumKeyPressCountMin2 = 20; // 20 * 25 = 500 ms
|
||||||
|
byte KeyPressCount2 = 0;
|
||||||
|
byte prevKeyState2 = HIGH; // button is active low
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
+1069
-192
File diff suppressed because it is too large
Load Diff
@@ -6,27 +6,51 @@
|
|||||||
|
|
||||||
> Because of it's open architecture and APIs it's easy to build new clients for different platforms (iOS, Android, Windows Universal Apps, Siri/Cortana integration, ...).
|
> Because of it's open architecture and APIs it's easy to build new clients for different platforms (iOS, Android, Windows Universal Apps, Siri/Cortana integration, ...).
|
||||||
|
|
||||||
|
[](https://youtu.be/rc6QVHKAXBs)
|
||||||
|
|
||||||
|
[](https://youtu.be/4JnGXZaPnrw)
|
||||||
|
|
||||||
___
|
___
|
||||||
Update 17.02.2018:
|
Update 07.04.2018:
|
||||||
|
And even more changes to McLighting! Most of them were contributed by user @debsahu. Thank you!
|
||||||
|
- Update arduino-esp8266 to latest, at least version 2.4.1
|
||||||
|
- AMQTT is now the default MQTT library, it's a bit more lightweight and stable. You can still use PubSubClient if you want to.
|
||||||
|
- You can use @debsahu great NeoAnimationFX library as a alternative to WS2812FX. It's based on the NeoPixelBus instead of Adafruits NeoPixel library. It can handle longer strips more efficient. If you want, give it a try. WS2812FX is still the default.
|
||||||
|
- Some more changes regarding Homeassistant integration.
|
||||||
|
Please see the [Wiki](https://github.com/toblum/McLighting/wiki/Software-installation) for details on the required libraries.
|
||||||
|
If you have problems with the new version, let us know. You can get the last version [here](https://github.com/toblum/McLighting/tree/Before_AMQTT_NeoAnimationFX).
|
||||||
|
|
||||||
|
I'm also working on a alternative web interface for McLighting in the meanwhile, but it may take some more time.
|
||||||
|
For the german users: McLighting was used in [Kliemannsland](https://youtu.be/3TUjszkS3bY?t=1211) (a funny web show) when they built a really big Neopixel installation.
|
||||||
|
|
||||||
|
Update 18.03.2018:
|
||||||
|
The code for integration with homeassistant was merged into master. It's currently active by default. You can safely disable it in definitions.h when use do not want to use it, or want to use McLighting on a small ESP_01.
|
||||||
|
There are some informations in the [Wiki](https://github.com/toblum/McLighting/wiki/Homeassistant-integration).
|
||||||
|
|
||||||
|
Update 17.02.2018:
|
||||||
User @debsahu contributed code for integration with homeassistant. It's currently in a separate branch (https://github.com/toblum/McLighting/tree/feature/ha_integration). If you're using Homeassistant, please try it out and give feedback.
|
User @debsahu contributed code for integration with homeassistant. It's currently in a separate branch (https://github.com/toblum/McLighting/tree/feature/ha_integration). If you're using Homeassistant, please try it out and give feedback.
|
||||||
User @FabLab-Luenen created a version of McLighting (https://github.com/FabLab-Luenen/McLighting) for 6812 and other RGBW strips. Give it a try, if you own such strips.
|
User @FabLab-Luenen created a version of McLighting (https://github.com/FabLab-Luenen/McLighting) for 6812 and other RGBW strips. Give it a try, if you own such strips.
|
||||||
A thank you goes to all contributors.
|
A thank you goes to all contributors.
|
||||||
|
|
||||||
Update 31.01.2018:
|
Update 12. / 15.02.2018:
|
||||||
|
Added Home Assistant Support using MQTT Light. A better implementation would be using MQTT Light JSON.
|
||||||
|
Replaced Home Assistant Support using MQTT Light to MQTT JSON Light.
|
||||||
|
|
||||||
|
Update 31.01.2018:
|
||||||
User @codmpm did a very professional McLighting installation and even designed his own PCBs. He has a great writeup for his project at: https://allgeek.de/2018/01/29/esp8266-neopixel-controller/ (in german).
|
User @codmpm did a very professional McLighting installation and even designed his own PCBs. He has a great writeup for his project at: https://allgeek.de/2018/01/29/esp8266-neopixel-controller/ (in german).
|
||||||
|
|
||||||
Update 27.01.2018:
|
Update 27.01.2018:
|
||||||
Many people asked if it's possible to connect more than one strip (currently not) or at least "sync" multiple McLighting nodes. Although it may be possible to connect more then one WS2812 strip to the same data pin (works in many cases, you just have to try), syncing many McLighting instances would be a benefit. This could easily be achieved done by software like [NodeRed](https://nodered.org/). I added a example flow to demonstrate that [here](https://github.com/toblum/McLighting/blob/master/clients/node_red/websocket_proxy.json). Have a look at the short video [here](https://youtu.be/g3CHtG9c520).
|
Many people asked if it's possible to connect more than one strip (currently not) or at least "sync" multiple McLighting nodes. Although it may be possible to connect more then one WS2812 strip to the same data pin (works in many cases, you just have to try), syncing many McLighting instances would be a benefit. This could easily be achieved done by software like [NodeRed](https://nodered.org/). I added a example flow to demonstrate that [here](https://github.com/toblum/McLighting/blob/master/clients/node_red/websocket_proxy.json). Have a look at the short video [here](https://youtu.be/g3CHtG9c520).
|
||||||
|
|
||||||
Update 21.01.2018:
|
Update 21.01.2018:
|
||||||
User @szepnorbee contributed code for button control. Thank you! It's merged into the master branch now. There is a short manual for configuration [here](https://github.com/toblum/McLighting/wiki/Button-control).
|
User @szepnorbee contributed code for button control. Thank you! It's merged into the master branch now. There is a short manual for configuration [here](https://github.com/toblum/McLighting/wiki/Button-control).
|
||||||
|
|
||||||
Update 06.01.2018:
|
Update 06.01.2018:
|
||||||
After som etesting I merged the "feature/save_state" banch into master, so everybody should now be able to use this new functionality. Basically McLighting now saves the current mode to EEPROM and restores the setting on reboot. So you wont need to select your favorite mode again. If you don't want to use this, you can disable it in definitions.h.
|
After som etesting I merged the "feature/save_state" banch into master, so everybody should now be able to use this new functionality. Basically McLighting now saves the current mode to EEPROM and restores the setting on reboot. So you wont need to select your favorite mode again. If you don't want to use this, you can disable it in definitions.h.
|
||||||
~~Some people noticed that there are currently problems compiling McLighting whe using ESP8266 core in version 2.4.0. This is due to a [problem](https://github.com/kitesurfer1404/WS2812FX/issues/58) with WS2812FX when using this version. For the moment you can stick to the 2.4.0 RC2 (also easily available via the boards manager).~~ (fixed now )
|
~~Some people noticed that there are currently problems compiling McLighting whe using ESP8266 core in version 2.4.0. This is due to a [problem](https://github.com/kitesurfer1404/WS2812FX/issues/58) with WS2812FX when using this version. For the moment you can stick to the 2.4.0 RC2 (also easily available via the boards manager).~~ (fixed now )
|
||||||
Funny! McLighting was featured in the german radio show ["Netzbasteln"](https://www.deutschlandfunknova.de/beitrag/netzbasteln-wolkenlampe-mit-cloud-anschluss) on Deutschlandfunk Nova with a nice audio tutorial.
|
Funny! McLighting was featured in the german radio show ["Netzbasteln"](https://www.deutschlandfunknova.de/beitrag/netzbasteln-wolkenlampe-mit-cloud-anschluss) on Deutschlandfunk Nova with a nice audio tutorial.
|
||||||
|
|
||||||
Update 16.12.2017:
|
Update 16.12.2017:
|
||||||
There was a breaking change in the WS2812FX library: Speeds have a new format (65535-0 instead of 0-255). I released a new version that converts the speeds settings. Please use the latest [WS2812FX library](https://github.com/kitesurfer1404/WS2812FX) (14.12.2017 or later) if use have an existing version installed.
|
There was a breaking change in the WS2812FX library: Speeds have a new format (65535-0 instead of 0-255). I released a new version that converts the speeds settings. Please use the latest [WS2812FX library](https://github.com/kitesurfer1404/WS2812FX) (14.12.2017 or later) if use have an existing version installed.
|
||||||
I got many messages from people who use McLighting for own projects. User Brian Lough built a lighting system for his wedding and made a nice instruction video for his build: https://goo.gl/NbfKi8
|
I got many messages from people who use McLighting for own projects. User Brian Lough built a lighting system for his wedding and made a nice instruction video for his build: https://goo.gl/NbfKi8
|
||||||
|
|
||||||
@@ -34,25 +58,25 @@ Update 30.09.2017:
|
|||||||
Thanks to [@moose4lord](https://github.com/moose4lord) Mclighting works with the newest version of WS1812FX and has a possibility to define autocycle patterns [Wiki](https://github.com/toblum/McLighting/wiki/Autocycling). Thank for contributing to McLighting everyone!
|
Thanks to [@moose4lord](https://github.com/moose4lord) Mclighting works with the newest version of WS1812FX and has a possibility to define autocycle patterns [Wiki](https://github.com/toblum/McLighting/wiki/Autocycling). Thank for contributing to McLighting everyone!
|
||||||
I was also informed of a new project that is loosely based on McLighting: [Responsive_LED_Control](https://github.com/doctormord/Responsive_LED_Control) That looks very promising.
|
I was also informed of a new project that is loosely based on McLighting: [Responsive_LED_Control](https://github.com/doctormord/Responsive_LED_Control) That looks very promising.
|
||||||
|
|
||||||
Update 07.08.2017:
|
Update 07.08.2017:
|
||||||
As requested by many of you, McLighting now also features MQTT support. Thanks at @LeonVos for his attempts on this. I implemented the same API as used in WebSockets now for MQTT. Please have a look here for details: https://github.com/toblum/McLighting/wiki/MQTT-API I will try to add a new instruction video soon.
|
As requested by many of you, McLighting now also features MQTT support. Thanks at @LeonVos for his attempts on this. I implemented the same API as used in WebSockets now for MQTT. Please have a look here for details: https://github.com/toblum/McLighting/wiki/MQTT-API I will try to add a new instruction video soon.
|
||||||
|
|
||||||
Many of you also took McLighting and adapted the software according your needs. This is great. I found some videos on YouTube that show these projects. I collected them here: https://goo.gl/yG7M4h
|
Many of you also took McLighting and adapted the software according your needs. This is great. I found some videos on YouTube that show these projects. I collected them here: https://goo.gl/yG7M4h
|
||||||
If you have done something similar with McLighting, please drop me a note. I'm always interested in what you've done with it.
|
If you have done something similar with McLighting, please drop me a note. I'm always interested in what you've done with it.
|
||||||
|
|
||||||
Update 19.02.2017:
|
Update 19.02.2017:
|
||||||
Added OTA support as promised by @markbajaj. Minor other improvements.
|
Added OTA support as promised by @markbajaj. Minor other improvements.
|
||||||
|
|
||||||
Update 05.02.2017:
|
Update 05.02.2017:
|
||||||
After a long time I was able to work a bit on McLighting v2 and it's finally out now. The main difference, among minor improvements and library updates, is the usage of the great WS2812FX library for color animations. It brings a lot (almost 50!) of new animations.
|
After a long time I was able to work a bit on McLighting v2 and it's finally out now. The main difference, among minor improvements and library updates, is the usage of the great WS2812FX library for color animations. It brings a lot (almost 50!) of new animations.
|
||||||
The API changed a little bit, because the speed can now be set as a value from 0 to 255, not the delay anymore. So the web inferface had to change accordingly. The new animation mode have to be set also by their number, instead of a dedicated url. The list of all animation modes can also be received by the API. All existing API endpoints are kept for downward compatibility. So you should be able to use the new version without big changes. The original version is kept as branch "mclighting_legacy". Documentation will be updated soon.
|
The API changed a little bit, because the speed can now be set as a value from 0 to 255, not the delay anymore. So the web inferface had to change accordingly. The new animation mode have to be set also by their number, instead of a dedicated url. The list of all animation modes can also be received by the API. All existing API endpoints are kept for downward compatibility. So you should be able to use the new version without big changes. The original version is kept as branch "mclighting_legacy". Documentation will be updated soon.
|
||||||
|
|
||||||
Update 04.01.2017:
|
Update 04.01.2017:
|
||||||
Now, there are two forks of McLighting (using the famous FastLED library). I did not notice it first, because I currently do not receive notification e-mails by Github (I have no idea why). Maybe you want to give them also a try, I will definitely do so as soon as I find time.
|
Now, there are two forks of McLighting (using the famous FastLED library). I did not notice it first, because I currently do not receive notification e-mails by Github (I have no idea why). Maybe you want to give them also a try, I will definitely do so as soon as I find time.
|
||||||
https://github.com/russp81/LEDLAMP_FASTLEDs
|
https://github.com/russp81/LEDLAMP_FASTLEDs
|
||||||
And this one was also forked: https://github.com/jake-b/Griswold-LED-Controller
|
And this one was also forked: https://github.com/jake-b/Griswold-LED-Controller
|
||||||
|
|
||||||
Update 12.08.2016:
|
Update 12.08.2016:
|
||||||
There is now a [gitter.im](https://gitter.im/mclighting/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link) chat room for this project.
|
There is now a [gitter.im](https://gitter.im/mclighting/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link) chat room for this project.
|
||||||
|
|
||||||
Update 11.06.2016:
|
Update 11.06.2016:
|
||||||
@@ -60,11 +84,6 @@ Today I presented the project at [Pi and More 9](https://piandmore.de/) and got
|
|||||||
___
|
___
|
||||||
|
|
||||||
|
|
||||||
[](https://youtu.be/rc6QVHKAXBs)
|
|
||||||
|
|
||||||
[](https://youtu.be/4JnGXZaPnrw)
|
|
||||||
|
|
||||||
|
|
||||||
## The Hardware
|
## The Hardware
|
||||||
|
|
||||||
The project ist based on the famous ESP8266 microcontroller and WD2811/WS2812 LED strips. There are many variations of the ESP chip out there, but I chose the NodeMCU dev board, because it's powered by micro USB and has a voltage converter included to power the ESP which uses 3.3V.
|
The project ist based on the famous ESP8266 microcontroller and WD2811/WS2812 LED strips. There are many variations of the ESP chip out there, but I chose the NodeMCU dev board, because it's powered by micro USB and has a voltage converter included to power the ESP which uses 3.3V.
|
||||||
@@ -110,15 +129,14 @@ I hope I didn't miss any sources and mentioned every author. In case I forgot so
|
|||||||
|
|
||||||
## Todos
|
## Todos
|
||||||
- [x] MQTT support
|
- [x] MQTT support
|
||||||
- [ ] Support multiple strips and control them separately or together
|
- [ ] Support multiple strips and control them separately or together [Issue](https://github.com/toblum/McLighting/issues/118)
|
||||||
- [ ] Save favourite effects? [Issue](https://github.com/toblum/McLighting/issues/35)
|
- [ ] Save favourite effects? [Issue](https://github.com/toblum/McLighting/issues/35)
|
||||||
- [ ] Make number of pixels, MQTT and PIN configurable via front end [Issue](https://github.com/toblum/McLighting/issues/93)
|
- [ ] Make number of pixels, MQTT and PIN configurable via front end [Issue](https://github.com/toblum/McLighting/issues/93) and [Issue](https://github.com/toblum/McLighting/issues/101)
|
||||||
- [ ] OTA update [Issue](https://github.com/toblum/McLighting/issues/93)
|
- [x] OTA update [Issue](https://github.com/toblum/McLighting/issues/93)
|
||||||
- [ ] Bundle webpages instead of SPIFFS [Issue](https://github.com/toblum/McLighting/issues/93)
|
- [ ] Bundle webpages instead of SPIFFS [Issue](https://github.com/toblum/McLighting/issues/93)
|
||||||
- [ ] Remove old / wrong EEPROM settings completely (https://github.com/toblum/McLighting/issues/92)
|
- [ ] Remove old / wrong EEPROM settings completely (https://github.com/toblum/McLighting/issues/92)
|
||||||
- [x] Fix issue with websockets connection problems
|
- [x] Fix issue with websockets connection problems
|
||||||
- [ ] Add support for 433MHz wireless socket using the [RC switch](https://github.com/sui77/rc-switch) library.
|
- [x] Switch to the [NeoPixelBus library](https://github.com/Makuna/NeoPixelBus/wiki)
|
||||||
- [ ] Switch to the [NeoPixelBus library](https://github.com/Makuna/NeoPixelBus/wiki)
|
|
||||||
- [x] Use the led strip for status information in connection phase
|
- [x] Use the led strip for status information in connection phase
|
||||||
- [x] Enhance the documentation
|
- [x] Enhance the documentation
|
||||||
- [x] Stability improvements
|
- [x] Stability improvements
|
||||||
@@ -128,9 +146,11 @@ I hope I didn't miss any sources and mentioned every author. In case I forgot so
|
|||||||
- [x] Button control [Issue](https://github.com/toblum/McLighting/issues/36)
|
- [x] Button control [Issue](https://github.com/toblum/McLighting/issues/36)
|
||||||
- [x] Retain last state [Issue](https://github.com/toblum/McLighting/issues/47)
|
- [x] Retain last state [Issue](https://github.com/toblum/McLighting/issues/47)
|
||||||
- [ ] Additional clients
|
- [ ] Additional clients
|
||||||
- [ ] If no wifi, at least enable button mode. [Issue](https://github.com/toblum/McLighting/issues/88)
|
- [ ] If no wifi, at least enable button mode.
|
||||||
- [ ] Also enable McLighting in Wifi AP mode.
|
- [ ] Also enable McLighting in Wifi AP mode.
|
||||||
- [ ] Make a set of NodeRed nodes.
|
- [x] Make a set of NodeRed nodes.
|
||||||
|
- [ ] Multiple buttons/GPIO Inputs. [Issue](https://github.com/toblum/McLighting/issues/119)
|
||||||
|
- [ ] Music visualizer / Bring back ArtNet [Issue](https://github.com/toblum/McLighting/issues/111)
|
||||||
|
|
||||||
|
|
||||||
## Licence
|
## Licence
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
light:
|
||||||
|
- platform: mqtt_json
|
||||||
|
name: "NeoPixel LEDs"
|
||||||
|
state_topic: "home/McLighting01_ha/state/out"
|
||||||
|
command_topic: "home/McLighting01_ha/state/in"
|
||||||
|
on_command_type: 'first'
|
||||||
|
effect: true
|
||||||
|
effect_list:
|
||||||
|
######
|
||||||
|
- "Blink"
|
||||||
|
- "Breath"
|
||||||
|
- "Color Wipe"
|
||||||
|
- "Color Wipe Inverse"
|
||||||
|
- "Color Wipe Reverse"
|
||||||
|
- "Color Wipe Reverse Inverse"
|
||||||
|
- "Color Wipe Random"
|
||||||
|
- "Random Color"
|
||||||
|
- "Single Dynamic"
|
||||||
|
- "Multi Dynamic"
|
||||||
|
- "Rainbow"
|
||||||
|
- "Rainbow Cycle"
|
||||||
|
- "Scan"
|
||||||
|
- "Dual Scan"
|
||||||
|
- "Fade"
|
||||||
|
- "Theater Chase"
|
||||||
|
- "Theater Chase Rainbow"
|
||||||
|
- "Running Lights"
|
||||||
|
- "Twinkle"
|
||||||
|
- "Twinkle Random"
|
||||||
|
- "Twinkle Fade"
|
||||||
|
- "Twinkle Fade Random"
|
||||||
|
- "Sparkle"
|
||||||
|
- "Flash Sparkle"
|
||||||
|
- "Hyper Sparkle"
|
||||||
|
- "Strobe"
|
||||||
|
- "Strobe Rainbow"
|
||||||
|
- "Multi Strobe"
|
||||||
|
- "Blink Rainbow"
|
||||||
|
- "Chase White"
|
||||||
|
- "Chase Color"
|
||||||
|
- "Chase Random"
|
||||||
|
- "Chase Rainbow"
|
||||||
|
- "Chase Flash"
|
||||||
|
- "Chase Flash Random"
|
||||||
|
- "Chase Rainbow White"
|
||||||
|
- "Chase Blackout"
|
||||||
|
- "Chase Blackout Rainbow"
|
||||||
|
- "Color Sweep Random"
|
||||||
|
- "Running Color"
|
||||||
|
- "Running Red Blue"
|
||||||
|
- "Running Random"
|
||||||
|
- "Larson Scanner"
|
||||||
|
- "Comet"
|
||||||
|
- "Fireworks"
|
||||||
|
- "Fireworks Random"
|
||||||
|
- "Merry Christmas"
|
||||||
|
- "Fire Flicker"
|
||||||
|
- "Fire Flicker (soft)"
|
||||||
|
- "Fire Flicker (intense)"
|
||||||
|
- "Circus Combustus"
|
||||||
|
- "Halloween"
|
||||||
|
- "Bicolor Chase"
|
||||||
|
- "Tricolor Chase"
|
||||||
|
- "ICU"
|
||||||
|
brightness: true
|
||||||
|
color_temp: true
|
||||||
|
rgb: true
|
||||||
|
optimistic: false
|
||||||
|
qos: 0
|
||||||
|
retain: true
|
||||||
|
|
||||||
|
input_number:
|
||||||
|
neopixel_animation_speed:
|
||||||
|
name: NeoPixel Animation Speed
|
||||||
|
initial: 200
|
||||||
|
min: 0
|
||||||
|
max: 255
|
||||||
|
step: 5
|
||||||
|
|
||||||
|
automation:
|
||||||
|
- id: 71938579813759813757
|
||||||
|
alias: NeoPixel Animation Speed Send
|
||||||
|
initial_state: true
|
||||||
|
hide_entity: false
|
||||||
|
trigger:
|
||||||
|
- entity_id: input_number.neopixel_animation_speed
|
||||||
|
platform: state
|
||||||
|
action:
|
||||||
|
- data_template:
|
||||||
|
payload_template: '{"speed": {{ trigger.to_state.state | int }}}'
|
||||||
|
retain: true
|
||||||
|
topic: home/McLighting01_ha/state/in
|
||||||
|
service: mqtt.publish
|
||||||
|
|
||||||
|
- id: 93786598732698756967
|
||||||
|
alias: NeoPixel Animation Speed Receive
|
||||||
|
trigger:
|
||||||
|
- platform: mqtt
|
||||||
|
topic: home/McLighting01_ha/state/out
|
||||||
|
action:
|
||||||
|
- data_template:
|
||||||
|
entity_id: input_number.neopixel_animation_speed
|
||||||
|
value: '{{ trigger.payload_json.speed | int }}'
|
||||||
|
service: input_number.set_value
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Reference in New Issue
Block a user