-const u8 keymap0[8] = {8, 7, 6, 5, 4, 3, 2, 1};
-const u8 keymap1[3] = {11, 10, 9};
+const u8 keymap0[8] = {KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8};
+const u8 keymap1[3] = {KEY_9, KEY_0, KEY_RESET};
+
+#define NO_KEY 8
+
+/* reads the keypad and returns the bit number that was turned on in the shift
+ * register (from 0..7). If no bits were turned on, it returns 8 (aka NO_KEY)
+ */
+extern inline u8 keypad_read_row(const u8 row) {
+ u8 i, num;