Archived
1
0

remove readPinCount from Row_uC, Row_ShiftRegisters: process() and scan()

This commit is contained in:
wolfv6 2016-07-12 08:31:17 -06:00
parent e860d059cf
commit 4d69fd2aed
8 changed files with 19 additions and 17 deletions

View File

@ -4,12 +4,12 @@ void Row_ShiftRegisters::process()
{
//these variables are all bitwise, one bit per key
read_pins_t rowState; //1 means pressed, 0 means released
uint8_t readPinCount;
//uint8_t readPinCount;
read_pins_t debouncedChanged; //1 means debounced changed
rowState = scanner.scan(readPinCount);
rowState = scanner.scan();
debouncedChanged = debouncer.debounce(rowState, debounced);
pressRelease(readPinCount, debouncedChanged);
pressRelease(READ_PIN_COUNT, debouncedChanged);
}
void Row_ShiftRegisters::begin()

View File

@ -30,9 +30,10 @@ class Row_ShiftRegisters : public Row
Scanner_ShiftRegs74HC165 scanner;
Debouncer_4Samples debouncer;
//Debouncer_Not debouncer; //passed test
const uint8_t READ_PIN_COUNT; //number of read pins
public:
Row_ShiftRegisters(const uint8_t STROBE_PIN, uint8_t READ_PIN_COUNT, Key *const ptrsKeys[])
: Row(ptrsKeys), scanner(STROBE_PIN, READ_PIN_COUNT) { }
: Row(ptrsKeys), scanner(STROBE_PIN, READ_PIN_COUNT), READ_PIN_COUNT(READ_PIN_COUNT) { }
void begin();
void process();
};

View File

@ -7,10 +7,10 @@ void Row_uC::process()
{
//these variables are all bitwise, one bit per key
read_pins_t rowState; //1 means pressed, 0 means released
uint8_t readPinCount;
//uint8_t readPinCount;
read_pins_t debouncedChanged; //1 means debounced changed
rowState = scanner.scan(readPinCount);
rowState = scanner.scan();
debouncedChanged = debouncer.debounce(rowState, debounced);
pressRelease(readPinCount, debouncedChanged);
pressRelease(READ_PIN_COUNT, debouncedChanged);
}

View File

@ -31,10 +31,11 @@ class Row_uC : public Row
private:
Scanner_uC scanner;
Debouncer_4Samples debouncer;
const uint8_t READ_PIN_COUNT; //number of read pins
public:
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) { }
: Row(ptrsKeys), scanner(strobePin, READ_PINS, READ_PIN_COUNT), READ_PIN_COUNT(READ_PIN_COUNT) { }
void process();
};
#endif

View File

@ -2,7 +2,7 @@
//constructor
Scanner_ShiftRegs74HC165::Scanner_ShiftRegs74HC165(const uint8_t STROBE_PIN, uint8_t READ_PIN_COUNT)
: STROBE_PIN(STROBE_PIN), BYTE_COUNT(ceil (float(READ_PIN_COUNT)/8)), READ_PIN_COUNT(READ_PIN_COUNT)
: STROBE_PIN(STROBE_PIN), BYTE_COUNT(ceil (float(READ_PIN_COUNT)/8))
{
//configure controller to communicate with shift register matrix
pinMode(STROBE_PIN, OUTPUT);
@ -18,7 +18,7 @@ void Scanner_ShiftRegs74HC165::begin()
/*
Sets readPinCount and returns rowState.
*/
read_pins_t Scanner_ShiftRegs74HC165::scan(uint8_t& readPinCount)
read_pins_t Scanner_ShiftRegs74HC165::scan()
{
read_pins_t rowState = 0;
@ -34,7 +34,7 @@ read_pins_t Scanner_ShiftRegs74HC165::scan(uint8_t& readPinCount)
//strobe row off
digitalWrite(STROBE_PIN, STROBE_OFF);
readPinCount = READ_PIN_COUNT;
// readPinCount = READ_PIN_COUNT;
//for testing on breadboard, clear unpowered pins
rowState &= 0b11110001000100010001000100010001; //todo

View File

@ -44,10 +44,10 @@ class Scanner_ShiftRegs74HC165
static const bool STROBE_OFF; //logic level of strobe off, complement of active state
const uint8_t STROBE_PIN; //Arduino pin number connected to this row
const uint8_t BYTE_COUNT; //number of bytes to read from shift registers
uint8_t READ_PIN_COUNT;
//uint8_t READ_PIN_COUNT;
public:
Scanner_ShiftRegs74HC165(const uint8_t STROBE_PIN, uint8_t READ_PIN_COUNT);
virtual read_pins_t scan(uint8_t& READ_PIN_COUNT);
virtual read_pins_t scan();
void begin();
};
#endif

View File

@ -36,7 +36,7 @@ https://www.arduino.cc/en/Reference/DigitalWrite
https://www.arduino.cc/en/Reference/DigitalRead
https://www.arduino.cc/en/Reference/Constants > Digital Pins modes: INPUT, INPUT_PULLUP, and OUTPUT
*/
read_pins_t Scanner_uC::scan(uint8_t& readPinCount)
read_pins_t Scanner_uC::scan()
{
read_pins_t rowState = 0; //bitwise, one col per bit, 1 means key is pressed
read_pins_t readMask = 1; //bitwise, one col per bit, active col bit is 1
@ -58,6 +58,6 @@ read_pins_t Scanner_uC::scan(uint8_t& readPinCount)
//strobe row off
digitalWrite(STROBE_PIN, STROBE_OFF);
readPinCount = READ_PIN_COUNT;
// readPinCount = READ_PIN_COUNT;
return rowState;
}

View File

@ -19,8 +19,8 @@ class Scanner_uC
const uint8_t READ_PIN_COUNT; //number of read pins
public:
Scanner_uC(const uint8_t STROBE_PIN,
const uint8_t READ_PINS[], const uint8_t READ_PIN_COUNT); //todo rename READ_PIN_COUNT to READ_PIN_COUNT ??
virtual read_pins_t scan(uint8_t& READ_PIN_COUNT);
const uint8_t READ_PINS[], const uint8_t READ_PIN_COUNT);
virtual read_pins_t scan();
};
#endif