199 int16_t
begin(uint8_t clockPin, uint8_t dataPin, uint8_t bufferMode = 0, uint8_t queueMode = 0, uint16_t queueAddress = 0xFFFF, uint8_t pullUpDown = 0)
212 int16_t result =
_sw.sendPacket(tx);
218 if (queueAddress != 0xFFFF)
228 return _sw.sendPacket(tx6);
241 uint8_t tx[8] = { 201,
_pin,
_pinMode, 0,0x55,0x55,0x55,0x55 };
243 _sw.sendPacket(tx, rx);
252 uint8_t tx[8] = { 202,
_pin,
_pinMode, 1,0x55,0x55,0x55,0x55 };
254 if (
_sw.sendPacket(tx, rx) < 0)
282 uint8_t tx[8] = { 203,
_pin,
_pinMode,0x55,0x55,0x55,0x55,0x55 };
284 _sw.sendPacket(tx, rx);
316 size_t write(
const uint8_t* buffer,
size_t size)
343 int bytesAvailable = 0;
344 uint32_t timeoutMillis = millis() +
timeout;
345 while (length > 0 && timeoutMillis > millis())
354 uint8_t tx[8] = { 202,
_pin,
_pinMode, (uint8_t)bytecount,0x55,0x55,0x55,0x55 };
356 _sw.sendPacket(tx, rx);
357 bytesAvailable = rx[3];
359 if (bytesAvailable == 0)
365 timeoutMillis = millis() +
timeout;
367 uint8_t bytesReturned = bytecount;
368 if (rx[3] < bytecount)
370 bytesReturned = rx[3];
372 for (
int i = 0; i < bytesReturned; ++i)
374 buffer[index] = rx[i + 4];
388 uint8_t tx[8] = { 207,
_pin,
_pinMode, startValue,0x55,0x55,0x55,0x55 };
391 int16_t result =
_sw.sendPacket(tx, rx);
398 for (
int i = 3; i < 8; ++i)
404 buffer[i - 3] = rx[i];
430 if (scanCode >= 0x80)
435 const uint8_t KBSCSet2[][2] =
569 return ( KBSCSet2[scanCode][ 1]);
572 return ( KBSCSet2[scanCode][0]);
590 if (buffer[0] == scanCode)
#define SW_LE16(_a)
Convert a uint16_t to two bytes in little endian format for array initialization.
@ CONFIGURE_PIN_MODE0
(200)
@ CONFIGURE_PIN_MODE6
(206)
@ PIN_MODE_PS2KEYBOARD
(32)
@ SCANCODE_OPENSINGLEQUOTE
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
SerialWombatPin(SerialWombatChip &serialWombatChip)
Instantiates a Serial Wombat Pin.
int peek()
Query the SerialWombatPS2Keyboard queue for the next avaialble byte, but don't remove it from the que...
bool isKeyPressed(uint8_t scanCode)
Check to see if a key is currently pressed (pin mode must be configured for bitfield mode)
int16_t readCurrentScanCodes(uint8_t *buffer, uint8_t startValue)
size_t write(uint8_t data)
Write a byte to the SerialWombatPS2Keyboard queue (Does Nothing)
int available()
Queries the SerialWombatPS2Keyboard for number bytes available to read.
size_t write(const uint8_t *buffer, size_t size)
Write bytes to the SerialWombatPS2Keyboard queue (Does nothing)
int read()
Reads a byte from the SerialWombatPS2Keyboard queue.
void setTimeout(long timeout_mS)
implemented to fulfill Stream requirement.
bool isKeyPressed(PS2KeyboardScanCode scanCode)
size_t readBytes(char *buffer, size_t length)
Reads a specified number of bytes from the SerialWombatPS2Keyboard queue queue.
int availableForWrite()
Number of bytes avaialble to write to SerialWombatPS2Keyboard queue. Returns 0.
void flush()
Discard all bytes from the SerialWombatPS2Keyboard queue.
uint8_t scanCodeToAscii(uint8_t scanCode, bool shiftActive=false)
convernts a set 2 Scan Code to Ascii
SerialWombatPS2Keyboard(SerialWombatChip &serialWombat)
Constructor for the SerialWombatPS2Keyboard class.
int16_t begin(uint8_t clockPin, uint8_t dataPin, uint8_t bufferMode=0, uint8_t queueMode=0, uint16_t queueAddress=0xFFFF, uint8_t pullUpDown=0)
Initalize the SerialWombatPS2Keyboard.