add StrobePort_PCA9655E::write() and const bool Scanner_Port::STROBE_OFF
This commit is contained in:
parent
37186b7586
commit
d5cd8e958b
@ -5,7 +5,3 @@ uint8_t ReadPort::getColPins()
|
|||||||
return readPins;
|
return readPins;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ReadPort::getPortState()
|
|
||||||
{
|
|
||||||
return portState;
|
|
||||||
}
|
|
||||||
|
@ -16,8 +16,7 @@ class ReadPort
|
|||||||
ReadPort(const uint8_t readPins): readPins(readPins), portState(0) {}
|
ReadPort(const uint8_t readPins): readPins(readPins), portState(0) {}
|
||||||
|
|
||||||
//read port and store it's pins values in portState
|
//read port and store it's pins values in portState
|
||||||
virtual void read()=0;
|
virtual uint8_t read()=0;
|
||||||
uint8_t getColPins();
|
uint8_t getColPins();
|
||||||
uint8_t getPortState();
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,7 +18,7 @@ void ReadPort_PCA9655E::begin()
|
|||||||
/*
|
/*
|
||||||
Saves all port-pin values to portState.
|
Saves all port-pin values to portState.
|
||||||
*/
|
*/
|
||||||
void ReadPort_PCA9655E::read()
|
uint8_t ReadPort_PCA9655E::read()
|
||||||
{
|
{
|
||||||
Wire.beginTransmission(port.ADDR);
|
Wire.beginTransmission(port.ADDR);
|
||||||
Wire.write(inputByteCommand); //input immediately before requestFrom
|
Wire.write(inputByteCommand); //input immediately before requestFrom
|
||||||
@ -26,10 +26,5 @@ void ReadPort_PCA9655E::read()
|
|||||||
|
|
||||||
Wire.requestFrom(port.ADDR, 1u); //request one byte from input port
|
Wire.requestFrom(port.ADDR, 1u); //request one byte from input port
|
||||||
|
|
||||||
portState = Wire.read();
|
return Wire.read();
|
||||||
/*if (portState)//todo
|
|
||||||
{
|
|
||||||
Keyboard.print(" portState=");
|
|
||||||
Keyboard.print(portState);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,6 @@ class ReadPort_PCA9655E : public ReadPort
|
|||||||
void begin();
|
void begin();
|
||||||
|
|
||||||
//read port and store result in portState
|
//read port and store result in portState
|
||||||
virtual void read();
|
virtual uint8_t read();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,29 +4,34 @@ Strobes the row and reads the columns.
|
|||||||
*/
|
*/
|
||||||
uint8_t Scanner_Port::scan()
|
uint8_t Scanner_Port::scan()
|
||||||
{
|
{
|
||||||
//strobe row on
|
uint8_t readState;
|
||||||
if (STROBE_ON == LOW) //if activeLow
|
|
||||||
|
/*if (STROBE_ON == LOW) //if activeLow
|
||||||
{
|
{
|
||||||
refStrobePort.setActivePinLow(strobePin);
|
refStrobePort.setActivePinLow(strobePin);
|
||||||
}
|
}
|
||||||
else //if activeHigh
|
else //if activeHigh
|
||||||
{
|
{
|
||||||
refStrobePort.setActivePinHigh(strobePin);
|
refStrobePort.setActivePinHigh(strobePin);
|
||||||
}
|
}*/
|
||||||
|
//strobe row on
|
||||||
|
refStrobePort.write(STROBE_PIN, STROBE_ON);
|
||||||
delayMicroseconds(3); //time to stablize voltage
|
delayMicroseconds(3); //time to stablize voltage
|
||||||
|
|
||||||
//read the port pins
|
//read the port pins
|
||||||
refReadPort.read();
|
readState = refReadPort.read();
|
||||||
|
|
||||||
//strobe row off
|
//strobe row off
|
||||||
if (STROBE_ON == LOW) //if activeLow
|
refStrobePort.write(STROBE_PIN, STROBE_OFF);
|
||||||
|
/*if (STROBE_ON == LOW) //if activeLow
|
||||||
{
|
{
|
||||||
refStrobePort.setActivePinHigh(strobePin);
|
refStrobePort.setActivePinHigh(strobePin);
|
||||||
}
|
}
|
||||||
else //if activeHigh
|
else //if activeHigh
|
||||||
{
|
{
|
||||||
refStrobePort.setActivePinLow(strobePin);
|
refStrobePort.setActivePinLow(strobePin);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return refReadPort.getPortState();
|
//return refReadPort.getPortState();
|
||||||
|
return readState;
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,13 @@ class Scanner_Port
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static const bool STROBE_ON; //HIGH or LOW logic level of strobe on, active state
|
static const bool STROBE_ON; //HIGH or LOW logic level of strobe on, active state
|
||||||
|
static const bool STROBE_OFF; //logic level of strobe off, complement of STROBE_ON
|
||||||
StrobePort& refStrobePort; //this row's IC port
|
StrobePort& refStrobePort; //this row's IC port
|
||||||
const uint8_t strobePin; //bitwise, 1 indicates IC pin connected to this row
|
const uint8_t STROBE_PIN; //bitwise, 1 indicates IC pin connected to this row
|
||||||
ReadPort& refReadPort;
|
ReadPort& refReadPort;
|
||||||
public:
|
public:
|
||||||
Scanner_Port(StrobePort &refStrobePort, const uint8_t strobePin, ReadPort& refReadPort)
|
Scanner_Port(StrobePort &refStrobePort, const uint8_t STROBE_PIN, ReadPort& refReadPort)
|
||||||
: refStrobePort(refStrobePort), strobePin(strobePin), refReadPort(refReadPort) {}
|
: refStrobePort(refStrobePort), STROBE_PIN(STROBE_PIN), refReadPort(refReadPort) {}
|
||||||
uint8_t scan();
|
uint8_t scan();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,5 +12,6 @@ class StrobePort
|
|||||||
public:
|
public:
|
||||||
virtual void setActivePinHigh(const uint8_t activePin)=0;
|
virtual void setActivePinHigh(const uint8_t activePin)=0;
|
||||||
virtual void setActivePinLow(const uint8_t activePin)=0;
|
virtual void setActivePinLow(const uint8_t activePin)=0;
|
||||||
|
virtual void write(const uint8_t pin, const bool level)=0;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,3 +38,19 @@ void StrobePort_PCA9655E::setActivePinHigh(const uint8_t activePin)
|
|||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
//todo delayMicroseconds(1500); still 4*bb w/o debouncer prints IOE rows sporadically
|
//todo delayMicroseconds(1500); still 4*bb w/o debouncer prints IOE rows sporadically
|
||||||
}
|
}
|
||||||
|
void StrobePort_PCA9655E::write(const uint8_t pin, const bool level)
|
||||||
|
{
|
||||||
|
if (level == LOW)
|
||||||
|
{
|
||||||
|
port.outputVal &= ~pin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
port.outputVal |= pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wire.beginTransmission(port.ADDR);
|
||||||
|
Wire.write(outputByteCommand);
|
||||||
|
Wire.write(port.outputVal);
|
||||||
|
Wire.endTransmission();
|
||||||
|
}
|
||||||
|
@ -44,7 +44,8 @@ class StrobePort_PCA9655E : public StrobePort
|
|||||||
StrobePort_PCA9655E(IOEPort& port);
|
StrobePort_PCA9655E(IOEPort& port);
|
||||||
void begin();
|
void begin();
|
||||||
|
|
||||||
virtual void setActivePinLow(const uint8_t activePin); //activePin is a port mask
|
virtual void setActivePinLow(const uint8_t activePin); //activePin is a port mask todo delete
|
||||||
virtual void setActivePinHigh(const uint8_t activePin);
|
virtual void setActivePinHigh(const uint8_t activePin); //todo delete also in StrobePort.h
|
||||||
|
virtual void write(const uint8_t pin, const bool level);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user