Skip to content

Instantly share code, notes, and snippets.

@michaellin
Created December 1, 2015 02:42
Show Gist options
  • Save michaellin/c8276e178b2caa2f9315 to your computer and use it in GitHub Desktop.
Save michaellin/c8276e178b2caa2f9315 to your computer and use it in GitHub Desktop.
/****************************************************************************
Module
BucketService.c
Revision
1
Description
This service is in charge of implementing the state machine for one the user interactions
in "Stop the DAM Leak" game for ME 218A Final Project.
Notes
History
When Who What/Why
-------------- --- --------
11/08/15 16:00 mal Began working on the module
****************************************************************************/
//#define TEST
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include "BITDEFS.H"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/pin_map.h"
#include "ES_Configure.h"
#include "BucketService.h"
#include "PWM12Tiva.h"
#include "PortFuncInit.h"
#include "TivaFunctions.h"
#include "Audio1.h"
#include "UncleEdSM.h"
#include "PipeSegment.h"
/************************* Prototypes ************************************/
// All function prototypes here
bool InitBucketService (uint8_t Priority); // Initialize Bucket module service
bool PostBucketService( ES_Event ThisEvent ); // Post an event to BucketService
ES_Event RunBucketService( ES_Event ThisEvent ); // BucketService main service routine
/** Private Functions **/
static void Bucket_HWInit( void ); // Initializes the servo pins to the correct frequency and sets them to be at initial angle
static void RandServoList( void); //Randomly selects a servo and set it off.
static bool SampleBucketSensor( uint8_t ); //Sample from a selected IR sensor
static void ResetServo( uint8_t whichServo ); //Resets servo to initial position
static void SetoffAllDripServo( void ); //Sets off all Drip Servos
static void TurnOnLED( uint8_t whichLED); //Turn on a selected LED
static void TurnOffLED( uint8_t whichLED); //Turn off a selected LED
static void ResetAllServos( void ); //Resets all Servos
static void StepAllServos( void ); //Step all active servos
/************************* Typedefs States of State Machine *******************************/
typedef enum { InitializeBucketService, Ready2Play, BucketPlaying} BucketState_t ;
/**************************** Macros ************************************/
#define INIT_TIME 100 // Time in microseconds
#define COLUMN_NUM 4 // Number of Servos used in this module
#define SERVO_INIT_PW 1375 // Set initial position of servos to be at 45 deg (1.1 ms)
#define SERVO_AT_BUCK 2125 // Angle at which servo is pointing at LED should be 5 cm below middle with lever arm of 15 cm
#define SERVO_FINAL_PW 2225 // Set final position of servos to be at 135 deg (2.18 ms)
#define STEP_SIZE 45 // Step by 45 ticks correspond to 3 s for an drip Servo to reach from init to final position if dripping at 0.1s rate
#define SetoffRate 2500 // Time between new drips is around 2.5seconds
#define BUCKET_THERE 0 // State of the IR sensor if bucket is at that position
#define BIT0MASK 0x1 // Mask for bit 0
//Definition for bucket to decide how fast to drip servos
#define SPEED2GOAL1 800 // within 0.5s
#define SPEED2GOAL2 1200 // within 0.5-1s
#define SPEED2GOAL3 1700 // within 1-1.5s
#define SPEED2GOAL4 2200 // within 1.5-2s
//Fastest is for speed greater than SPEED2GOAL4
/************************* Module Variables ******************************/
static uint8_t MyPriority; //Priority associated with service call to this module
static BucketState_t CurrentState = InitializeBucketService; //Begin out state at a Pseudo Init state
static uint8_t dripServoList[COLUMN_NUM] = { 0, 1, 4, 5 }; //List of PWM channels connected to servos used for water drops
static uint16_t dripServosPos[COLUMN_NUM]; //List of the current position for each Servo
static uint16_t dripRateList[5] = {180, 150, 130, 100, 50}; //From slowest to fastest (i.e. 6s, 3.9s, 3.3s, 2.7s, 1.8s)
// This service uses PWM pins PB6, PB7 (group 0) and PE4, PE5 (group 2)
static uint8_t activeServoList = 0x00; //4 bits list: each bit indicates: 0 is inactive; 1 is active (only manipulate bit 0 thru 3)
static uint8_t numActiveServos = 0; //Keep track of how many servos are active
static int WhichColumn; //used for which coin sensor to check when servo reaeches bucket height
static bool BucketSensorState;
static bool PipeDown = false; //flag to indicate if any pipe is currently down
static uint16_t DripRate = 100; //Initial set off rate at 0.1s WARN: Assuming clock is in 1ms tick
static uint16_t ServoSetoffRate = 600; //Initial set off rate at 0.6s WARN: Assuming clock is in 1ms tick
/**
* function: InitBucketService
* description: Initialize the service, timers and required Tiva Hardware.
*
*/
bool InitBucketService (uint8_t Priority)
{
MyPriority = Priority; // Remember the service priority to know which queue to post events to
Bucket_HWInit(); // Initialize the hardware connected to Bucket Module
// Enter a ready to play state, where we guarantee hardware is initialized and are waiting for the start button
CurrentState = InitializeBucketService;
//Post event ES_Init this service
ES_Event ThisEvent;
ThisEvent.EventType = ES_INIT;
bool ReturnVal = PostBucketService( ThisEvent);
//End of InitializeBucketService
return ReturnVal;
}
/**
* function: PostBucketService
* description: Public function to post an event to Bucket State machine's event queue
*
*/
bool PostBucketService( ES_Event ThisEvent )
{
return ES_PostToService(MyPriority, ThisEvent);
}
/**
* function: RunBucketService
* description: Main service routine for Bucket State Machine
*
*/
ES_Event RunBucketService( ES_Event ThisEvent )
{
ES_Event ReturnEvent;
ReturnEvent.EventType = ES_NO_EVENT; //assume no errors
ES_Event Event2PostAudio;
ES_Event Event2PostUncleEd;
ES_Event Event2PostPipe;
switch (CurrentState) {
case InitializeBucketService :
//If ThisEvent is ES_Init
if (ThisEvent.EventType == ES_INIT){
//Set NextState to Ready2Play
CurrentState = Ready2Play;
}
break;
case Ready2Play :
//If Event is StartButton:
if (ThisEvent.EventType == ES_START_BUTTON_DBDOWN){
//Take coin sensor inputs back to input.
EnableTivaPinsInput(Port_E, (GPIO_PIN2|GPIO_PIN3)); //Enable PE2, PE3 as input
EnableTivaPinsInput(Port_C, (GPIO_PIN6|GPIO_PIN7)); //Enable PC6, PC7 as input
CurrentState = BucketPlaying;
//set off DRIP_SETOFF_TIMER with initial SetoffRate at 0.1s
ES_Timer_InitTimer(DRIP_SETOFF_TIMER, 100); //Note: Setoff Rate is defined as 0.6s at the top of this page
ES_Timer_InitTimer(DRIP_SPEED_TIMER, DripRate);
}
break;
case BucketPlaying:
//If Event is Timeout and Timer == DRIP_TIMER:
if ((ThisEvent.EventType == ES_TIMEOUT)&&(ThisEvent.EventParam == DRIP_SPEED_TIMER)){
// Call function StepAllServos from activeServoList
StepAllServos(); //Need to define this function
// Set off DripTimer with DripRate
ES_Timer_InitTimer(DRIP_SPEED_TIMER, DripRate); //Note drip rate should be defined from ES_WRENCH2GOAL event paramter
}
//Else if Event is Timeout and Timer == DRIP_SETOFF_TIMER:
else if ((ThisEvent.EventType == ES_TIMEOUT)&&(ThisEvent.EventParam == DRIP_SETOFF_TIMER)&&(PipeDown==false)){
//RandomFreeColumn = select random servo that is not in activeServoList
RandServoList(); // Choose a random inactive servo and put it as active
//Set off DripTimer with DripRate
ES_Timer_InitTimer(DRIP_SETOFF_TIMER, ServoSetoffRate);
}
//Else if Event is DripServoAtBucket:
else if (ThisEvent.EventType == ES_DRIP_SERVO_AT_BUCKET){ //Note: Need to make an event checker that checks for this
//Get column number from Event parameter (1,2,3 or 4)
WhichColumn = ThisEvent.EventParam; // Which servo reached the bucket
BucketSensorState = SampleBucketSensor(WhichColumn); // (return bool- 0 if activated)
if ((BucketSensorState == BUCKET_THERE) && (PipeDown == false)) { // BUCKET_THERE is defined as 0 (for sensor activated)
// Post ES_GAINED_POINT to uncle ed to update LCD Display
Event2PostAudio.EventType = ES_GAINED_POINT;
PostAudio1(Event2PostAudio);
//call postAudioService ES_PLAY_TUNE with Success Sound
Event2PostAudio.EventType = ES_PLAY_TUNE;
Event2PostAudio.EventParam = SuccessBucket;
PostAudio1(Event2PostAudio);
//call ResetServo(WhichColumn) to put it back at the beginning, LED off and make it available
ResetServo(WhichColumn); //Need to define this function. It should clear the bit in the ActiveServoList also
}
}
//Else if Event is DripServoAtBottom:
else if (ThisEvent.EventType == ES_DRIP_SERVO_AT_BOTTOM){
//WARN: Remember that in pipe down we could have 4 of these events at the same time. Make service queue big enough!
if (PipeDown == true) {
Event2PostPipe.EventType = ES_PIPE_DOWN_LOST; //Pipe servos reached the bottom when we are in pipe down mode, notify pipe segment service
PostPipeSegment(Event2PostPipe);
}
//post ES_LOST_POINT to UncleEdService
Event2PostUncleEd.EventType = ES_LOST_POINT;
PostUncleEd(Event2PostUncleEd);
//post to audio service to play failed sound
Event2PostAudio.EventType = ES_PLAY_TUNE;
Event2PostAudio.EventParam = FailBucket;
PostAudio1(Event2PostAudio);
//call ResetServo(WhichColumn) to put it back at the beginning and LED off and make it available
//Get WhichColumn from Event parameter
WhichColumn = ThisEvent.EventParam;
ResetServo(WhichColumn);
if ((PipeDown == true) && (activeServoList == 0x00)) { //If all servos reached bottom in case of pipe down
ES_Timer_InitTimer(DRIP_SETOFF_TIMER, ServoSetoffRate); //Reset the timer
PipeDown = false;
}
}
//Else if Event is Timeout and Timer == PIPE_TIMER:
else if ((ThisEvent.EventType == ES_TIMEOUT)&&(ThisEvent.EventParam == PIPE_TIMER)){
DripRate = 200; //Put drip rate back to 0.1s to make it consistent
PipeDown = true;
SetoffAllDripServo(); // Puts all 4 dripServo active and start at the beginning.
}
//Else if Event is PipeRecovered:
else if ((ThisEvent.EventType == ES_PIPE_RECOVERED) && (PipeDown == true)){ // Accept Pipe Segment to post this back to me
PipeDown = false; // Set the flag to not pipe down
ResetAllServos(); //It should clear all bits in the ActiveServoList and put them at init position
ES_Timer_InitTimer(DRIP_SETOFF_TIMER, ServoSetoffRate); //Reset the timer
}
//Else if Event is Timeout and Timer == ED_TIMER:
//else if ((ThisEvent.EventType == ES_TIMEOUT)&&(ThisEvent.EventParam == ED_TIMER)){
else if (ThisEvent.EventType == ES_GAMEOVER){
// call ResetAllServos to put them back at their beginning position
ResetAllServos();
CurrentState = Ready2Play;
PipeDown = false;
}
else if (ThisEvent.EventType == ES_WRENCH2GOAL){
// call ResetAllServos to put them back at their beginning position
uint16_t time2goal = ThisEvent.EventParam;
//Given the speed of the wrench decide how hard to make it to the player with the bucket
if (time2goal <= SPEED2GOAL1) { //If wrench player is fast make water drip slower
DripRate = dripRateList[0];
} else if ((time2goal >SPEED2GOAL1) && (time2goal <= SPEED2GOAL2)) {
DripRate = dripRateList[1];
} else if ((time2goal >SPEED2GOAL2) && (time2goal <= SPEED2GOAL3)) {
DripRate = dripRateList[2];
} else if ((time2goal >SPEED2GOAL3) && (time2goal <= SPEED2GOAL4)) {
DripRate = dripRateList[3];
} else if (time2goal >SPEED2GOAL4) { //If wrench player is slow make water drip rate very fast
DripRate = dripRateList[4];
}
}
break;
}
return ReturnEvent;
}
/***************************************************************************
private functions
***************************************************************************/
#define ALL_BITS (0xff << 2) // Used for getting the right address of the GPIO pins
/****************************************************************************
Function
Bucket_HWInit()
Parameters
nothing
Returns
nothing
Description
initializes the hardware for the bucket service to work (i.e. tiva pin enables). Initialize
pins B0 to B1 as output for the servo driving.
Author
Michael Lin, 11/08/15,12:35
****************************************************************************/
void Bucket_HWInit( void )
{
// Do Servos initializations
PWM_TIVA_SetPeriod(25000, 0); // Set group 0 (PB6 and PB7) to be at 50 Hz (period count in 0.8us)
PWM_TIVA_SetPeriod(25000, 2); // Set group 2 (PE4 and PE5) to be at 50 Hz (period count in 0.8us)
for (int i=0; i<COLUMN_NUM; i++) // Go through each servo and put them at their initial positions
{
PWM_TIVA_SetPulseWidth(SERVO_INIT_PW, dripServoList[i]); //Put servo at initial position
dripServosPos[i] = SERVO_INIT_PW; //Update the position of the servo
}
// Enable all pins used in this module
//Initialize pins for coin sensors
EnableTivaPort(Port_C);
EnableTivaPort(Port_E);
EnableTivaPinsInput(Port_E, (GPIO_PIN2|GPIO_PIN3)); //Enable pin PE2-3 input for coin sensors as input
EnableTivaPinsInput(Port_C, (GPIO_PIN6|GPIO_PIN7)); //Enable pin PC6-7 input for coin sensors as input
//Initialize pins for water LEDs
EnableTivaPort(Port_D);
EnableTivaPinsOutput(Port_D, (GPIO_PIN3|GPIO_PIN6|GPIO_PIN7)); //Enable pin PD3,6,7 output for water LEDs
EnableTivaPinsOutput(Port_E, (GPIO_PIN1)); //Enable pin PE1 for water LED
// All input output pins should be enabled at this point
}
/****************************************************************************
Function
StepAllServos()
Parameters
nothing
Returns
nothing
Description
Goes through the list of active servos and step all of them that are active
Author
Michael Lin, 11/10/15,12:35
****************************************************************************/
void StepAllServos( void )
{
for (uint8_t i=0; i < COLUMN_NUM; i++) {
uint8_t activeServoMask = 1<<i; //Get the mask for each individual servo in the servo Mask list
if ((activeServoList & activeServoMask) > 0) {
//If current servo is in the active list step it
uint16_t currentServoPos = dripServosPos[i]; //Get the current position of the servo
uint16_t nextServoPos = currentServoPos+STEP_SIZE //Increment this position;
if ((nextServoPos >= SERVO_AT_BUCK) && (nextServoPos <= SERVO_AT_BUCK+STEP_SIZE)) { // If dripServo position is at bucket position
ES_Event ThisEvent;
ThisEvent.EventType = ES_DRIP_SERVO_AT_BUCKET;
ThisEvent.EventParam = i+1; //Pass the number of the column for which Servo is at bucket
PostBucketService(ThisEvent);
}
if (nextServoPos >= SERVO_FINAL_PW) { //If Servo is at bottom position post Drip servo at bottom and let state machine handle
ES_Event ThisEvent;
ThisEvent.EventType = ES_DRIP_SERVO_AT_BOTTOM;
ThisEvent.EventParam = i+1; //Pass the number of the column for which Servo is at bottom
PostBucketService(ThisEvent);
} else {
PWM_TIVA_SetPulseWidth(nextServoPos, dripServoList[i]);
}
dripServosPos[i] = nextServoPos; //Update the current position of the servo. IMPORTANT!
}
}
}
/****************************************************************************
Function
ResetServo()
Parameters
int: indicates which servo to reset (i.e. 1, 2, 3, 4)
Returns
nothing
Description
Reset the selected servo by putting it back at the intial angle, puting it as inactive in the
list and decrementing the numActiveServos
Author
Michael Lin, 11/10/15,12:35
****************************************************************************/
void ResetServo( uint8_t whichServo )
{
if (whichServo == 0) {
printf("\n\r Requested invalid servo reset\r\n");
}
activeServoList &= ~(BIT0MASK << (whichServo-1)); //Set servo as inactive
dripServosPos[whichServo-1] = SERVO_INIT_PW;
PWM_TIVA_SetPulseWidth(SERVO_INIT_PW, dripServoList[whichServo-1]); //Put servo angle back to initial position
uint8_t whichLED = whichServo;
TurnOffLED(whichLED);
numActiveServos--;
}
/****************************************************************************
Function
ResetAllServo()
Parameters
nothing
Returns
nothing
Description
Reset all servos by putting them back at the intial angle, puting it as inactive in the
list and decrementing the numActiveServos
Author
Michael Lin, 11/10/15,12:35
****************************************************************************/
void ResetAllServos( void )
{
for (int i = 1; i<= COLUMN_NUM; i++) {
ResetServo(i); //Reset each servo
}
numActiveServos = 0; //Redundant, but for safety
}
/****************************************************************************
Function
SetoffAllDripServo()
Parameters
nothing
Returns
nothing
Description
Will put all the servos in the active list
Author
Michael Lin, 11/10/15,12:35
****************************************************************************/
void SetoffAllDripServo( void )
{
ResetAllServos(); // Put all servos at the beginning and set them off
activeServoList = 0x0f; //Turn on all LSB bits to indicate all 4 servos are active
numActiveServos = 4; //All servos are active
for (int i = 1; i<=COLUMN_NUM; i++) { //Turn on all LEDs on Servos
TurnOnLED(i);
}
}
/****************************************************************************
Function
RandServoList()
Parameters
nothing
Returns
nothing
Description
RandServoList will select a random available servo, set it to unavailable, update the total numActiveServos.
When the activeServoList is update the servo will be set off automatically
Author
Aaron Manheim, 11/09/15,12:35
****************************************************************************/
void RandServoList( void){
srand(ES_Timer_GetTime()); //Generate random seed for rand module
uint8_t randNum= rand()%(COLUMN_NUM-numActiveServos); //Randomly chose an int within the range of available servos
uint8_t counter = 0; //Counter used to select the 'randNum'th servo
for (uint8_t i=0; i < COLUMN_NUM; i++) { //Gets the 'randNum'th servo if we get into this for loop we should always be able to find available servo
uint8_t active = (activeServoList & (1 << i)); // Check if the ith servo is available
if ((active == 0)&&(counter == randNum)) { //If servo is available and we are at the randomly selected servo
activeServoList |= (1 << i); //Update the activeServoList
numActiveServos++; //Remember to update the total amount of active servos!
TurnOnLED(i+1);
return;
} else if (active == 0) {
counter++; //If we are not at the 'randNum'th servo yet but current servo is active then increment counter
}
}
//If reached here then there are no servos available
}
/****************************************************************************
Function
TurnOnLED()
Parameters
uint8_t: Which LED to turn on (i.e. 1, 2, 3, 4)
Returns
nothing
Description
Will turn on selected LED
Author
Michael Lin, 11/10/15,12:35
****************************************************************************/
void TurnOnLED( uint8_t whichLED)
{
if (whichLED == 1) {
HWREG(GPIO_PORTD_BASE+(GPIO_O_DATA + ALL_BITS)) |= BIT3HI; //LED at pin PD3
} else if (whichLED == 2) {
HWREG(GPIO_PORTD_BASE+(GPIO_O_DATA + ALL_BITS)) |= BIT6HI; //LED at pin PD6
} else if (whichLED == 3) {
HWREG(GPIO_PORTD_BASE+(GPIO_O_DATA + ALL_BITS)) |= BIT7HI; //LED at pin PD7
} else if (whichLED == 4) {
HWREG(GPIO_PORTE_BASE+(GPIO_O_DATA + ALL_BITS)) |= BIT1HI; //LED at pin PE1
} else {
printf("\n\r Got a bad number for which LED to turn on. Number %d\r\n", whichLED);
}
}
/****************************************************************************
Function
TurnOffLED()
Parameters
uint8_t: Which LED to turn on (i.e. 1, 2, 3, 4)
Returns
nothing
Description
Will turn off selected LED
Author
Michael Lin, 11/10/15,12:35
****************************************************************************/
void TurnOffLED( uint8_t whichLED)
{
if (whichLED == 1) {
HWREG(GPIO_PORTD_BASE+(GPIO_O_DATA + ALL_BITS)) &= ~BIT3HI; //LED at pin PD3
} else if (whichLED == 2) {
HWREG(GPIO_PORTD_BASE+(GPIO_O_DATA + ALL_BITS)) &= ~BIT6HI; //LED at pin PD6
} else if (whichLED == 3) {
HWREG(GPIO_PORTD_BASE+(GPIO_O_DATA + ALL_BITS)) &= ~BIT7HI; //LED at pin PD7
} else if (whichLED == 4) {
HWREG(GPIO_PORTE_BASE+(GPIO_O_DATA + ALL_BITS)) &= ~BIT1HI; //LED at pin PE1
} else {
printf("\n\r Got a bad number for which LED to turn off. Number %d\r\n", whichLED);
}
}
/****************************************************************************
Function
SampleBucketSensor()
Parameters
int: indicates which IR
Returns
nothing
Description
Samples the reading from a chosen IR sensor connected to PE2-3 and PC6-7.
Author
Michael Lin, 11/10/15,12:35
****************************************************************************/
bool SampleBucketSensor( uint8_t whichIR )
{
if (whichIR == 1) {
uint16_t input = (HWREG(GPIO_PORTE_BASE+(GPIO_O_DATA + ALL_BITS)) & BIT2HI);
return (input > 0); //Return state of pin PE2
} else if (whichIR == 2) {
uint16_t input = (HWREG(GPIO_PORTE_BASE+(GPIO_O_DATA + ALL_BITS)) & BIT3HI);
return (input > 0); //Return state of pin PE3
} else if (whichIR == 3) {
uint16_t input = (HWREG(GPIO_PORTC_BASE+(GPIO_O_DATA + ALL_BITS)) & BIT6HI);
return (input > 0); //Return state of pin PC4
} else if (whichIR == 4) {
uint16_t input = (HWREG(GPIO_PORTC_BASE+(GPIO_O_DATA + ALL_BITS)) & BIT7HI);
return (input > 0); //Return state of pin PC4
}
return false;
}
#ifdef TEST
/* Use this test for testing LCDService Functions */
#include "termio.h"
#define TEST7
int main(void)
{
// Set the clock to run at 40MhZ using the PLL and 16MHz external crystal
SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN
| SYSCTL_XTAL_16MHZ);
// initialize the timer sub-system and console I/O
_HW_Timer_Init(ES_Timer_RATE_1mS);
TERMIO_Init();
puts("\n\r Initialized terminal\r\n");
#ifdef TEST1
puts("\n\r Test1\r\n");
Bucket_HWInit(); //Should init all PWM pins and LED pins
HWREG(GPIO_PORTE_BASE+(GPIO_O_DATA + ALL_BITS)) |= BIT1HI;
//HWREG(GPIO_PORTF_BASE+(GPIO_O_DATA + ALL_BITS)) |= BIT4HI;
HWREG(GPIO_PORTD_BASE+(GPIO_O_DATA + ALL_BITS)) |= BIT3HI;
HWREG(GPIO_PORTD_BASE+(GPIO_O_DATA + ALL_BITS)) |= BIT6HI;
HWREG(GPIO_PORTD_BASE+(GPIO_O_DATA + ALL_BITS)) |= BIT7HI;
#endif
#ifdef TEST2
puts("\n\r Test2 Only PB6 should be at higher PW than the rest\r\n");
Bucket_HWInit();
activeServoList |= 0x01;
printf("\n\r activeServoList %d\r\n", activeServoList);
for (int i=0; i< 30; i++){
StepAllServos();
}
#endif
#ifdef TEST3
puts("\n\r Test3 Puts PB6 and PB7 at highest then resets PB6\r\n");
Bucket_HWInit();
activeServoList |= 0x03;
printf("\n\r activeServoList %d\r\n", activeServoList);
for (int i=0; i< 30; i++){
StepAllServos();
}
ResetServo(1);
#endif
#ifdef TEST4
puts("\n\r Test4 Puts all servos at highest then resets all\r\n");
Bucket_HWInit();
activeServoList |= 0x0f;
printf("\n\r activeServoList %d\r\n", activeServoList);
for (int i=0; i< 30; i++){
StepAllServos();
}
ResetAllServos();
#endif
#ifdef TEST5
puts("\n\r Test5 Puts all servos at highest\r\n");
Bucket_HWInit();
SetoffAllDripServo();
for (int i=0; i< 30; i++){
StepAllServos();
}
#endif
#ifdef TEST6
puts("\n\r Test6 Sample from PE2\r\n");
Bucket_HWInit();
bool inpuState = SampleBucketSensor(1);
if (inpuState == true) {
puts("\n\r pin is high\r\n");
}
#endif
#ifdef TEST7
puts("\n\r Test7 Run ES_Framework\r\n");
puts("\n\r Initialize Event Services with 1ms timer rate\r\n");
ES_Initialize(ES_Timer_RATE_1mS);
puts("\n\r Begin to run Event Services\r\n");
if (ES_Run() != Success) {
puts("\n\r There was a failure in ES_Run\r\n");
}
#endif
#ifdef TEST8
puts("\n\r Test8 Test RandServoList\r\n");
Bucket_HWInit();
for (int i = 0; i<4;i++) {
RandServoList();
}
#endif
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment