
RP6 ROBOT SYSTEM - 4. Programming the RP6
An example will demonstrate the basic idea:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
void
outputSomething
(
uint8_t
something
)
{
writeString
(
"[The following value was passed to this function: "
);
writeInteger
(
something
,
DEC
);
writeString
(
"]\n"
);
}
uint8_t
calculate
(
uint8_t
param1,
uint8_t
param2
)
{
writeString
(
"[CALC]\n"
);
return
(
param2
)
;
}
int
main
(
void
)
{
initRobotBase
();
// Now execute a few function calls with parameters:
outputSomething
(
199
);
outputSomething
(
10
);
outputSomething
(
255
);
u
int8_t
result = calculate
(
10
,
30
);
// return value...
outputSomething
(
result
);
return
0
;
}
Output:
[The following value was passed to this function: 199]
[The following value was passed to this function: 10]
[The following value was passed to this function: 255]
[CALC]
[The following value was passed to this function: 40]
The RP6 Library provides a great number of functions. A quick look at the code of a
few modules and example programs will clarify the basic principles of developing pro-
grams with functions.
- 74 -