-
Notifications
You must be signed in to change notification settings - Fork 0
Serial
This page covers formatting of input types for serial messages.
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.
254,0,50,100,255
Here, all integers separated by commas can be cast to integers, and can be converted to a byte.
1234,-80,some_text
This message will fail because:
-
1234cannot be converted to a byte (>255). -
-80cannot be converted to a byte (<0). -
some_textcannot be cast to int.
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.
50,some_text,-30,1000
In this message:
-
50can be cast to int and will be converted to a byte (0 < 50 < 255). -
some_textwill converted to a byterray using its string literal. -
-30will be converted to a bytearray using its string literal (30 < 0). -
1000will be converted to a bytearray using its string literal (1000 > 255).
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.
Input
rainbowwave
Output
254,0,11,rainbowwave,255
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.
A String message type will have no formatting applied, it will simply be encoded into a bytearray and sent to the selected device.
This is a string message 1, 2, 3, 1000
FreeRGB | License | Code of Conduct | Contributing | Wiki | Code