kopia lustrzana https://github.com/Aircoookie/WLED
				
				
				
			Merge remote-tracking branch 'origin/master'
						commit
						4644912ee4
					
				| 
						 | 
				
			
			@ -4,7 +4,8 @@
 | 
			
		|||
[platformio]
 | 
			
		||||
src_dir = ./wled00
 | 
			
		||||
data_dir = ./wled00/data
 | 
			
		||||
lib_extra_dirs = ./wled00/src
 | 
			
		||||
;lib_extra_dirs = ./wled00/src
 | 
			
		||||
lib_dir = ./wled00/src
 | 
			
		||||
; Please uncomment one of the 5 lines below to select your board
 | 
			
		||||
; env_default = nodemcuv2
 | 
			
		||||
; env_default = esp01
 | 
			
		||||
| 
						 | 
				
			
			@ -76,8 +77,8 @@ build_flags =
 | 
			
		|||
  ; -D WLED_DISABLE_ALEXA
 | 
			
		||||
  -D WLED_DISABLE_BLYNK
 | 
			
		||||
  -D WLED_DISABLE_CRONIXIE
 | 
			
		||||
  ; -D WLED_DISABLE_HUESYNC
 | 
			
		||||
  -D WLED_DISABLE_INFRARED
 | 
			
		||||
  -D WLED_DISABLE_HUESYNC
 | 
			
		||||
  ; -D WLED_DISABLE_INFRARED
 | 
			
		||||
 | 
			
		||||
[common:esp8266_512k]
 | 
			
		||||
platform = espressif8266@1.8.0
 | 
			
		||||
| 
						 | 
				
			
			@ -89,15 +90,15 @@ build_flags =
 | 
			
		|||
  ; -D WLED_DISABLE_ALEXA
 | 
			
		||||
  -D WLED_DISABLE_BLYNK
 | 
			
		||||
  -D WLED_DISABLE_CRONIXIE
 | 
			
		||||
  ; -D WLED_DISABLE_HUESYNC
 | 
			
		||||
  -D WLED_DISABLE_INFRARED
 | 
			
		||||
  -D WLED_DISABLE_HUESYNC
 | 
			
		||||
  ; -D WLED_DISABLE_INFRARED
 | 
			
		||||
 | 
			
		||||
[common:esp32]
 | 
			
		||||
platform = espressif32@1.11.1
 | 
			
		||||
build_flags =
 | 
			
		||||
  -D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
 | 
			
		||||
  -D ARDUINO_ARCH_ESP32
 | 
			
		||||
  -D WLED_DISABLE_INFRARED
 | 
			
		||||
  -D WLED_DISABLE_INFRARED 
 | 
			
		||||
 | 
			
		||||
# see: http://docs.platformio.org/en/latest/platforms/espressif8266.html
 | 
			
		||||
[env:nodemcuv2]
 | 
			
		||||
| 
						 | 
				
			
			@ -124,6 +125,48 @@ build_flags =
 | 
			
		|||
lib_deps =
 | 
			
		||||
  ${common.lib_deps_external}
 | 
			
		||||
 | 
			
		||||
[env:esp8285_4CH_H801]
 | 
			
		||||
board = esp8285
 | 
			
		||||
platform = ${common:esp8266_1M.platform}
 | 
			
		||||
monitor_speed = ${common.monitor_speed}
 | 
			
		||||
upload_speed = ${common.upload_speed}
 | 
			
		||||
framework = ${common.framework}
 | 
			
		||||
build_flags =
 | 
			
		||||
  ${common.build_flags}
 | 
			
		||||
  ${common:esp8266_1M.build_flags}
 | 
			
		||||
  -D WLED_USE_ANALOG_LEDS
 | 
			
		||||
  -D WLED_USE_H801
 | 
			
		||||
lib_deps =
 | 
			
		||||
  ${common.lib_deps_external}
 | 
			
		||||
 | 
			
		||||
[env:esp8285_4CH_MagicHome]
 | 
			
		||||
board = esp8285
 | 
			
		||||
platform = ${common:esp8266_1M.platform}
 | 
			
		||||
monitor_speed = ${common.monitor_speed}
 | 
			
		||||
upload_speed = ${common.upload_speed}
 | 
			
		||||
framework = ${common.framework}
 | 
			
		||||
build_flags =
 | 
			
		||||
  ${common.build_flags}
 | 
			
		||||
  ${common:esp8266_1M.build_flags}
 | 
			
		||||
  -D WLED_USE_ANALOG_LEDS
 | 
			
		||||
lib_deps =
 | 
			
		||||
  ${common.lib_deps_external}
 | 
			
		||||
 | 
			
		||||
[env:esp8285_5CH_H801]
 | 
			
		||||
board = esp8285
 | 
			
		||||
platform = ${common:esp8266_1M.platform}
 | 
			
		||||
monitor_speed = ${common.monitor_speed}
 | 
			
		||||
upload_speed = ${common.upload_speed}
 | 
			
		||||
framework = ${common.framework}
 | 
			
		||||
build_flags =
 | 
			
		||||
  ${common.build_flags}
 | 
			
		||||
  ${common:esp8266_1M.build_flags}
 | 
			
		||||
  -D WLED_USE_ANALOG_LEDS
 | 
			
		||||
  -D WLED_USE_5CH_LEDS 
 | 
			
		||||
  -D WLED_USE_H801
 | 
			
		||||
lib_deps =
 | 
			
		||||
  ${common.lib_deps_external}
 | 
			
		||||
 | 
			
		||||
[env:esp01_1m]
 | 
			
		||||
board = esp01_1m
 | 
			
		||||
platform = ${common:esp8266_1M.platform}
 | 
			
		||||
| 
						 | 
				
			
			@ -147,6 +190,7 @@ framework = ${common.framework}
 | 
			
		|||
build_flags =
 | 
			
		||||
  ${common.build_flags}
 | 
			
		||||
  ${common:esp8266_512k.build_flags}
 | 
			
		||||
  -D WLED_DISABLE_INFRARED
 | 
			
		||||
lib_deps =
 | 
			
		||||
  ${common.lib_deps_external}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										34
									
								
								readme.md
								
								
								
								
							
							
						
						
									
										34
									
								
								readme.md
								
								
								
								
							| 
						 | 
				
			
			@ -1,11 +1,15 @@
 | 
			
		|||
   
 | 
			
		||||
 | 
			
		||||
[](https://github.com/Aircoookie/WLED/releases)
 | 
			
		||||
[](https://github.com/Def3nder/WLED/releases)
 | 
			
		||||
[](https://discord.gg/KuqP7NE)
 | 
			
		||||
[](https://github.com/Aircoookie/WLED/wiki)
 | 
			
		||||
[](https://github.com/Aircoookie/WLED-App)
 | 
			
		||||
 | 
			
		||||
## Welcome to my project WLED!
 | 
			
		||||
## Welcome to the modded version of the brilliant project WLED
 | 
			
		||||
 | 
			
		||||
The Mod enables **analog RGBW stripes** instead of digital ones.
 | 
			
		||||
 | 
			
		||||
### All the acknowledgement goes to Aircoookie, the author of WLED
 | 
			
		||||
 | 
			
		||||
A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control NeoPixel (WS2812B, WS2811, SK6812, APA102) LEDs!
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -25,19 +29,19 @@ A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control
 | 
			
		|||
- Configurable Auto Brightness limit for safer operation  
 | 
			
		||||
 | 
			
		||||
### Supported light control interfaces:
 | 
			
		||||
- WLED app for Android and iOS  
 | 
			
		||||
- JSON and HTTP request APIs  
 | 
			
		||||
- MQTT  
 | 
			
		||||
- Blynk IoT  
 | 
			
		||||
- E1.31  
 | 
			
		||||
- Hyperion  
 | 
			
		||||
- UDP realtime  
 | 
			
		||||
- Alexa voice control (including dimming and color)  
 | 
			
		||||
- Sync to Philips hue lights  
 | 
			
		||||
- Adalight (PC ambilight via serial)  
 | 
			
		||||
- Sync color of multiple WLED devices (UDP notifier)  
 | 
			
		||||
- Infrared remotes (24-key RGB, receiver required)  
 | 
			
		||||
- Simple timers/schedules (time from NTP, timezones/DST supported)  
 | 
			
		||||
  - WLED app for Android and iOS  
 | 
			
		||||
  - JSON and HTTP request APIs  
 | 
			
		||||
  - MQTT  
 | 
			
		||||
  - Blynk IoT  
 | 
			
		||||
  - E1.31  
 | 
			
		||||
  - Hyperion  
 | 
			
		||||
  - UDP realtime  
 | 
			
		||||
  - Alexa voice control (including dimming and color)  
 | 
			
		||||
  - Sync to Philips hue lights  
 | 
			
		||||
  - Adalight (PC ambilight via serial)  
 | 
			
		||||
  - Sync color of multiple WLED devices (UDP notifier)  
 | 
			
		||||
  - Infrared remotes (24-key RGB, receiver required)  
 | 
			
		||||
  - Simple timers/schedules (time from NTP, timezones/DST supported)  
 | 
			
		||||
 | 
			
		||||
### Quick start guide and documentation:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,10 +5,19 @@
 | 
			
		|||
//PIN CONFIGURATION
 | 
			
		||||
#define LEDPIN 2     //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos)
 | 
			
		||||
//#define USE_APA102 // Uncomment for using APA102 LEDs.
 | 
			
		||||
#define BTNPIN 0     //button pin. Needs to have pullup (gpio0 recommended)
 | 
			
		||||
#define IR_PIN 4     //infrared pin (-1 to disable)
 | 
			
		||||
#define RLYPIN 12    //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,...
 | 
			
		||||
#define AUXPIN -1    //debug auxiliary output pin (-1 to disable)
 | 
			
		||||
#ifdef WLED_USE_H801
 | 
			
		||||
  #define BTNPIN -1 //button pin. Needs to have pullup (gpio0 recommended)
 | 
			
		||||
  #define IR_PIN  0 //infrared pin (-1 to disable)  MagicHome: 4, H801 Wifi: 0
 | 
			
		||||
#else
 | 
			
		||||
  #define BTNPIN  0 //button pin. Needs to have pullup (gpio0 recommended)
 | 
			
		||||
  #define IR_PIN  4 //infrared pin (-1 to disable)  MagicHome: 4, H801 Wifi: 0
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef WLED_USE_ANALOG_LEDS
 | 
			
		||||
  #define RLYPIN -1 //disable RLYPIN as it will be used for the RGB-PINs
 | 
			
		||||
#else
 | 
			
		||||
  #define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,...
 | 
			
		||||
#endif
 | 
			
		||||
#define AUXPIN -1 //debug auxiliary output pin (-1 to disable)
 | 
			
		||||
 | 
			
		||||
#define RLYMDE 1     //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -20,6 +29,22 @@
 | 
			
		|||
 #endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef WLED_USE_ANALOG_LEDS
 | 
			
		||||
  //PWM pins - PINs 15,13,12,14 (W2 = 04)are used with H801 Wifi LED Controller
 | 
			
		||||
  #ifdef WLED_USE_H801
 | 
			
		||||
    #define RPIN 15   //R pin for analog LED strip   
 | 
			
		||||
    #define GPIN 13   //G pin for analog LED strip
 | 
			
		||||
    #define BPIN 12   //B pin for analog LED strip
 | 
			
		||||
    #define WPIN 14   //W pin for analog LED strip (W1: 14, W2: 04)
 | 
			
		||||
    #define W2PIN 04  //W2 pin for analog LED strip 
 | 
			
		||||
  #else
 | 
			
		||||
  //PWM pins - PINs 12,5,13,15 are used with Magic Home LED Controller
 | 
			
		||||
    #define GPIN 12   //G pin for analog LED strip
 | 
			
		||||
    #define RPIN 5   //R pin for analog LED strip   
 | 
			
		||||
    #define WPIN 13   //W pin for analog LED strip
 | 
			
		||||
    #define BPIN 15   //B pin for analog LED strip
 | 
			
		||||
  #endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
//automatically uses the right driver method for each platform
 | 
			
		||||
#ifdef ARDUINO_ARCH_ESP32
 | 
			
		||||
| 
						 | 
				
			
			@ -104,15 +129,84 @@ public:
 | 
			
		|||
      #endif
 | 
			
		||||
        _pGrbw->Begin();
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
        #ifdef WLED_USE_ANALOG_LEDS      
 | 
			
		||||
          //init PWM pins - PINs 5,12,13,15 are used with Magic Home LED Controller
 | 
			
		||||
          pinMode(RPIN, OUTPUT);
 | 
			
		||||
          pinMode(GPIN, OUTPUT);
 | 
			
		||||
          pinMode(BPIN, OUTPUT);
 | 
			
		||||
          switch (_type) {
 | 
			
		||||
            case NeoPixelType_Grb:                                                    break;
 | 
			
		||||
            #ifdef WLED_USE_5CH_LEDS
 | 
			
		||||
              case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT); pinMode(W2PIN, OUTPUT);  break;
 | 
			
		||||
            #else
 | 
			
		||||
              case NeoPixelType_Grbw: pinMode(WPIN, OUTPUT);                          break;
 | 
			
		||||
            #endif
 | 
			
		||||
          }
 | 
			
		||||
          analogWriteRange(255);  //same range as one RGB channel
 | 
			
		||||
          analogWriteFreq(880);   //PWM frequency proven as good for LEDs
 | 
			
		||||
        #endif
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#ifdef WLED_USE_ANALOG_LEDS      
 | 
			
		||||
    void SetRgbwPwm(uint8_t r, uint8_t g, uint8_t b, uint8_t w, uint8_t w2=0)
 | 
			
		||||
    {
 | 
			
		||||
      analogWrite(RPIN, r);
 | 
			
		||||
      analogWrite(GPIN, g);
 | 
			
		||||
      analogWrite(BPIN, b);
 | 
			
		||||
      switch (_type) {
 | 
			
		||||
        case NeoPixelType_Grb:                                                  break;
 | 
			
		||||
        #ifdef WLED_USE_5CH_LEDS
 | 
			
		||||
          case NeoPixelType_Grbw: analogWrite(WPIN, w); analogWrite(W2PIN, w2); break;
 | 
			
		||||
        #else
 | 
			
		||||
          case NeoPixelType_Grbw: analogWrite(WPIN, w);                         break;
 | 
			
		||||
        #endif
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  void Show()
 | 
			
		||||
  {
 | 
			
		||||
    byte b;
 | 
			
		||||
    switch (_type)
 | 
			
		||||
    {
 | 
			
		||||
      case NeoPixelType_Grb:  _pGrb->Show();   break;
 | 
			
		||||
      case NeoPixelType_Grbw: _pGrbw->Show();  break;
 | 
			
		||||
      case NeoPixelType_Grb: {
 | 
			
		||||
        _pGrb->Show();
 | 
			
		||||
        #ifdef WLED_USE_ANALOG_LEDS      
 | 
			
		||||
          RgbColor color = _pGrb->GetPixelColor(0);
 | 
			
		||||
          b = _pGrb->GetBrightness();
 | 
			
		||||
          SetRgbwPwm(color.R * b / 255, color.G * b / 255, color.B * b / 255, 0);
 | 
			
		||||
        #endif
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
      case NeoPixelType_Grbw: {
 | 
			
		||||
        _pGrbw->Show();
 | 
			
		||||
        #ifdef WLED_USE_ANALOG_LEDS      
 | 
			
		||||
          RgbwColor colorW = _pGrbw->GetPixelColor(0);
 | 
			
		||||
          b = _pGrbw->GetBrightness();
 | 
			
		||||
          // check color values for Warm / COld white mix (for RGBW)  // EsplanexaDevice.cpp
 | 
			
		||||
          #ifdef WLED_USE_5CH_LEDS
 | 
			
		||||
            if        (colorW.R == 255 & colorW.G == 255 && colorW.B == 255 && colorW.W == 255) {  
 | 
			
		||||
              SetRgbwPwm(0, 0, 0,                  0, colorW.W * b / 255);
 | 
			
		||||
            } else if (colorW.R == 127 & colorW.G == 127 && colorW.B == 127 && colorW.W == 255) {  
 | 
			
		||||
              SetRgbwPwm(0, 0, 0, colorW.W * b / 512, colorW.W * b / 255);
 | 
			
		||||
            } else if (colorW.R ==   0 & colorW.G ==   0 && colorW.B ==   0 && colorW.W == 255) {  
 | 
			
		||||
              SetRgbwPwm(0, 0, 0, colorW.W * b / 255,                  0);
 | 
			
		||||
            } else if (colorW.R == 130 & colorW.G ==  90 && colorW.B ==   0 && colorW.W == 255) {  
 | 
			
		||||
              SetRgbwPwm(0, 0, 0, colorW.W * b / 255, colorW.W * b / 512);
 | 
			
		||||
            } else if (colorW.R == 255 & colorW.G == 153 && colorW.B ==   0 && colorW.W == 255) {  
 | 
			
		||||
              SetRgbwPwm(0, 0, 0, colorW.W * b / 255,                  0);
 | 
			
		||||
            } else {  // not only white colors
 | 
			
		||||
              SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255);
 | 
			
		||||
            }
 | 
			
		||||
          #else
 | 
			
		||||
            SetRgbwPwm(colorW.R * b / 255, colorW.G * b / 255, colorW.B * b / 255, colorW.W * b / 255);
 | 
			
		||||
          #endif         
 | 
			
		||||
        #endif
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -187,7 +187,7 @@ const char PAGE_settings_sync[] PROGMEM = R"=====(<!DOCTYPE html>
 | 
			
		|||
<h2>Sync setup</h2>
 | 
			
		||||
<h3>Button setup</h3>
 | 
			
		||||
On/Off button enabled: <input type="checkbox" name="BT"><br>
 | 
			
		||||
Infrared receiver enabled: <input type="checkbox" name="IR"><br>
 | 
			
		||||
Infrared receiver type (0 = disabled): <input name="IR" type="number" min="0" max="4" required><br>
 | 
			
		||||
<a href="https://github.com/Aircoookie/WLED/wiki/Infrared-Control" target="_blank">IR info</a>
 | 
			
		||||
<h3>WLED Broadcast</h3>
 | 
			
		||||
UDP Port: <input name="UP" type="number" min="1" max="65535" required><br>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,66 +30,165 @@
 | 
			
		|||
#define IR24_FADE      0xF7C837 
 | 
			
		||||
#define IR24_SMOOTH    0xF7E817 
 | 
			
		||||
 | 
			
		||||
/* 44-key defs, to be done later
 | 
			
		||||
#define IR44_BPlus  0xFF3AC5  // 
 | 
			
		||||
#define IR44_BMinus 0xFFBA45  // 
 | 
			
		||||
#define IR44_ON     0xFF827D  // 
 | 
			
		||||
#define IR44_OFF    0xFF02FD  // 
 | 
			
		||||
#define IR44_R      0xFF1AE5  // 
 | 
			
		||||
#define IR44_G      0xFF9A65  // 
 | 
			
		||||
#define IR44_B      0xFFA25D  // 
 | 
			
		||||
#define IR44_W      0xFF22DD  // 
 | 
			
		||||
#define IR44_B1     0xFF2AD5  // 
 | 
			
		||||
#define IR44_B2     0xFFAA55  // 
 | 
			
		||||
#define IR44_B3     0xFF926D  // 
 | 
			
		||||
#define IR44_B4     0xFF12ED  // 
 | 
			
		||||
#define IR44_B5     0xFF0AF5  // 
 | 
			
		||||
#define IR44_B6     0xFF8A75  // 
 | 
			
		||||
#define IR44_B7     0xFFB24D  // 
 | 
			
		||||
#define IR44_B8     0xFF32CD  // 
 | 
			
		||||
#define IR44_B9     0xFF38C7  // 
 | 
			
		||||
#define IR44_B10    0xFFB847  // 
 | 
			
		||||
#define IR44_B11    0xFF7887  // 
 | 
			
		||||
#define IR44_B12    0xFFF807  // 
 | 
			
		||||
#define IR44_B13    0xFF18E7  // 
 | 
			
		||||
#define IR44_B14    0xFF9867  // 
 | 
			
		||||
#define IR44_B15    0xFF58A7  // 
 | 
			
		||||
#define IR44_B16    0xFFD827  // 
 | 
			
		||||
#define IR44_UPR    0xFF28D7  // 
 | 
			
		||||
#define IR44_UPG    0xFFA857  // 
 | 
			
		||||
#define IR44_UPB    0xFF6897  // 
 | 
			
		||||
#define IR44_QUICK  0xFFE817  // 
 | 
			
		||||
#define IR44_DOWNR  0xFF08F7  // 
 | 
			
		||||
#define IR44_DOWNG  0xFF8877  // 
 | 
			
		||||
#define IR44_DOWNB  0xFF48B7  // 
 | 
			
		||||
#define IR44_SLOW   0xFFC837  // 
 | 
			
		||||
#define IR44_DIY1   0xFF30CF  // 
 | 
			
		||||
#define IR44_DIY2   0xFFB04F  // 
 | 
			
		||||
#define IR44_DIY3   0xFF708F  // 
 | 
			
		||||
#define IR44_AUTO   0xFFF00F  // 
 | 
			
		||||
#define IR44_DIY4   0xFF10EF  // 
 | 
			
		||||
#define IR44_DIY5   0xFF906F  // 
 | 
			
		||||
#define IR44_DIY6   0xFF50AF  // 
 | 
			
		||||
#define IR44_FLASH  0xFFD02F  // 
 | 
			
		||||
#define IR44_JUMP3  0xFF20DF  // 
 | 
			
		||||
#define IR44_JUMP7  0xFFA05F  // 
 | 
			
		||||
#define IR44_FADE3  0xFF609F  // 
 | 
			
		||||
#define IR44_FADE7  0xFFE01F  // 
 | 
			
		||||
*/
 | 
			
		||||
// 24-key defs for white remote control with CW / WW / CT+ and CT- keys (from ALDI LED pillar lamp)
 | 
			
		||||
#define IR24_CT_BRIGHTER   0xF700FF // BRI +
 | 
			
		||||
#define IR24_CT_DARKER     0xF7807F // BRI -
 | 
			
		||||
#define IR24_CT_OFF        0xF740BF // OFF
 | 
			
		||||
#define IR24_CT_ON         0xF7C03F // ON
 | 
			
		||||
#define IR24_CT_RED        0xF720DF // RED
 | 
			
		||||
#define IR24_CT_REDDISH    0xF710EF // REDDISH
 | 
			
		||||
#define IR24_CT_ORANGE     0xF730CF // ORANGE
 | 
			
		||||
#define IR24_CT_YELLOWISH  0xF708F7 // YELLOWISH
 | 
			
		||||
#define IR24_CT_YELLOW     0xF728D7 // YELLOW
 | 
			
		||||
#define IR24_CT_GREEN      0xF7A05F // GREEN
 | 
			
		||||
#define IR24_CT_GREENISH   0xF7906F // GREENISH
 | 
			
		||||
#define IR24_CT_TURQUOISE  0xF7B04F // TURQUOISE
 | 
			
		||||
#define IR24_CT_CYAN       0xF78877 // CYAN
 | 
			
		||||
#define IR24_CT_AQUA       0xF7A857 // AQUA
 | 
			
		||||
#define IR24_CT_BLUE       0xF7609F // BLUE
 | 
			
		||||
#define IR24_CT_DEEPBLUE   0xF750AF // DEEPBLUE
 | 
			
		||||
#define IR24_CT_PURPLE     0xF7708F // PURPLE
 | 
			
		||||
#define IR24_CT_MAGENTA    0xF748B7 // MAGENTA
 | 
			
		||||
#define IR24_CT_PINK       0xF76897 // PINK
 | 
			
		||||
#define IR24_CT_COLDWHITE  0xF7E01F // CW
 | 
			
		||||
#define IR24_CT_WARMWHITE  0xF7D02F // WW
 | 
			
		||||
#define IR24_CT_CTPLUS     0xF7F00F // CT+
 | 
			
		||||
#define IR24_CT_CTMINUS    0xF7C837 // CT-
 | 
			
		||||
#define IR24_CT_MEMORY     0xF7E817 // MEMORY
 | 
			
		||||
 | 
			
		||||
#define COLOR_RED       0xFF0000
 | 
			
		||||
#define COLOR_REDDISH   0xFF7800
 | 
			
		||||
#define COLOR_ORANGE    0xFFA000
 | 
			
		||||
#define COLOR_YELLOWISH 0xFFC800
 | 
			
		||||
#define COLOR_YELLOW    0xFFFF00
 | 
			
		||||
#define COLOR_GREEN     0x00FF00
 | 
			
		||||
#define COLOR_GREENISH  0x00FF78
 | 
			
		||||
#define COLOR_TURQUOISE 0x00FFA0
 | 
			
		||||
#define COLOR_CYAN      0x00FFDC
 | 
			
		||||
#define COLOR_AQUA      0x00C8FF
 | 
			
		||||
#define COLOR_BLUE      0x00A0FF
 | 
			
		||||
#define COLOR_DEEPBLUE  0x0000FF
 | 
			
		||||
#define COLOR_PURPLE    0xAA00FF
 | 
			
		||||
#define COLOR_MAGENTA   0xFF00DC
 | 
			
		||||
#define COLOR_PINK      0xFF00A0
 | 
			
		||||
#define COLOR_WHITE     0xFFFFDC
 | 
			
		||||
// 24-key defs for old remote control 
 | 
			
		||||
#define IR24_OLD_BRIGHTER  0xFF906F // Brightness Up     
 | 
			
		||||
#define IR24_OLD_DARKER    0xFFB847 // Brightness Down   
 | 
			
		||||
#define IR24_OLD_OFF       0xFFF807 // Power OFF         
 | 
			
		||||
#define IR24_OLD_ON        0xFFB04F // Power On          
 | 
			
		||||
#define IR24_OLD_RED       0xFF9867 // RED               
 | 
			
		||||
#define IR24_OLD_REDDISH   0xFFE817 // Light RED		
 | 
			
		||||
#define IR24_OLD_ORANGE    0xFF02FD // Orange            
 | 
			
		||||
#define IR24_OLD_YELLOWISH 0xFF50AF // Light Orange		
 | 
			
		||||
#define IR24_OLD_YELLOW    0xFF38C7 // YELLOW            
 | 
			
		||||
#define IR24_OLD_GREEN     0xFFD827 // GREEN             
 | 
			
		||||
#define IR24_OLD_GREENISH  0xFF48B7 // Light GREEN		
 | 
			
		||||
#define IR24_OLD_TURQUOISE 0xFF32CD // TURQUOISE         
 | 
			
		||||
#define IR24_OLD_CYAN      0xFF7887 // CYAN
 | 
			
		||||
#define IR24_OLD_AQUA      0xFF28D7 // AQUA	
 | 
			
		||||
#define IR24_OLD_BLUE      0xFF8877 // BLUE              
 | 
			
		||||
#define IR24_OLD_DEEPBLUE  0xFF6897 // Dark BLUE
 | 
			
		||||
#define IR24_OLD_PURPLE    0xFF20DF // PURPLE		
 | 
			
		||||
#define IR24_OLD_MAGENTA   0xFF708F // MAGENTA           
 | 
			
		||||
#define IR24_OLD_PINK      0xFFF00F // PINK              
 | 
			
		||||
#define IR24_OLD_WHITE     0xFFA857 // WHITE             
 | 
			
		||||
#define IR24_OLD_FLASH     0xFFB24D // FLASH Mode       
 | 
			
		||||
#define IR24_OLD_STROBE    0xFF00FF // STROBE Mode       
 | 
			
		||||
#define IR24_OLD_FADE      0xFF58A7 // FADE Mode         
 | 
			
		||||
#define IR24_OLD_SMOOTH    0xFF30CF // SMOOTH Mode       
 | 
			
		||||
 | 
			
		||||
// 40-key defs for blue remote control 
 | 
			
		||||
#define IR40_BPLUS         0xFF3AC5  // 
 | 
			
		||||
#define IR40_BMINUS        0xFFBA45  // 
 | 
			
		||||
#define IR40_OFF           0xFF827D  // 
 | 
			
		||||
#define IR40_ON            0xFF02FD  // 
 | 
			
		||||
#define IR40_RED           0xFF1AE5  // 
 | 
			
		||||
#define IR40_GREEN         0xFF9A65  // 
 | 
			
		||||
#define IR40_BLUE          0xFFA25D  // 
 | 
			
		||||
#define IR40_WHITE         0xFF22DD  // natural white
 | 
			
		||||
#define IR40_REDDISH       0xFF2AD5  // 
 | 
			
		||||
#define IR40_GREENISH      0xFFAA55  // 
 | 
			
		||||
#define IR40_DEEPBLUE      0xFF926D  // 
 | 
			
		||||
#define IR40_WARMWHITE2    0xFF12ED  // warmest white
 | 
			
		||||
#define IR40_ORANGE        0xFF0AF5  // 
 | 
			
		||||
#define IR40_TURQUOISE     0xFF8A75  // 
 | 
			
		||||
#define IR40_PURPLE        0xFFB24D  // 
 | 
			
		||||
#define IR40_WARMWHITE     0xFF32CD  // warm white
 | 
			
		||||
#define IR40_YELLOWISH     0xFF38C7  // 
 | 
			
		||||
#define IR40_CYAN          0xFFB847  // 
 | 
			
		||||
#define IR40_MAGENTA       0xFF7887  // 
 | 
			
		||||
#define IR40_COLDWHITE     0xFFF807  // cold white
 | 
			
		||||
#define IR40_YELLOW        0xFF18E7  // 
 | 
			
		||||
#define IR40_AQUA          0xFF9867  // 
 | 
			
		||||
#define IR40_PINK          0xFF58A7  // 
 | 
			
		||||
#define IR40_COLDWHITE2    0xFFD827  // coldest white
 | 
			
		||||
#define IR40_WPLUS         0xFF28D7  // white chanel bright plus
 | 
			
		||||
#define IR40_WMINUS        0xFFA857  // white chanel bright minus
 | 
			
		||||
#define IR40_WOFF          0xFF6897  // white chanel on
 | 
			
		||||
#define IR40_WON           0xFFE817  // white chanel off
 | 
			
		||||
#define IR40_W25           0xFF08F7  // white chanel 25%
 | 
			
		||||
#define IR40_W50           0xFF8877  // white chanel 50%
 | 
			
		||||
#define IR40_W75           0xFF48B7  // white chanel 75%
 | 
			
		||||
#define IR40_W100          0xFFC837  // white chanel 100%
 | 
			
		||||
#define IR40_JUMP3         0xFF30CF  // JUMP3
 | 
			
		||||
#define IR40_FADE3         0xFFB04F  // FADE3
 | 
			
		||||
#define IR40_JUMP7         0xFF708F  // JUMP7
 | 
			
		||||
#define IR40_QUICK         0xFFF00F  // QUICK
 | 
			
		||||
#define IR40_FADE7         0xFF10EF  // FADE7
 | 
			
		||||
#define IR40_FLASH         0xFF906F  // FLASH
 | 
			
		||||
#define IR40_AUTO          0xFF50AF  // AUTO
 | 
			
		||||
#define IR40_SLOW          0xFFD02F  // SLOW
 | 
			
		||||
 | 
			
		||||
// 44-key defs, to be done later
 | 
			
		||||
#define IR44_BPLUS         0xFF3AC5  // 
 | 
			
		||||
#define IR44_BMINUS        0xFFBA45  // 
 | 
			
		||||
#define IR44_OFF           0xFF827D  // 
 | 
			
		||||
#define IR44_ON            0xFF02FD  // 
 | 
			
		||||
#define IR44_RED           0xFF1AE5  // 
 | 
			
		||||
#define IR44_GREEN         0xFF9A65  // 
 | 
			
		||||
#define IR44_BLUE          0xFFA25D  // 
 | 
			
		||||
#define IR44_WHITE         0xFF22DD  // natural white
 | 
			
		||||
#define IR44_REDDISH       0xFF2AD5  // 
 | 
			
		||||
#define IR44_GREENISH      0xFFAA55  // 
 | 
			
		||||
#define IR44_DEEPBLUE      0xFF926D  // 
 | 
			
		||||
#define IR44_WARMWHITE2    0xFF12ED  // warmest white
 | 
			
		||||
#define IR44_ORANGE        0xFF0AF5  // 
 | 
			
		||||
#define IR44_TURQUOISE     0xFF8A75  // 
 | 
			
		||||
#define IR44_PURPLE        0xFFB24D  // 
 | 
			
		||||
#define IR44_WARMWHITE     0xFF32CD  // warm white
 | 
			
		||||
#define IR44_YELLOWISH     0xFF38C7  // 
 | 
			
		||||
#define IR44_CYAN          0xFFB847  // 
 | 
			
		||||
#define IR44_MAGENTA       0xFF7887  // 
 | 
			
		||||
#define IR44_COLDWHITE     0xFFF807  // cold white
 | 
			
		||||
#define IR44_YELLOW        0xFF18E7  // 
 | 
			
		||||
#define IR44_AQUA          0xFF9867  // 
 | 
			
		||||
#define IR44_PINK          0xFF58A7  // 
 | 
			
		||||
#define IR44_COLDWHITE2    0xFFD827  // coldest white
 | 
			
		||||
#define IR44_REDPLUS       0xFF28D7  // 
 | 
			
		||||
#define IR44_GREENPLUS     0xFFA857  // 
 | 
			
		||||
#define IR44_BLUEPLUS      0xFF6897  // 
 | 
			
		||||
#define IR44_QUICK         0xFFE817  // 
 | 
			
		||||
#define IR44_REDMINUS      0xFF08F7  // 
 | 
			
		||||
#define IR44_GREENMINUS    0xFF8877  // 
 | 
			
		||||
#define IR44_BLUEMINUS     0xFF48B7  // 
 | 
			
		||||
#define IR44_SLOW          0xFFC837  // 
 | 
			
		||||
#define IR44_DIY1          0xFF30CF  // 
 | 
			
		||||
#define IR44_DIY2          0xFFB04F  // 
 | 
			
		||||
#define IR44_DIY3          0xFF708F  // 
 | 
			
		||||
#define IR44_AUTO          0xFFF00F  // 
 | 
			
		||||
#define IR44_DIY4          0xFF10EF  // 
 | 
			
		||||
#define IR44_DIY5          0xFF906F  // 
 | 
			
		||||
#define IR44_DIY6          0xFF50AF  // 
 | 
			
		||||
#define IR44_FLASH         0xFFD02F  // 
 | 
			
		||||
#define IR44_JUMP3         0xFF20DF  // 
 | 
			
		||||
#define IR44_JUMP7         0xFFA05F  // 
 | 
			
		||||
#define IR44_FADE3         0xFF609F  // 
 | 
			
		||||
#define IR44_FADE7         0xFFE01F  // 
 | 
			
		||||
 | 
			
		||||
// Color definitions
 | 
			
		||||
#define COLOR_RED           0xFF0000
 | 
			
		||||
#define COLOR_REDDISH       0xFF7800
 | 
			
		||||
#define COLOR_ORANGE        0xFFA000
 | 
			
		||||
#define COLOR_YELLOWISH     0xFFC800
 | 
			
		||||
#define COLOR_YELLOW        0xFFFF00
 | 
			
		||||
#define COLOR_GREEN         0x00FF00
 | 
			
		||||
#define COLOR_GREENISH      0x00FF78
 | 
			
		||||
#define COLOR_TURQUOISE     0x00FFA0
 | 
			
		||||
#define COLOR_CYAN          0x00FFDC
 | 
			
		||||
#define COLOR_AQUA          0x00C8FF
 | 
			
		||||
#define COLOR_BLUE          0x00A0FF
 | 
			
		||||
#define COLOR_DEEPBLUE      0x0000FF
 | 
			
		||||
#define COLOR_PURPLE        0xAA00FF
 | 
			
		||||
#define COLOR_MAGENTA       0xFF00DC
 | 
			
		||||
#define COLOR_PINK          0xFF00A0
 | 
			
		||||
#define COLOR_WHITE         0xFFFFDC
 | 
			
		||||
#define COLOR_WARMWHITE2    0xFFFF9900
 | 
			
		||||
#define COLOR_WARMWHITE     0xFF825A00 
 | 
			
		||||
#define COLOR_NEUTRALWHITE  0xFF000000
 | 
			
		||||
#define COLOR_COLDWHITE     0xFF7F7F7F
 | 
			
		||||
#define COLOR_COLDWHITE2    0xFFFFFFFF
 | 
			
		||||
| 
						 | 
				
			
			@ -95,6 +95,18 @@ float EspalexaDevice::getY()
 | 
			
		|||
  return _y;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float EspalexaDevice::minf (float v, float w)
 | 
			
		||||
{
 | 
			
		||||
  if (w > v) return v;
 | 
			
		||||
  return w;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float EspalexaDevice::maxf (float v, float w)
 | 
			
		||||
{
 | 
			
		||||
  if (w > v) return w;
 | 
			
		||||
  return v;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint16_t EspalexaDevice::getCt()
 | 
			
		||||
{
 | 
			
		||||
  if (_ct == 0) return 500;
 | 
			
		||||
| 
						 | 
				
			
			@ -110,8 +122,8 @@ uint32_t EspalexaDevice::getKelvin()
 | 
			
		|||
uint32_t EspalexaDevice::getRGB()
 | 
			
		||||
{
 | 
			
		||||
  if (_rgb != 0) return _rgb; //color has not changed
 | 
			
		||||
  uint8_t rgb[3];
 | 
			
		||||
  float r, g, b;
 | 
			
		||||
  byte rgb[4]{0, 0, 0, 0}; 
 | 
			
		||||
  float r, g, b, w;
 | 
			
		||||
  
 | 
			
		||||
  if (_mode == EspalexaColorMode::none) return 0;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -122,27 +134,38 @@ uint32_t EspalexaDevice::getRGB()
 | 
			
		|||
    float temp = 10000/ _ct; //kelvins = 1,000,000/mired (and that /100)
 | 
			
		||||
    float r, g, b;
 | 
			
		||||
 | 
			
		||||
    if( temp <= 66 ){ 
 | 
			
		||||
      r = 255; 
 | 
			
		||||
      g = temp;
 | 
			
		||||
      g = 99.470802 * log(g) - 161.119568;
 | 
			
		||||
      if( temp <= 19){
 | 
			
		||||
          b = 0;
 | 
			
		||||
      } else {
 | 
			
		||||
          b = temp-10;
 | 
			
		||||
          b = 138.517731 * log(b) - 305.044793;
 | 
			
		||||
    // Cold white to warm white receiving from Alexa: _ct = 199 234 284 350 383
 | 
			
		||||
    switch (_ct) {
 | 
			
		||||
      case 199: rgb[0]=255,rgb[1]=255,rgb[2]=255;rgb[3]=255;break;
 | 
			
		||||
      case 234: rgb[0]=127,rgb[1]=127,rgb[2]=127;rgb[3]=255;break;
 | 
			
		||||
      case 284: rgb[0]=0,rgb[1]=0,rgb[2]=0;rgb[3]=255;break;
 | 
			
		||||
      case 350: rgb[0]=130,rgb[1]=90,rgb[2]=0;rgb[3]=255;break;
 | 
			
		||||
      case 383: rgb[0]=255,rgb[1]=153,rgb[2]=0;rgb[3]=255;break;
 | 
			
		||||
      default: {
 | 
			
		||||
        if( temp <= 66 ){ 
 | 
			
		||||
          r = 255; 
 | 
			
		||||
          g = temp;
 | 
			
		||||
          g = 99.470802 * log(g) - 161.119568;
 | 
			
		||||
          if( temp <= 19){
 | 
			
		||||
              b = 0;
 | 
			
		||||
          } else {
 | 
			
		||||
              b = temp-10;
 | 
			
		||||
              b = 138.517731 * log(b) - 305.044793;
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          r = temp - 60;
 | 
			
		||||
          r = 329.698727 * pow(r, -0.13320476);
 | 
			
		||||
          g = temp - 60;
 | 
			
		||||
          g = 288.12217 * pow(g, -0.07551485 );
 | 
			
		||||
          b = 255;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        rgb[0] = (byte)constrain(r,0.1,255.1);
 | 
			
		||||
        rgb[1] = (byte)constrain(g,0.1,255.1);
 | 
			
		||||
        rgb[2] = (byte)constrain(b,0.1,255.1);
 | 
			
		||||
        RGBtoRGBW(rgb);        
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
      r = temp - 60;
 | 
			
		||||
      r = 329.698727 * pow(r, -0.13320476);
 | 
			
		||||
      g = temp - 60;
 | 
			
		||||
      g = 288.12217 * pow(g, -0.07551485 );
 | 
			
		||||
      b = 255;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    rgb[0] = (byte)constrain(r,0.1,255.1);
 | 
			
		||||
    rgb[1] = (byte)constrain(g,0.1,255.1);
 | 
			
		||||
    rgb[2] = (byte)constrain(b,0.1,255.1);
 | 
			
		||||
  } else if (_mode == EspalexaColorMode::hs)
 | 
			
		||||
  {
 | 
			
		||||
    float h = ((float)_hue)/65535.0;
 | 
			
		||||
| 
						 | 
				
			
			@ -160,6 +183,7 @@ uint32_t EspalexaDevice::getRGB()
 | 
			
		|||
      case 4: rgb[0]=t,rgb[1]=p,rgb[2]=255;break;
 | 
			
		||||
      case 5: rgb[0]=255,rgb[1]=p,rgb[2]=q;
 | 
			
		||||
    }
 | 
			
		||||
    RGBtoRGBW(rgb);
 | 
			
		||||
  } else if (_mode == EspalexaColorMode::xy)
 | 
			
		||||
  {
 | 
			
		||||
    //Source: https://www.developers.meethue.com/documentation/color-conversions-rgb-xy
 | 
			
		||||
| 
						 | 
				
			
			@ -215,11 +239,17 @@ uint32_t EspalexaDevice::getRGB()
 | 
			
		|||
    rgb[0] = 255.0*r;
 | 
			
		||||
    rgb[1] = 255.0*g;
 | 
			
		||||
    rgb[2] = 255.0*b;
 | 
			
		||||
    RGBtoRGBW(rgb);
 | 
			
		||||
  }
 | 
			
		||||
  _rgb = ((rgb[0] << 16) | (rgb[1] << 8) | (rgb[2]));
 | 
			
		||||
  _rgb = ((rgb[3] << 24) | (rgb[0] << 16) | (rgb[1] << 8) | (rgb[2]));
 | 
			
		||||
  return _rgb;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t EspalexaDevice::getW()
 | 
			
		||||
{
 | 
			
		||||
  return (getRGB() >> 24) & 0xFF;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t EspalexaDevice::getR()
 | 
			
		||||
{
 | 
			
		||||
  return (getRGB() >> 16) & 0xFF;
 | 
			
		||||
| 
						 | 
				
			
			@ -312,6 +342,38 @@ void EspalexaDevice::setColor(uint8_t r, uint8_t g, uint8_t b)
 | 
			
		|||
  _mode = EspalexaColorMode::xy;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void EspalexaDevice::RGBtoRGBW(byte* rgb) //rgb to rgbw (http://codewelt.com/rgbw)
 | 
			
		||||
{
 | 
			
		||||
  // https://stackoverflow.com/questions/40312216/converting-rgb-to-rgbw
 | 
			
		||||
  float Ri=rgb[0], Gi=rgb[1], Bi=rgb[2];
 | 
			
		||||
  //Get the maximum between R, G, and B
 | 
			
		||||
  float tM = maxf(Ri, maxf(Gi, Bi));
 | 
			
		||||
  
 | 
			
		||||
  //If the maximum value is 0, immediately return pure black.
 | 
			
		||||
  if(tM == 0) rgb[3] = 0;
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    //This section serves to figure out what the color with 100% hue is
 | 
			
		||||
    float multiplier = 255.0f / tM;
 | 
			
		||||
    float hR = Ri * multiplier;
 | 
			
		||||
    float hG = Gi * multiplier;
 | 
			
		||||
    float hB = Bi * multiplier;  
 | 
			
		||||
    
 | 
			
		||||
    //This calculates the Whiteness (not strictly speaking Luminance) of the color
 | 
			
		||||
    float M = maxf(hR, maxf(hG, hB));
 | 
			
		||||
    float m = minf(hR, minf(hG, hB));
 | 
			
		||||
    float Luminance = ((M + m) / 2.0f - 127.5f) * (255.0f/127.5f) / multiplier;
 | 
			
		||||
    
 | 
			
		||||
    //Calculate and trim the output values
 | 
			
		||||
    int Wo = (byte)constrain(Luminance,0.1,255.1);
 | 
			
		||||
    int Bo = (byte)constrain(Bi - Luminance,0.1,255.1);
 | 
			
		||||
    int Ro = (byte)constrain(Ri - Luminance,0.1,255.1);
 | 
			
		||||
    int Go = (byte)constrain(Gi - Luminance,0.1,255.1);
 | 
			
		||||
    
 | 
			
		||||
    rgb[0]=Ro; rgb[1]=Go; rgb[2]=Bo; rgb[3]=Wo; 
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void EspalexaDevice::doCallback()
 | 
			
		||||
{
 | 
			
		||||
  if (_callback != nullptr) {_callback(_val); return;}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,7 +47,10 @@ public:
 | 
			
		|||
  uint32_t getKelvin();
 | 
			
		||||
  float getX();
 | 
			
		||||
  float getY();
 | 
			
		||||
  float minf (float v, float w);
 | 
			
		||||
  float maxf (float v, float w);
 | 
			
		||||
  uint32_t getRGB();
 | 
			
		||||
  uint8_t getW();
 | 
			
		||||
  uint8_t getR();
 | 
			
		||||
  uint8_t getG();
 | 
			
		||||
  uint8_t getB();
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +66,7 @@ public:
 | 
			
		|||
  void setColor(uint16_t hue, uint8_t sat);
 | 
			
		||||
  void setColorXY(float x, float y);
 | 
			
		||||
  void setColor(uint8_t r, uint8_t g, uint8_t b);
 | 
			
		||||
  void RGBtoRGBW(byte* rgb);
 | 
			
		||||
  
 | 
			
		||||
  void doCallback();
 | 
			
		||||
  
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,6 +32,11 @@
 | 
			
		|||
//to toggle usb serial debug (un)comment the following line
 | 
			
		||||
//#define WLED_DEBUG
 | 
			
		||||
 | 
			
		||||
//to toggle using analog RGB or RGBW led strips (un)comment the following line
 | 
			
		||||
//#define WLED_USE_ANALOG_LEDS
 | 
			
		||||
 | 
			
		||||
//to toggle using 5CH analog RGBWS led strips (un)comment the following line
 | 
			
		||||
//#define WLED_USE_5CH_LEDS
 | 
			
		||||
 | 
			
		||||
//library inclusions
 | 
			
		||||
#include <Arduino.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -85,6 +90,7 @@
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef ARDUINO_ARCH_ESP32
 | 
			
		||||
  #undef WLED_USE_ANALOG_LEDS  // Solid RGBW not implemented for ESP32 yet
 | 
			
		||||
 /*#ifndef WLED_DISABLE_INFRARED
 | 
			
		||||
  #include <IRremote.h>
 | 
			
		||||
 #endif*/ //there are issues with ESP32 infrared, so it is disabled for now
 | 
			
		||||
| 
						 | 
				
			
			@ -160,7 +166,7 @@ bool syncToggleReceive = false;               //UIs which only have a single but
 | 
			
		|||
 | 
			
		||||
//Sync CONFIG
 | 
			
		||||
bool buttonEnabled =  true;
 | 
			
		||||
bool irEnabled     = false;                   //Infrared receiver
 | 
			
		||||
byte irEnabled     =  1;                      //Infrared receiver
 | 
			
		||||
 | 
			
		||||
uint16_t udpPort    = 21324;                  //WLED notifier default port
 | 
			
		||||
uint16_t udpRgbPort = 19446;                  //Hyperion port
 | 
			
		||||
| 
						 | 
				
			
			@ -279,6 +285,7 @@ uint32_t nightlightDelayMs = 10;
 | 
			
		|||
uint8_t nightlightDelayMinsDefault = nightlightDelayMins;
 | 
			
		||||
unsigned long nightlightStartTime;
 | 
			
		||||
byte briNlT = 0;                              //current nightlight brightness
 | 
			
		||||
byte colNlT[]{0, 0, 0, 0};                    //current nightlight color
 | 
			
		||||
 | 
			
		||||
//brightness
 | 
			
		||||
unsigned long lastOnTime = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -249,7 +249,7 @@ void getSettingsJS(byte subPage, char* dest)
 | 
			
		|||
  if (subPage == 4)
 | 
			
		||||
  {
 | 
			
		||||
    sappend('c',"BT",buttonEnabled);
 | 
			
		||||
    sappend('c',"IR",irEnabled);
 | 
			
		||||
    sappend('v',"IR",irEnabled);
 | 
			
		||||
    sappend('v',"UP",udpPort);
 | 
			
		||||
    sappend('c',"RB",receiveNotificationBrightness);
 | 
			
		||||
    sappend('c',"RC",receiveNotificationColor);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -120,7 +120,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
 | 
			
		|||
  if (subPage == 4)
 | 
			
		||||
  {
 | 
			
		||||
    buttonEnabled = request->hasArg("BT");
 | 
			
		||||
    irEnabled = request->hasArg("IR");
 | 
			
		||||
    irEnabled = request->arg("IR").toInt();
 | 
			
		||||
    int t = request->arg("UP").toInt();
 | 
			
		||||
    if (t > 0) udpPort = t;
 | 
			
		||||
    receiveNotificationBrightness = request->hasArg("RB");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -217,11 +217,20 @@ void handleNightlight()
 | 
			
		|||
      nightlightDelayMs = (int)(nightlightDelayMins*60000);
 | 
			
		||||
      nightlightActiveOld = true;
 | 
			
		||||
      briNlT = bri;
 | 
			
		||||
      for (byte i=0; i<4; i++)
 | 
			
		||||
      {
 | 
			
		||||
        colNlT[i] = col[i];                                  // remember starting color
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
    }
 | 
			
		||||
    float nper = (millis() - nightlightStartTime)/((float)nightlightDelayMs);
 | 
			
		||||
    if (nightlightFade)
 | 
			
		||||
    {
 | 
			
		||||
      bri = briNlT + ((nightlightTargetBri - briNlT)*nper);
 | 
			
		||||
      for (byte i=0; i<4; i++)
 | 
			
		||||
      {
 | 
			
		||||
        col[i] = colNlT[i]+ ((colSec[i] - colNlT[i])*nper);  // fading from actual color to secondary color
 | 
			
		||||
      }
 | 
			
		||||
      colorUpdated(5);
 | 
			
		||||
    }
 | 
			
		||||
    if (nper >= 1)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,10 +62,10 @@ void onAlexaChange(EspalexaDevice* dev)
 | 
			
		|||
  } else //color
 | 
			
		||||
  {
 | 
			
		||||
    uint32_t color = espalexaDevice->getRGB();
 | 
			
		||||
    col[3] = ((color >> 24) & 0xFF);
 | 
			
		||||
    col[0] = ((color >> 16) & 0xFF);
 | 
			
		||||
    col[1] = ((color >>  8) & 0xFF);
 | 
			
		||||
    col[2] = (color & 0xFF);
 | 
			
		||||
    if (useRGBW) colorRGBtoRGBW(col);
 | 
			
		||||
    colorUpdated(10);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,6 +17,22 @@ void colorFromUint32(uint32_t in, bool secondary)
 | 
			
		|||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void colorFromUint24(uint32_t in)
 | 
			
		||||
{
 | 
			
		||||
  col[0] = in >> 16 & 0xFF;
 | 
			
		||||
  col[1] = in >> 8  & 0xFF;
 | 
			
		||||
  col[2] = in       & 0xFF;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//relatively change white brightness, minumum A=5
 | 
			
		||||
void relativeChangeWhite(int8_t amount, byte lowerBoundary =0)
 | 
			
		||||
{
 | 
			
		||||
  int16_t new_val = (int16_t) col[3] + amount;
 | 
			
		||||
  if (new_val > 0xFF) new_val = 0xFF;
 | 
			
		||||
  else if (new_val < lowerBoundary) new_val = lowerBoundary;
 | 
			
		||||
  col[3] = new_val;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void colorHStoRGB(uint16_t hue, byte sat, byte* rgb) //hue, sat to rgb
 | 
			
		||||
{
 | 
			
		||||
  float h = ((float)hue)/65535.0;
 | 
			
		||||
| 
						 | 
				
			
			@ -165,6 +181,6 @@ void colorRGBtoRGBW(byte* rgb) //rgb to rgbw (http://codewelt.com/rgbw)
 | 
			
		|||
  float low = minf(rgb[0],minf(rgb[1],rgb[2]));
 | 
			
		||||
  float high = maxf(rgb[0],maxf(rgb[1],rgb[2]));
 | 
			
		||||
  if (high < 0.1f) return;
 | 
			
		||||
  float sat = 255.0f * ((high - low) / high);
 | 
			
		||||
  float sat = 100.0f * ((high - low) / high);   // maximum saturation is 100  (corrected from 255)
 | 
			
		||||
  rgb[3] = (byte)((255.0f - sat) / 255.0f * (rgb[0] + rgb[1] + rgb[2]) / 3);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,15 +48,23 @@ void decodeIR(uint32_t code)
 | 
			
		|||
  if (code == 0xFFFFFFFF) //repeated code, continue brightness up/down
 | 
			
		||||
  {
 | 
			
		||||
    irTimesRepeated++;
 | 
			
		||||
    if (lastValidCode == IR24_BRIGHTER)
 | 
			
		||||
    if (lastValidCode == IR24_BRIGHTER | lastValidCode == IR40_BPLUS )
 | 
			
		||||
    { 
 | 
			
		||||
      relativeChange(&bri, 10); colorUpdated(2);
 | 
			
		||||
    }
 | 
			
		||||
    else if (lastValidCode == IR24_DARKER)
 | 
			
		||||
    else if (lastValidCode == IR24_DARKER | lastValidCode == IR40_BMINUS )
 | 
			
		||||
    {
 | 
			
		||||
      relativeChange(&bri, -10, 5); colorUpdated(2);
 | 
			
		||||
    }
 | 
			
		||||
    else if (lastValidCode == IR24_ON && irTimesRepeated > 7)
 | 
			
		||||
    if (lastValidCode == IR40_WPLUS)
 | 
			
		||||
    { 
 | 
			
		||||
      relativeChangeWhite(10); colorUpdated(2);
 | 
			
		||||
    }
 | 
			
		||||
    else if (lastValidCode == IR40_WMINUS)
 | 
			
		||||
    {
 | 
			
		||||
      relativeChangeWhite(-10, 5); colorUpdated(2);
 | 
			
		||||
    }
 | 
			
		||||
    else if ((lastValidCode == IR24_ON | lastValidCode == IR44_ON) && irTimesRepeated > 7 )
 | 
			
		||||
    {
 | 
			
		||||
      nightlightActive = true;
 | 
			
		||||
      nightlightStartTime = millis();
 | 
			
		||||
| 
						 | 
				
			
			@ -68,8 +76,16 @@ void decodeIR(uint32_t code)
 | 
			
		|||
 | 
			
		||||
  if (decodeIRCustom(code)) return;
 | 
			
		||||
  if      (code > 0xFFFFFF) return; //invalid code
 | 
			
		||||
  else if (code > 0xFF0000) decodeIR44(code); //is in 44-key remote range
 | 
			
		||||
  else if (code > 0xF70000 && code < 0xF80000) decodeIR24(code); //is in 24-key remote range
 | 
			
		||||
  else if (code > 0xFF0000) {
 | 
			
		||||
    switch (irEnabled) {
 | 
			
		||||
      case 1: decodeIR24OLD(code); break;  // white 24-key remote (old) - it sends 0xFF0000 values
 | 
			
		||||
      case 2: decodeIR24CT(code);  break;  // white 24-key remote with CW, WW, CT+ and CT- keys
 | 
			
		||||
      case 3: decodeIR40(code);    break;  // blue  40-key remote with 25%, 50%, 75% and 100% keys
 | 
			
		||||
      case 4: decodeIR44(code);    break;  // white 44-key remote with color-up/down keys and DIY1 to 6 keys 
 | 
			
		||||
      default: return;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  //code <= 0xF70000 also invalid
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -108,15 +124,183 @@ void decodeIR24(uint32_t code)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void decodeIR24OLD(uint32_t code)
 | 
			
		||||
{
 | 
			
		||||
  switch (code) {
 | 
			
		||||
    case IR24_OLD_BRIGHTER  : relativeChange(&bri, 10);            break;
 | 
			
		||||
    case IR24_OLD_DARKER    : relativeChange(&bri, -10, 5);        break;
 | 
			
		||||
    case IR24_OLD_OFF       : briLast = bri; bri = 0;              break;
 | 
			
		||||
    case IR24_OLD_ON        : bri = briLast;                       break;
 | 
			
		||||
    case IR24_OLD_RED       : colorFromUint32(COLOR_RED);          break;
 | 
			
		||||
    case IR24_OLD_REDDISH   : colorFromUint32(COLOR_REDDISH);      break;
 | 
			
		||||
    case IR24_OLD_ORANGE    : colorFromUint32(COLOR_ORANGE);       break;
 | 
			
		||||
    case IR24_OLD_YELLOWISH : colorFromUint32(COLOR_YELLOWISH);    break;
 | 
			
		||||
    case IR24_OLD_YELLOW    : colorFromUint32(COLOR_YELLOW);       break;
 | 
			
		||||
    case IR24_OLD_GREEN     : colorFromUint32(COLOR_GREEN);        break;
 | 
			
		||||
    case IR24_OLD_GREENISH  : colorFromUint32(COLOR_GREENISH);     break;
 | 
			
		||||
    case IR24_OLD_TURQUOISE : colorFromUint32(COLOR_TURQUOISE);    break;
 | 
			
		||||
    case IR24_OLD_CYAN      : colorFromUint32(COLOR_CYAN);         break;
 | 
			
		||||
    case IR24_OLD_AQUA      : colorFromUint32(COLOR_AQUA);         break;
 | 
			
		||||
    case IR24_OLD_BLUE      : colorFromUint32(COLOR_BLUE);         break;
 | 
			
		||||
    case IR24_OLD_DEEPBLUE  : colorFromUint32(COLOR_DEEPBLUE);     break;
 | 
			
		||||
    case IR24_OLD_PURPLE    : colorFromUint32(COLOR_PURPLE);       break;
 | 
			
		||||
    case IR24_OLD_MAGENTA   : colorFromUint32(COLOR_MAGENTA);      break;
 | 
			
		||||
    case IR24_OLD_PINK      : colorFromUint32(COLOR_PINK);         break;
 | 
			
		||||
    case IR24_OLD_WHITE     : colorFromUint32(COLOR_WHITE);        effectCurrent = 0;     break;
 | 
			
		||||
    case IR24_OLD_FLASH     : if (!applyPreset(1)) effectCurrent = FX_MODE_COLORTWINKLE;  effectPalette = 0; break;
 | 
			
		||||
    case IR24_OLD_STROBE    : if (!applyPreset(2)) effectCurrent = FX_MODE_RAINBOW_CYCLE; effectPalette = 0; break;
 | 
			
		||||
    case IR24_OLD_FADE      : if (!applyPreset(3)) effectCurrent = FX_MODE_BREATH;        effectPalette = 0; break;
 | 
			
		||||
    case IR24_OLD_SMOOTH    : if (!applyPreset(4)) effectCurrent = FX_MODE_RAINBOW;       effectPalette = 0; break;
 | 
			
		||||
    default: return;
 | 
			
		||||
  }
 | 
			
		||||
  lastValidCode = code;
 | 
			
		||||
  colorUpdated(2); //for notifier, IR is considered a button input
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void decodeIR24CT(uint32_t code)
 | 
			
		||||
{
 | 
			
		||||
  switch (code) {
 | 
			
		||||
    case IR24_CT_BRIGHTER   : relativeChange(&bri, 10);            break;
 | 
			
		||||
    case IR24_CT_DARKER     : relativeChange(&bri, -10, 5);        break;
 | 
			
		||||
    case IR24_CT_OFF        : briLast = bri; bri = 0;              break;
 | 
			
		||||
    case IR24_CT_ON         : bri = briLast;                       break;
 | 
			
		||||
    case IR24_CT_RED        : colorFromUint32(COLOR_RED);          break;
 | 
			
		||||
    case IR24_CT_REDDISH    : colorFromUint32(COLOR_REDDISH);      break;
 | 
			
		||||
    case IR24_CT_ORANGE     : colorFromUint32(COLOR_ORANGE);       break;
 | 
			
		||||
    case IR24_CT_YELLOWISH  : colorFromUint32(COLOR_YELLOWISH);    break;
 | 
			
		||||
    case IR24_CT_YELLOW     : colorFromUint32(COLOR_YELLOW);       break;
 | 
			
		||||
    case IR24_CT_GREEN      : colorFromUint32(COLOR_GREEN);        break;
 | 
			
		||||
    case IR24_CT_GREENISH   : colorFromUint32(COLOR_GREENISH);     break;
 | 
			
		||||
    case IR24_CT_TURQUOISE  : colorFromUint32(COLOR_TURQUOISE);    break;
 | 
			
		||||
    case IR24_CT_CYAN       : colorFromUint32(COLOR_CYAN);         break;
 | 
			
		||||
    case IR24_CT_AQUA       : colorFromUint32(COLOR_AQUA);         break;
 | 
			
		||||
    case IR24_CT_BLUE       : colorFromUint32(COLOR_BLUE);         break;
 | 
			
		||||
    case IR24_CT_DEEPBLUE   : colorFromUint32(COLOR_DEEPBLUE);     break;
 | 
			
		||||
    case IR24_CT_PURPLE     : colorFromUint32(COLOR_PURPLE);       break;
 | 
			
		||||
    case IR24_CT_MAGENTA    : colorFromUint32(COLOR_MAGENTA);      break;
 | 
			
		||||
    case IR24_CT_PINK       : colorFromUint32(COLOR_PINK);         break;
 | 
			
		||||
    case IR24_CT_COLDWHITE  : colorFromUint32(COLOR_COLDWHITE);    effectCurrent = 0;  break;
 | 
			
		||||
    case IR24_CT_WARMWHITE  : colorFromUint32(COLOR_WARMWHITE);    effectCurrent = 0;  break;
 | 
			
		||||
    case IR24_CT_CTPLUS     : colorFromUint32(COLOR_COLDWHITE2);   effectCurrent = 0;  break;
 | 
			
		||||
    case IR24_CT_CTMINUS    : colorFromUint32(COLOR_WARMWHITE2);   effectCurrent = 0;  break;
 | 
			
		||||
    case IR24_CT_MEMORY   : {
 | 
			
		||||
      if (col[3] > 0) col[3] = 0; 
 | 
			
		||||
      else colorFromUint32(COLOR_NEUTRALWHITE); effectCurrent = 0; }                    break;
 | 
			
		||||
    default: return; 
 | 
			
		||||
  }
 | 
			
		||||
  lastValidCode = code;
 | 
			
		||||
  colorUpdated(2); //for notifier, IR is considered a button input
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void decodeIR40(uint32_t code)
 | 
			
		||||
{
 | 
			
		||||
  switch (code) {
 | 
			
		||||
    case IR40_BPLUS        : relativeChange(&bri, 10);                                   break;
 | 
			
		||||
    case IR40_BMINUS       : relativeChange(&bri, -10, 5);                               break;
 | 
			
		||||
    case IR40_OFF          : briLast = bri; bri = 0;                                     break;
 | 
			
		||||
    case IR40_ON           : bri = briLast;                                              break;
 | 
			
		||||
    case IR40_RED          : colorFromUint24(COLOR_RED);                                 break;
 | 
			
		||||
    case IR40_REDDISH      : colorFromUint24(COLOR_REDDISH);                             break;
 | 
			
		||||
    case IR40_ORANGE       : colorFromUint24(COLOR_ORANGE);                              break;
 | 
			
		||||
    case IR40_YELLOWISH    : colorFromUint24(COLOR_YELLOWISH);                           break;
 | 
			
		||||
    case IR40_YELLOW       : colorFromUint24(COLOR_YELLOW);                              break;
 | 
			
		||||
    case IR40_GREEN        : colorFromUint24(COLOR_GREEN);                               break;
 | 
			
		||||
    case IR40_GREENISH     : colorFromUint24(COLOR_GREENISH);                            break;
 | 
			
		||||
    case IR40_TURQUOISE    : colorFromUint24(COLOR_TURQUOISE);                           break;
 | 
			
		||||
    case IR40_CYAN         : colorFromUint24(COLOR_CYAN);                                break;
 | 
			
		||||
    case IR40_AQUA         : colorFromUint24(COLOR_AQUA);                                break;
 | 
			
		||||
    case IR40_BLUE         : colorFromUint24(COLOR_BLUE);                                break;
 | 
			
		||||
    case IR40_DEEPBLUE     : colorFromUint24(COLOR_DEEPBLUE);                            break;
 | 
			
		||||
    case IR40_PURPLE       : colorFromUint24(COLOR_PURPLE);                              break;
 | 
			
		||||
    case IR40_MAGENTA      : colorFromUint24(COLOR_MAGENTA);                             break;
 | 
			
		||||
    case IR40_PINK         : colorFromUint24(COLOR_PINK);                                break;
 | 
			
		||||
    case IR40_WARMWHITE2   : colorFromUint32(COLOR_WARMWHITE2);    effectCurrent = 0;    break;
 | 
			
		||||
    case IR40_WARMWHITE    : colorFromUint32(COLOR_WARMWHITE);     effectCurrent = 0;    break;
 | 
			
		||||
    case IR40_WHITE        : colorFromUint32(COLOR_NEUTRALWHITE);  effectCurrent = 0;    break;
 | 
			
		||||
    case IR40_COLDWHITE    : colorFromUint32(COLOR_COLDWHITE);     effectCurrent = 0;    break;
 | 
			
		||||
    case IR40_COLDWHITE2   : colorFromUint32(COLOR_COLDWHITE2);    effectCurrent = 0;    break;
 | 
			
		||||
    case IR40_WPLUS        : relativeChangeWhite(10);                                    break;
 | 
			
		||||
    case IR40_WMINUS       : relativeChangeWhite(-10, 5);                                break;
 | 
			
		||||
    case IR40_WOFF         : whiteLast = col[3]; col[3] = 0;                             break;
 | 
			
		||||
    case IR40_WON          : col[3] = whiteLast;                                         break;
 | 
			
		||||
    case IR40_W25          : bri = 63;                                                   break;
 | 
			
		||||
    case IR40_W50          : bri = 127;                                                  break;
 | 
			
		||||
    case IR40_W75          : bri = 191;                                                  break;
 | 
			
		||||
    case IR40_W100         : bri = 255;                                                  break;
 | 
			
		||||
    case IR40_QUICK        : relativeChange(&effectSpeed, 10);                           break;
 | 
			
		||||
    case IR40_SLOW         : relativeChange(&effectSpeed, -10, 5);                       break;
 | 
			
		||||
    case IR40_JUMP7        : relativeChange(&effectIntensity, 10);                       break;
 | 
			
		||||
    case IR40_AUTO         : relativeChange(&effectIntensity, -10, 5);                   break;
 | 
			
		||||
    case IR40_JUMP3        : if (!applyPreset(1)) effectCurrent = FX_MODE_STATIC;        effectPalette = 0; break;
 | 
			
		||||
    case IR40_FADE3        : if (!applyPreset(2)) effectCurrent = FX_MODE_BREATH;        effectPalette = 0; break;
 | 
			
		||||
    case IR40_FADE7        : if (!applyPreset(3)) effectCurrent = FX_MODE_FIRE_FLICKER;  effectPalette = 0; break;
 | 
			
		||||
    case IR40_FLASH        : if (!applyPreset(4)) effectCurrent = FX_MODE_RAINBOW;       effectPalette = 0; break;
 | 
			
		||||
  }
 | 
			
		||||
  lastValidCode = code;
 | 
			
		||||
  colorUpdated(2); //for notifier, IR is considered a button input 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void decodeIR44(uint32_t code)
 | 
			
		||||
{
 | 
			
		||||
  //not implemented for now
 | 
			
		||||
  switch (code) {
 | 
			
		||||
    case IR44_BPLUS       : relativeChange(&bri, 10);                                   break;
 | 
			
		||||
    case IR44_BMINUS      : relativeChange(&bri, -10, 5);                               break;
 | 
			
		||||
    case IR44_OFF         : briLast = bri; bri = 0;                                     break;
 | 
			
		||||
    case IR44_ON          : bri = briLast;                                              break;
 | 
			
		||||
    case IR44_RED         : colorFromUint24(COLOR_RED);                                 break;
 | 
			
		||||
    case IR44_GREEN       : colorFromUint24(COLOR_GREEN);                               break;
 | 
			
		||||
    case IR44_BLUE        : colorFromUint24(COLOR_BLUE);                                break;
 | 
			
		||||
    case IR44_WHITE       : {
 | 
			
		||||
      if (col[3] > 0) col[3] = 0; 
 | 
			
		||||
      else colorFromUint32(COLOR_NEUTRALWHITE); effectCurrent = 0; }                    break;
 | 
			
		||||
    case IR44_REDDISH     : colorFromUint24(COLOR_REDDISH);                             break;
 | 
			
		||||
    case IR44_GREENISH    : colorFromUint24(COLOR_GREENISH);                            break;
 | 
			
		||||
    case IR44_DEEPBLUE    : colorFromUint24(COLOR_DEEPBLUE);                            break;
 | 
			
		||||
    case IR44_WARMWHITE2  : colorFromUint32(COLOR_WARMWHITE2);   effectCurrent = 0;     break;
 | 
			
		||||
    case IR44_ORANGE      : colorFromUint24(COLOR_ORANGE);                              break;
 | 
			
		||||
    case IR44_TURQUOISE   : colorFromUint24(COLOR_TURQUOISE);                           break;
 | 
			
		||||
    case IR44_PURPLE      : colorFromUint24(COLOR_PURPLE);                              break;
 | 
			
		||||
    case IR44_WARMWHITE   : colorFromUint32(COLOR_WARMWHITE);    effectCurrent = 0;     break;
 | 
			
		||||
    case IR44_YELLOWISH   : colorFromUint24(COLOR_YELLOWISH);                           break;
 | 
			
		||||
    case IR44_CYAN        : colorFromUint24(COLOR_CYAN);                                break;
 | 
			
		||||
    case IR44_MAGENTA     : colorFromUint24(COLOR_MAGENTA);                             break;
 | 
			
		||||
    case IR44_COLDWHITE   : colorFromUint32(COLOR_COLDWHITE);    effectCurrent = 0;     break;
 | 
			
		||||
    case IR44_YELLOW      : colorFromUint24(COLOR_YELLOW);                              break;
 | 
			
		||||
    case IR44_AQUA        : colorFromUint24(COLOR_AQUA);                                break;
 | 
			
		||||
    case IR44_PINK        : colorFromUint24(COLOR_PINK);                                break;
 | 
			
		||||
    case IR44_COLDWHITE2  : colorFromUint32(COLOR_COLDWHITE2);   effectCurrent = 0;     break;
 | 
			
		||||
    case IR44_REDPLUS     : relativeChange(&effectCurrent, 1);                          break;
 | 
			
		||||
    case IR44_REDMINUS    : relativeChange(&effectCurrent, -1, 0);                      break;
 | 
			
		||||
    case IR44_GREENPLUS   : relativeChange(&effectPalette, 1);                          break;
 | 
			
		||||
    case IR44_GREENMINUS  : relativeChange(&effectPalette, -1, 0);                      break;
 | 
			
		||||
    case IR44_BLUEPLUS    : relativeChange(&effectIntensity, 10);                       break;
 | 
			
		||||
    case IR44_BLUEMINUS   : relativeChange(&effectIntensity, -10, 5);                   break;
 | 
			
		||||
    case IR44_QUICK       : relativeChange(&effectSpeed, 10);                           break;
 | 
			
		||||
    case IR44_SLOW        : relativeChange(&effectSpeed, -10, 5);                       break;
 | 
			
		||||
    case IR44_DIY1        : if (!applyPreset(1)) effectCurrent = FX_MODE_STATIC;        effectPalette = 0; break;
 | 
			
		||||
    case IR44_DIY2        : if (!applyPreset(2)) effectCurrent = FX_MODE_BREATH;        effectPalette = 0; break;
 | 
			
		||||
    case IR44_DIY3        : if (!applyPreset(3)) effectCurrent = FX_MODE_FIRE_FLICKER;  effectPalette = 0; break;
 | 
			
		||||
    case IR44_DIY4        : if (!applyPreset(4)) effectCurrent = FX_MODE_RAINBOW;       effectPalette = 0; break;
 | 
			
		||||
    case IR44_DIY5        : if (!applyPreset(5)) effectCurrent = FX_MODE_METEOR_SMOOTH; effectPalette = 0; break;
 | 
			
		||||
    case IR44_DIY6        : if (!applyPreset(6)) effectCurrent = FX_MODE_RAIN;          effectPalette = 0; break;
 | 
			
		||||
    case IR44_AUTO        : effectCurrent = FX_MODE_STATIC;                             break;
 | 
			
		||||
    case IR44_FLASH       : effectCurrent = FX_MODE_PALETTE;                            break;
 | 
			
		||||
    case IR44_JUMP3       : bri = 63;                                                   break;
 | 
			
		||||
    case IR44_JUMP7       : bri = 127;                                                  break;
 | 
			
		||||
    case IR44_FADE3       : bri = 191;                                                  break;
 | 
			
		||||
    case IR44_FADE7       : bri = 255;                                                  break;
 | 
			
		||||
  }
 | 
			
		||||
  lastValidCode = code;
 | 
			
		||||
  colorUpdated(2); //for notifier, IR is considered a button input 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void initIR()
 | 
			
		||||
{
 | 
			
		||||
  if (irEnabled)
 | 
			
		||||
  if (irEnabled > 0)
 | 
			
		||||
  {
 | 
			
		||||
    irrecv = new IRrecv(IR_PIN);
 | 
			
		||||
    irrecv->enableIRIn();
 | 
			
		||||
| 
						 | 
				
			
			@ -126,10 +310,10 @@ void initIR()
 | 
			
		|||
 | 
			
		||||
void handleIR()
 | 
			
		||||
{
 | 
			
		||||
  if (irEnabled && millis() - irCheckedTime > 120)
 | 
			
		||||
  if (irEnabled > 0 && millis() - irCheckedTime > 120)
 | 
			
		||||
  {
 | 
			
		||||
    irCheckedTime = millis();
 | 
			
		||||
    if (irEnabled)
 | 
			
		||||
    if (irEnabled > 0)
 | 
			
		||||
    {
 | 
			
		||||
      if (irrecv == NULL)
 | 
			
		||||
      { 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue