Load Neopixel type (NEO_RGB etc) from text file

Hi folks, I have a number of different LED (neopixel ws2812/ sk8618) types running on different nodes (ESP8266), and I want to load their config details from a txt file stored in the file system of each node. I have it working for unit ID and number of LEDs, and now I want to add the LED type eg NEO_GRB etc. Which looks like a string, but obviously isn’t; the Adafruit_Neopixel.h file defines then as eg

#define NEO_RBG  ((0<<6) | (0<<4) | (2<<2) | (1)) ///< Transmit as R,B,G
#define NEO_GRB  ((1<<6) | (1<<4) | (0<<2) | (2)) ///< Transmit as G,R,B

so I guess they are ints, and have this typedef:

typedef uint8_t  neoPixelType; ///< 3rd arg to Adafruit_NeoPixel constructor

so uint8_t. But I can’t call NEO_RGB.toInt(), or whatever, obviously…

I need ultimately to call

strip.updateType(neoPixelType t);

on my Adafruit_Neopixel object.

I am sure I just have to look at this issue in a different way and it will be clear, but can anyone help me see that different way?

This is running on ESP8266. My code so far:

File file = LittleFS.open("id.txt", "r");
    String line;
    line = file.readStringUntil('\n');  //id number
    gID = line.toInt();
    Serial.printf("gID = %d\n",gID);
    line = file.readStringUntil('\n');  //num leds
    gNumLeds = line.toInt(); 
    Serial.printf("gNumLeds = %d\n",gNumLeds);

Thanks in advance,


I do not see where you load the pixel-type, but eventually you just need to convert the bitwise operation to an integer and store that as a line. You could also just store "RGB" or "GRB" as a line and then make a comparison in code:

line = loadLineFromFile()
if line equals "RGB" then strip.updateType(NEO_RGB)
else if line equals "GRB" then strip.updateType(NEO_GRB)

And so on..

Ha! Elegantly (and embarrassingly) simple!

Thanks (slightly red-faced)