
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
digit
shows 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.
∗
Page 195
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 in
rom/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.
Содержание MINDSTORMS Robots
Страница 22: ...Page 18 The back tread wheels are anchored to the shafts with the 16t gears ...
Страница 23: ...Page 19 Page 20 Next start building support for the drive motors ...
Страница 25: ...Page 22 Attach the motor wires to output A and output C Next build the platform for the front bumpers ...
Страница 26: ...Page 23 The touch sensors are attached only by the shaft that runs through them ...
Страница 41: ...Page 41 ...
Страница 43: ...Next build the support for the light sensor ...
Страница 80: ...Page 85 Make sure the bump on the long pin is up against the 4u beam ...
Страница 82: ......
Страница 84: ...Page 89 ...
Страница 85: ...Step 14 is similar to Step 11 take a deep breath and go slowly ...
Страница 86: ...Page 90 Grabber Arm In Step 17 the half bushings go between the center block and the cams pear shaped pieces ...
Страница 87: ...Page 91 ...
Страница 88: ...Page 92 Make sure that the two sides are at the same angle They should mirror each other ...
Страница 89: ...Page 93 Page 94 ...
Страница 90: ...Structural Support Page 95 ...
Страница 91: ...Idler Wheel Page 96 ...
Страница 92: ...Page 97 Drive Motor ...
Страница 93: ...While you re putting the motor in hold on to the worm gear so it doesn t slip off Page 98 ...
Страница 94: ...Grabber Arm Motor ...
Страница 95: ...Page 99 ...
Страница 96: ...Page 100 RCX Attach the RCX on both sides as shown Page 101 ...
Страница 158: ......
Страница 159: ...Page 175 The 16t gears are nestled inside the tread wheels ...
Страница 160: ...Page 176 ...
Страница 161: ...Page 177 Attach the motors to output A and output C as shown Page 178 ...
Страница 162: ...The light sensor which is mounted on the bumper is attached to input 2 The touch sensor goes on input 1 Page 179 ...