diff --git a/examples/keybrd_shift_register/keybrd_shift_register.ino b/examples/keybrd_shift_register/keybrd_shift_register.ino index f281f8f..f559269 100644 --- a/examples/keybrd_shift_register/keybrd_shift_register.ino +++ b/examples/keybrd_shift_register/keybrd_shift_register.ino @@ -98,40 +98,40 @@ Code_LEDLock o_capsLock(KEY_CAPS_LOCK, LED1); // ================= LEFT ROWS ================= Key* ptrsKeys_L0[] = { &o_capsLock, &s_a }; -Row_uC row_L0(0, readPins, ptrsKeys_L0, READ_PIN_COUNT); +Row_uC row_L0(0, readPins, READ_PIN_COUNT, ptrsKeys_L0); Key* ptrsKeys_L1[] = { &s_b, &s_c }; -Row_uC row_L1(1, readPins, ptrsKeys_L1, READ_PIN_COUNT); +Row_uC row_L1(1, readPins, READ_PIN_COUNT, ptrsKeys_L1); // ================= RIGHT ROWS ================ //typedef should be large in /home/wolfv/Documents/Arduino/keybrd_proj/keybrd/src/config_keybrd.h -//Row_ShiftRegisters(STROBE_PIN, ptrsKeys[], READ_PIN_COUNT) +//Row_ShiftRegisters(STROBE_PIN, READ_PIN_COUNT, ptrsKeys[]) //the s_z are place holders and should not print /* //prints 0 1 Key* ptrsKeys_R0[] = { &s_0, &s_z, &s_z, &s_z, &s_1, &s_z, &s_z, &s_z }; const uint8_t READ_PIN_COUNT_R0 = sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0); -Row_ShiftRegisters row_R0(8, ptrsKeys_R0, READ_PIN_COUNT_R0); +Row_ShiftRegisters row_R0(8, READ_PIN_COUNT_R0, ptrsKeys_R0); //prints a b Key* ptrsKeys_R1[] = { &s_a, &s_z, &s_z, &s_z, &s_b, &s_z, &s_z, &s_z }; const uint8_t READ_PIN_COUNT_R1 = sizeof(ptrsKeys_R1)/sizeof(*ptrsKeys_R1); -Row_ShiftRegisters row_R1(9, ptrsKeys_R1, READ_PIN_COUNT_R1); +Row_ShiftRegisters row_R1(9, READ_PIN_COUNT_R1, ptrsKeys_R1); */ /* //prints 0 1 2 Key* ptrsKeys_R0[] = { &s_0, &s_z, &s_z, &s_z, &s_1, &s_z, &s_z, &s_z, &s_2, &s_z, &s_z, &s_z }; const uint8_t READ_PIN_COUNT_R0 = sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0); -Row_ShiftRegisters row_R0(8, ptrsKeys_R0, READ_PIN_COUNT_R0); +Row_ShiftRegisters row_R0(8, READ_PIN_COUNT_R0, ptrsKeys_R0); */ /* //prints 0 1 2 3 Key* ptrsKeys_R0[] = { &s_0, &s_z, &s_z, &s_z, &s_1, &s_z, &s_z, &s_z, &s_2, &s_z, &s_z, &s_z, &s_3, &s_z, &s_z, &s_z }; const uint8_t READ_PIN_COUNT_R0 = sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0); -Row_ShiftRegisters row_R0(8, ptrsKeys_R0, READ_PIN_COUNT_R0); +Row_ShiftRegisters row_R0(8, READ_PIN_COUNT_R0, ptrsKeys_R0); */ /* //prints 0 1 2 3 4 5 @@ -139,7 +139,7 @@ Key* ptrsKeys_R0[] = { &s_0, &s_z, &s_z, &s_z, &s_1, &s_z, &s_z, &s_z, &s_2, &s_z, &s_z, &s_z, &s_3, &s_z, &s_z, &s_z, &s_4, &s_z, &s_z, &s_z, &s_5, &s_z, &s_z, &s_z }; const uint8_t READ_PIN_COUNT_R0 = sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0); -Row_ShiftRegisters row_R0(8, ptrsKeys_R0, READ_PIN_COUNT_R0); +Row_ShiftRegisters row_R0(8, READ_PIN_COUNT_R0, ptrsKeys_R0); */ //prints 0 1 2 3 3 4 5 6, microseconds_per_scan=87 with SAMPLE_COUNT 4 @@ -148,7 +148,7 @@ Key* ptrsKeys_R0[] = { &s_0, &s_z, &s_z, &s_z, &s_1, &s_z, &s_z, &s_z, &s_4, &s_z, &s_z, &s_z, &s_5, &s_z, &s_z, &s_z, &s_6, &s_z, &s_z, &s_z, &s_3, &s_4, &s_5, &s_6 }; const uint8_t READ_PIN_COUNT_R0 = sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0); -Row_ShiftRegisters row_R0(0, ptrsKeys_R0, READ_PIN_COUNT_R0); +Row_ShiftRegisters row_R0(0, READ_PIN_COUNT_R0, ptrsKeys_R0); //prints a b c d u v w x Key* ptrsKeys_R1[] = { &s_a, &s_z, &s_z, &s_z, &s_b, &s_z, &s_z, &s_z, @@ -156,7 +156,7 @@ Key* ptrsKeys_R1[] = { &s_a, &s_z, &s_z, &s_z, &s_b, &s_z, &s_z, &s_z, &s_e, &s_z, &s_z, &s_z, &s_f, &s_z, &s_z, &s_z, &s_g, &s_z, &s_z, &s_z, &s_u, &s_v, &s_w, &s_x }; const uint8_t READ_PIN_COUNT_R1 = sizeof(ptrsKeys_R1)/sizeof(*ptrsKeys_R1); -Row_ShiftRegisters row_R1(1, ptrsKeys_R1, READ_PIN_COUNT_R1); +Row_ShiftRegisters row_R1(1, READ_PIN_COUNT_R1, ptrsKeys_R1); // ################### MAIN #################### void setup() diff --git a/src/Row.cpp b/src/Row.cpp index 28f843d..3dc0130 100644 --- a/src/Row.cpp +++ b/src/Row.cpp @@ -3,7 +3,7 @@ pressRelease() calls key's press() or release() function if it was pressed or released. Both parameters are bitwise. */ -void Row::pressRelease(const uint8_t READ_PIN_COUNT, const read_pins_t debouncedChanged) +void Row::pressRelease(const uint8_t readPinCount, const read_pins_t debouncedChanged) { read_pins_t isFallingEdge; //bitwise, 1 means falling edge read_pins_t isRisingEdge; //bitwise, 1 means rising edge @@ -16,7 +16,7 @@ void Row::pressRelease(const uint8_t READ_PIN_COUNT, const read_pins_t debounced //bit=1 if last debounced changed from 0 to 1, else bit=0 isRisingEdge = debouncedChanged & debounced; - for (readMask=1, i=0; i < READ_PIN_COUNT; readMask<<=1, i++) //for each key in row + for (readMask=1, i=0; i < readPinCount; readMask<<=1, i++) //for each key in row { //release before press avoids impossible key sequence if (readMask & isFallingEdge) //if key was released diff --git a/src/Row.h b/src/Row.h index 3e2c238..bb927f4 100644 --- a/src/Row.h +++ b/src/Row.h @@ -14,7 +14,7 @@ class Row virtual void keyWasPressed(); protected: read_pins_t debounced; //bitwise, 1 means pressed, 0 means released - void pressRelease(const uint8_t READ_PIN_COUNT, const read_pins_t debouncedChanged); + void pressRelease(const uint8_t readPinCount, const read_pins_t debouncedChanged); public: Row(Key *const ptrsKeys[]) : ptrsKeys(ptrsKeys), debounced(0) { } virtual void process()=0; diff --git a/src/Row_ShiftRegisters.h b/src/Row_ShiftRegisters.h index 970685b..d017e36 100644 --- a/src/Row_ShiftRegisters.h +++ b/src/Row_ShiftRegisters.h @@ -31,7 +31,7 @@ class Row_ShiftRegisters : public Row Debouncer_4Samples debouncer; //Debouncer_Not debouncer; //passed test public: - Row_ShiftRegisters(const uint8_t STROBE_PIN, Key *const ptrsKeys[], uint8_t READ_PIN_COUNT) + Row_ShiftRegisters(const uint8_t STROBE_PIN, uint8_t READ_PIN_COUNT, Key *const ptrsKeys[]) : Row(ptrsKeys), scanner(STROBE_PIN, READ_PIN_COUNT) { } void begin(); void process(); diff --git a/src/Row_uC.h b/src/Row_uC.h index 1b4afc7..ca4482c 100644 --- a/src/Row_uC.h +++ b/src/Row_uC.h @@ -32,8 +32,8 @@ class Row_uC : public Row Scanner_uC scanner; Debouncer_4Samples debouncer; public: - Row_uC(const uint8_t strobePin, const uint8_t READ_PINS[], - Key *const ptrsKeys[], const uint8_t READ_PIN_COUNT) + Row_uC(const uint8_t strobePin, const uint8_t READ_PINS[], const uint8_t READ_PIN_COUNT, + Key *const ptrsKeys[]) : Row(ptrsKeys), scanner(strobePin, READ_PINS, READ_PIN_COUNT) { } void process(); };