Controlling LED strips

Control Blocks have a strip of LEDs which can be controlled via an LEDRow object.

A pointer to an LEDRow object can be obtained from the Block::getLEDRow() method of a Block — see the Discovering BLOCKS section for details of how to obtain a Block object. Once you have an LEDRow there are a few functions that you can use to interact with the strip of LEDs on a device. A code snippet showing how to turn the whole strip of LEDs on a Block yellow is shown below.

class BlockLEDExample
void setWholeLEDRowYellow (Block& block)
if (auto ledRow = block.getLEDRow())
for (int i = 0; i < ledRow->getNumLEDs(); ++i)
ledRow->setLEDColour (i, LEDColour (0xffffff00));

Example usage

To add this functionality to the BlockFinder example project, add the above function to the BlockFinder class implementation. Then in the topologyChanged() callback, check if the connected Block is a Control Block and call the above function as shown below:

void topologyChanged() override
for (auto& block : currentTopology.blocks)
if (block->getType() == Block::liveBlock || block->getType() == Block::loopBlock
setWholeLEDRowYellow (*block);

If you run the application now and connect a Control Block, you should see the LEDs in the strip turn yellow.

The LED strip on a Control Block

Learn more about other Block methods from the following pages:

Getting touch events

Getting control button events

Controlling LED grids

Controlling control buttons

@ developerControlBlock
Developer control block type.
Definition: juce_Block.h:48
@ liveBlock
Live control block type.
Definition: juce_Block.h:46
virtual Type getType() const =0
Returns the type of this device.
@ loopBlock
Loop control block type.
Definition: juce_Block.h:47
virtual LEDRow * getLEDRow()=0
If this block has a row of LEDs, this will return an object to control it.
Represents an individual BLOCKS device.
Definition: juce_Block.h:32
A simple ARGB colour class for setting LEDs.
Definition: juce_LEDGrid.h:32
@ touchBlock
Touch control block type.
Definition: juce_Block.h:49