LittleFoot Functions
juce_blocks_basics

Functions available in the LittleFoot language. More...

## Enumerations

enum | ControlType { internalConfig = 0, midiCC, sysex }
| Control type for use with initControl. More...
enum | ControlMode { toggle = 0, togglePulse, gate, trigger, cycle, incDec, triState }
| Control mode for use with initControl. More...

## Functions

int | getHeapByte (int byteIndex)
| Reads and returns the value of a single byte from the heap. More...
int | getHeapInt (int byteIndex)
| Reads 4 bytes from the heap and returns the value as an integer. More...
int | getHeapBits (int startBitIndex, int numBits)
| Reads a sequence of bits from the heap and returns the value as an integer. More...
void | setHeapByte (int byteIndex, int newValue)
| Writes a single byte to the heap. More...
void | setHeapInt (int byteIndex, int newValue)
| Writes 4 bytes to the heap. More...
int | min (int a, int b)
| Returns the smaller of two integer values. More...
float | min (float a, float b)
| Returns the smaller of two floating point values. More...
int | max (int a, int b)
| Returns the larger of two integer values. More...
float | max (float a, float b)
| Returns the larger of two floating point values. More...
int | clamp (int lowerLimit, int upperLimit, int valueToConstrain)
| Constrains an integer value to keep it within a given range. More...
float | clamp (float lowerLimit, float upperLimit, float valueToConstrain)
| Constrains a floating point value to keep it within a given range. More...
int | abs (int arg)
| Returns the absolute value of an integer value. More...
float | abs (float arg)
| Returns the absolute value of a floating point value. More...
float | map (float value, float sourceMin, float sourceMax, float destMin, float destMax)
| Remaps a value from a source range to a target range. More...
float | map (float value, float sourceMin, float sourceMax)
| Remaps a value from a source range to the range 0 - 1.0. More...
int | mod (int dividend, int divisor)
| Performs a modulo operation (can cope with the dividend being negative). More...
float | getRandomFloat ()
| Returns a random floating-point number. More...
int | getRandomInt (int maxValue)
| Returns a random integer, limited to a given range. More...
int | getMillisecondCounter ()
| Returns the number of milliseconds since a fixed event (usually system startup). More...
int | getTimeInCurrentFunctionCall ()
| Returns the length of time spent in the current function call in milliseconds. More...
void | log (int data)
| Logs an integer value to the console. More...
void | logHex (int data)
| Logs a hexadecimal value to the console. More...
void | sendMIDI (int byte0)
| Sends a 1-byte short midi message. More...
void | sendMIDI (int byte0, int byte1)
| Sends a 2-byte short midi message. More...
void | sendMIDI (int byte0, int byte1, int byte2)
| Sends a 3-byte short midi message. More...
void | sendNoteOn (int channel, int noteNumber, int velocity)
| Sends a key-down message. More...
void | sendNoteOff (int channel, int noteNumber, int velocity)
| Sends a key-up message. More...
void | sendAftertouch (int channel, int noteNumber, int level)
| Sends an aftertouch message. More...
void | sendCC (int channel, int controller, int value)
| Sends a controller message. More...
void | sendPitchBend (int channel, int position)
| Sends a pitch bend message. More...
void | sendChannelPressure (int channel, int pressure)
| Sends a channel-pressure change event. More...
void | setChannelRange (bool useMPE, int lowChannel, int highChannel)
| Sets the MIDI channel range. More...
int | assignChannel (int noteNumber)
| Assigns a MIDI channel to a note number. More...
void | deassignChannel (int noteNumber, int channel)
| Deassigns a channel from a note number. More...
int | getControlChannel ()
| Returns the channel that is being used for control messages. More...
void | useMPEDuplicateFilter (bool active)
| Sets whether duplicate notes should be filtered out when MPE is enabled. More...
void | repaint ()
| Use this method to draw the display. More...
void | handleButtonDown (int index)
| Called when a button is pushed. More...
void | handleButtonUp (int index)
| Called when a button is released. More...
void | onControlPress (int buttonIndex)
| Call this when a control block button is pressed to trigger the buttons default behaviour. More...
void | onControlRelease (int buttonIndex)
| Call this when a control block button is released to trigger the buttons default behaviour. More...
void | touchStart (int index, float x, float y, float z, float vz)
| Called when a touch event starts. More...
void | touchMove (int index, float x, float y, float z, float vz)
| Called when a touch event moves. More...
void | touchEnd (int index, float x, float y, float z, float vz)
| Called when a touch event ends. More...
void | initialise ()
| Called when a program is loaded onto the block and is about to start. More...
void | handleMIDI (int byte0, int byte1, int byte2)
| Called when a block receives a MIDI message. More...
void | handleMessage (int param1, int param2, int param3)
| Called when a block receives a message. More...
int | makeARGB (int alpha, int red, int green, int blue)
| Combines a set of 8-bit ARGB values into a 32-bit colour and returns the result. More...
int | blendARGB (int baseColour, int overlaidColour)
| Blends the overlaid ARGB colour onto the base one and returns the new colour. More...
void | displayBatteryLevel ()
| Displays an animation indicating the current battery level of this block. More...
void | clearDisplay ()
| Clears the display and sets all the LEDs to black. More...
void | clearDisplay (int rgb)
| Clears the display and sets all the LEDs to a specified colour. More...
void | fillPixel (int rgb, int x, int y)
| Sets a pixel to a specified colour with full alpha. More...
void | blendPixel (int argb, int x, int y)
| Blends the current pixel colour with a specified colour. More...
void | fillRect (int rgb, int x, int y, int width, int height)
| Fills a rectangle on the display with a specified colour. More...
void | blendRect (int argb, int x, int y, int width, int height)
| Blends a rectangle on the display with a specified colour. More...
void | blendGradientRect (int colourNW, int colourNE, int colourSE, int colourSW, int x, int y, int width, int height)
| Fills a rectangle on the display with four corner colours blended together. More...
void | blendCircle (int argb, float xCentre, float yCentre, float radius, bool fill)
| Blends a circle on the display with a specified colour. More...
void | drawNumber (int value, int colour, int x, int y)
| Draws a number on the display. More...
int | getFirmwareVersion ()
| Returns the current firmware version of this block. More...
float | getBatteryLevel ()
| Returns the battery level of this block, between 0 and 1.0. More...
bool | isBatteryCharging ()
| Returns true if this block's battery is charging. More...
void | setStatusOverlayActive (bool active)
| Sets whether status overlays should be displayed on this block. More...
void | setPowerSavingEnabled (bool enabled)
| Sets whether power saving mode should be enabled on this block. More...
int | getBlockTypeForID (int blockID)
| Returns the type of the block with a given ID. More...
void | sendMessageToBlock (int blockID, int param1, int param2, int param3)
| Sends a message to the block with the specified ID. More...
void | sendMessageToHost (int param1, int param2, int param3)
| Sends a message to the host. More...
void | addPressurePoint (int argb, float touchX, float touchY, float touchZ)
| Draws a pressure point with a specified colour and pressure. More...
void | drawPressureMap ()
| Draws the pressure map on the display. More...
void | fadePressureMap ()
| Fades the pressure map on the display. More...
void | linkBlockIDtoController (int blockID)
| Links a another block to this control block. More...
void | repaintControl ()
| Repaints the control block display. More...
void | initControl (int buttonIndex, int modeToUse, int outputType, int val, int min, int max, int index, int onColourToUse, int offColourToUse)
| Initialises one of the control block buttons. More...
void | handleTouchAsSeaboard (int touchIndex)
| Forces a touch event to be handled as seaboard playing. More...
int | getNumBlocksInTopology ()
| Returns the number of blocks in the current topology. More...
int | getBlockIDForIndex (int index)
| Returns the ID of a block at a given index in the topology. More...
bool | isMasterBlock ()
| Returns true if this block is directly connected to the host, as opposed to only being connected to a different block via a connection port. More...
bool | isConnectedToHost ()
| Returns true if this block is connected to the host computer, this can be directly or through connections to other blocks. More...
int | getBlockIDOnPort (int port)
| Returns the ID of a block connected to a specified port on this block. More...
int | getPortToMaster ()
| Returns the port number that is connected to the master block. More...
int | getHorizontalDistFromMaster ()
| Returns the horizontal distance between this block and the master block in block units. More...
int | getVerticalDistFromMaster ()
| Returns the vertical distance between this block and the master block in block units. More...
int | getAngleFromMaster ()
| Returns the angle of this block relative to the master block in degrees. More...
void | setAutoRotate (bool enabled)
| Sets whether this block should auto-rotate when its angle relative to the master block changes. More...
int | getClusterIndex ()
| Returns the index of this block in the current cluster. More...
int | getClusterWidth ()
| Returns how many blocks wide the current cluster is. More...
int | getClusterHeight ()
| Returns how many blocks high the current cluster is. More...
int | getClusterXpos ()
| Returns the x index of this block in the current cluster. More...
int | getClusterYpos ()
| Returns the y index of this block in the current cluster. More...
int | getNumBlocksInCurrentCluster ()
| Returns the number of blocks in the current cluster. More...
int | getBlockIdForBlockInCluster (int index)
| Returns the block ID for a block in the current cluster. More...
bool | isMasterInCurrentCluster ()
| Returns true if the master block is in the current cluster. More...
int | getLocalConfig (int item)
| Returns current value of one of the local config items. More...
void | setLocalConfig (int item, int value)
| Sets the current value of one of the local config items. More...
void | requestRemoteConfig (int longAddress, int item)
| Sets the local config of a block to the config item of a remote block. More...
void | setRemoteConfig (int longAddress, int item, int value)
| Sets the config of a remote block. More...
void | setLocalConfigItemRange (int item, int min, int max)
| Sets the range of one of the local config items. More...
void | setLocalConfigActiveState (int item, bool isActive, bool saveToFlash)
| Sets whether a local config item should be active. More...

## Detailed Description

Functions available in the LittleFoot language.

## Enumeration Type Documentation

## ControlType

enum ControlType

Control type for use with initControl.

See also
  initControl

Enumerator
internalConfig |
midiCC |
sysex |

## ControlMode

enum ControlMode

Control mode for use with initControl.

See also
  initControl

Enumerator
toggle |
togglePulse |
gate |
trigger |
cycle |
incDec |
triState |

## Function Documentation

## getHeapByte()

int getHeapByte | ( | int | byteIndex | ) |

Reads and returns the value of a single byte from the heap.

Parameters

  byteIndex | the index (in bytes) of the byte to read

Returns
  the value of the byte

## getHeapInt()

int getHeapInt | ( | int | byteIndex | ) |

Reads 4 bytes from the heap and returns the value as an integer.

Parameters

  byteIndex | the index (in bytes) of the start of the 4 bytes to read

Returns
  the value of the 4 bytes as an integer

## getHeapBits()

int getHeapBits | ( | int | startBitIndex,
|  | int | numBits
| ) |  |

Reads a sequence of bits from the heap and returns the value as an integer.

Parameters

  startBitIndex | the index (in bits) of the start of the sequence of bits to read
  numBits | how many bits to read

Returns
  the value of the sequence of bits as an integer

## setHeapByte()

void setHeapByte | ( | int | byteIndex,
|  | int | newValue
| ) |  |

Writes a single byte to the heap.

Parameters

  byteIndex | the index (in bytes) of the byte to set
  newValue | the new value to set this byte to

## setHeapInt()

void setHeapInt | ( | int | byteIndex,
|  | int | newValue
| ) |  |

Writes 4 bytes to the heap.

Parameters

  byteIndex | the index (in bytes) of the start of the 4 bytes to set
  newValue | the new value to set the 4 bytes to

## min() [1/2]

int min | ( | int | a,
|  | int | b
| ) |  |

Returns the smaller of two integer values.

Parameters

  a | The first parameter
  b | The second parameter

Return values

  The | minimum of a and b

Referenced by approximatelyEqual(), BlocksProtocol::HostPacketDecoder< Handler >::handleConfigMessage(), BlockConfigManager::handleConfigUpdateMessage(), dsp::SIMDRegister< Type >::min(), BlockConfigManager::setItemMin(), and BlockConfigManager::ConfigDescription::toConfigMetaData().

## min() [2/2]

float min | ( | float | a,
|  | float | b
| ) |  |

Returns the smaller of two floating point values.

Parameters

  a | The first parameter
  b | The second parameter

Return values

  The | minimum of a and b

## max() [1/2]

int max | ( | int | a,
|  | int | b
| ) |  |

Returns the larger of two integer values.

Parameters

  a | The first parameter
  b | The second parameter

Return values

  The | maximum of a and b

Referenced by String::appendCharPointer(), approximatelyEqual(), BlocksProtocol::HostPacketDecoder< Handler >::handleConfigMessage(), BlockConfigManager::handleConfigUpdateMessage(), dsp::SIMDRegister< Type >::max(), BlockConfigManager::setItemMax(), BlockConfigManager::ConfigDescription::toConfigMetaData(), String::toDecimalStringWithSignificantFigures(), and truncatePositiveToUnsignedInt().

## max() [2/2]

float max | ( | float | a,
|  | float | b
| ) |  |

Returns the larger of two floating point values.

Parameters

  a | The first parameter
  b | The second parameter

Return values

  The | maximum of a and b

## clamp() [1/2]

int clamp | ( | int | lowerLimit,
|  | int | upperLimit,
|  | int | valueToConstrain
| ) |  |

Constrains an integer value to keep it within a given range.

Parameters

  lowerLimit | the minimum value to return
  upperLimit | the maximum value to return
  valueToConstrain | the value to try to return

Returns
  the closest value to valueToConstrain which lies between lowerLimit and upperLimit (inclusive)

## clamp() [2/2]

float clamp | ( | float | lowerLimit,
|  | float | upperLimit,
|  | float | valueToConstrain
| ) |  |

Constrains a floating point value to keep it within a given range.

Parameters

  lowerLimit | the minimum value to return
  upperLimit | the maximum value to return
  valueToConstrain | the value to try to return

Returns
  the closest value to valueToConstrain which lies between lowerLimit and upperLimit (inclusive)

## abs() [1/2]

int abs | ( | int | arg | ) |

Returns the absolute value of an integer value.

Parameters

  arg | The argument to compute the absolute value of

Return values

  either | -arg if arg is negative or arg if arg is positive

Referenced by approximatelyEqual(), NormalisableRange< float >::convertFrom0to1(), NormalisableRange< float >::convertTo0to1(), UnitTest::expectWithinAbsoluteError(), AnimatedPositionBehaviours::ContinuousWithMomentum::getNextPosition(), AnimatedPositionBehaviours::SnapToPageBoundaries::isStopped(), isWithin(), and SmoothedValue< Type >::setStepSize().

## abs() [2/2]

float abs | ( | float | arg | ) |

Returns the absolute value of a floating point value.

Parameters

  arg | The argument to compute the absolute value of

Return values

  either | -arg if arg is negative or arg if arg is positive

## map() [1/2]

float map | ( | float | value,
|  | float | sourceMin,
|  | float | sourceMax,
|  | float | destMin,
|  | float | destMax
| ) |  |

Remaps a value from a source range to a target range.

Parameters

  value | the value within the source range to map
  sourceMin | the minimum value of the source range
  sourceMax | the maximum value of the source range
  destMin | the minimum value of the destination range
  destMax | the maximum value of the destination range

Returns
  the original value mapped to the destination range

Referenced by MemoryMappedAudioFormatReader::getNumBytesUsed(), and MemoryMappedAudioFormatReader::sampleToPointer().

## map() [2/2]

float map | ( | float | value,
|  | float | sourceMin,
|  | float | sourceMax
| ) |  |

Remaps a value from a source range to the range 0 - 1.0.

Parameters

  value | the value within the source range to map
  sourceMin | the minimum value of the source range
  sourceMax | the maximum value of the source range

Returns
  the original value mapped to the range 0 - 1.0

## mod()

int mod | ( | int | dividend,
|  | int | divisor
| ) |  |

Performs a modulo operation (can cope with the dividend being negative).

The divisor must be greater than zero.

Returns
  the result of the modulo operation

## getRandomFloat()

float getRandomFloat | ( |  | ) |

Returns a random floating-point number.

Returns
  a random value in the range 0 (inclusive) to 1.0 (exclusive)

## getRandomInt()

int getRandomInt | ( | int | maxValue | ) |

Returns a random integer, limited to a given range.

Returns
  a random integer between 0 (inclusive) and maxValue (exclusive).

## getMillisecondCounter()

int getMillisecondCounter | ( |  | ) |

Returns the number of milliseconds since a fixed event (usually system startup).

Returns
  a monotonically increasing value which is unaffected by changes to the system clock. It should be accurate to within a few millisecseconds.

## getTimeInCurrentFunctionCall()

int getTimeInCurrentFunctionCall | ( |  | ) |

Returns the length of time spent in the current function call in milliseconds.

Returns
  the length of time spent in the current function call in milliseconds.

## log()

void log | ( | int | data | ) |

Logs an integer value to the console.

Parameters

  data | The 32 bit signed integer to log to the topology as an integer

Referenced by NormalisableRange< float >::convertFrom0to1(), NormalisableRange< float >::setSkewForCentre(), and SmoothedValue< Type >::setStepSize().

## logHex()

void logHex | ( | int | data | ) |

Logs a hexadecimal value to the console.

Parameters

  data | The 32 bit signed integer to log to the topology as a hexidecimal int

## sendMIDI() [1/3]

void sendMIDI | ( | int | byte0 | ) |

Sends a 1-byte short midi message.

## sendMIDI() [2/3]

void sendMIDI | ( | int | byte0,
|  | int | byte1
| ) |  |

Sends a 2-byte short midi message.

## sendMIDI() [3/3]

void sendMIDI | ( | int | byte0,
|  | int | byte1,
|  | int | byte2
| ) |  |

Sends a 3-byte short midi message.

## sendNoteOn()

void sendNoteOn | ( | int | channel,
|  | int | noteNumber,
|  | int | velocity
| ) |  |

Sends a key-down message.

Parameters

  channel | the midi channel, in the range 0 to 15
  noteNumber | the key number, in the range 0 to 127
  velocity | the velocity, in the range 0 to 127

## sendNoteOff()

void sendNoteOff | ( | int | channel,
|  | int | noteNumber,
|  | int | velocity
| ) |  |

Sends a key-up message.

Parameters

  channel | the midi channel, in the range 0 to 15
  noteNumber | the key number, in the range 0 to 127
  velocity | the velocity, in the range 0 to 127

## sendAftertouch()

void sendAftertouch | ( | int | channel,
|  | int | noteNumber,
|  | int | level
| ) |  |

Sends an aftertouch message.

Parameters

  channel | the midi channel, in the range 0 to 15
  noteNumber | the key number, in the range 0 to 127
  level | the amount of aftertouch, in the range 0 to 127

## sendCC()

void sendCC | ( | int | channel,
|  | int | controller,
|  | int | value
| ) |  |

Sends a controller message.

Parameters

  channel | the midi channel, in the range 0 to 15
  controller | the type of controller
  value | the controller value

## sendPitchBend()

void sendPitchBend | ( | int | channel,
|  | int | position
| ) |  |

Sends a pitch bend message.

Parameters

  channel | the midi channel, in the range 0 to 15
  position | the wheel position, in the range 0 to 16383

## sendChannelPressure()

void sendChannelPressure | ( | int | channel,
|  | int | pressure
| ) |  |

Sends a channel-pressure change event.

Parameters

  channel | the midi channel, in the range 0 to 15
  pressure | the pressure, in the range 0 to 127

## setChannelRange()

void setChannelRange | ( | bool | useMPE,
|  | int | lowChannel,
|  | int | highChannel
| ) |  |

Sets the MIDI channel range.

Parameters

  useMPE | whether to use MPE mode
  lowChannel | the lowest MIDI channel
  highChannel | the highest MIDI channel

## assignChannel()

int assignChannel | ( | int | noteNumber | ) |

Assigns a MIDI channel to a note number.

Parameters

  noteNumber | the note number to assign the channel to

Returns
  the MIDI channel that has been assigned

## deassignChannel()

void deassignChannel | ( | int | noteNumber,
|  | int | channel
| ) |  |

Deassigns a channel from a note number.

Parameters

  noteNumber | the note number to deassign
  channel | the MIDI channel

## getControlChannel()

int getControlChannel | ( |  | ) |

Returns the channel that is being used for control messages.

Returns
  the channel that is being used for control messages. (If MPE is enabled then this will be the first channel.)

## useMPEDuplicateFilter()

void useMPEDuplicateFilter | ( | bool | active | ) |

Sets whether duplicate notes should be filtered out when MPE is enabled.

## repaint()

void repaint | ( |  | ) |

Use this method to draw the display.

The block will call this approximately 25 times per second.

## handleButtonDown()

void handleButtonDown | ( | int | index | ) |

Called when a button is pushed.

Parameters

  index | the index of the button that was pushed

## handleButtonUp()

void handleButtonUp | ( | int | index | ) |

Called when a button is released.

Parameters

  index | the index of the button that was released

## onControlPress()

void onControlPress | ( | int | buttonIndex | ) |

Call this when a control block button is pressed to trigger the buttons default behaviour.

Parameters

  buttonIndex | the index of the button

Note
  Requires >= 0.2.5 firmware
  Only valid with a control block

See also
  initControl onControlRelease

## onControlRelease()

void onControlRelease | ( | int | buttonIndex | ) |

Call this when a control block button is released to trigger the buttons default behaviour.

Parameters

  buttonIndex | the index of the button

Note
  Requires >= 0.2.5 firmware
  Only valid with a control block

See also
  initControl onControlPress

## touchStart()

void touchStart | ( | int | index,
|  | float | x,
|  | float | y,
|  | float | z,
|  | float | vz
| ) |  |

Called when a touch event starts.

Block units follow the number of DNA connectors on the side of the device. For instance, a Lightpad Block is 2x2 and a Control Block is 2x1.

Parameters

  index | the touch index, which will stay constant for each finger as it is tracked
  x | the X position of this touch on the device, in block units starting from 0 (left)
  y | the Y position of this touch on the device, in block units starting from 0 (top)
  z | the current pressure of this touch, in the range 0.0 (no pressure) to 1.0 (very hard)
  vz | the rate at which pressure is currently changing, measured in units/second

## touchMove()

void touchMove | ( | int | index,
|  | float | x,
|  | float | y,
|  | float | z,
|  | float | vz
| ) |  |

Called when a touch event moves.

Block units follow the number of DNA connectors on the side of the device. For instance, a Lightpad Block is 2x2 and a Control Block is 2x1.

Parameters

  index | the touch index, which will stay constant for each finger as it is tracked
  x | the X position of this touch on the device, in block units starting from 0 (left)
  y | the Y position of this touch on the device, in block units starting from 0 (top)
  z | the current pressure of this touch, in the range 0.0 (no pressure) to 1.0 (very hard)
  vz | the rate at which pressure is currently changing, measured in units/second

## touchEnd()

void touchEnd | ( | int | index,
|  | float | x,
|  | float | y,
|  | float | z,
|  | float | vz
| ) |  |

Called when a touch event ends.

Block units follow the number of DNA connectors on the side of the device. For instance, a Lightpad Block is 2x2 and a Control Block is 2x1.

Parameters

  index | the touch index, which will stay constant for each finger as it is tracked
  x | the X position of this touch on the device, in block units starting from 0 (left)
  y | the Y position of this touch on the device, in block units starting from 0 (top)
  z | the current pressure of this touch, in the range 0.0 (no pressure) to 1.0 (very hard)
  vz | the rate at which pressure is currently changing, measured in units/second

## initialise()

void initialise | ( |  | ) |

Called when a program is loaded onto the block and is about to start.

Do any setup here.

## handleMIDI()

void handleMIDI | ( | int | byte0,
|  | int | byte1,
|  | int | byte2
| ) |  |

Called when a block receives a MIDI message.

## handleMessage()

void handleMessage | ( | int | param1,
|  | int | param2,
|  | int | param3
| ) |  |

Called when a block receives a message.

See also
  sendMessageToBlock

## makeARGB()

int makeARGB | ( | int | alpha,
|  | int | red,
|  | int | green,
|  | int | blue
| ) |  |

Combines a set of 8-bit ARGB values into a 32-bit colour and returns the result.

Returns
  a 32-bit colour

Parameters

  alpha | The alpha in range 0 - 255 inclusive
  red | The red in range 0 - 255 inclusive
  green | The green in range 0 - 255 inclusive
  blue | The blue in range 0 - 255 inclusive

## blendARGB()

int blendARGB | ( | int | baseColour,
|  | int | overlaidColour
| ) |  |

Blends the overlaid ARGB colour onto the base one and returns the new colour.

Parameters

  baseColour | the colour to blend on to
  overlaidColour | The colour to blend in to the baseColour

Returns
  The blended colour

## displayBatteryLevel()

void displayBatteryLevel | ( |  | ) |

Displays an animation indicating the current battery level of this block.

A control block will light up its top LEDs indicating battery level and a lightpad block will draw the battery level on the display.

Note
  Requires >= 0.2.5 firmware

## clearDisplay() [1/2]

void clearDisplay | ( |  | ) |

Clears the display and sets all the LEDs to black.

## clearDisplay() [2/2]

void clearDisplay | ( | int | rgb | ) |

Clears the display and sets all the LEDs to a specified colour.

Parameters

  rgb | the colour to use (0xff...)

## fillPixel()

void fillPixel | ( | int | rgb,
|  | int | x,
|  | int | y
| ) |  |

Sets a pixel to a specified colour with full alpha.

Parameters

  rgb | the colour to use (0xff...)
  x | the x coordinate of the pixel to fill
  y | the y coordinate of the pixel to fill

## blendPixel()

void blendPixel | ( | int | argb,
|  | int | x,
|  | int | y
| ) |  |

Blends the current pixel colour with a specified colour.

Parameters

  argb | the colour to use
  x | the x coordinate of the pixel to blend
  y | the y coordinate of the pixel to blend

## fillRect()

void fillRect | ( | int | rgb,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height
| ) |  |

Fills a rectangle on the display with a specified colour.

Parameters

  rgb | the colour to use (0xff...)
  x | the x coordinate of the rectangle to draw
  y | the y coordinate of the rectangle to draw
  width | the width of the rectangle to draw
  height | the height of the rectangle to draw

## blendRect()

void blendRect | ( | int | argb,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height
| ) |  |

Blends a rectangle on the display with a specified colour.

Parameters

  argb | the colour to use
  x | the x coordinate of the rectangle to blend
  y | the y coordinate of the rectangle to blend
  width | the width of the rectangle to blend
  height | the height of the rectangle to blend

## blendGradientRect()

void blendGradientRect | ( | int | colourNW,
|  | int | colourNE,
|  | int | colourSE,
|  | int | colourSW,
|  | int | x,
|  | int | y,
|  | int | width,
|  | int | height
| ) |  |

Fills a rectangle on the display with four corner colours blended together.

Parameters

  colourNW | the colour to use in the north west corner of the rectangle
  colourNE | the colour to use in the north east corner of the rectangle
  colourSE | the colour to use in the south east corner of the rectangle
  colourSW | the colour to use in the south west corner of the rectangle
  x | the x coordinate of the rectangle
  y | the y coordinate of the rectangle
  width | the width of the rectangle
  height | the height of the rectangle

## blendCircle()

void blendCircle | ( | int | argb,
|  | float | xCentre,
|  | float | yCentre,
|  | float | radius,
|  | bool | fill
| ) |  |

Blends a circle on the display with a specified colour.

Parameters

  argb | the colour to use
  xCentre | the x position of the circle's centre in block units
  yCentre | the y position of the circle's centre in block units
  radius | the radius of the circle in block units
  fill | if true then the circle will be filled, if false the circle will be an outline

Note
  Requires >= 0.2.5 firmware

## drawNumber()

void drawNumber | ( | int | value,
|  | int | colour,
|  | int | x,
|  | int | y
| ) |  |

Draws a number on the display.

Parameters

  value | the number to draw between 0 and 99
  colour | the colour to use
  x | the x coordinate to use
  y | the y coordinate to use

## getFirmwareVersion()

int getFirmwareVersion | ( |  | ) |

Returns the current firmware version of this block.

Returns
  The firmware version of the form 0xMJMIRV (where MJ = Major, MI = Minor, RV = Revision)

Note
  Requires >= 0.2.5 firmware

## getBatteryLevel()

float getBatteryLevel | ( |  | ) |

Returns the battery level of this block, between 0 and 1.0.

Returns
  the battery level of this block, between 0 and 1.0.

Note
  Requires >= 0.2.5 firmware

## isBatteryCharging()

bool isBatteryCharging | ( |  | ) |

Returns true if this block's battery is charging.

Returns
  true if this block's battery is charging

Note
  Requires >= 0.2.5 firmware

## setStatusOverlayActive()

void setStatusOverlayActive | ( | bool | active | ) |

Sets whether status overlays should be displayed on this block.

Note
  Requires >= 0.2.5 firmware

## setPowerSavingEnabled()

void setPowerSavingEnabled | ( | bool | enabled | ) |

Sets whether power saving mode should be enabled on this block.

Note
  Requires >= 0.2.5 firmware

## getBlockTypeForID()

int getBlockTypeForID | ( | int | blockID | ) |

Returns the type of the block with a given ID.

Returns
  an enum indicating the type of block

See also
  Block::Type

Note
  Requires >= 0.2.5 firmware

## sendMessageToBlock()

void sendMessageToBlock | ( | int | blockID,
|  | int | param1,
|  | int | param2,
|  | int | param3
| ) |  |

Sends a message to the block with the specified ID.

This will be processed in the handleMessage() callback.

Parameters

  blockID | the ID of the block to send this message to
  param1 | the first chunk of data to send
  param2 | the second chunk of data to send
  param3 | the third chunk of data to send

## sendMessageToHost()

void sendMessageToHost | ( | int | param1,
|  | int | param2,
|  | int | param3
| ) |  |

Sends a message to the host.

To receive this the host will need to implement the Block::ProgramEventListener::handleProgramEvent() method.

Parameters

  param1 | the first chunk of data to send
  param2 | the second chunk of data to send
  param3 | the third chunk of data to send

## addPressurePoint()

void addPressurePoint | ( | int | argb,
|  | float | touchX,
|  | float | touchY,
|  | float | touchZ
| ) |  |

Draws a pressure point with a specified colour and pressure.

Parameters

  argb | the colour to use
  touchX | the x position of the touch in block units
  touchY | the y position of the touch in block units
  touchZ | the pressure value of the touch

## drawPressureMap()

void drawPressureMap | ( |  | ) |

Draws the pressure map on the display.

## fadePressureMap()

void fadePressureMap | ( |  | ) |

Fades the pressure map on the display.

## linkBlockIDtoController()

void linkBlockIDtoController | ( | int | blockID | ) |

Links a another block to this control block.

Parameters

  blockID | the ID of the block to link

Note
  Requires >= 0.2.5 firmware
  Only valid with a control block

## repaintControl()

void repaintControl | ( |  | ) |

Repaints the control block display.

Note
  Requires >= 0.2.5 firmware
  Only valid with a control block

## initControl()

void initControl | ( | int | buttonIndex,
|  | int | modeToUse,
|  | int | outputType,
|  | int | val,
|  | int | min,
|  | int | max,
|  | int | index,
|  | int | onColourToUse,
|  | int | offColourToUse
| ) |  |

Initialises one of the control block buttons.

Parameters

  buttonIndex | the index of the button to initialise
  modeToUse | the mode to use for this button

See also
  ControlMode

Parameters

  outputType | the control type to use

See also
  ControlType

Parameters

  val | the current value to set this button to
  min | the minimum value for this button
  max | the maximum value for this button
  index | the item index
  onColourToUse | the colour to use when this button is on
  offColourToUse | the colour to use when this button is off

Note
  Requires >= 0.2.5 firmware
  Only valid with a control block

## handleTouchAsSeaboard()

void handleTouchAsSeaboard | ( | int | touchIndex | ) |

Forces a touch event to be handled as seaboard playing.

Parameters

  touchIndex | the index of the touch event

Note
  Requires >= 0.2.5 firmware
  Only valid on a Seaboard

## getNumBlocksInTopology()

int getNumBlocksInTopology | ( |  | ) |

Returns the number of blocks in the current topology.

Note
  Requires >= 0.2.5 firmware

## getBlockIDForIndex()

int getBlockIDForIndex | ( | int | index | ) |

Returns the ID of a block at a given index in the topology.

Parameters

  index | The index of the block to find in the topology

Returns
  int The id of the block

Note
  Requires >= 0.2.5 firmware

## isMasterBlock()

bool isMasterBlock | ( |  | ) |

Returns true if this block is directly connected to the host, as opposed to only being connected to a different block via a connection port.

Note
  Requires >= 0.2.5 firmware

## isConnectedToHost()

bool isConnectedToHost | ( |  | ) |

Returns true if this block is connected to the host computer, this can be directly or through connections to other blocks.

Note
  Requires >= 0.2.5 firmware

## getBlockIDOnPort()

int getBlockIDOnPort | ( | int | port | ) |

Returns the ID of a block connected to a specified port on this block.

Note
  Requires >= 0.2.5 firmware

## getPortToMaster()

int getPortToMaster | ( |  | ) |

Returns the port number that is connected to the master block.

Returns 0xFF if there is no port connected to master.

Returns
  the port number that is connected to the master block. Returns 0xFF if there is no port connected to master.

Note
  Requires >= 0.2.5 firmware

## getHorizontalDistFromMaster()

int getHorizontalDistFromMaster | ( |  | ) |

Returns the horizontal distance between this block and the master block in block units.

Note
  Requires >= 0.2.5 firmware

## getVerticalDistFromMaster()

int getVerticalDistFromMaster | ( |  | ) |

Returns the vertical distance between this block and the master block in block units.

Note
  Requires >= 0.2.5 firmware

## getAngleFromMaster()

int getAngleFromMaster | ( |  | ) |

Returns the angle of this block relative to the master block in degrees.

Note
  Requires >= 0.2.5 firmware

## setAutoRotate()

void setAutoRotate | ( | bool | enabled | ) |

Sets whether this block should auto-rotate when its angle relative to the master block changes.

Note
  Requires >= 0.2.5 firmware

## getClusterIndex()

int getClusterIndex | ( |  | ) |

Returns the index of this block in the current cluster.

Note
  Requires >= 0.2.5 firmware

## getClusterWidth()

int getClusterWidth | ( |  | ) |

Returns how many blocks wide the current cluster is.

Returns
  the width of the cluster (note that a single block will return 1 here)

Note
  Requires >= 0.2.5 firmware

## getClusterHeight()

int getClusterHeight | ( |  | ) |

Returns how many blocks high the current cluster is.

Returns
  the height of the cluster (note that a single block will return 1 here)

Note
  Requires >= 0.2.5 firmware

## getClusterXpos()

int getClusterXpos | ( |  | ) |

Returns the x index of this block in the current cluster.

Returns
  int The cluster x position. (0, 0) is considered to be the top left block

Note
  Requires >= 0.2.5 firmware

## getClusterYpos()

int getClusterYpos | ( |  | ) |

Returns the y index of this block in the current cluster.

Returns
  int The cluster x position. (0, 0) is considered to be the top left block

Note
  Requires >= 0.2.5 firmware

## getNumBlocksInCurrentCluster()

int getNumBlocksInCurrentCluster | ( |  | ) |

Returns the number of blocks in the current cluster.

Returns
  the number of blocks in the current cluster.

Note
  Requires >= 0.2.5 firmware

## getBlockIdForBlockInCluster()

int getBlockIdForBlockInCluster | ( | int | index | ) |

Returns the block ID for a block in the current cluster.

Parameters

  index | the cluster index of the block to get the ID of

Note
  Requires >= 0.2.5 firmware

## isMasterInCurrentCluster()

bool isMasterInCurrentCluster | ( |  | ) |

Returns true if the master block is in the current cluster.

Note
  Requires >= 0.2.5 firmware

## getLocalConfig()

int getLocalConfig | ( | int | item | ) |

Returns current value of one of the local config items.

Parameters

  item | the config item to get (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)

Note
  Requires >= 0.2.5 firmware

## setLocalConfig()

void setLocalConfig | ( | int | item,
|  | int | value
| ) |  |

Sets the current value of one of the local config items.

Parameters

  item | the config item to set the value of (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)
  value | the value to set the config to

Note
  Requires >= 0.2.5 firmware

## requestRemoteConfig()

void requestRemoteConfig | ( | int | longAddress,
|  | int | item
| ) |  |

Sets the local config of a block to the config item of a remote block.

Parameters

  longAddress | the address of the remote block
  item | the config item (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)

Note
  Requires >= 0.2.5 firmware

## setRemoteConfig()

void setRemoteConfig | ( | int | longAddress,
|  | int | item,
|  | int | value
| ) |  |

Sets the config of a remote block.

Parameters

  longAddress | the address of the remote block
  item | the config item (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)
  value | the value to set the config to

Note
  Requires >= 0.2.5 firmware

## setLocalConfigItemRange()

void setLocalConfigItemRange | ( | int | item,
|  | int | min,
|  | int | max
| ) |  |

Sets the range of one of the local config items.

Parameters

  item | the config item to set the range of (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)
  min | the minimum value this config item should use
  max | the maximum value this config item should use

Note
  Requires >= 0.2.5 firmware

## setLocalConfigActiveState()

void setLocalConfigActiveState | ( | int | item,
|  | bool | isActive,
|  | bool | saveToFlash
| ) |  |

Sets whether a local config item should be active.

Parameters

  item | the config item to set active (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)
  isActive | sets whether the config should be active or not
  saveToFlash | if true then this config item will be saved to the flash memory of the block

Note
  Requires >= 0.2.5 firmware