Pull request to 3colors
master includes now 3colors and ir remote
This commit is contained in:
+531
-629
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,101 +1,97 @@
|
|||||||
#define USE_WS2812FX_DMA // Uses PIN is ignored & set to RX/GPIO3 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
;
|
||||||
//#define USE_WS2812FX_UART1 // Uses PIN is ignored & set to D4/GPIO2 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
#define USE_WS2812FX_DMA 0 // 0 = Used PIN is ignored & set to RX/GPIO3; 1 = Used PIN is ignored & set to D4/GPIO2; 2 = Uses PIN is ignored & set to TX/GPIO1; Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
||||||
//#define USE_WS2812FX_UART2 // Uses PIN is ignored & set to TX/GPIO1 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX
|
|
||||||
|
|
||||||
// Neopixel
|
// Neopixel
|
||||||
#define PIN 3 // PIN (15 / D8) where neopixel / WS2811 strip is attached
|
#define PIN 3 // PIN (15 / D8) where neopixel / WS2811 strip is attached
|
||||||
#define NUMLEDS 144 // Number of leds in the strip
|
#define NUMLEDS 144 // 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 LED_BUILTIN 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192
|
||||||
#define BUTTON 14 // Input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button.
|
|
||||||
#define BUTTON_GY33 12 // Input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
|
|
||||||
#define RGBW // If defined, use RGBW Strips
|
#define RGBW // If defined, use RGBW Strips
|
||||||
|
|
||||||
const char HOSTNAME[] = "McLightingRGBW"; // Friedly hostname
|
const char HOSTNAME[] = "McLightingRGBW_01"; // Friedly hostname
|
||||||
|
|
||||||
#define HTTP_OTA // If defined, enable ESP8266HTTPUpdateServer OTA code.
|
#define ENABLE_OTA 1 // If defined, enable Arduino OTA code. If set to 0 enable Arduino OTA code, if set to 1 enable ESP8266HTTPUpdateServer OTA code.
|
||||||
//#define ENABLE_OTA // If defined, enable Arduino OTA code.
|
#define ENABLE_MQTT 1 // If defined use MQTT OR AMQTT, if set to 0 enable MQTT client code, see: https://github.com/toblum/McLighting/wiki/MQTT-API, if set to 1, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client
|
||||||
#define ENABLE_AMQTT // If defined, enable Async MQTT code, see: https://github.com/marvinroger/async-mqtt-client
|
//#define ENABLE_MQTT_HOSTNAME_CHIPID // Uncomment/comment to add ESPChipID to end of MQTT hostname
|
||||||
//#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_HOMEASSISTANT // If defined, enable Homeassistant integration, ENABLE_MQTT or ENABLE_AMQTT must be active
|
#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
|
||||||
#define ENABLE_BUTTON // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control
|
#define ENABLE_BUTTON 14 // If defined, enable button handling code, see: https://github.com/toblum/McLighting/wiki/Button-control, the value defines the input pin (14 / D5) for switching the LED strip on / off, connect this PIN to ground to trigger button.
|
||||||
//#define ENABLE_BUTTON_GY33 // If defined, enable button handling code for GY-33 color sensor to scan color
|
//#define ENABLE_BUTTON_GY33 12 // If defined, enable button handling code for GY-33 color sensor to scan color. The value defines the input pin (12 / D6) for read color data with RGB sensor, connect this PIN to ground to trigger button.
|
||||||
//#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth
|
//#define ENABLE_REMOTE 13 // If defined, enable Remote Control via TSOP31238. The value defines the input pin (13 / D7) for TSOP31238 Out
|
||||||
#define ENABLE_LEGACY_ANIMATIONS // Enable Legacy Animations
|
|
||||||
#define ENABLE_E131 // E1.31 implementation You have to uncomment #define USE_WS2812FX_DMA
|
|
||||||
#define ENABLE_TV // Enable TV Animation
|
|
||||||
|
|
||||||
#ifdef ENABLE_E131
|
#define ENABLE_STATE_SAVE 1 // If defined, save state on reboot, if set to 0 in EEPROM, if set to 1 on SPIFFS
|
||||||
|
|
||||||
|
#define ENABLE_LEGACY_ANIMATIONS // Enable Legacy Animations
|
||||||
|
#define ENABLE_E131 // E1.31 implementation You have to uncomment #define USE_WS2812FX_DMA and set it to 0
|
||||||
|
#define ENABLE_TV // Enable TV Animation
|
||||||
|
|
||||||
|
#if defined(ENABLE_E131)
|
||||||
#define START_UNIVERSE 1 // First DMX Universe to listen for
|
#define START_UNIVERSE 1 // First DMX Universe to listen for
|
||||||
#define END_UNIVERSE 2 // Total number of Universes to listen for, starting at UNIVERSE
|
#define END_UNIVERSE 2 // Total number of Universes to listen for, starting at UNIVERSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_REMOTE)
|
||||||
|
int selected_color = 1;
|
||||||
|
int chng = 1;
|
||||||
|
uint64_t last_remote_cmd;
|
||||||
|
enum RMT_BTN {ON_OFF, MODE_UP, MODE_DOWN, RED_UP, RED_DOWN, GREEN_UP, GREEN_DOWN, BLUE_UP, BLUE_DOWN, WHITE_UP, WHITE_DOWN, BRIGHTNESS_UP, BRIGHTNESS_DOWN, SPEED_UP, SPEED_DOWN, COL_M, COL_B, COL_X, AUTOMODE, CUST_1, CUST_2, CUST_3, CUST_4, CUST_5, REPEATCMD, BTN_CNT};
|
||||||
|
// Change your IR Commands here. You can see them in console, after you pressed a button on the remote
|
||||||
|
uint64_t rmt_commands[BTN_CNT] = {0xF7C03F, 0xF7708F, 0xF7F00F, 0xF720DF, 0xF710EF, 0xF7A05F, 0xF7906F, 0xF7609F, 0xF750AF, 0xF7E01F, 0xF7D02F, 0xF730CF, 0xF7B04F, 0xF748B7, 0xF7C837, 0xF700FF, 0xF7807F, 0xF740BF, 0xF708F7, 0xF78877, 0xF728D7, 0xF7A857, 0xF76897, 0xF7E817, 0xFFFFFFFFFFFFFFFF};
|
||||||
|
#endif
|
||||||
//#define WIFIMGR_PORTAL_TIMEOUT 180
|
//#define WIFIMGR_PORTAL_TIMEOUT 180
|
||||||
//#define WIFIMGR_SET_MANUAL_IP
|
//#define WIFIMGR_SET_MANUAL_IP
|
||||||
|
|
||||||
#ifdef WIFIMGR_SET_MANUAL_IP
|
#if defined(WIFIMGR_SET_MANUAL_IP)
|
||||||
uint8_t _ip[4] = {192,168,0,128};
|
uint8_t _ip[4] = {192,168,0,128};
|
||||||
uint8_t _gw[4] = {192,168,0,1};
|
uint8_t _gw[4] = {192,168,0,1};
|
||||||
uint8_t _sn[4] = {255,255,255,0};
|
uint8_t _sn[4] = {255,255,255,0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MQTT_HOME_ASSISTANT_SUPPORT
|
#if defined(MQTT_HOME_ASSISTANT_SUPPORT)
|
||||||
#define MQTT_HOME_ASSISTANT_0_84_SUPPORT // Comment if using HA version < 0.84
|
#define MQTT_HOME_ASSISTANT_0_84_SUPPORT // Comment if using HA version < 0.84
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_WS2812FX_DMA) and defined(USE_WS2812FX_UART)
|
#if defined(ENABLE_HOMEASSISTANT) and !defined(ENABLE_MQTT)
|
||||||
#error "Cant have both DMA and UART method."
|
|
||||||
#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"
|
#error "To use HA, you have to either enable PubCubClient or AsyncMQTT"
|
||||||
#endif
|
#endif
|
||||||
#if ( !defined(ENABLE_HOMEASSISTANT) and defined(MQTT_HOME_ASSISTANT_SUPPORT) )
|
#if !defined(ENABLE_HOMEASSISTANT) and defined(MQTT_HOME_ASSISTANT_SUPPORT)
|
||||||
#error "To use HA support, you have to either enable Homeassistant component"
|
#error "To use HA support, you have to either enable Homeassistant component"
|
||||||
#endif
|
#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[][6] = { // main_color, back_color, xtra_color, speed, mode, duration (seconds)
|
||||||
{0xff000000, 120, 1, 5}, // blink red for 5 seconds
|
{0xff000000, 0x00ff0000, 0x00000000, 200, 1, 5}, // blink red/geen for 5 seconds
|
||||||
{0x00ff0000, 120, 3, 10}, // wipe green for 10 seconds
|
{0x00ff0000, 0x0000ff00, 0x00000000, 200, 3, 10}, // wipe green/blue for 10 seconds
|
||||||
{0x0000ff00, 196, 14, 5}, // dual scan blue for 5 seconds
|
{0x0000ff00, 0xff000000, 0x00000000, 60, 14, 10}, // dual scan blue on red for 10 seconds
|
||||||
{0x0000ff00, 196, 46, 15} // fireworks for 15 seconds
|
{0x0000ff00, 0xff000000, 0x00000000, 40, 45, 15}, // fireworks blue/red for 15 seconds
|
||||||
|
{0xff000000, 0x00ff0000, 0x0000ff00, 40, 54, 15} // tricolor chase red/green/blue for 15 seconds
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(ENABLE_MQTT) or defined(ENABLE_AMQTT)
|
#if defined(ENABLE_MQTT)
|
||||||
#ifdef ENABLE_MQTT
|
char mqtt_buf[80];
|
||||||
|
char mqtt_intopic[strlen(HOSTNAME) + 3 + 1]; // Topic in will be: <HOSTNAME>/in
|
||||||
|
char mqtt_outtopic[strlen(HOSTNAME) + 4 + 1]; // Topic out will be: <HOSTNAME>/out
|
||||||
|
#if ENABLE_MQTT == 0
|
||||||
#define MQTT_MAX_PACKET_SIZE 2048
|
#define MQTT_MAX_PACKET_SIZE 2048
|
||||||
#define MQTT_MAX_RECONNECT_TRIES 4
|
#define MQTT_MAX_RECONNECT_TRIES 4
|
||||||
|
|
||||||
int mqtt_reconnect_retries = 0;
|
int mqtt_reconnect_retries = 0;
|
||||||
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
|
|
||||||
uint8_t qossub = 0; // PubSubClient can sub qos 0 or 1
|
uint8_t qossub = 0; // PubSubClient can sub qos 0 or 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_AMQTT
|
#if ENABLE_MQTT == 1
|
||||||
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 qossub = 0; // AMQTT can sub qos 0 or 1 or 2
|
||||||
uint8_t qospub = 0; // AMQTT can pub qos 0 or 1 or 2
|
uint8_t qospub = 0; // AMQTT can pub qos 0 or 1 or 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_HOMEASSISTANT
|
#if defined(ENABLE_HOMEASSISTANT)
|
||||||
String mqtt_ha = "home/" + String(HOSTNAME) + "_ha/";
|
char mqtt_ha_state_in[5 + strlen(HOSTNAME) + 12 + 1]; // Topic in will be: home/<HOSTNAME>_ha/state/in"
|
||||||
String mqtt_ha_state_in = mqtt_ha + "state/in";
|
char mqtt_ha_state_out[5 + strlen(HOSTNAME) + 13 + 1]; // Topic in will be: home/<HOSTNAME>_ha/state/out"
|
||||||
String mqtt_ha_state_out = mqtt_ha + "state/out";
|
|
||||||
|
|
||||||
const char* on_cmd = "ON";
|
const char* on_cmd = "ON";
|
||||||
const char* off_cmd = "OFF";
|
const char* off_cmd = "OFF";
|
||||||
bool stateOn = false;
|
|
||||||
bool animation_on = false;
|
|
||||||
bool new_ha_mqtt_msg = false;
|
bool new_ha_mqtt_msg = false;
|
||||||
uint16_t color_temp = 327; // min is 154 and max is 500
|
uint16_t color_temp = 327; // min is 154 and max is 500
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define ENABLE_MQTT_HOSTNAME_CHIPID // Uncomment/comment to add ESPChipID to end of MQTT hostname
|
#if defined(ENABLE_MQTT_HOSTNAME_CHIPID)
|
||||||
#ifdef ENABLE_MQTT_HOSTNAME_CHIPID
|
|
||||||
char mqtt_clientid[64];
|
char mqtt_clientid[64];
|
||||||
#else
|
#else
|
||||||
const char* mqtt_clientid = HOSTNAME;
|
const char* mqtt_clientid = HOSTNAME;
|
||||||
@@ -114,16 +110,8 @@ 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
|
||||||
#ifdef ENABLE_LEGACY_ANIMATIONS
|
enum MODE {OFF, AUTO, TV, E131, CUSTOM, HOLD, SET_ALL, SET_MODE, SET_COLOR, SET_SPEED, SET_BRIGHTNESS};
|
||||||
enum MODE {OFF, AUTO, TV, E131, SET_MODE, HOLD, CUSTOM, SETCOLOR, SETSPEED, BRIGHTNESS, WIPE, RAINBOW, RAINBOWCYCLE, THEATERCHASE, TWINKLERANDOM, THEATERCHASERAINBOW};
|
MODE mode = SET_MODE; // Standard mode that is active when software starts
|
||||||
MODE mode = RAINBOW; // Standard mode that is active when software starts
|
|
||||||
#else
|
|
||||||
enum MODE {OFF, AUTO, TV, E131, SET_MODE, HOLD, CUSTOM, SETCOLOR, SETSPEED, BRIGHTNESS};
|
|
||||||
MODE mode = SET_MODE; // Standard mode that is active when software starts
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_TV
|
|
||||||
bool exit_func = false; // Global helper variable to get out of the color modes when mode changes
|
|
||||||
#endif
|
|
||||||
MODE prevmode = mode;
|
MODE prevmode = mode;
|
||||||
|
|
||||||
int ws2812fx_speed = 196; // Global variable for storing the delay between color changes --> smaller == faster
|
int ws2812fx_speed = 196; // Global variable for storing the delay between color changes --> smaller == faster
|
||||||
@@ -133,6 +121,7 @@ int ws2812fx_mode = 0; // Helper variable to set WS2812FX modes
|
|||||||
|
|
||||||
bool shouldSaveConfig = false; // For WiFiManger custom config
|
bool shouldSaveConfig = false; // For WiFiManger custom config
|
||||||
|
|
||||||
|
uint32_t hex_colors[3] = {}; // Color array for setting WS2812FX
|
||||||
struct ledstate // Data structure to store a state of a single led
|
struct ledstate // Data structure to store a state of a single led
|
||||||
{
|
{
|
||||||
uint8_t red;
|
uint8_t red;
|
||||||
@@ -144,33 +133,19 @@ struct ledstate // Data structure to store a state of a single le
|
|||||||
typedef struct ledstate LEDState; // Define the datatype LEDState
|
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 = { 255, 0, 0, 0 }; // Store the "main color" of the strip used in single color modes
|
LEDState main_color = { 255, 0, 0, 0 }; // Store the "main color" of the strip used in single color modes
|
||||||
|
LEDState back_color = { 0, 0, 0, 0 }; // Store the "2nd color" of the strip used in single color modes
|
||||||
|
LEDState xtra_color = { 0, 0, 0, 0 }; // Store the "3rd color" of the strip used in single color modes
|
||||||
|
|
||||||
|
char last_state[67]; // Keeps the state representation before auto or off mode
|
||||||
#define ENABLE_STATE_SAVE_SPIFFS // If defined, saves state on SPIFFS
|
bool updateState = false;
|
||||||
//#define ENABLE_STATE_SAVE_EEPROM // If defined, save state on reboot
|
|
||||||
|
|
||||||
char beforeoffauto_state[36]; // Keeps the state representation before auto mode
|
|
||||||
#ifdef ENABLE_STATE_SAVE_EEPROM
|
|
||||||
char current_state[36]; // Keeps the current state representation
|
|
||||||
char last_state[36]; // Save the last state as string representation
|
|
||||||
unsigned long time_statechange = 0; // Time when the state last changed
|
|
||||||
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
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_STATE_SAVE_SPIFFS
|
|
||||||
bool updateStateFS = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Button handling
|
// Button handling
|
||||||
#if defined(ENABLE_BUTTON) || defined(ENABLE_BUTTON_GY33)
|
|
||||||
boolean buttonState = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_BUTTON
|
|
||||||
#define BTN_MODE_SHORT "STA| 1| 0|245|196| 0| 0| 0|255" // Static white
|
|
||||||
#define BTN_MODE_MEDIUM "STA| 1| 48|245|196|255|102| 0| 0" // Fire flicker
|
|
||||||
#define BTN_MODE_LONG "STA| 1| 46|253|196|255|102| 0| 0" // Fireworks random
|
|
||||||
|
|
||||||
|
#if defined(ENABLE_BUTTON)
|
||||||
|
//#define BTN_MODE_SHORT "STA|mo|fxm| h| s| r1| g1| b1| w1| r2| g2| b2| w2| r3| g3| b3| w3" // Example
|
||||||
|
#define BTN_MODE_SHORT "STA| 5| 0|255|196| 0| 0| 0|255| 0| 0| 0| 0| 0| 0| 0| 0" // Static white
|
||||||
|
#define BTN_MODE_MEDIUM "STA| 5| 48|200|196|255|102| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0" // Fire flicker
|
||||||
|
#define BTN_MODE_LONG "STA| 5| 46|200|196|255|102| 0| 0| 0| 0| 0| 0| 0| 0| 0| 0" // Fireworks random
|
||||||
unsigned long keyPrevMillis = 0;
|
unsigned long keyPrevMillis = 0;
|
||||||
const unsigned long keySampleIntervalMs = 25;
|
const unsigned long keySampleIntervalMs = 25;
|
||||||
byte longKeyPressCountMax = 80; // 80 * 25 = 2000 ms
|
byte longKeyPressCountMax = 80; // 80 * 25 = 2000 ms
|
||||||
@@ -179,7 +154,7 @@ char beforeoffauto_state[36]; // Keeps the state representation befor
|
|||||||
byte prevKeyState = HIGH; // button is active low
|
byte prevKeyState = HIGH; // button is active low
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_BUTTON_GY33
|
#if defined(ENABLE_BUTTON_GY33)
|
||||||
unsigned long keyPrevMillis_gy33 = 0;
|
unsigned long keyPrevMillis_gy33 = 0;
|
||||||
const unsigned long keySampleIntervalMs_gy33 = 25;
|
const unsigned long keySampleIntervalMs_gy33 = 25;
|
||||||
byte longKeyPressCountMax_gy33 = 80; // 80 * 25 = 2000 ms
|
byte longKeyPressCountMax_gy33 = 80; // 80 * 25 = 2000 ms
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
// Color modes
|
// TV mode
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
int dipInterval = 10;
|
int dipInterval = 10;
|
||||||
@@ -24,16 +24,13 @@ void hsb2rgbAN1(uint16_t index, uint8_t sat, uint8_t bright, uint8_t myled) {
|
|||||||
temp[0] = temp[3] = (uint8_t)(( (sat ^ 255) * bright) / 255);
|
temp[0] = temp[3] = (uint8_t)(( (sat ^ 255) * bright) / 255);
|
||||||
temp[1] = temp[4] = (uint8_t)((((( (index & 255) * sat) / 255) + (sat ^ 255)) * bright) / 255);
|
temp[1] = temp[4] = (uint8_t)((((( (index & 255) * sat) / 255) + (sat ^ 255)) * bright) / 255);
|
||||||
temp[2] = (uint8_t)(((((((index & 255) ^ 255) * sat) / 255) + (sat ^ 255)) * bright) / 255);
|
temp[2] = (uint8_t)(((((((index & 255) ^ 255) * sat) / 255) + (sat ^ 255)) * bright) / 255);
|
||||||
|
|
||||||
strip.setPixelColor(myled, temp[n + 2], temp[n + 1], temp[n], 0);
|
strip.setPixelColor(myled, temp[n + 2], temp[n + 1], temp[n], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void updateLed (int led, int brightness) {
|
void updateLed (int led, int brightness) {
|
||||||
ledStates[led] = brightness;
|
ledStates[led] = brightness;
|
||||||
|
for (int i=0; i<NUMLEDS; i++) {
|
||||||
for (int i=0; i<NUMLEDS; i++)
|
|
||||||
{
|
|
||||||
uint16_t index = (i%3 == 0) ? 400 : random(0,767);
|
uint16_t index = (i%3 == 0) ? 400 : random(0,767);
|
||||||
hsb2rgbAN1(index, 200, ledStates[i], i);
|
hsb2rgbAN1(index, 200, ledStates[i], i);
|
||||||
}
|
}
|
||||||
@@ -42,34 +39,22 @@ void updateLed (int led, int brightness) {
|
|||||||
|
|
||||||
|
|
||||||
// See: http://forum.mysensors.org/topic/85/phoneytv-for-vera-is-here/13
|
// See: http://forum.mysensors.org/topic/85/phoneytv-for-vera-is-here/13
|
||||||
void tv() {
|
void handleTV() {
|
||||||
checkForRequests();
|
if (timeToDip == false) {
|
||||||
if (exit_func) {
|
|
||||||
exit_func = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timeToDip == false)
|
|
||||||
{
|
|
||||||
currentMillis = millis();
|
currentMillis = millis();
|
||||||
if(currentMillis-previousMillis > interval)
|
if(currentMillis-previousMillis > interval) {
|
||||||
{
|
|
||||||
previousMillis = currentMillis;
|
previousMillis = currentMillis;
|
||||||
//interval = random(750,4001);//Adjusts the interval for more/less frequent random light changes
|
//interval = random(750,4001);//Adjusts the interval for more/less frequent random light changes
|
||||||
interval = random(1000-(ws2812fx_speed*2),5001-(ws2812fx_speed*8));
|
interval = random(1000-(ws2812fx_speed*2),5001-(ws2812fx_speed*8));
|
||||||
twitch = random(40,100);// Twitch provides motion effect but can be a bit much if too high
|
twitch = random(40,100);// Twitch provides motion effect but can be a bit much if too high
|
||||||
dipCount = dipCount++;
|
dipCount = dipCount++;
|
||||||
}
|
}
|
||||||
if(currentMillis-previousMillis<twitch)
|
if(currentMillis-previousMillis<twitch) {
|
||||||
{
|
|
||||||
led=random(0, (strip.numPixels()-1));
|
led=random(0, (strip.numPixels()-1));
|
||||||
analogLevel=random(50,255);// set the range of the 3 pwm leds
|
analogLevel=random(50,255);// set the range of the 3 pwm leds
|
||||||
ledState = ledState == LOW ? HIGH: LOW; // if the LED is off turn it on and vice-versa:
|
ledState = ledState == LOW ? HIGH: LOW; // if the LED is off turn it on and vice-versa:
|
||||||
|
|
||||||
updateLed(led, (ledState) ? 255 : 0);
|
updateLed(led, (ledState) ? 255 : 0);
|
||||||
|
if (dipCount > dipInterval) {
|
||||||
if (dipCount > dipInterval)
|
|
||||||
{
|
|
||||||
DBG_OUTPUT_PORT.println("dip");
|
DBG_OUTPUT_PORT.println("dip");
|
||||||
timeToDip = true;
|
timeToDip = true;
|
||||||
dipCount = 0;
|
dipCount = 0;
|
||||||
@@ -77,22 +62,15 @@ void tv() {
|
|||||||
darkTime = random(50,150);
|
darkTime = random(50,150);
|
||||||
dipInterval = random(5,250);// cycles of flicker
|
dipInterval = random(5,250);// cycles of flicker
|
||||||
}
|
}
|
||||||
//strip.show();
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
DBG_OUTPUT_PORT.println("Dip Time");
|
DBG_OUTPUT_PORT.println("Dip Time");
|
||||||
currentDipTime = millis();
|
currentDipTime = millis();
|
||||||
if (currentDipTime - dipStartTime < darkTime)
|
if (currentDipTime - dipStartTime < darkTime) {
|
||||||
{
|
for (int i=3; i<strip.numPixels(); i++) {
|
||||||
for (int i=3; i<strip.numPixels(); i++)
|
|
||||||
{
|
|
||||||
updateLed(i, 0);
|
updateLed(i, 0);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
timeToDip = false;
|
timeToDip = false;
|
||||||
}
|
}
|
||||||
strip.show();
|
strip.show();
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1 +1 @@
|
|||||||
#define SKETCH_VERSION "2.2.0"
|
#define SKETCH_VERSION "2.2.0.rgbw.3c"
|
||||||
|
|||||||
@@ -59,4 +59,10 @@
|
|||||||
* 6 Jan 2018 v 2.2.0
|
* 6 Jan 2018 v 2.2.0
|
||||||
* - fix webserver not responding when E1.31 is mode is acivated: do a webserver.loop() for every 1.31 packet
|
* - fix webserver not responding when E1.31 is mode is acivated: do a webserver.loop() for every 1.31 packet
|
||||||
* - HA E1.31 mode added
|
* - HA E1.31 mode added
|
||||||
|
*
|
||||||
|
* 15 Feb 2018 v 2.2.0 rgbw 3colors
|
||||||
|
* - Code cleanup
|
||||||
|
* - Implemented support for back- and xtra-color
|
||||||
|
* - Implemented IR remote control
|
||||||
|
* - Remove some string data types (to be continued)
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user