Merge branch 'master' into dev

This commit is contained in:
Blaž Kristan 2021-09-06 13:36:26 +02:00
commit c436b586d2
4 changed files with 34 additions and 3 deletions

View File

@ -2,6 +2,12 @@
### Builds after release 0.12.0 ### Builds after release 0.12.0
#### Build 2108250
- Added Sync groups (PR #2150)
- Added JSON API over Serial support
- Live color correction (PR #1902)
#### Build 2108180 #### Build 2108180
- Fixed JSON IR remote not working with codes greater than 0xFFFFFF (fixes #2135) - Fixed JSON IR remote not working with codes greater than 0xFFFFFF (fixes #2135)

View File

@ -900,7 +900,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
WS2812FX::Segment& seg = strip.getSegment(i); WS2812FX::Segment& seg = strip.getSegment(i);
if (!seg.isSelected()) continue; if (!seg.isSelected()) continue;
if (effectCurrent != prevEffect) { if (effectCurrent != prevEffect) {
seg.mode = effectCurrent; strip.setMode(i, effectCurrent);
effectChanged = true; effectChanged = true;
} }
if (effectSpeed != prevSpeed) { if (effectSpeed != prevSpeed) {

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2109032 #define VERSION 2109061
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG

View File

@ -21,6 +21,8 @@ enum class AdaState {
void handleSerial() void handleSerial()
{ {
if (pinManager.isPinAllocated(3)) return;
#ifdef WLED_ENABLE_ADALIGHT #ifdef WLED_ENABLE_ADALIGHT
static auto state = AdaState::Header_A; static auto state = AdaState::Header_A;
static uint16_t count = 0; static uint16_t count = 0;
@ -32,13 +34,35 @@ void handleSerial()
while (Serial.available() > 0) while (Serial.available() > 0)
{ {
yield(); yield();
byte next = Serial.read(); byte next = Serial.peek();
switch (state) { switch (state) {
case AdaState::Header_A: case AdaState::Header_A:
if (next == 'A') state = AdaState::Header_d; if (next == 'A') state = AdaState::Header_d;
else if (next == 0xC9) { //TPM2 start byte else if (next == 0xC9) { //TPM2 start byte
state = AdaState::TPM2_Header_Type; state = AdaState::TPM2_Header_Type;
} }
else if (next == '{') { //JSON API
bool verboseResponse = false;
{
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
Serial.setTimeout(100);
DeserializationError error = deserializeJson(doc, Serial);
if (error) return;
fileDoc = &doc;
verboseResponse = deserializeState(doc.as<JsonObject>());
fileDoc = nullptr;
}
//only send response if TX pin is unused for other purposes
if (verboseResponse && !pinManager.isPinAllocated(1)) {
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
JsonObject state = doc.createNestedObject("state");
serializeState(state);
JsonObject info = doc.createNestedObject("info");
serializeInfo(info);
serializeJson(doc, Serial);
}
}
break; break;
case AdaState::Header_d: case AdaState::Header_d:
if (next == 'd') state = AdaState::Header_a; if (next == 'd') state = AdaState::Header_a;
@ -98,6 +122,7 @@ void handleSerial()
} }
break; break;
} }
Serial.read(); //discard the byte
} }
#endif #endif
} }