Skip to content

Instantly share code, notes, and snippets.

@benjamind
Created January 8, 2017 21:10
Show Gist options
  • Save benjamind/e62f5177a975086051b19f35475e8713 to your computer and use it in GitHub Desktop.
Save benjamind/e62f5177a975086051b19f35475e8713 to your computer and use it in GitHub Desktop.
FastLED power management per controller pseudocode
// this is all pseudocode and will probably not compile but it should give you an idea
// init...
// create your controllers
CLEDController controllerA = FastLED.addLEDs(LED_TYPE, DATA_PIN, COLOR_ORDER(ledsA, 0, NUM_LEDS_A);
CLEDController controllerB = FastLED.addLEDs(LED_TYPE, DATA_PIN, COLOR_ORDER(ledsB, 0, NUM_LEDS_B);
// loop....
// calculate power per controller
uint8_t scaleA = calculate_max_brightness_for_power_mW(controllerA.leds(), controllerA.size(), targetBrightness, MAX_POWER_MW_A);
uint8_t scaleB = calculate_max_brightness_for_power_mW(controllerB.leds(), controllerB.size(), targetBrightness, MAX_POWER_MW_B);
// show the controllers using their appropriate scales
uint8_t d = controllerA.getDither();
controllerA.showLeds(scaleA);
controllerA.setDither(d);
controllerB.getDither();
controllerB.showLeds(scaleB);
controllerB.setDither(d);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment