Page 82 - The Unofficial Guide to Lego Mindstorms Robots
P. 82
71
Table 4-6. Display Values
Value Des cription
0 System clock
1 View Input 1
2 View Input 2
3 View Input 3
4 View Output A
5 View Output B
6 View Output C
You can se t the clock in the RCX using the following macro:
SetWatch( const hours, const minutes)
Use this m acro to set the current time of the RCX's clock. Unfortunately, only constant values can be used.
The Datalog
With the d efault firmware, your RCX supports an interesting option called a dtalog. The datalog is simply a list of numbers.
You can create a new datalog and put numbers into it. Datalogs can be uploaded to your PC for analysis or display. The
datalog commands are:
CreateData log(const size)
This comm and tells the RCX to make space for the given number of elements. There is only one datalog, so this command will
erase any pre vious datalog.
AddToDatalog(expression v)
This command adds a value to the datalog. It's up to you to keep track of how many values are in the datalog. If you try to add
values after the datalog is full, nothing happens.
The fo llowing example waits for a touch sensor on input 1 to be pressed. For each press, the value of timer 0 is stored in the
d atalog , which holds 20 values in this example:
int count;
task main() {
CreateDatalog(20);
ClearTimer(0);
SetSensor(SENSOR_1, SENSOR_TOUCH);
count = 0;
until (count == 20) {
until(SENSOR_1 == 1);
AddToDatalog(Timer(0));