Skip to content

Instantly share code, notes, and snippets.

@hpwit
Created May 28, 2024 08:43
Show Gist options
  • Save hpwit/268f2cb41b9baf392f56376b1310a3a4 to your computer and use it in GitHub Desktop.
Save hpwit/268f2cb41b9baf392f56376b1310a3a4 to your computer and use it in GitHub Desktop.
change to have multistrip should work for one or more
if (fixture.doAllocPins) {
unsigned pinNr = 0;
int pins[16];
int lengths[16];
int nb_pins=0;
for (PinObject &pinObject: pins->pinObjects) {
if (pins->isOwner(pinNr, "Leds")) { //if pin owned by leds, (assigned in projectAndMap)
//dirty trick to decode nrOfLedsPerPin
char details[32];
strcpy(details, pinObject.details); //copy as strtok messes with the string
char * after = strtok((char *)details, "-");
if (after != NULL ) {
char * before;
before = after;
after = strtok(NULL, " ");
stackUnsigned16 startLed = atoi(before);
stackUnsigned16 nrOfLeds = atoi(after) - atoi(before) + 1;
ppf("driver.initled new %d: %d-%d\n", pinNr, startLed, nrOfLeds-1);
pins[nb_pins]=pinNr;
lengths[nb_pins]=nrOfLeds;
nb_pins++;
} //if led range in details (- in details e.g. 0-1023)
} //if pin owned by leds
pinNr++;
} // for pins
if(nb_pins>0)
{
driver.initled((uint8_t*) fixture.ledsP, pins, lengths, nb_pins, ORDER_GRB);
driverInit = true;
}
fixture.doAllocPins = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment