Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

FpuSerial Library

The FpuSerial library provides functions for sending FPU strings to the serial port. This library is included with the Fpu Library download and requires the use of the uM-FPU V3.1 chip. When the FPU chip is available, the FpuSerial functions can display floating point numbers with very little additional overhead.

Functions

printVersion()
Sends the VERSION opcode, then calls printString to send the version string on the serial port.
Example:
FpuSerial.printVersion(VERSION);  // display FPU version string

printFloat(char format)
Sends the FTOA,format opcode to convert the floating point value in register A to a formatted string. It then calls printString to send the string on the serial port. The format parameter is used to specify the desired format. If format is zero, the length of the displayed value is variable and can be from 3 to 12 characters in length. Up to eight significant digits will be displayed if required, and very large or very small numbers are displayed in exponential notation. The special cases of NaN (Not a Number), +Infinity, -Infinity, and -0.0 are handled. Examples of the display format are as follows:
1.0          NaN          0.0
1.5e20       Infinity     -0.0
3.1415927    -Infinity    1.0
-52.333334   -3.5e-5      0.01
If format is non-zero, the tens digit specifies the total number of characters to display and the ones digit specifies the number of digits after the decimal point. If the value in register A is too large for the format specified, then asterisks will be displayed. If the number of digits after the decimal points is zero, no decimal point will be displayed. Examples of the display format are as follows:
Value in A register    format      Display format
    123.567           61 (6.1)      [ 123.6]
    123.567           62 (6.2)      [123.57]
    123.567           42 (4.2)      [**.*]
    0.9999            20 (2.0)      [ 1]
    0.9999            31 (3.1)      [1.0]
Example:
Fpu.write(SELECTA, 1);     // select register 1
FpuSerial.printFloat(63);  // display float in 6.3 format

printLong(char format)
Sends the LTOA,format opcode to convert the 32-bit integer value in register A to a formatted string. It then calls printString to send the string on the serial port. The format parameter is used to specify the desired format. If format is zero, the length of the displayed value is variable and the displayed value can range from 1 to 11 characters in length. Examples of the display format are as follows:
1
500000
-3598390
If format parameter is non-zero, it determines the display format. A value between 0 and 15 specifies the number of characters to display. The formatted string is right justified, with blank fill if format is positive, or zero fill if format is negative. If the value 100 is added to format the value is displayed as an unsigned long integer. If the value in register A is too large for the format specified, asterisks will be displayed. If the number of character to display is specified as zero, as many characters as required to display the number with be used. Examples of the display format are as follows:
Value in A register   format             Display format
    -1                10  (signed 10)     [        -1]
    -1                110 (unsigned 10)   [4294967295]
    -1                4   (signed 4)      [  -1]
    -1                104 (unsigned 4)    [****]
    0                 4   (signed 4)      [   0]
    0                 0   (unformatted)   [0]
    1000              6   (signed 6)      [  1000]
    1000              -6  (signed 6)      [001000]
Examples:
Fpu.write(SELECTA, 1);    // select register 1 
FpuSerial.printLong(5);   // display signed 32-bit integer(5 character field)
or
Fpu.write(SELECTA, 1);    // select register 1 
FpuSerial.printLong(100)  // display as unsigned 32-bit integer

printString()
printString(byte opcode)
Reads a zero-terminated string from the FPU and sends the string to the serial port. By default, the entire string buffer is read using the READSTR opcode. If the opcode parameter is READSEL, only the current string selection is read. The following functions are called by printString before the string is read:
wait()
write(READSTR) or Fpu.write(READSEL)
readDelay()
Examples:
FpuSerial.printString();         // display string buffer
or
FpuSerial.printString(READSEL);  // display current string selection