Merge branch 'master' into master-merge

Few UI fixes.
This commit is contained in:
Blaz Kristan
2022-02-03 17:40:44 +01:00
22 changed files with 2016 additions and 1884 deletions

View File

@@ -19,6 +19,21 @@ enum class AdaState {
TPM2_Header_CountLo,
};
uint16_t currentBaud = 1152; //default baudrate 115200 (divided by 100)
void updateBaudRate(uint32_t rate){
uint16_t rate100 = rate/100;
if (rate100 == currentBaud || rate100 < 96) return;
currentBaud = rate100;
if (!pinManager.isPinAllocated(1) || pinManager.getPinOwner(1) == PinOwner::DebugOut){
Serial.print(F("Baud is now ")); Serial.println(rate);
}
Serial.flush();
Serial.begin(rate);
}
void handleSerial()
{
if (pinManager.isPinAllocated(3)) return;
@@ -30,6 +45,8 @@ void handleSerial()
static byte check = 0x00;
static byte red = 0x00;
static byte green = 0x00;
uint16_t nBytes = 0;
while (Serial.available() > 0)
{
@@ -46,6 +63,41 @@ void handleSerial()
return;
} else if (next == 'v') {
Serial.print("WLED"); Serial.write(' '); Serial.println(VERSION);
} else if (next == 0xB0) {updateBaudRate( 115200);
} else if (next == 0xB1) {updateBaudRate( 230400);
} else if (next == 0xB2) {updateBaudRate( 460800);
} else if (next == 0xB3) {updateBaudRate( 500000);
} else if (next == 0xB4) {updateBaudRate( 576000);
} else if (next == 0xB5) {updateBaudRate( 921600);
} else if (next == 0xB6) {updateBaudRate(1000000);
} else if (next == 0xB7) {updateBaudRate(1500000);
} else if (next == 'l') { //RGB(W) LED data return as JSON array. Slow, but easy to use on the other end.
if (!pinManager.isPinAllocated(1) || pinManager.getPinOwner(1) == PinOwner::DebugOut){
uint16_t used = strip.getLengthTotal();
Serial.write('[');
for (uint16_t i=0; i<used; i+=1) {
Serial.print(strip.getPixelColor(i));
if (i != used-1) Serial.write(',');
}
Serial.println("]");
}
} else if (next == 'L') { //RGB LED data returned as bytes in tpm2 format. Faster, and slightly less easy to use on the other end.
if (!pinManager.isPinAllocated(1) || pinManager.getPinOwner(1) == PinOwner::DebugOut) {
Serial.write(0xC9); Serial.write(0xDA);
uint16_t used = strip.getLengthTotal();
uint16_t len = used*3;
Serial.write((len << 8) & 0xFF);
Serial.write( len & 0xFF);
for (uint16_t i=0; i < used; i++) {
uint32_t c = strip.getPixelColor(i);
Serial.write(qadd8(W(c), R(c))); //R, add white channel to RGB channels as a simple RGBW -> RGB map
Serial.write(qadd8(W(c), G(c))); //G
Serial.write(qadd8(W(c), B(c))); //B
}
Serial.write(0x36); Serial.write('\n');
}
} else if (next == '{') { //JSON API
bool verboseResponse = false;
if (!requestJSONBufferLock(16)) return;
@@ -57,7 +109,7 @@ void handleSerial()
}
verboseResponse = deserializeState(doc.as<JsonObject>());
//only send response if TX pin is unused for other purposes
if (verboseResponse && !pinManager.isPinAllocated(1)) {
if (verboseResponse && (!pinManager.isPinAllocated(1) || pinManager.getPinOwner(1) == PinOwner::DebugOut)) {
doc.clear();
JsonObject state = doc.createNestedObject("state");
serializeState(state);