Merge branch 'master' of github.com:Aircoookie/WLED into disable_n_leds_for_all_fx

 Conflicts:
	wled00/data/settings_leds.htm
This commit is contained in:
emerrill
2019-11-29 10:56:59 -07:00
11 changed files with 265 additions and 34 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -16,14 +16,14 @@
//You are required to disable over-the-air updates:
//#define WLED_DISABLE_OTA
//You need to choose 1-2 of these features to disable:
//You need to choose some of these features to disable:
//#define WLED_DISABLE_ALEXA
//#define WLED_DISABLE_BLYNK
//#define WLED_DISABLE_CRONIXIE
//#define WLED_DISABLE_HUESYNC
//#define WLED_DISABLE_INFRARED //there is no pin left for this on ESP8266-01
//#define WLED_DISABLE_MOBILE_UI
#define WLED_ENABLE_ADALIGHT //only saves about 500b
#define WLED_DISABLE_FILESYSTEM //SPIFFS is not used by any WLED feature yet
//#define WLED_ENABLE_FS_SERVING //Enable sending html file from SPIFFS before serving progmem version
@@ -437,7 +437,7 @@ AsyncMqttClient* mqtt = NULL;
void serveMessage(AsyncWebServerRequest*,uint16_t,String,String,byte);
void handleE131Packet(e131_packet_t*, IPAddress);
#define E131_MAX_UNIVERSE_COUNT 7
#define E131_MAX_UNIVERSE_COUNT 9
//udp interface objects
WiFiUDP notifierUdp, rgbUdp;

View File

@@ -1,40 +1,87 @@
/*
* Utility for SPIFFS filesystem & Serial console
*/
enum class AdaState {
Header_A,
Header_d,
Header_a,
Header_CountHi,
Header_CountLo,
Header_CountCheck,
Data_Red,
Data_Green,
Data_Blue
};
void handleSerial()
{
if (Serial.available() > 0) //support for Adalight protocol to high-speed control LEDs over serial
#ifdef WLED_ENABLE_ADALIGHT
static auto state = AdaState::Header_A;
static uint16_t count = 0;
static uint16_t pixel = 0;
static byte check = 0x00;
static byte red = 0x00;
static byte green = 0x00;
static bool changed = false;
while (Serial.available() > 0)
{
byte next = Serial.read();
switch (state) {
case AdaState::Header_A:
if (next == 'A') state = AdaState::Header_d;
break;
case AdaState::Header_d:
if (next == 'd') state = AdaState::Header_a;
else state = AdaState::Header_A;
break;
case AdaState::Header_a:
if (next == 'a') state = AdaState::Header_CountHi;
else state = AdaState::Header_A;
break;
case AdaState::Header_CountHi:
pixel = 0;
count = next * 0x100;
check = next;
state = AdaState::Header_CountLo;
break;
case AdaState::Header_CountLo:
count += next + 1;
check = check ^ next ^ 0x55;
state = AdaState::Header_CountCheck;
break;
case AdaState::Header_CountCheck:
if (check == next) state = AdaState::Data_Red;
else state = AdaState::Header_A;
break;
case AdaState::Data_Red:
red = next;
state = AdaState::Data_Green;
break;
case AdaState::Data_Green:
green = next;
state = AdaState::Data_Blue;
break;
case AdaState::Data_Blue:
byte blue = next;
changed = true;
setRealtimePixel(pixel++, red, green, blue, 0);
if (--count > 0) state = AdaState::Data_Red;
else state = AdaState::Header_A;
break;
}
}
if (changed)
{
if (!Serial.find("Ada")) return;
if (!realtimeActive && bri == 0) strip.setBrightness(briLast);
arlsLock(realtimeTimeoutMs);
yield();
byte hi = Serial.read();
byte ledc = Serial.read();
byte chk = Serial.read();
if(chk != (hi ^ ledc ^ 0x55)) return;
if (ledCount < ledc) ledc = ledCount;
byte sc[3]; int t =-1; int to = 0;
for (int i=0; i < ledc; i++)
{
for (byte j=0; j<3; j++)
{
while (Serial.peek()<0) //no data yet available
{
yield();
to++;
if (to>15) {strip.show(); return;} //unexpected end of transmission
}
to = 0;
sc[j] = Serial.read();
}
setRealtimePixel(i,sc[0],sc[1],sc[2],0);
}
strip.show();
changed = false;
}
#endif
}