Browse Source

BLOCKS API: Added support for some extended topology messages

tags/2021-05-28
jules 8 years ago
parent
commit
84f4362a40
2 changed files with 36 additions and 4 deletions
  1. +13
    -0
      modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h
  2. +23
    -4
      modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h

+ 13
- 0
modules/juce_blocks_basics/protocol/juce_BlocksProtocolDefinitions.h View File

@@ -53,6 +53,8 @@ enum class MessageFromDevice
deviceTopology = 0x01,
packetACK = 0x02,
firmwareUpdateACK = 0x03,
deviceTopologyExtend = 0x04,
deviceTopologyEnd = 0x05,
touchStart = 0x10,
touchMove = 0x11,
@@ -153,6 +155,8 @@ struct DeviceConnection
ConnectorPort port1, port2;
};
static constexpr uint8 maxBlocksInTopologyPacket = 6;
static constexpr uint8 maxConnectionsInTopologyPacket = 24;
//==============================================================================
/** The coordinates of a touch. */
@@ -299,6 +303,14 @@ static constexpr const char* ledProgramLittleFootFunctions[] =
"getBlockTypeForID/ii",
"sendMessageToBlock/viiii",
"sendMessageToHost/viii",
"getHorizontalDistFromMaster/i",
"getVerticalDistFromMaster/i",
"getAngleFromMaster/i",
"setAutoRotate/vb",
"getClusterWidth/i",
"getClusterHeight/i",
"getClusterXpos/i",
"getClusterYpos/i",
"makeARGB/iiiii",
"blendARGB/iii",
"fillPixel/viii",
@@ -306,6 +318,7 @@ static constexpr const char* ledProgramLittleFootFunctions[] =
"fillRect/viiiii",
"blendRect/viiiii",
"blendGradientRect/viiiiiiii",
"blendCircle/vifffb",
"addPressurePoint/vifff",
"drawPressureMap/v",
"fadePressureMap/v",


+ 23
- 4
modules/juce_blocks_basics/protocol/juce_HostPacketDecoder.h View File

@@ -69,7 +69,9 @@ struct HostPacketDecoder
switch ((MessageFromDevice) messageType)
{
case MessageFromDevice::deviceTopology: return handleTopology (handler, reader);
case MessageFromDevice::deviceTopology: return handleTopology (handler, reader, true);
case MessageFromDevice::deviceTopologyExtend: return handleTopology (handler, reader, false);
case MessageFromDevice::deviceTopologyEnd: return handleTopologyEnd (handler, reader);
case MessageFromDevice::touchStart: return handleTouch (handler, reader, deviceIndex, packetTimestamp, true, false);
case MessageFromDevice::touchMove: return handleTouch (handler, reader, deviceIndex, packetTimestamp, false, false);
case MessageFromDevice::touchEnd: return handleTouch (handler, reader, deviceIndex, packetTimestamp, false, true);
@@ -90,7 +92,7 @@ struct HostPacketDecoder
}
}
static bool handleTopology (Handler& handler, Packed7BitArrayReader& reader)
static bool handleTopology (Handler& handler, Packed7BitArrayReader& reader, bool newTopology)
{
if (reader.getRemainingBits() < DeviceCount::bits + ConnectionCount::bits)
{
@@ -116,7 +118,8 @@ struct HostPacketDecoder
return false;
}
handler.beginTopology ((int) numDevices, (int) numConnections);
if (newTopology)
handler.beginTopology ((int) numDevices, (int) numConnections);
for (uint32 i = 0; i < numDevices; ++i)
handleTopologyDevice (handler, reader);
@@ -124,8 +127,24 @@ struct HostPacketDecoder
for (uint32 i = 0; i < numConnections; ++i)
handleTopologyConnection (handler, reader);
handler.endTopology();
// Packet must be last in topology, otherwise wait for topology end message
if (numDevices < maxBlocksInTopologyPacket && numConnections < maxConnectionsInTopologyPacket)
handler.endTopology();
return true;
}
static bool handleTopologyEnd (Handler& handler, Packed7BitArrayReader& reader)
{
auto deviceProtocolVersion = reader.read<ProtocolVersion>();
if (deviceProtocolVersion > currentProtocolVersion)
{
jassertfalse;
return false;
}
handler.endTopology();
return true;
}


Loading…
Cancel
Save