Преглед на файлове

move proccess() form RowBase to children

tags/v0.5.0
wolfv6 преди 8 години
родител
ревизия
f195c8f56a
променени са 8 файла, в които са добавени 36 реда и са изтрити 45 реда
  1. 0
    16
      src/RowBase.cpp
  2. 1
    3
      src/RowBase.h
  3. 9
    6
      src/Row_IOE.cpp
  4. 1
    2
      src/Row_IOE.h
  5. 11
    8
      src/Row_ShiftRegisters.cpp
  6. 1
    2
      src/Row_ShiftRegisters.h
  7. 12
    6
      src/Row_uC.cpp
  8. 1
    2
      src/Row_uC.h

+ 0
- 16
src/RowBase.cpp Целия файл

#include "RowBase.h" #include "RowBase.h"
/*
process() scans the row and calls any newly pressed or released keys.
*/
void RowBase::process()
{
//these variables are all bitwise, one bit per key
read_pins_t rowState; //1 means pressed, 0 means released
read_pins_mask_t rowEnd; //1 bit marks positioned after last key of row
read_pins_t debouncedChanged; //1 means debounced changed
wait();
rowState = scan(rowEnd);
debouncedChanged = debounce(rowState, debounced);
pressRelease(rowEnd, debouncedChanged);
}
/* wait() delay's scan to give switches time to debounce. /* wait() delay's scan to give switches time to debounce.
This version of wait() is very simple. More sophisticated versions can override this one. This version of wait() is very simple. More sophisticated versions can override this one.

+ 1
- 3
src/RowBase.h Целия файл

void pressRelease(const read_pins_mask_t rowEnd, const read_pins_t debouncedChanged); void pressRelease(const read_pins_mask_t rowEnd, const read_pins_t debouncedChanged);
public: public:
RowBase(Key *const ptrsKeys[]) : ptrsKeys(ptrsKeys), debounced(0) { } RowBase(Key *const ptrsKeys[]) : ptrsKeys(ptrsKeys), debounced(0) { }
virtual void process();
virtual read_pins_t scan(read_pins_mask_t& rowEnd)=0;
virtual read_pins_t debounce(const read_pins_t rowState, read_pins_t& debounced)=0;
virtual void process()=0;
}; };
#endif #endif

+ 9
- 6
src/Row_IOE.cpp Целия файл

#include "Row_IOE.h" #include "Row_IOE.h"


read_pins_t Row_IOE::scan(read_pins_mask_t& rowEnd)
void Row_IOE::process()
{ {
return scanner.scan(rowEnd);
}
//these variables are all bitwise, one bit per key
read_pins_t rowState; //1 means pressed, 0 means released
read_pins_mask_t rowEnd; //1 bit marks positioned after last key of row
read_pins_t debouncedChanged; //1 means debounced changed


read_pins_t Row_IOE::debounce(const read_pins_t rowState, read_pins_t& debounced)
{
return debouncer.debounce(rowState, debounced);
wait();
rowState = scanner.scan(rowEnd);
debouncedChanged = debouncer.debounce(rowState, debounced);
pressRelease(rowEnd, debouncedChanged);
} }

+ 1
- 2
src/Row_IOE.h Целия файл

Row_IOE( RowPort& refRowPort, const uint8_t strobePin, Row_IOE( RowPort& refRowPort, const uint8_t strobePin,
ColPort& refColPort, Key *const ptrsKeys[]) ColPort& refColPort, Key *const ptrsKeys[])
: RowBase(ptrsKeys), scanner(refRowPort, strobePin, refColPort) { } : RowBase(ptrsKeys), scanner(refRowPort, strobePin, refColPort) { }
read_pins_t scan(read_pins_mask_t& rowEnd);
read_pins_t debounce(const read_pins_t rowState, read_pins_t& debounced);
void process();
}; };
#endif #endif

+ 11
- 8
src/Row_ShiftRegisters.cpp Целия файл

#include "Row_ShiftRegisters.h" #include "Row_ShiftRegisters.h"


void Row_ShiftRegisters::begin()
void Row_ShiftRegisters::process()
{ {
scanner.begin();
}
//these variables are all bitwise, one bit per key
read_pins_t rowState; //1 means pressed, 0 means released
read_pins_mask_t rowEnd; //1 bit marks positioned after last key of row
read_pins_t debouncedChanged; //1 means debounced changed


read_pins_t Row_ShiftRegisters::scan(read_pins_mask_t& rowEnd)
{
return scanner.scan(rowEnd);
wait();
rowState = scanner.scan(rowEnd);
debouncedChanged = debouncer.debounce(rowState, debounced);
pressRelease(rowEnd, debouncedChanged);
} }


read_pins_t Row_ShiftRegisters::debounce(const read_pins_t rowState, read_pins_t& debounced)
void Row_ShiftRegisters::begin()
{ {
return debouncer.debounce(rowState, debounced);
scanner.begin();
} }

+ 1
- 2
src/Row_ShiftRegisters.h Целия файл

Row_ShiftRegisters(const uint8_t STROBE_PIN, Key *const ptrsKeys[], uint8_t KEY_COUNT) Row_ShiftRegisters(const uint8_t STROBE_PIN, Key *const ptrsKeys[], uint8_t KEY_COUNT)
: RowBase(ptrsKeys), scanner(STROBE_PIN, KEY_COUNT) { } : RowBase(ptrsKeys), scanner(STROBE_PIN, KEY_COUNT) { }
void begin(); void begin();
read_pins_t scan(read_pins_mask_t& rowEnd);
read_pins_t debounce(const read_pins_t rowState, read_pins_t& debounced);
void process();
}; };
#endif #endif

+ 12
- 6
src/Row_uC.cpp Целия файл

#include "Row_uC.h" #include "Row_uC.h"


read_pins_t Row_uC::scan(read_pins_mask_t& rowEnd)
/*
process() scans the row and calls any newly pressed or released keys.
*/
void Row_uC::process()
{ {
return scanner.scan(rowEnd);
}
//these variables are all bitwise, one bit per key
read_pins_t rowState; //1 means pressed, 0 means released
read_pins_mask_t rowEnd; //1 bit marks positioned after last key of row
read_pins_t debouncedChanged; //1 means debounced changed


read_pins_t Row_uC::debounce(const read_pins_t rowState, read_pins_t& debounced)
{
return debouncer.debounce(rowState, debounced);
wait();
rowState = scanner.scan(rowEnd);
debouncedChanged = debouncer.debounce(rowState, debounced);
pressRelease(rowEnd, debouncedChanged);
} }

+ 1
- 2
src/Row_uC.h Целия файл

Row_uC(const uint8_t strobePin, const uint8_t readPins[], const uint8_t READ_PIN_COUNT, Row_uC(const uint8_t strobePin, const uint8_t readPins[], const uint8_t READ_PIN_COUNT,
Key *const ptrsKeys[]) Key *const ptrsKeys[])
: RowBase(ptrsKeys), scanner(strobePin, readPins, READ_PIN_COUNT) { } : RowBase(ptrsKeys), scanner(strobePin, readPins, READ_PIN_COUNT) { }
read_pins_t scan(read_pins_mask_t& rowEnd);
read_pins_t debounce(const read_pins_t rowState, read_pins_t& debounced);
void process();
}; };
#endif #endif