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.

58 lines
2.9KB

  1. /**
  2. @page controlling_led_grids Controlling LED grids
  3. @section 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 an LED grid requires an LEDGrid::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 comminucate 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. // This should be called when doing the initial configuration of your application.
  12. void setBitmapLEDProgram (Block& block)
  13. {
  14. if (auto grid = block->getLEDGrid())
  15. grid->setProgram (new BitmapLEDProgram (*grid));
  16. }
  17. // Once a BitmapLEDProgram is loaded we can use its setLED method to change the
  18. // colour of LEDs on the corresponding device.
  19. void setLED (Block& block, int x, int y, Colour c)
  20. {
  21. if (auto grid = block->getLEDGrid())
  22. if (auto program = dynamic_cast<BitmapLEDProgram*> (grid->getProgram()))
  23. program->setLED (x, y, c);
  24. }
  25. @endcode
  26. @section advanced_usage Advanced Usage
  27. Using a custom %LEDGrid::Program allows more precise control over the operation of the LEDs.
  28. The code which will actually execute on the device, returned by your overriden LEDGrid::Program::getLittleFootProgram() function, must be specified in the LittleFoot language.
  29. @subsection the_littlefoot_language The LittleFoot Language
  30. A description of the LittleFoot language is contained in the SDK source code at <tt>juce_blocks_basics/littlefoot/LittleFoot Language README.txt</tt>:
  31. @includedoc "LittleFoot Language README.txt"
  32. @subsection littlefoot_example A LittleFoot example
  33. The %BitmapLEDProgram class is a simple example of a LittleFoot program.
  34. <tt>%juce_blocks_basics/visualisers/juce_BitmapLEDProgram.h</tt>
  35. @include juce_blocks_basics/visualisers/juce_BitmapLEDProgram.h
  36. <tt>juce_blocks_basics/visualisers/juce_BitmapLEDProgram.cpp</tt>
  37. @include juce_blocks_basics/visualisers/juce_BitmapLEDProgram.cpp
  38. The repaint() method of the LittleFoot program is called at approximately 25 Hz, and each time it simply inspects the heap (the shared area of memory used to communicate between your application code and your LittleFoot program) and sets the LEDs based on the heap's content.
  39. To update the heap, and hence the LEDS, your application code calls BitmapLEDProgram::setLED.
  40. A more advanced example can be found in the source code of the DrumPadGridProgram class.
  41. */