GroupA / Mbed 2 deprecated WaG_final

Dependencies:   mbed

Fork of Lab_6_WaG by GroupA

utility.cpp

Committer:
phn10
Date:
2018-04-24
Revision:
74:8881f4aeb174
Parent:
35:ad2b3d6f0e5a

File content as of revision 74:8881f4aeb174:

/******************************************************************************
* EECS 397
*
* Assignment Name: Lab 6: WaG
* 
* Authors: Sam Morrison and Phong Nguyen 
* File name: utility.cpp
* Purpose: Utility functions
*
* Created: 03/20/2018
* Last Modified: 03/20/2018
*
******************************************************************************/

#include "mbed.h"
#include "io_pins.h"
#include "utility.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

extern DigitalIn start_button;

/*
 * int uti_chk_ubutton();
 * Description: returns true when button is pressed and released
 *
 * Inputs: 
 *      Parameters:
 *      Globals:
 *      
 * Outputs:
 *      Returns: void
*/
int uti_chk_ubutton() {
    if (start_button == 0)
        return 0; // exits if button is not pressed
    else {
        //cycle until button is released
        do { 
        wait(0.02); 
        } while (start_button == 1); 
        wait(0.02); //delay to prevent debounce
        return 1;
    }
}