You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
635B

  1. #include "app/ModuleLightWidget.hpp"
  2. namespace rack {
  3. void ModuleLightWidget::step() {
  4. if (!module)
  5. return;
  6. assert(module->lights.size() >= firstLightId + baseColors.size());
  7. std::vector<float> values(baseColors.size());
  8. for (size_t i = 0; i < baseColors.size(); i++) {
  9. float brightness = module->lights[firstLightId + i].getBrightness();
  10. if (!std::isfinite(brightness))
  11. brightness = 0.f;
  12. // Because LEDs are nonlinear, this seems to look more natural.
  13. brightness = std::sqrt(brightness);
  14. brightness = math::clamp(brightness, 0.f, 1.f);
  15. values[i] = brightness;
  16. }
  17. setValues(values);
  18. }
  19. } // namespace rack