LEGO MINDSTORMS Robots Manual page 176

Unofficial guide
Table of Contents

Advertisement

To display a number, use lcd_number():
void lcd_number(int i, lcd_number_style n, lcd_comma_style c)
Use this function to show a number, i, on the display. The number style is one of sign, unsign or digit. Signed and unsigned numbers are shown in the main display area, while
digitshows a single digit on the right side of the display. The comma style is digit_comma (for use with the digit number style), e0, e_1, e_2 or e_3, indicating the number of digits to
the right of the decimal point.
In many cases, you won't need to call lcd_number () directly; rom/lcd.h includes definitions for four macros that simplify the process of displaying numbers:
lcd_int(i)
Use this macro to display a signed integer. Values over 9999 are shown as 9999.
lcd_unsigned(u)
This macro displays an unsigned value. Leading digits are padded with zero if necessary—for example, 123 is shown 0123.
∗ The source code is subject to the Mozilla Public License (MPL), which is fully described at the following URL:
lcd_clock(t)
This macro simulates showing a digital clock on the display. The supplied number is shown as a time, with the decimal point between the first two and last two digits.
lcd_digit(d)
Use this macro to display a single digit on the right side of the display.
The RCX's display contains many symbols, as well— indicators for the outputs, inputs, datalog, battery level, download status, and others. Each display segment can be controlled individually:
void lcd_show(lcd_segment segment)
Show a single display segment with this function. The lcd_segment enumeration is defined inrom/lcd.h; the comments in that file describe each segment type. To show the low battery
indicator, for example, you would do this:
lcd_show(battery_x);
lcd_refresh();
void lcd_hide(lcd_segment segment)
This function hides a specific display segment.
Finally, to clean up when you're done playing, use lcd_clear():
void lcd_clear(void)
This function clears the entire display. (You still have to call lcd_refresh() afterwards.)
As your program is running, legOS will try to animate the running man. Keep this in mind as it may modify your display unexpectedly.
Text, kind of (conio.h)
The conio.h file defines several functions that are handy for displaying text on the RCX:
void cputs(char ∗s)
This function displays the supplied string, as nearly as possible. Only the first five characters of the string are shown. Letters like "w" and "m" don't come out very well, but overall this is a great
function for debugging.
http://www.mozilla.org/MPL/.
Page 195

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the MINDSTORMS Robots and is the answer not in the manual?

Table of Contents