/**************************************************************************************************
---------------------------------------------------------------------------------------------------
	Copyright (c) 2004, Jonathan Bagg
	All rights reserved.

	 Redistribution and use in source and binary forms, with or without modification, are permitted 
	 provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of 
	  conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of 
	  conditions and the following disclaimer in the documentation and/or other materials provided 
	  with the distribution.
    * Neither the name of Jonathan Bagg nor the names of its contributors may be used to 
	  endorse or promote products derived from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------------------------------
   Project name : Infidigm AVR Drivers
   Processor	: ATMega16
   File name    : keypad.h
---------------------------------------------------------------------------------------------------
   Modifications: 

   Revision 1.0  2004/12/24 	Bagg
   - Cleaned up for release
   
---------------------------------------------------------------------------------------------------
   Created      : 22 November 2004                Author(s) : Jonathan Bagg
---------------------------------------------------------------------------------------------------
   4x4 KeyPad Driver
---------------------------------------------------------------------------------------------------
**************************************************************************************************/

/**************************************************************************************************
*   KEY VALUE Definitions
**************************************************************************************************/
#define NOKEY	0xFF
#define	KEY0	0xEE
#define	KEY1	0xDE
#define	KEY2	0xBE
#define	KEY3	0x7E
#define	KEY4	0xED
#define	KEY5	0xDD
#define	KEY6	0xBD
#define	KEY7	0x7D
#define	KEY8	0xEB
#define	KEY9	0xDB
#define	KEYA	0xBB
#define	KEYB	0x7B
#define	KEYC	0xE7
#define	KEYD	0xD7
#define	KEYE	0xB7
#define	KEYF	0x77

/**************************************************************************************************
*
*   Function          : pad_update
*
*   Description       : Performs the scan sequence on the key pad. Reads the rows and then the 
*						columns. Two identical reads are required for an liable scan.  Flags that
*						a new key has been pressed.
*
*   Parameters        : None
*
*   Functions Called  : timer_get(), timer_reset(), timer_check(), timer_release()
*
*   Returns           : None
*
**************************************************************************************************/
void pad_update(void);

/**************************************************************************************************
*
*   Function          : pad_read
*
*   Description       : This function is used to read the value of the last KEY pressed.
*
*   Parameters        : None
*
*   Functions Called  : None
*
*   Returns           : The value of the key that was last pressed.
*
**************************************************************************************************/
unsigned char pad_read(void);

/**************************************************************************************************
*
*   Function          : pad_press
*
*   Description       : This function is polled to determin if a new key has been pressed. The 
*						function acts as a one-shot; once it has been called and returns a 
*						'1', it will return a '0' for every time it is called until a new key is
*						pressed.
*
*   Parameters        : None
*
*   Functions Called  : None
*
*   Returns           : 0 = no new key press, 1 = new key pressed
*
**************************************************************************************************/
unsigned char pad_press(void);
