I m在我ESP8266从互联网上获得彩色海螺的项目上工作,然后我用这个颜色为LED。
我收到的一个实例是“3#FF00FF”
然而,如果B值为非零,那么“3#FF00FF”和“3#FF0012”的“3#FF0012”将坠毁,但“3#FF0000美元”不会落空。 这里是我法典的缩略语。 同样,当它坠毁和ESP8266自动电离层电离层电离层装置不停时,我猜测它会泄露记忆。
int r1 = 0;
int g1 = 0;
int b1 = 0;
void setup() {
// boilerplate
}
void loop() {
String data = // getting string of data from server, format is like "$3#FF0000"
if (data.charAt(0) == $ && dataLen == 9) {
char ledStrip = data.charAt(1);
char buffer[10];
data.toCharArray(buffer, sizeof(buffer));
r1 = strtol(data.substring(3, 5).c_str(), NULL, 16); // Parse hex to int
g1 = strtol(data.substring(5, 7).c_str(), NULL, 16);
// Note it does crash after this line but indiscriminately after
// If I remove this line the error does not ever happening
// So I m assuming is a memory issue
b1 = strtol(data.substring(7, 9).c_str(), NULL, 16);
Serial.print("Received RGB values for Strip 1 & 2: R=");
Serial.print(r1);
Serial.print(", G=");
Serial.print(g1);
Serial.print(", B=");
Serial.println(b1);
}
}