Archived
1
0

run AStyle

This commit is contained in:
wolfv6 2016-09-28 14:37:40 -06:00
parent 25c644f012
commit 07a66b0505
11 changed files with 22 additions and 23 deletions

View File

@ -7,15 +7,15 @@ The electrical limitation to bus speed is bus capacitance and the length of the
Longer wires require lower clock speeds. Longer wires require lower clock speeds.
*/ */
uint8_t Port_MCP23S17::transfer(const uint8_t command, const uint8_t registerAddr, 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 uint8_t portState; //bit pattern
SPI.beginTransaction( SPISettings(5000000, MSBFIRST, SPI_MODE0) ); //control SPI bus, 5 MHz SPI.beginTransaction( SPISettings(5000000, MSBFIRST, SPI_MODE0) ); //control SPI bus, 5 MHz
digitalWrite(SS, LOW); //enable Slave Select digitalWrite(SS, LOW); //enable Slave Select
SPI.transfer(command); //write or read command SPI.transfer(command); //write or read command
SPI.transfer(registerAddr); //register address to write data to SPI.transfer(registerAddr); //register address to write data to
portState = SPI.transfer(data); //write data, read portState portState = SPI.transfer(data); //write data, read portState
digitalWrite(SS, HIGH); //disable Slave Select digitalWrite(SS, HIGH); //disable Slave Select
SPI.endTransaction(); SPI.endTransaction();

View File

@ -4,9 +4,9 @@
init() is called once for each row, to set scanner's uC strobePin to output. init() is called once for each row, to set scanner's uC strobePin to output.
*/ */
Row::Row(ScannerInterface& refScanner, const uint8_t strobePin, 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), : refScanner(refScanner), strobePin(strobePin),
ptrsKeys(ptrsKeys), keyCount(keyCount), debounced(0) ptrsKeys(ptrsKeys), keyCount(keyCount), debounced(0)
{ {
refScanner.init(strobePin); refScanner.init(strobePin);
} }

View File

@ -31,7 +31,7 @@ class Row
read_pins_t debounced; //bit pattern, state of keys after debouncing, 1=pressed, 0=released read_pins_t debounced; //bit pattern, state of keys after debouncing, 1=pressed, 0=released
public: public:
Row(ScannerInterface& refScanner, const uint8_t strobePin, Row(ScannerInterface& refScanner, const uint8_t strobePin,
Key* const ptrsKeys[], const uint8_t keyCount); Key* const ptrsKeys[], const uint8_t keyCount);
virtual void process(); virtual void process();
}; };
#endif #endif

View File

@ -22,9 +22,9 @@ class Scanner_IOE : public ScannerInterface
PortInterface& refPortRead; //the IC's read port PortInterface& refPortRead; //the IC's read port
public: public:
Scanner_IOE(const bool strobeOn, Scanner_IOE(const bool strobeOn,
PortInterface &refPortWrite, PortInterface& refPortRead) PortInterface &refPortWrite, PortInterface& refPortRead)
: strobeOn(strobeOn), strobeOff(!strobeOn), : strobeOn(strobeOn), strobeOff(!strobeOn),
refPortWrite(refPortWrite), refPortRead(refPortRead) {} refPortWrite(refPortWrite), refPortRead(refPortRead) {}
void init(const uint8_t strobePin); void init(const uint8_t strobePin);
void begin(); void begin();
read_pins_t scan(const uint8_t strobePin); read_pins_t scan(const uint8_t strobePin);

View File

@ -5,7 +5,7 @@
Scanner_ShiftRegsPISOMultiRow::Scanner_ShiftRegsPISOMultiRow(const bool strobeOn, Scanner_ShiftRegsPISOMultiRow::Scanner_ShiftRegsPISOMultiRow(const bool strobeOn,
const uint8_t slaveSelect, const uint8_t byte_count) const uint8_t slaveSelect, const uint8_t byte_count)
: strobeOn(strobeOn), strobeOff(!strobeOn), : strobeOn(strobeOn), strobeOff(!strobeOn),
slaveSelect(slaveSelect), byte_count(byte_count) slaveSelect(slaveSelect), byte_count(byte_count)
{ {
pinMode(slaveSelect, OUTPUT); pinMode(slaveSelect, OUTPUT);
} }
@ -39,8 +39,8 @@ read_pins_t Scanner_ShiftRegsPISOMultiRow::scan(const uint8_t strobePin)
delayMicroseconds(3); //time to stablize voltage delayMicroseconds(3); //time to stablize voltage
//read all the column pins //read all the column pins
digitalWrite(slaveSelect, LOW); //load parallel inputs to the register digitalWrite(slaveSelect, LOW); //load parallel inputs to the register
digitalWrite(slaveSelect, HIGH); //shift the data toward a serial output digitalWrite(slaveSelect, HIGH); //shift the data toward a serial output
SPI.transfer(&readState, byte_count); SPI.transfer(&readState, byte_count);
//strobe row off //strobe row off

View File

@ -43,12 +43,11 @@ class Scanner_ShiftRegsPISOMultiRow : public ScannerInterface
private: private:
const bool strobeOn; //logic level of strobe on, active state HIGH or LOW 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 bool strobeOff; //logic level of strobe off, complement of strobeOn
const uint8_t slaveSelect; //controller's pin number that is const uint8_t slaveSelect;//controller pin number connected to shift register SHIFT-LOAD pin
// connected to shift register's SHIFT-LOAD pin
const uint8_t byte_count; //number of bytes to read from shift registers const uint8_t byte_count; //number of bytes to read from shift registers
public: public:
Scanner_ShiftRegsPISOMultiRow(const bool strobeOn, 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 init(const uint8_t strobePin);
virtual void begin(); virtual void begin();
virtual read_pins_t scan(const uint8_t strobePin); virtual read_pins_t scan(const uint8_t strobePin);

View File

@ -45,12 +45,11 @@ Controller's MISO pin is connected to shift register's serial output (QH) pin
class Scanner_ShiftRegsPISOSingleRow : public ScannerInterface class Scanner_ShiftRegsPISOSingleRow : public ScannerInterface
{ {
private: private:
const uint8_t slaveSelect; //controller's pin number that is const uint8_t slaveSelect;//controller pin number connected to shift register SHIFT-LOAD pin
// connected to shift register's SHIFT-LOAD pin
const uint8_t byte_count; //number of bytes to read from shift registers const uint8_t byte_count; //number of bytes to read from shift registers
public: public:
Scanner_ShiftRegsPISOSingleRow(const bool strobeOn, 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 init(const uint8_t strobePin);
void begin(); void begin();
virtual read_pins_t scan(const uint8_t strobePin); virtual read_pins_t scan(const uint8_t strobePin);

View File

@ -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 Key* ptrsKeys_R0[] = { &s_6, &s_5, &s_4, &s_3, //shift register on right
&s_c, &s_d, &s_e, &s_f, &s_c, &s_d, &s_e, &s_f,
&s_2, &s_1, &s_0, &s_g, //shift register on left &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)); Row row_R0(scanner_R, 0, ptrsKeys_R0, sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0));
// ################### MAIN #################### // ################### MAIN ####################