The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

55 lines
1.9KB

  1. /**
  2. @page controlling_led_strips Controlling LED strips
  3. Control Blocks have a strip of LEDs which can be controlled via an LEDRow object.
  4. A pointer to an %LEDRow object can be obtained from the Block::getLEDRow() method of a Block --- see the @ref discovering_blocks section for details of how to obtain a %Block object.
  5. Once you have an %LEDRow there are a few functions that you can use to interact with the strip of LEDs on a device.
  6. A code snippet showing how to turn the whole strip of LEDs on a %Block yellow is shown below.
  7. @code{.cpp}
  8. class BlockLEDExample
  9. {
  10. public:
  11. void setWholeLEDRowYellow (Block& block)
  12. {
  13. if (auto ledRow = block.getLEDRow())
  14. for (int i = 0; i < ledRow->getNumLEDs(); ++i)
  15. ledRow->setLEDColour (i, LEDColour (0xffffff00));
  16. }
  17. };
  18. @endcode
  19. @section controlling_led_strips_example_usage Example usage
  20. To add this functionality to the BlockFinder example project, add the above function to the BlockFinder class implementation. Then in the @s_projcode{topologyChanged()} callback, check if the connected %Block is a Control %Block and call the above function as shown below:
  21. @code{.cpp}
  22. void topologyChanged() override
  23. {
  24. //...
  25. for (auto& block : currentTopology.blocks)
  26. {
  27. //...
  28. if (block->getType() == Block::liveBlock || block->getType() == Block::loopBlock
  29. || block->getType() == Block::developerControlBlock || block->getType() == Block::touchBlock)
  30. {
  31. setWholeLEDRowYellow (*block);
  32. }
  33. }
  34. }
  35. @endcode
  36. If you run the application now and connect a Control %Block, you should see the LEDs in the strip turn yellow.
  37. Learn more about other Block methods from the following pages:
  38. @ref getting_touch_events
  39. @ref getting_control_button_events
  40. @ref controlling_led_grids
  41. @ref controlling_control_buttons
  42. */