/*              mija 2008       

                *.h file for defines key.c

                key                             KEY1
                                                KEY2
                                                KEY3
                                                KEY4

        !!!!NOTE must be set PIN with PORT and DDR
*/

#ifndef __key_h_included__
#define __key_h_included__

#define KEYSTABLETIME           5               //umerne rychlosti main smycky cca
                                                                        //pocet opakovani fce procesKey() za cca 30ms
#define KEYFIRSTREPEATTIME      200
#define KEYREPEATTIME           100

#define KEY1                    PC0
#define PORT_KEY1               PORTC
#define DDR_KEY1                DDRC
#define PIN_KEY1                PINC

#define KEY2                    PC1
#define PORT_KEY2               PORTC
#define DDR_KEY2                DDRC
#define PIN_KEY2                PINC

void ProcesKey(uint8_t *key);
void KeyInit();

//*******************************************************************
//internal

#define KEY1Input()             (!(PIN_KEY1  & (_BV(KEY1))))
#define KEY1Init()              DDR_KEY1 &= (~(_BV(KEY1)))
#define KEY1Pullup()            PORT_KEY1 |= _BV(KEY1)

#define KEY2Input()             (!(PIN_KEY2  & (_BV(KEY2))))
#define KEY2Init()              DDR_KEY2 &= (~(_BV(KEY2)))
#define KEY2Pullup()            PORT_KEY2 |= _BV(KEY2)

#define NOKEY   0
#define TL1             1
#define TL2             2
#define TL1TL2  3
//enum{NOKEY=0,TL1,TL2,TL3,TL4,TL1TL2};

#endif /* __key_h_included__ */