Skip to content

Commit f2fb320

Browse files
committed
Fix keyboardreset status keeping track
Documentation and write pulse interrupt tidy
1 parent a98f0e0 commit f2fb320

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# PS2KeyAdvanced
22
## Arduino PS2 Keyboard FULL keyboard protocol support and full keys to integer coding
3+
**V1.0.6** January 2020 - Fix typos, correct keyboard reset status improve library.properties
4+
and additional platform handling
35

4-
**V1.0.4** Agust 2018 - Minor reduction in available() method to remove redundant extra safety checks on buffers
6+
V1.0.4 August 2018 - Minor reduction in available() method to remove redundant extra safety checks on buffers
57

68
V1.0.3 July 2018 Improved keywords file
79

@@ -19,7 +21,7 @@ For other versions that just read the keycodes for all keyboard types or allow y
1921
### Test Environment
2022

2123
All platforms versions of test R3 Hardware
22-
Arduino V1.6.7
24+
Arduino V1.6.7 and newer
2325
DUE Board Manager package V1.6.6
2426

2527
## Important Hardware Notes

src/PS2KeyAdvanced.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
/* Version V1.0.5
1+
/* Version V1.0.6
22
PS2KeyAdvanced.cpp - PS2KeyAdvanced library
33
Copyright (c) 2007 Free Software Foundation. All right reserved.
44
Written by Paul Carpenter, PC Services <[email protected]>
55
Created September 2014
66
Updated January 2016 - Paul Carpenter - add tested on Due and tidy ups for V1.5 Library Management
7+
January 2020 Fix typos, correct keyboard reset status improve library.properties
8+
and additional platform handling and some documentation
79
810
IMPORTANT WARNING
911
@@ -17,6 +19,7 @@
1719
September 2014 Uno and Mega 2560 September 2014 using Arduino V1.6.0
1820
January 2016 Uno, Mega 2560 and Due using Arduino 1.6.7 and Due Board
1921
Manager V1.6.6
22+
2023
2124
Assumption - Only ONE keyboard added to one Arduino
2225
- No stream support
@@ -469,30 +472,28 @@ if( !( _tx_ready & _HANDSHAKE ) && ( _tx_ready & _COMMAND ) )
469472
_ps2mode |= _WAIT_RESPONSE;
470473
}
471474

475+
// STOP interrupt handler
476+
// Setting pin output low will cause interrupt before ready
477+
detachInterrupt( digitalPinToInterrupt( PS2_IrqPin ) );
472478
// set pins to outputs and high
473479
digitalWrite( PS2_DataPin, HIGH );
474480
pinMode( PS2_DataPin, OUTPUT );
475481
digitalWrite( PS2_IrqPin, HIGH );
476482
pinMode( PS2_IrqPin, OUTPUT );
483+
// Essential for PS2 spec compliance
477484
delayMicroseconds( 10 );
478-
#if defined(ARDUINO_ARCH_SAM)
479-
// STOP interrupt handler as Due etc. a lot faster than Uno/Mega
480-
// Setting pin output low will cause interrupt before ready
481-
detachInterrupt( digitalPinToInterrupt( PS2_IrqPin ) );
482-
#endif
483485
// set Clock LOW
484486
digitalWrite( PS2_IrqPin, LOW );
487+
// Essential for PS2 spec compliance
485488
// set clock low for 60us
486489
delayMicroseconds( 60 );
487490
// Set data low - Start bit
488491
digitalWrite( PS2_DataPin, LOW );
489-
// set clock to input_pullup
492+
// set clock to input_pullup data stays as output while writing to keyboard
490493
pininput( PS2_IrqPin );
491-
#if defined(ARDUINO_ARCH_SAM)
492-
// Restart interrupt handler as Due etc. a lot faster than Uno/Mega
494+
// Restart interrupt handler
493495
attachInterrupt( digitalPinToInterrupt( PS2_IrqPin ), ps2interrupt, FALLING );
494496
// wait clock interrupt to send data
495-
#endif
496497
}
497498

498499

@@ -872,7 +873,10 @@ void PS2KeyAdvanced::resetKey()
872873
send_byte( PS2_KC_RESET ); // send command
873874
send_byte( PS2_KEY_IGNORE ); // wait ACK
874875
if( ( send_byte( PS2_KEY_IGNORE ) ) ) // wait data PS2_KC_BAT or PS2_KC_ERROR
875-
send_next(); // if idle start transmission
876+
send_next(); // if idle start transmission
877+
// LEDs and KeyStatus Reset too... to match keyboard
878+
PS2_led_lock = 0;
879+
PS2_keystatus = 0;
876880
}
877881

878882

src/PS2KeyAdvanced.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
/* Version V1.0.5
1+
/* Version V1.0.6
22
PS2KeyAdvanced.h - PS2KeyAdvanced library
33
Copyright (c) 2007 Free Software Foundation. All right reserved.
44
Written by Paul Carpenter, PC Services <[email protected]>
55
Created September 2014
66
Updated January 2016 - Paul Carpenter - add tested on Due and tidy ups for V1.5 Library Management
7+
January 2020 Fix typos, correct keyboard reset status improve library.properties
8+
and additional platform handling and some documentation
79
810
IMPORTANT WARNING
911

0 commit comments

Comments
 (0)