run AStyle
This commit is contained in:
parent
25c644f012
commit
07a66b0505
@ -7,15 +7,15 @@ The electrical limitation to bus speed is bus capacitance and the length of the
|
||||
Longer wires require lower clock speeds.
|
||||
*/
|
||||
uint8_t Port_MCP23S17::transfer(const uint8_t command, const uint8_t registerAddr,
|
||||
const uint8_t data)
|
||||
const uint8_t data)
|
||||
{
|
||||
uint8_t portState; //bit pattern
|
||||
|
||||
SPI.beginTransaction( SPISettings(5000000, MSBFIRST, SPI_MODE0) ); //control SPI bus, 5 MHz
|
||||
digitalWrite(SS, LOW); //enable Slave Select
|
||||
SPI.transfer(command); //write or read command
|
||||
SPI.transfer(registerAddr); //register address to write data to
|
||||
portState = SPI.transfer(data); //write data, read portState
|
||||
SPI.transfer(command); //write or read command
|
||||
SPI.transfer(registerAddr); //register address to write data to
|
||||
portState = SPI.transfer(data); //write data, read portState
|
||||
digitalWrite(SS, HIGH); //disable Slave Select
|
||||
SPI.endTransaction();
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
init() is called once for each row, to set scanner's uC strobePin to output.
|
||||
*/
|
||||
Row::Row(ScannerInterface& refScanner, const uint8_t strobePin,
|
||||
Key* const ptrsKeys[], const uint8_t keyCount)
|
||||
Key* const ptrsKeys[], const uint8_t keyCount)
|
||||
: refScanner(refScanner), strobePin(strobePin),
|
||||
ptrsKeys(ptrsKeys), keyCount(keyCount), debounced(0)
|
||||
ptrsKeys(ptrsKeys), keyCount(keyCount), debounced(0)
|
||||
{
|
||||
refScanner.init(strobePin);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class Row
|
||||
read_pins_t debounced; //bit pattern, state of keys after debouncing, 1=pressed, 0=released
|
||||
public:
|
||||
Row(ScannerInterface& refScanner, const uint8_t strobePin,
|
||||
Key* const ptrsKeys[], const uint8_t keyCount);
|
||||
Key* const ptrsKeys[], const uint8_t keyCount);
|
||||
virtual void process();
|
||||
};
|
||||
#endif
|
||||
|
@ -22,9 +22,9 @@ class Scanner_IOE : public ScannerInterface
|
||||
PortInterface& refPortRead; //the IC's read port
|
||||
public:
|
||||
Scanner_IOE(const bool strobeOn,
|
||||
PortInterface &refPortWrite, PortInterface& refPortRead)
|
||||
PortInterface &refPortWrite, PortInterface& refPortRead)
|
||||
: strobeOn(strobeOn), strobeOff(!strobeOn),
|
||||
refPortWrite(refPortWrite), refPortRead(refPortRead) {}
|
||||
refPortWrite(refPortWrite), refPortRead(refPortRead) {}
|
||||
void init(const uint8_t strobePin);
|
||||
void begin();
|
||||
read_pins_t scan(const uint8_t strobePin);
|
||||
|
@ -5,7 +5,7 @@
|
||||
Scanner_ShiftRegsPISOMultiRow::Scanner_ShiftRegsPISOMultiRow(const bool strobeOn,
|
||||
const uint8_t slaveSelect, const uint8_t byte_count)
|
||||
: strobeOn(strobeOn), strobeOff(!strobeOn),
|
||||
slaveSelect(slaveSelect), byte_count(byte_count)
|
||||
slaveSelect(slaveSelect), byte_count(byte_count)
|
||||
{
|
||||
pinMode(slaveSelect, OUTPUT);
|
||||
}
|
||||
@ -39,8 +39,8 @@ read_pins_t Scanner_ShiftRegsPISOMultiRow::scan(const uint8_t strobePin)
|
||||
delayMicroseconds(3); //time to stablize voltage
|
||||
|
||||
//read all the column pins
|
||||
digitalWrite(slaveSelect, LOW); //load parallel inputs to the register
|
||||
digitalWrite(slaveSelect, HIGH); //shift the data toward a serial output
|
||||
digitalWrite(slaveSelect, LOW); //load parallel inputs to the register
|
||||
digitalWrite(slaveSelect, HIGH); //shift the data toward a serial output
|
||||
SPI.transfer(&readState, byte_count);
|
||||
|
||||
//strobe row off
|
||||
|
@ -43,12 +43,11 @@ class Scanner_ShiftRegsPISOMultiRow : public ScannerInterface
|
||||
private:
|
||||
const bool strobeOn; //logic level of strobe on, active state HIGH or LOW
|
||||
const bool strobeOff; //logic level of strobe off, complement of strobeOn
|
||||
const uint8_t slaveSelect; //controller's pin number that is
|
||||
// connected to shift register's SHIFT-LOAD pin
|
||||
const uint8_t slaveSelect;//controller pin number connected to shift register SHIFT-LOAD pin
|
||||
const uint8_t byte_count; //number of bytes to read from shift registers
|
||||
public:
|
||||
Scanner_ShiftRegsPISOMultiRow(const bool strobeOn,
|
||||
const uint8_t slaveSelect, const uint8_t byte_count);
|
||||
const uint8_t slaveSelect, const uint8_t byte_count);
|
||||
virtual void init(const uint8_t strobePin);
|
||||
virtual void begin();
|
||||
virtual read_pins_t scan(const uint8_t strobePin);
|
||||
|
@ -45,12 +45,11 @@ Controller's MISO pin is connected to shift register's serial output (QH) pin
|
||||
class Scanner_ShiftRegsPISOSingleRow : public ScannerInterface
|
||||
{
|
||||
private:
|
||||
const uint8_t slaveSelect; //controller's pin number that is
|
||||
// connected to shift register's SHIFT-LOAD pin
|
||||
const uint8_t slaveSelect;//controller pin number connected to shift register SHIFT-LOAD pin
|
||||
const uint8_t byte_count; //number of bytes to read from shift registers
|
||||
public:
|
||||
Scanner_ShiftRegsPISOSingleRow(const bool strobeOn,
|
||||
const uint8_t slaveSelect, const uint8_t byte_count);
|
||||
const uint8_t slaveSelect, const uint8_t byte_count);
|
||||
void init(const uint8_t strobePin);
|
||||
void begin();
|
||||
virtual read_pins_t scan(const uint8_t strobePin);
|
||||
|
@ -68,7 +68,8 @@ Row row_L1(scanner_L, 1, ptrsKeys_L1, KEY_COUNT_L1);
|
||||
Key* ptrsKeys_R0[] = { &s_6, &s_5, &s_4, &s_3, //shift register on right
|
||||
&s_c, &s_d, &s_e, &s_f,
|
||||
&s_2, &s_1, &s_0, &s_g, //shift register on left
|
||||
&s_a, &s_b }; //unused input pins are grounded
|
||||
&s_a, &s_b
|
||||
}; //unused input pins are grounded
|
||||
Row row_R0(scanner_R, 0, ptrsKeys_R0, sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0));
|
||||
|
||||
// ################### MAIN ####################
|
||||
|
Reference in New Issue
Block a user