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.

79 lines
2.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. BitmapLEDProgram::BitmapLEDProgram (LEDGrid& lg) : Program (lg) {}
  18. /*
  19. The heap format for this program is just an array of 15x15 5:6:5 colours,
  20. and the program just copies them onto the screen each frame.
  21. */
  22. void BitmapLEDProgram::setLED (uint32 x, uint32 y, LEDColour colour)
  23. {
  24. auto w = (uint32) ledGrid.getNumColumns();
  25. auto h = (uint32) ledGrid.getNumRows();
  26. if (x < w && y < h)
  27. {
  28. auto bit = (x + y * w) * 16;
  29. ledGrid.setDataBits (bit, 5, colour.getRed() >> 3);
  30. ledGrid.setDataBits (bit + 5, 6, colour.getGreen() >> 2);
  31. ledGrid.setDataBits (bit + 11, 5, colour.getBlue() >> 3);
  32. }
  33. }
  34. uint32 BitmapLEDProgram::getHeapSize()
  35. {
  36. return 15 * 15 * 16;
  37. }
  38. juce::String BitmapLEDProgram::getLittleFootProgram()
  39. {
  40. auto program = R"littlefoot(
  41. void repaint()
  42. {
  43. for (int y = 0; y < NUM_ROWS; ++y)
  44. {
  45. for (int x = 0; x < NUM_COLUMNS; ++x)
  46. {
  47. int bit = (x + y * NUM_COLUMNS) * 16;
  48. setLED (x, y, makeARGB (255,
  49. getHeapBits (bit, 5) << 3,
  50. getHeapBits (bit + 5, 6) << 2,
  51. getHeapBits (bit + 11, 5) << 3));
  52. }
  53. }
  54. }
  55. )littlefoot";
  56. return juce::String (program)
  57. .replace ("NUM_COLUMNS", juce::String (ledGrid.getNumColumns()))
  58. .replace ("NUM_ROWS", juce::String (ledGrid.getNumRows()));
  59. }