2016-05-31 12:36:51 +00:00
|
|
|
#ifndef ROWBASE_H
|
|
|
|
#define ROWBASE_H
|
2016-05-09 14:05:08 +00:00
|
|
|
#include <Arduino.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <Key.h>
|
|
|
|
#include <RowPort.h>
|
|
|
|
#include <ColPort.h>
|
|
|
|
|
2016-06-02 15:58:33 +00:00
|
|
|
/* RowBase is an abstract base class.
|
2016-05-09 14:05:08 +00:00
|
|
|
*/
|
2016-05-31 12:36:51 +00:00
|
|
|
class RowBase
|
2016-05-09 14:05:08 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
Key *const *const ptrsKeys; //array of Key pointers
|
|
|
|
|
|
|
|
RowPort &refRowPort; //this row's IC port
|
|
|
|
const uint8_t rowPin; //bitwise, 1 indicates IC pin connected to this row
|
|
|
|
|
|
|
|
ColPort *const *const ptrsColPorts; //array of column ports
|
|
|
|
const uint8_t colPortCount;
|
|
|
|
|
2016-05-31 12:36:51 +00:00
|
|
|
void scan(const bool activeHigh);
|
|
|
|
uint8_t getRowState(uint16_t& rowEnd, const bool activeHigh);
|
2016-06-01 21:59:59 +00:00
|
|
|
virtual uint8_t debounce(const uint8_t rowState)=0;
|
2016-06-01 19:04:46 +00:00
|
|
|
void pressRelease(const uint16_t rowEnd, const uint8_t debouncedChanged);
|
2016-05-09 14:05:08 +00:00
|
|
|
virtual void keyWasPressed();
|
2016-05-31 12:36:51 +00:00
|
|
|
protected:
|
2016-06-01 15:58:03 +00:00
|
|
|
uint8_t previousDebounced; //bitwise, one bit per key
|
2016-05-09 14:05:08 +00:00
|
|
|
public:
|
2016-05-31 12:36:51 +00:00
|
|
|
RowBase( RowPort &refRowPort, const uint8_t rowPin,
|
2016-05-09 14:05:08 +00:00
|
|
|
ColPort *const ptrsColPorts[], const uint8_t colPortCount,
|
|
|
|
Key *const ptrsKeys[])
|
|
|
|
: ptrsKeys(ptrsKeys), refRowPort(refRowPort), rowPin(rowPin),
|
|
|
|
ptrsColPorts(ptrsColPorts), colPortCount(colPortCount),
|
2016-06-01 15:58:03 +00:00
|
|
|
previousDebounced(0) { }
|
2016-05-31 12:36:51 +00:00
|
|
|
//Key* getPtrKey(uint8_t col) const; todo delete, no longer needed 5/31/16
|
2016-05-09 14:05:08 +00:00
|
|
|
void process(const bool activeHigh);
|
|
|
|
};
|
|
|
|
#endif
|