MCPcopy Create free account
hub / github.com/FastLED/FastLED / setMixedBitPattern

Function setMixedBitPattern

examples/AutoResearch/AutoResearchTest.cpp:1208–1254  ·  view source on GitHub ↗

Set mixed RGB bit patterns to test MSB vs LSB handling

Source from the content-addressed store, hash-verified

1206
1207// Set mixed RGB bit patterns to test MSB vs LSB handling
1208void setMixedBitPattern(CRGB* leds, size_t count, int pattern_id) {
1209 switch (pattern_id) {
1210 case 0:
1211 // Pattern A: R=0xF0 (high nibble), G=0x0F (low nibble), B=0xAA (alternating)
1212 // Tests: High bits in R, low bits in G, mixed bits in B
1213 for (size_t i = 0; i < count; i++) {
1214 leds[i] = CRGB(0xF0, 0x0F, 0xAA);
1215 }
1216 break;
1217
1218 case 1:
1219 // Pattern B: R=0x55 (alternating 01010101), G=0xFF (all high), B=0x00 (all low)
1220 // Tests: Alternating bits, all-high boundary, all-low boundary
1221 for (size_t i = 0; i < count; i++) {
1222 leds[i] = CRGB(0x55, 0xFF, 0x00);
1223 }
1224 break;
1225
1226 case 2:
1227 // Pattern C: R=0x0F (low nibble), G=0xAA (alternating), B=0xF0 (high nibble)
1228 // Tests: Rotated pattern from A, ensures driver handles different channel values
1229 for (size_t i = 0; i < count; i++) {
1230 leds[i] = CRGB(0x0F, 0xAA, 0xF0);
1231 }
1232 break;
1233
1234 case 3:
1235 // Pattern D: Solid colors alternating (Red, Green, Blue repeating)
1236 // Baseline test - ensures basic RGB transmission works
1237 for (size_t i = 0; i < count; i++) {
1238 int color_index = i % 3;
1239 if (color_index == 0) {
1240 leds[i] = CRGB::Red; // RGB(255, 0, 0)
1241 } else if (color_index == 1) {
1242 leds[i] = CRGB::Green; // RGB(0, 255, 0)
1243 } else {
1244 leds[i] = CRGB::Blue; // RGB(0, 0, 255)
1245 }
1246 }
1247 break;
1248
1249 default:
1250 // Fallback: all black
1251 fill_solid(leds, count, CRGB::Black);
1252 break;
1253 }
1254}
1255
1256// Get name of bit pattern for logging
1257const char* getBitPatternName(int pattern_id) {

Callers 2

Calls 2

CRGBClass · 0.50
fill_solidFunction · 0.50

Tested by

no test coverage detected