/* ************************************************************************** */
/** Descriptive File Name
@Company
Company Name
@File Name
filename.c
@Summary
Brief description of the file.
@Description
Describe the purpose of this file.
*/
/* ************************************************************************** */
/* ************************************************************************** */
/* ************************************************************************** */
/* Section: Included Files */
/* ************************************************************************** */
/* ************************************************************************** */
/* This section lists the other files that are included in this file.
*/
/* TODO: Include other files here if needed. */
#include <stdio.h>
#include <stdlib.h>
#include "serial.h"
#include "BOARD.h"
#include "roach.h"
#include "timers.h"
#include "Bumpers.h"
/* ************************************************************************** */
/* ************************************************************************** */
/* Section: File Scope or Global Data */
/* ************************************************************************** */
/* ************************************************************************** */
/* A brief description of a section can be given directly below the section
banner.
*/
int CheckForBumps(void) {
static char lastBump;
char thisBump;
thisBump = Roach_ReadBumpers();
if (thisBump != lastBump) {
lastBump = thisBump;
return 1;
} else {
lastBump = thisBump;
return 0;
}
}
int CheckWhichBump(void) {
static char lastBump;
char thisBump;
thisBump = Roach_ReadBumpers();
if (((thisBump & 0b0001) == 1) && ((lastBump & 0b0001) == 0)) {
lastBump = thisBump;
printf("Front Left Bumper is pressed!\r\n");
return FL_DOWN;
}
if (((thisBump & 0b0001) == 0) && ((lastBump & 0b0001) == 1)) {
lastBump = thisBump;
printf("Front Left Bumper is released!\r\n");
return FL_UP;
}
if (((thisBump & 0b0010) == 2) && ((lastBump & 0b0010) == 0)) {
lastBump = thisBump;
printf("Front Right Bumper is pressed!\r\n");
return FR_DOWN;
}
if (((thisBump & 0b0010) == 0) && ((lastBump & 0b0010) == 2)) {
lastBump = thisBump;
printf("Front Right Bumper is released!\r\n");
return FR_UP;
}
if (((thisBump & 0b0100) == 4) && ((lastBump & 0b0100) == 0)) {
lastBump = thisBump;
printf("Rear Left Bumper is pressed!\r\n");
return RR_DOWN;
}
if (((thisBump & 0b0100) == 0) && ((lastBump & 0b0100) == 4)) {
lastBump = thisBump;
printf("Rear Left Bumper is released!\r\n");
return RR_UP;
}
if (((thisBump & 0b1000) == 8) && ((lastBump & 0b1000) == 0)) {
lastBump = thisBump;
printf("Rear Right Bumper is pressed!\r\n");
return RR_DOWN;
}
if (((thisBump & 0b1000) == 0) && ((lastBump & 0b1000) == 8)) {
lastBump = thisBump;
printf("Rear Right Bumper is released!\r\n");
return RR_UP;
} else {
lastBump = thisBump;
return 0;
}
}
/* ************************************************************************** */
/** Descriptive Data Item Name
@Summary
Brief one-line summary of the data item.
@Description
Full description, explaining the purpose and usage of data item.
<p>
Additional description in consecutive paragraphs separated by HTML
paragraph breaks, as necessary.
<p>
Type "JavaDoc" in the "How Do I?" IDE toolbar for more information on tags.
@Remarks
Any additional remarks
*/
/* ************************************************************************** */
/* ************************************************************************** */
// Section: Local Functions */
/* ************************************************************************** */
/* ************************************************************************** */
/* A brief description of a section can be given directly below the section
banner.
*/
/* ************************************************************************** */
/**
@Function
int ExampleLocalFunctionName ( int param1, int param2 )
@Summary
Brief one-line description of the function.
@Description
Full description, explaining the purpose and usage of the function.
<p>
Additional description in consecutive paragraphs separated by HTML
paragraph breaks, as necessary.
<p>
Type "JavaDoc" in the "How Do I?" IDE toolbar for more information on tags.
@Precondition
List and describe any required preconditions. If there are no preconditions,
enter "None."
@Parameters
@param param1 Describe the first parameter to the function.
@param param2 Describe the second parameter to the function.
@Returns
List (if feasible) and describe the return values of the function.
<ul>
<li>1 Indicates an error occurred
<li>0 Indicates an error did not occur
</ul>
@Remarks
Describe any special behavior not described above.
<p>
Any additional remarks.
@Example
@code
if(ExampleFunctionName(1, 2) == 0)
{
return 3;
}
*/
/* ************************************************************************** */
/* ************************************************************************** */
// Section: Interface Functions */
/* ************************************************************************** */
/* ************************************************************************** */
/* A brief description of a section can be given directly below the section
banner.
*/
// *****************************************************************************
/**
@Function
int ExampleInterfaceFunctionName ( int param1, int param2 )
@Summary
Brief one-line description of the function.
@Remarks
Refer to the example_file.h interface header for function usage details.
*/
/* *****************************************************************************
End of File
*/