Skip to content
Milan edited this page Feb 5, 2021 · 2 revisions

This page covers formatting of input types for serial messages.

Integer

Each integer, separated by a comma, will be converted into a byte. If this fails (<0, >255, cannot cast to int), the message will not be sent. Otherwise, this array of bytes will be sent to the selected device as a bytearray through serial.

Working example

254,0,50,100,255

Here, all integers separated by commas can be cast to integers, and can be converted to a byte.

Failing example

1234,-80,some_text

This message will fail because:

  • 1234 cannot be converted to a byte (>255).
  • -80 cannot be converted to a byte (<0).
  • some_text cannot be cast to int.

Integer-Char

For each input separated by a comma, if the input cannot be converted to a byte through the integer input type conversion, it will instead be encoded into a bytearray. All bytes (integers) and bytearrays (string literals) will be concatenated into a single bytearray and sent to the selected device through serial.

Working Example

50,some_text,-30,1000

In this message:

  • 50 can be cast to int and will be converted to a byte (0 < 50 < 255).
  • some_text will converted to a byterray using its string literal.
  • -30 will be converted to a bytearray using its string literal (30 < 0).
  • 1000 will be converted to a bytearray using its string literal (1000 > 255).

ArduRGB

Payload inputs will be handled through the integer-char input type, however will be formatted for an ArduRGB message.

An ArduRGB is formed by the following:

<StartByte>,<StripNumber>,<StringLength>,<String>,(OPTIONAL <ArgNumber>,<Arg1>,<Arg2>,...),<EndByte>

By default, FreeRGB uses 254 as a start byte and 255 as an end byte. The strip number is simply the byte representing the currently selected strip i.e. strip 1 -> 1 The string is the name of the effect to be selected, for example rainbowcycle. The strip length is the number of characters in the string; in this case 12. If any additional message arguments are present, such as R, G, B values for setting a solid colour, they would be added between the string and end byte. The arg number is a byte representing the number of arguments present; in the case of R, G, and B arguments, the arg number would be 3.

For the following examples, assume the selected strip is 0.

No Args Example

Input

rainbowwave

Output

254,0,11,rainbowwave,255

Args Example

Input

solidcolor,50,60,70

Output

254,0,10,solidcolor,3,50,60,70,255

Remember that the output is always parsed as an Integer-Char message.


String

A String message type will have no formatting applied, it will simply be encoded into a bytearray and sent to the selected device.

Example

This is a string message 1, 2, 3, 1000

Clone this wiki locally