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.

71 lines
2.9KB

  1. /**
  2. @page controlling_led_grids Controlling LED grids
  3. @section controlling_led_grids_basic_usage Basic usage
  4. An LED grid on a BLOCKS device can be controlled via an LEDGrid object, which can be obtained from the Block::getLEDGrid() function of a Block --- see the @ref discovering_blocks section for details of how to obtain a %Block object.
  5. Using a LED grid requires a Block::Program to operate the LEDs.
  6. This program specifies some code to run on the device, and can also provide methods to be called from your application which can communicate with the code running on the device via a block of shared memory.
  7. The code which runs on the device must be specified using @ref the_littlefoot_language, which is described in the corresponding section.
  8. However, for a very wide range of applications, the BitmapLEDProgram provided with the BLOCKS SDK is sufficient and you will not need to create your own.
  9. Using a %BitmapLEDProgram to change the colour of LEDs is demonstated below.
  10. @code{.cpp}
  11. class BlockProgramExample
  12. {
  13. public:
  14. // This should be called when doing the initial configuration of your application.
  15. void setBitmapLEDProgram (Block& block)
  16. {
  17. block.setProgram (new BitmapLEDProgram (block));
  18. }
  19. // Once a BitmapLEDProgram is loaded we can use its setLED() method to change the
  20. // colour of LEDs on the corresponding device.
  21. void setLED (Block& block, int x, int y, LEDColour c)
  22. {
  23. if (auto program = dynamic_cast<BitmapLEDProgram*> (block.getProgram()))
  24. program->setLED (x, y, c);
  25. }
  26. };
  27. @endcode
  28. @section controlling_led_grids_example_usage Example usage
  29. To add this functionality to the BlockFinder example project, add the above functions to the BlockFinder class implementation. Then in the @s_projcode{topologyChanged()} callback, check if the connected %Block is a Lightpad and call the above functions as shown below:
  30. @code{.cpp}
  31. void topologyChanged() override
  32. {
  33. //...
  34. for (auto& block : currentTopology.blocks)
  35. {
  36. //...
  37. if (block->getType() == Block::lightPadBlock)
  38. {
  39. setBitmapLEDProgram (*block);
  40. setLED (*block, 7, 7, LEDColour (0xff00ff00));
  41. }
  42. }
  43. }
  44. @endcode
  45. If you run the application now and connect a Lightpad, you should see a single green dot displayed in the centre of the surface.
  46. @section controlling_led_grids_advanced_usage Advanced Usage
  47. Using a custom %Block::Program allows more precise control over the operation of the LEDs.
  48. The code which will actually execute on the device, returned by your overriden Block::Program::getLittleFootProgram() function, must be specified in the LittleFoot language.
  49. Learn more about other Block methods from the following pages:
  50. @ref getting_touch_events
  51. @ref getting_control_button_events
  52. @ref controlling_led_strips
  53. @ref controlling_control_buttons
  54. */