Difference between revisions of "VEX2 Functions Display"

From ROBOTC API Guide
Jump to: navigation, search
(Information)
Line 29: Line 29:
 
|-
 
|-
 
|}
 
|}
 
 
== Information ==
 
{|
 
|-
 
|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.
 
 
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:center; font-size:100%; border-collapse: separate; border-spacing: 0; border-width: 1px; border-style: solid; border-color: #000;" cellpadding="5%"
 
  ! style="border-style: solid; border-width: 0px 1px 1px 0px"|''Specifier''
 
  ! style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Output
 
  ! style="border-style: solid; border-width: 0px 1px 1px 0px"|Example Code
 
  ! style="border-style: solid; border-width: 0px 0px 1px 0px"|Example Output
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%d or %i
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Signed decimal integer
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|"%d"
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|4246
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%e
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Scientific notation (mantise/exponent) using e character
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|"%e"
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|3.9265e+2
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%E
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Scientific notation (mantise/exponent) using E character
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|"%E"
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|3.9265E+2
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%f
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Decimal floating point number
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|"%f"
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|3.14159
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%o
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Signed octal
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|"%o"
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|157
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%s
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|String of characters
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|"%s"
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|ROBOTC
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%x
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Unsigned hexadecimal integer
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|"%x"
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|7fa
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%X
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Unsigned hexadecimal integer (capital letters)
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|"%X"
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|7FA
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 0px 0px"|%c
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 0px 0px"|Character
 
  | style="border-style: solid; border-width: 0px 1px 0px 0px"|"%c"
 
  | style="border-style: solid; border-width: 0px 0px 0px 0px"|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 <span class="keywordB">PI</span> '''(3.14159265)''', but you only want to dispay '''"3.14"''', your string should contain, <span class="codePunc">"%</span><span class="codeStringsNums">1.2f</span><span class="codePunc">"</span>. 
 
 
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 <span class="codePunc">"%</span><span class="codeStringsNums">1.2f</span><span class="codePunc">"</span> 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:'''
 
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:center; font-size:100%; border-collapse: separate; border-spacing: 0; border-width: 1px; border-style: solid; border-color: #000;" cellpadding="5%"
 
  ! style="border-style: solid; border-width: 0px 1px 1px 0px"|''Specifier''
 
  ! style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Description
 
  ! style="border-style: solid; border-width: 0px 0px 1px 0px"|Example Output
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%d
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Prints a decimial integer
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|50
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%6d
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Prints a decimal integer, at least 6 characters wide
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|_ _ _ _ 50
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%f
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Prints a floating point number
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|50.5
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%6f
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Prints a floating point number, at least 6 characters wide
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|_ _ _ 50.5
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 1px 0px"|%.2f
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 1px 0px"|Prints a floating point number, with at least 2 decimal places
 
  | style="border-style: solid; border-width: 0px 0px 1px 0px"|50.50
 
  |-
 
  | style="border-style: solid; border-width: 0px 1px 0px 0px"|%6.2f
 
  | style="text-align:left; border-style: solid; border-width: 0px 1px 0px 0px"|Prints a floating point number, with at least 6 characters wide and 2 decimal places
 
  | style="border-style: solid; border-width: 0px 0px 0px 0px"|__ 50.50
 
  |-
 
  |}
 
''Note: Underscore ( _ ) character denotes a space.''
 
|-
 
|}
 
<br />
 
 
  
  

Revision as of 20:50, 10 February 2012

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


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


Contents

Color Key
Function:
Variable:


nxtSetPixel

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)