mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-19 01:04:20 +00:00
BLOCKS SDK: New and updated version of juce_blocks_basics, adding functionality and compatibility with latest Dashboard-compatible firmware
This commit is contained in:
parent
beab10fca7
commit
f207ebb6d8
19 changed files with 1302 additions and 566 deletions
|
|
@ -233,7 +233,7 @@ public:
|
|||
scaleX = (float) (grid->getNumColumns()) / activeBlock->getWidth();
|
||||
scaleY = (float) (grid->getNumRows()) / activeBlock->getHeight();
|
||||
|
||||
setLEDProgram (grid);
|
||||
setLEDProgram (*activeBlock);
|
||||
}
|
||||
|
||||
// Make the on screen Lighpad component visible
|
||||
|
|
@ -286,7 +286,7 @@ private:
|
|||
{
|
||||
// Switch to canvas mode and set the LEDGrid program
|
||||
currentMode = canvas;
|
||||
setLEDProgram (activeBlock->getLEDGrid());
|
||||
setLEDProgram (*activeBlock);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -325,7 +325,7 @@ private:
|
|||
{
|
||||
// Switch to colour palette mode and set the LEDGrid program
|
||||
currentMode = colourPalette;
|
||||
setLEDProgram (activeBlock->getLEDGrid());
|
||||
setLEDProgram (*activeBlock);
|
||||
}
|
||||
|
||||
stopTimer();
|
||||
|
|
@ -350,7 +350,7 @@ private:
|
|||
}
|
||||
|
||||
/** Sets the LEDGrid Program for the selected mode */
|
||||
void setLEDProgram (LEDGrid* grid)
|
||||
void setLEDProgram (Block& block)
|
||||
{
|
||||
canvasProgram = nullptr;
|
||||
colourPaletteProgram = nullptr;
|
||||
|
|
@ -358,10 +358,10 @@ private:
|
|||
if (currentMode == canvas)
|
||||
{
|
||||
// Create a new BitmapLEDProgram for the LEDGrid
|
||||
canvasProgram = new BitmapLEDProgram (*grid);
|
||||
canvasProgram = new BitmapLEDProgram (block);
|
||||
|
||||
// Set the LEDGrid program
|
||||
grid->setProgram (canvasProgram);
|
||||
block.setProgram (canvasProgram);
|
||||
|
||||
// Redraw any previously drawn LEDs
|
||||
redrawLEDs();
|
||||
|
|
@ -369,10 +369,10 @@ private:
|
|||
else if (currentMode == colourPalette)
|
||||
{
|
||||
// Create a new DrumPadGridProgram for the LEDGrid
|
||||
colourPaletteProgram = new DrumPadGridProgram (*grid);
|
||||
colourPaletteProgram = new DrumPadGridProgram (block);
|
||||
|
||||
// Set the LEDGrid program
|
||||
grid->setProgram (colourPaletteProgram);
|
||||
block.setProgram (colourPaletteProgram);
|
||||
|
||||
// Setup the grid layout
|
||||
colourPaletteProgram->setGridFills (layout.numColumns,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
// If this is a Lightpad then set the grid program to be blank
|
||||
if (auto grid = block->getLEDGrid())
|
||||
grid->setProgram (new BitmapLEDProgram(*grid));
|
||||
block->setProgram (new BitmapLEDProgram (*block));
|
||||
|
||||
// If this is a Lightpad then redraw it at 25Hz
|
||||
if (block->getType() == Block::lightPadBlock)
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ public:
|
|||
scaleX = static_cast<float> (grid->getNumColumns() - 1) / activeBlock->getWidth();
|
||||
scaleY = static_cast<float> (grid->getNumRows() - 1) / activeBlock->getHeight();
|
||||
|
||||
setLEDProgram (grid);
|
||||
setLEDProgram (*activeBlock);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -227,7 +227,7 @@ private:
|
|||
currentMode = waveformSelectionMode;
|
||||
|
||||
// Set the LEDGrid program to the new mode
|
||||
setLEDProgram (activeBlock->getLEDGrid());
|
||||
setLEDProgram (*activeBlock);
|
||||
}
|
||||
|
||||
#if JUCE_IOS
|
||||
|
|
@ -259,15 +259,15 @@ private:
|
|||
}
|
||||
|
||||
/** Sets the LEDGrid Program for the selected mode */
|
||||
void setLEDProgram (LEDGrid* grid)
|
||||
void setLEDProgram (Block& block)
|
||||
{
|
||||
if (currentMode == waveformSelectionMode)
|
||||
{
|
||||
// Create a new WaveshapeProgram for the LEDGrid
|
||||
waveshapeProgram = new WaveshapeProgram (*grid);
|
||||
waveshapeProgram = new WaveshapeProgram (block);
|
||||
|
||||
// Set the LEDGrid program
|
||||
grid->setProgram (waveshapeProgram);
|
||||
block.setProgram (waveshapeProgram);
|
||||
|
||||
// Initialise the program
|
||||
waveshapeProgram->setWaveshapeType (static_cast<uint8> (waveshapeMode));
|
||||
|
|
@ -276,10 +276,16 @@ private:
|
|||
else if (currentMode == playMode)
|
||||
{
|
||||
// Create a new DrumPadGridProgram for the LEDGrid
|
||||
gridProgram = new DrumPadGridProgram (*grid);
|
||||
gridProgram = new DrumPadGridProgram (block);
|
||||
|
||||
// Set the LEDGrid program
|
||||
grid->setProgram (gridProgram);
|
||||
auto error = block.setProgram (gridProgram);
|
||||
|
||||
if (error.failed())
|
||||
{
|
||||
DBG (error.getErrorMessage());
|
||||
jassertfalse;
|
||||
}
|
||||
|
||||
// Setup the grid layout
|
||||
gridProgram->setGridFills (layout.numColumns,
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@
|
|||
/**
|
||||
A Program to draw moving waveshapes onto the LEDGrid
|
||||
*/
|
||||
class WaveshapeProgram : public LEDGrid::Program
|
||||
class WaveshapeProgram : public Block::Program
|
||||
{
|
||||
public:
|
||||
WaveshapeProgram (LEDGrid& lg) : Program (lg) {}
|
||||
WaveshapeProgram (Block& b) : Program (b) {}
|
||||
|
||||
/** Sets the waveshape type to display on the grid */
|
||||
void setWaveshapeType (uint8 type)
|
||||
{
|
||||
ledGrid.setDataByte (0, type);
|
||||
block.setDataByte (0, type);
|
||||
}
|
||||
|
||||
/** Generates the Y coordinates for 1.5 cycles of each of the four waveshapes and stores them
|
||||
|
|
@ -74,22 +74,19 @@ public:
|
|||
// Store the values for each of the waveshapes at the correct offsets in the shared data heap
|
||||
for (uint8 i = 0; i < 45; ++i)
|
||||
{
|
||||
ledGrid.setDataByte (sineWaveOffset + i, sineWaveY[i]);
|
||||
ledGrid.setDataByte (squareWaveOffset + i, squareWaveY[i]);
|
||||
ledGrid.setDataByte (sawWaveOffset + i, sawWaveY[i]);
|
||||
ledGrid.setDataByte (triangleWaveOffset + i, triangleWaveY[i]);
|
||||
block.setDataByte (sineWaveOffset + i, sineWaveY[i]);
|
||||
block.setDataByte (squareWaveOffset + i, squareWaveY[i]);
|
||||
block.setDataByte (sawWaveOffset + i, sawWaveY[i]);
|
||||
block.setDataByte (triangleWaveOffset + i, triangleWaveY[i]);
|
||||
}
|
||||
}
|
||||
|
||||
uint32 getHeapSize() override
|
||||
{
|
||||
return totalDataSize;
|
||||
}
|
||||
|
||||
String getLittleFootProgram() override
|
||||
{
|
||||
return R"littlefoot(
|
||||
|
||||
#heapsize: 256
|
||||
|
||||
int yOffset;
|
||||
|
||||
int min (int a, int b)
|
||||
|
|
@ -173,8 +170,6 @@ private:
|
|||
static constexpr uint32 sawWaveOffset = 91; // 1 byte * 45
|
||||
static constexpr uint32 triangleWaveOffset = 136; // 1 byte * 45
|
||||
|
||||
static constexpr uint32 totalDataSize = triangleWaveOffset + 45;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WaveshapeProgram)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue