summaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2014-06-01 19:02:09 (GMT)
committerChristian Pointner <equinox@helsinki.at>2014-06-01 19:02:09 (GMT)
commit31c61e05a1a1d95574cc1ca4bcb9b2cc41d914cb (patch)
treea9616d673355781092d886effd5f5653dea956be /software
parent683f79ee498764e2dff0f61760f6f9d075d6fbb4 (diff)
furhter cleanup
Diffstat (limited to 'software')
-rw-r--r--software/rhmixxx/keypad.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/software/rhmixxx/keypad.c b/software/rhmixxx/keypad.c
index 196050b..7a58ad0 100644
--- a/software/rhmixxx/keypad.c
+++ b/software/rhmixxx/keypad.c
@@ -28,19 +28,22 @@
#define KEYPAD_PIN PINA
#define KEYPAD_PORT PORTA
#define KEYPAD_DDR DDRA
+#define KEYPAD_NUM_COLS 4
+#define KEYPAD_NUM_ROWS 4
+#define KEYPAD_NUM_KEYS KEYPAD_NUM_COLS * KEYPAD_NUM_ROWS
#define KEYPAD_LP_CNT_MAX 200
static struct {
uint8_t last_sent;
int16_t lp_cnt;
-} keypad_state[16];
+} keypad_state[KEYPAD_NUM_KEYS];
void keypad_init(void)
{
KEYPAD_DDR = 0x00;
KEYPAD_PORT = 0x0F;
uint8_t i;
- for(i = 0; i < 16; ++i) {
+ for(i = 0; i < KEYPAD_NUM_KEYS; ++i) {
keypad_state[i].last_sent = 0;
keypad_state[i].lp_cnt = 0;
}
@@ -146,13 +149,13 @@ static void keypad_key_lowpass(uint8_t key_idx, uint8_t current_state)
void keypad_task(void)
{
uint8_t col, row;
- for(col = 0; col < 4; ++col) {
+ for(col = 0; col < KEYPAD_NUM_COLS; ++col) {
KEYPAD_DDR = 1 << (col + 4);
KEYPAD_PORT = 0x0F;
_delay_us(10);
- for(row = 0; row < 4; ++row) {
- uint8_t key_idx = col*4 + row;
+ for(row = 0; row < KEYPAD_NUM_ROWS; ++row) {
+ uint8_t key_idx = col*KEYPAD_NUM_ROWS + row;
uint8_t current_state = KEYPAD_PIN & (1 << row);
keypad_key_lowpass(key_idx, current_state);