我想使用的功能和結構,以然後返回結構與功能 - 沒有指定類型
我已經成功地完成大部分數據的十六進制顏色字符串轉換成RGB值工作,但我努力瞭解一下我的Struct和Function應該如何一起工作。
這裏是我的代碼,返回錯誤RGB does not name a type
//Define my Struct
struct RGB {
byte r;
byte g;
byte b;
};
//Create my function to return my Struct
RGB getRGB(String hexValue) {
char newVarOne[40];
hexValue.toCharArray(newVarOne, sizeof(newVarOne)-1);
long number = (long) strtol(newVarOne,NULL,16);
int r = number >> 16;
int g = number >> 8 & 0xFF;
int b = number & 0xFF;
RGB value = {r,g,b}
return value;
}
//Function to call getRGB and return the RGB colour values
void solid(String varOne) {
RGB theseColours;
theseColours = getRGB(varOne);
fill_solid(leds, NUM_LEDS, CRGB(theseColours.r,theseColours.g,theseColours.b));
FastLED.show();
}
它示數有關該生產線是:
RGB getRGB(String hexValue) {
有人能解釋我做了什麼錯誤,以及如何解決它,請?
編譯器抱怨哪一行是代碼?此外,語句'RGB值= {r,g,b}'在最後缺少分號。 –