/*
 * klavesnice.h
 *
 * Created: 25.3.2012 15:58:42
 *  Author: Kain
 */


#ifndef KLAVESNICE_H_
#define KLAVESNICE_H_
#include "rfchannel.h"

#define KB_PORT_COLS PORTD
#define KB_DDR_COLS  DDRD
#define KB_PIN_COLS  PIND
#define KB_PORT_ROWS PORTB
#define KB_DDR_ROWS  DDRB
#define KB_PIN_ROWS  PINB

// Piny klavesnice - musi sedet se zapojenim ve schematu
#define KB_COL1 (1<<4)
#define KB_COL2 (1<<5)
#define KB_COL3 (1<<6)
#define KB_COL4 (1<<7)
#define KB_ROW1 (1<<0)
#define KB_ROW2 (1<<1)
#define KB_ROW3 (1<<2)
#define KB_ROW4 (1<<3)
//
#define KB_0    (KB_COL2 | KB_ROW4)
#define KB_1    (KB_COL1 | KB_ROW1)
#define KB_2    (KB_COL2 | KB_ROW1)
#define KB_3    (KB_COL3 | KB_ROW1)
#define KB_4    (KB_COL1 | KB_ROW2)
#define KB_5    (KB_COL2 | KB_ROW2)
#define KB_6    (KB_COL3 | KB_ROW2)
#define KB_7    (KB_COL1 | KB_ROW3)
#define KB_8    (KB_COL2 | KB_ROW3)
#define KB_9    (KB_COL3 | KB_ROW3)
#define KB_MRIZKA   (KB_COL3 | KB_ROW4)
#define KB_A    (KB_COL4 | KB_ROW1)
#define KB_B    (KB_COL4 | KB_ROW2)
#define KB_C    (KB_COL4 | KB_ROW3)
#define KB_D    (KB_COL4 | KB_ROW4)

#define KB_COLS_MASK 0xf0
#define KB_ROWS_MASK 0x0f

uint8_t KB_getKeyPress();
void KB_doTheJob(const uint8_t key);



#endif /* KLAVESNICE_H_ */