Archived
1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
keybrd/src/RowBase.h

42 lines
1.5 KiB
C
Raw Normal View History

#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>
/* RowBase is an abstract base class.
2016-05-09 14:05:08 +00:00
*/
class RowBase
2016-05-09 14:05:08 +00:00
{
private:
2016-06-02 16:26:53 +00:00
static const unsigned int DELAY_MICROSECONDS; //delay between each Row scan for debouncing
2016-05-09 14:05:08 +00:00
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-06-02 16:26:53 +00:00
void wait();
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;
void pressRelease(const uint16_t rowEnd, const uint8_t debouncedChanged);
2016-05-09 14:05:08 +00:00
virtual void keyWasPressed();
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:
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) { }
//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