/*
* File: roach.h
* Author: mdunne
*
* Created on January 6, 2012, 10:59 AM
* Modified by: Max Dunne on 2015.09.18 to implement LED functions and remap
* pins for NEW_ROACH functionality.
*
* Implements basic functionality for Roach robot for sensors and actuators
*
* If using a new roach, create a NEW_ROACH macro at the project level
* in MPLAB-X using the global preprocessor directives.
*/
#ifndef ROACH_H
#define ROACH_H
#include <BOARD.h>
/*******************************************************************************
* PUBLIC FUNCTION PROTOTYPES *
******************************************************************************/
#define BUMPER_TRIPPED 1
#define BUMPER_NOT_TRIPPED 0
#define ROACH_MAX_SPEED 100
/**
* @Function Roach_Init(void)
* @param None.
* @return None.
* @brief Performs all the initialization necessary for the roach. this includes initializing
* the PWM module, the A/D converter, the data directions on some pins, and
* setting the initial motor directions.
* @note None.
* @author Max Dunne, 2012.01.06 */
void Roach_Init(void);
/**
* @Function Roach_LeftMtrSpeed(char newSpeed)
* @param newSpeed - A value between -100 and 100 which is the new speed
* @param of the motor. 0 stops the motor. A negative value is reverse.
* @return SUCCESS or ERROR
* @brief This function is used to set the speed and direction of the left motor.
* @author Max Dunne, 2012.01.06 */
char Roach_LeftMtrSpeed(char newSpeed);
/**
* @Function Roach_RightMtrSpeed(char newSpeed)
* @param newSpeed - A value between -100 and 100 which is the new speed
* @param of the motor. 0 stops the motor. A negative value is reverse.
* @return SUCCESS or ERROR
* @brief This function is used to set the speed and direction of the left motor.
* @author Max Dunne, 2012.01.06 */
char Roach_RightMtrSpeed(char newSpeed);
/**
* @Function Roach_LightLevel(void)
* @param None.
* @return a 10-bit value corresponding to the amount of light received.
* @brief Returns the current light level. A higher value means less light is detected.
* @author Max Dunne, 2012.01.06 */
unsigned int Roach_LightLevel(void);
/**
* @Function Roach_BatteryVoltage(void)
* @param None.
* @return a 10-bit value corresponding to the current voltage of the roach
* @brief returns a 10:1 scaled value of the roach battery level
* @author Max Dunne, 2013.07.12 */
unsigned int Roach_BatteryVoltage(void);
/**
* @Function Roach_ReadFrontLeftBumper(void)
* @param None.
* @return BUMPER_TRIPPED or BUMPER_NOT_TRIPPED
* @brief Returns the state of the front left bumper
* @author Max Dunne, 2012.01.06 */
unsigned char Roach_ReadFrontLeftBumper(void);
/**
* @Function Roach_ReadFrontRightBumper(void)
* @param None.
* @return BUMPER_TRIPPED or BUMPER_NOT_TRIPPED
* @brief Returns the state of the front right bumper
* @author Max Dunne, 2012.01.06 */
unsigned char Roach_ReadFrontRightBumper(void);
/**
* @Function Roach_ReadRearLeftBumper(void)
* @param None.
* @return BUMPER_TRIPPED or BUMPER_NOT_TRIPPED
* @brief Returns the state of the rear left bumper
* @author Max Dunne, 2012.01.06 */
unsigned char Roach_ReadRearLeftBumper(void);
/**
* @Function Roach_ReadRearRightBumper(void)
* @param None.
* @return BUMPER_TRIPPED or BUMPER_NOT_TRIPPED
* @brief Returns the state of the rear right bumper
* @author Max Dunne, 2012.01.06 */
unsigned char Roach_ReadRearRightBumper(void);
/**
* @Function Roach_ReadBumpers(void)
* @param None.
* @return 4-bit value representing all four bumpers in following order: front left,front right, rear left, rear right
* @brief Returns the state of all 4 bumpers
* @author Max Dunne, 2012.01.06 */
unsigned char Roach_ReadBumpers(void);
/**
* @Function Roach_LEDSSet( unsigned char pattern)
* @param pattern - sets LEDs on (1) or off (0) as in the pattern.
* @return SUCCESS or ERROR
* @brief Forces the LEDs in (bank) to on (1) or off (0) to match the pattern.
* @author Gabriel Hugh Elkaim, 2011.12.25 01:16 Max Dunne 2015.09.18 */
char Roach_LEDSSet(uint16_t pattern);
/**
* @Function Roach_LEDSGet(void)
* @return uint16_t: ERROR or state of BANK
* @author Max Dunne, 203.10.21 01:16 2015.09.18 */
uint16_t Roach_LEDSGet(void);
/**
* @Function Roach_BarGraph(uint8_t Number)
* @param Number - value to light between 0 and 12 leds
* @return SUCCESS or ERROR
* @brief allows all leds to be used as a bar graph
* @author Max Dunne 2015.09.18 */
char Roach_BarGraph(uint8_t Number);
#endif