Page 23
The C language prototypes for these five functions are:
void
motor(
int
m,
int
p);
void
mav(
int
m,
int
vel);
void
mrp(
int
m,
int
vel,
int
ticks);
void
bmd(
int
m);
void
ao();
void
off(
int
m);
Other Functions Commonly Used With the KIPR Link
msleep(
<
milliseconds
>
)
KIPR Link Library function that pauses the currently executing thread, resuming execution of the
thread after a time equal to or slightly greater than the number of milliseconds specified.
printf(
<
string
>
, . . .)
Standard C library function for formatting output directed to standard out (which is the program
output console screen for the KIPR Link). If the string contains % codes then the arguments
after the initial string (the . . . portion of the function's arguments) will be printed in place of the
% codes using the format specified by the matching % code. See the Appendix or consult a C
language reference for a listing of % codes and how they are interpreted for formatting data.
beep()
KIPR Link Library function that creates a short beep sound.
The C language prototypes for these three functions are:
void
msleep(
int
msecs);
int
printf(
char
s[], ...);
(
...
represents 0 or more values corresponding to % codes present in s)
void
beep();
Example use of these functions (along with motor functions, motor in motor port 2):
int
t=
1000
, m=
2
;
mrp(m,
500
,
500
);
// move motor at 500 ticks per second
printf(
"Running m%d %d mseconds\n"
,m,p);
// use %d for int values
msleep(t);
// suspend the current thread for p milliseconds
off(m);
// turn off motor
beep();
// beep when thread resumes executing
In 1 second the motor should move 500 ticks. In contrast to using
bmd
,
msleep
forces the motor off
after 1 second even if it is short of its target position. The
printf
output will be
Running m2 1000 mseconds
For more information on KIPR Link Library functions, consult the on-line documentation under the KISS
IDE
Help
tab as well as the appendices to this Guide.