MakerPlot-J analyzes incoming data string, whether from the serial port, the Debug/Immediate Window or from instructions being ran. All strings must end in a carriage return or new line (CR or NL or \r, \n) before being processed.
Analog Data
Analog data is comma separated values, such as: 10,20,30
Up to 100 values may be accepted in a single string and they are stored in [ain0] to [ain99] from left-most to right-most. Certain controls, such as analog plots, process this incoming string or the resultant [ainXX] values.
From the controller, data must match this format, such as with the Arduino: Serial.print(val1); // NOTE: print not println for all but last
Serial.print(","); // insert comma between values
Serial.print(val2);
Serial.print(",");
Serial.println(val3); //println to add the line feed character
See More on Analog Data
Digital Data
Digital data is in the format of %bit-values, such as: %1001
Up to 100 values may be accepted in a single string and they are stored in [din0] to [din99] processed RIGHT to LEFT for LSB to MSB. Certain controls, such as plots, process this incoming string or the resultant [dinXX] values.
From the controller, data must match this format, such as with the Arduino: Serial.print("%"); // NOTE: print not println for all but last
Serial.print(bit3);
Serial.print(bit2);
Serial.print(bit1);
Serial.println(bit0); //println to add the line feed character
See more on Digital Data
Instructions
Instructions perform an operation of MPJ and start with ! in most cases (constant drawings, not cleared on a plot reset, start with @). These may come from the controller via the serial port, the DEBUG/Immediate Window or event code in MPJ. There are instructions which operate on the environment and ones specific to controls.
Some example instructions: !plot.reset // reset the plot
!list.clear // clear a list box
!clearDrawings // Clears drawing on the background
!plot.drawLine 0,0,100,100,RED // Draw a line on the plot !read [sldTemp] // Returns the value of slider names temp to the controller
Instructions may be sent by the controller, to create controls, set control values, read controls, or take some control action.
Serial.println("!plot.reset");
See more on Instructions
Messages
Messages are strings that don't match the above, such as:
Hello World!
The entire string may be accessed with [messageString], or if comma separated, with [str0] to [strXX] to access portions of it.
Serial.println("Hello World!");
See more on Messages
Properties
Setting properties, like instructions, begin with a ! and are used to set some parameter of MakerPlot-J, such as control's appearance or characteristics.
!plot.backColor=BLUE
Note that properties use an equal sign to set some value. Properties may also be accessed through the editor by pressing F3 when the mouse is over it.
Read properties or system controlled values by enclosing in brackets (? means print to the Debug window): ? [plot.backColor]
See more on Setting Properties
See more on Reading Properties
The controller may, of course, use instructions to set properties: Serial.println("!txtInfo = Heater On");
Serial.println("!plot.colorCh0=RED");
Variables
Variables may be created with an instruction: !makeVar varTest=0
Set as a property: !varTest=10
And read as a property: ? [varTest]
Read More on Variables
Math Operations
There are 2 forms of math operations, Standard (Infix) and Post-Fix.
In Standard-Math (Infix), uses typical math to process data and are defined by enclosing in curly braces, {}.
? { 2 * (3 + 4) } // returns 14
Post-Fix operates from left to right, storing values and performing operation on them. They are defined using {:: }. These operate much faster but are limited in their functions. Many are used in string manipulation.
? {:: 3 4 + 2 *} // returns 14
? {:: Hello World!::6::12::subString } // Return World!, :: between parameters is required if the string has spaces.
Read more on Standard Math and Post-Fix Math
Through the use of these elements, code processing is performed, such as: !txtAverage = { [ain0] + [ain1] / 2 }
Debug Indicator
Starting a string with ? will direct the data to be sent to the Debug/CLI Window for display.
|