A LittleFoot example
The BitmapLEDProgram class is a simple example of a LittleFoot program.
roli_blocks_basics/visualisers/roli_BitmapLEDProgram.h
{
{
private:
juce::String getLittleFootProgram() override;
};
}
Represents an individual BLOCKS device.
Definition: roli_Block.h:31
Definition: roli_BlockConfigId.h:28
A simple Program to set the colours of individual LEDs.
Definition: roli_BitmapLEDProgram.h:31
A program that can be loaded onto a block.
Definition: roli_Block.h:242
A simple ARGB colour class for setting LEDs.
Definition: roli_LEDGrid.h:31
roli_blocks_basics/visualisers/roli_BitmapLEDProgram.cpp
{
{
{
if (x < w && y < h)
{
auto bit = (x + y * w) * 16;
}
}
else
{
jassertfalse;
}
}
juce::String BitmapLEDProgram::getLittleFootProgram()
{
juce::String program (R"littlefoot(
#heapsize: 15 * 15 * 2
void repaint()
{
for (int y = 0; y < NUM_ROWS; ++y)
{
for (int x = 0; x < NUM_COLUMNS; ++x)
{
int bit = (x + y * NUM_COLUMNS) * 16;
fillPixel (makeARGB (255,
getHeapBits (bit, 5) << 3,
getHeapBits (bit + 5, 6) << 2,
getHeapBits (bit + 11, 5) << 3), x, y);
}
}
}
)littlefoot");
return program.replace ("NUM_COLUMNS", juce::String (ledGrid->getNumColumns()))
.replace ("NUM_ROWS", juce::String (ledGrid->getNumRows()));
jassertfalse;
return {};
}
}
virtual void setDataBits(juce::uint32 startBit, juce::uint32 numBits, juce::uint32 value)=0
Sets multiple bits on the littlefoot heap.
virtual LEDGrid * getLEDGrid() const =0
If this block has a grid of LEDs, this will return an object to control it.
BitmapLEDProgram(Block &)
void setLED(juce::uint32 x, juce::uint32 y, LEDColour)
Set the colour of the LED at coordinates {x, y}.
Block & block
Definition: roli_Block.h:252
juce::uint8 getBlue() const noexcept
Definition: roli_LEDGrid.h:44
juce::uint8 getRed() const noexcept
Definition: roli_LEDGrid.h:42
juce::uint8 getGreen() const noexcept
Definition: roli_LEDGrid.h:43
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. To update the heap, and hence the LEDs, your application code calls BitmapLEDProgram::setLED().
A more advanced example can be found in the source code of the DrumPadGridProgram class or in the BlocksSynth example.