VEX2 Functions Display

Revision as of 19:57, 10 February 2012 by Bfeher (Talk | contribs)

Jump to: navigation, search

Main >> CORTEX >> Functions and Variables >> Display

For information about ROBOTC string, please see the article: Strings.

Color Key


ROBOTC has a rich set of functionality for drawing text and shapes on the LCD screen. The NXT is equipped with a 100 wide by 64 pixels high display.
  • The bottom left corner is point (0, 0) and the top right corner of the display is point (99, 63).
  • There are eight text lines numbers 0 to 7. 0 is the top line and 7 is the bottom line of the display.
Specifier Output Example Code Example Output
%d or %i Signed decimal integer "%d" 4246
%e Scientific notation (mantise/exponent) using e character "%e" 3.9265e+2
%E Scientific notation (mantise/exponent) using E character "%E" 3.9265E+2
%f Decimal floating point number "%f" 3.14159
%o Signed octal "%o" 157
%s String of characters "%s" ROBOTC
%x Unsigned hexadecimal integer "%x" 7fa
%X Unsigned hexadecimal integer (capital letters) "%X" 7FA
%c Character "%c" b

NOTE on Displaying Digits: When displaying floats, for example, you can tell ROBOTC how many decimals places to display. This is standard across all 'C' - like programing languages. For example, if your float is PI (3.14159265), but you only want to dispay "3.14", your string should contain, "%1.2f".

The number before the decimal is how many digits before the decimal you wish to display, while the number after the decimal is how many digits after the decimal you wish to display. So "%1.2f" tells us to display one digit before the decimal and two digits after the decimal, with "3.14" as the final result.

The tag can also contain flags, width, .precision and modifiers sub-specifiers, which are optional and follow these specifications:

Specifier Description Example Output
%d Prints a decimial integer 50
%6d Prints a decimal integer, at least 6 characters wide _ _ _ _ 50
%f Prints a floating point number 50.5
%6f Prints a floating point number, at least 6 characters wide _ _ _ 50.5
%.2f Prints a floating point number, with at least 2 decimal places 50.50
%6.2f Prints a floating point number, with at least 6 characters wide and 2 decimal places __ 50.50

Note: Underscore ( _ ) character denotes a space.


void nxtSetPixel(const int xPos, const int yPos)
(void) Sets a single pixel on the NXT LCD screen.
Parameter Explanation Data Type
xPos X-coordinate of pixel int
yPos Y-coordinate of pixel int
nxtSetPixel(42, 46);  // "set" a pixel (make it black) at position (42,46)