Final Project files for mBed development.
Dependencies:
m3pi
mbed
« Back to documentation index
main.h File Reference
Main header file for includes and defs.
More...
Go to the source code of this file.
Functions
int retrieve_inst (char *buf, int *x, int *y, int *draw)
get values of next PostScript instruction.
void forward (int amt)
Driver forward for a time.
void backward (int amt)
Drive backward for a time.
void right (float deg)
Turn right by some angle.
void left (float deg)
Turn left by some angle.
void timerWait (float amt)
Wait for a number of seconds, possibly fractional.
int find_corner (int left)
Follows the non-reflective line to a corner.
void find_line ()
Turns towards the base line and moves to reach it.
float distance (int x1, int y1, int x2, int y2)
Computes the Euclidean distance between two points.
void robot_printf (int line, const char *format,...)
prints to the m3pi's screen
float compute_turn_angle (int last_x, int last_y, int x, int y, float angle)
computes the angle to turn to face towards (x,y)
void pen_up ()
sends the signal on the output pin for the led to turn it on
void pen_down ()
turns off the signal to the led
Detailed Description
Main header file for includes and defs.
Author: John Wilkey
Alec Guertin
Chester Chu
Definition in file main.h .
Function Documentation
void backward
(
int
amt )
Drive backward for a time.
Parameters:
[in] amt Amount to drive backward. In milliseconds.
Definition at line 417 of file main.c .
float compute_turn_angle
(
int
last_x ,
int
last_y ,
int
x ,
int
y ,
float
angle
)
computes the angle to turn to face towards (x,y)
Parameters:
[in] last_x the current x-coordinate
[in] last_y the current y-coordinate
[in] x the desired x-coordinate
[in] y the desired y-coordinate
[in] angle the current angle the m3pi is facing
Returns: the angle to turn left
Definition at line 270 of file main.c .
float distance
(
int
x1 ,
int
y1 ,
int
x2 ,
int
y2
)
Computes the Euclidean distance between two points.
Parameters:
[in] x1 the x-coordinate of the first point
[in] y1 the y-coordinate of the first point
[in] x2 the x-coordinate of the second point
[in] y2 the y-coordinate of the second point
Returns: the distance between points (x1,y1) and (x2,y2)
Definition at line 321 of file main.c .
int find_corner
(
int
left )
Follows the non-reflective line to a corner.
Parameters:
[in] left boolean specifying if the corner to look for is a left corner
Returns: returns an error code
Definition at line 340 of file main.c .
Turns towards the base line and moves to reach it.
Definition at line 326 of file main.c .
Driver forward for a time.
Parameters:
[in] amt Amount to drive forward. In milliseconds.
Definition at line 393 of file main.c .
Turn left by some angle.
Parameters:
[in] deg Desired final turn angle in degrees from start. Note that a negative angle will turn in the opposite direction.
Definition at line 426 of file main.c .
turns off the signal to the led
Definition at line 461 of file main.c .
sends the signal on the output pin for the led to turn it on
Definition at line 466 of file main.c .
int retrieve_inst
(
char *
buf ,
int *
x ,
int *
y ,
int *
draw
)
get values of next PostScript instruction.
Parameters:
buf Buffer with PS instructions.
x Pointer to storage for x coordinate.
y Pointer to storage for y coordinate.
draw Pointer to storage for draw/move boolean.
Returns: Success or failure code.
Definition at line 369 of file main.c .
Turn right by some angle.
Parameters:
[in] deg Desired final turn angle in degrees from start. Note that a negative angle will turn in the opposite direction.
Definition at line 440 of file main.c .
void robot_printf
(
int
line ,
const char *
format ,
...
)
prints to the m3pi's screen
Parameters:
[in] line the line on the screen to print to, in {0,1}
[in] format the format string to print
[in] ... the arguments to pass into the format string
Definition at line 309 of file main.c .
void timerWait
(
float
amt )
Wait for a number of seconds, possibly fractional.
Timer resolution is on the order of microseconds. A negative wait time does nothing.
Parameters:
[in] amt Time to wait, in seconds.
Definition at line 454 of file main.c .