Archived
1
0

move READ_PIN_COUNT parameter in constructors

This commit is contained in:
wolfv6 2016-07-12 07:38:59 -06:00
parent a5d6fb8d9e
commit e860d059cf
5 changed files with 16 additions and 16 deletions

View File

@ -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()

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -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();
};