You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# PS2KeyAdvanced
2
2
## 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
3
+
**V1.0.7** February 2020 - Add notes for porting to other platforms
4
+
5
+
V1.0.6 January 2020 - Fix typos, correct keyboard reset status improve library.properties
4
6
and additional reduction for easier platform handling
5
7
6
8
V1.0.4 August 2018 - Minor reduction in available() method to remove redundant extra safety checks on buffers
@@ -15,8 +17,10 @@ For other versions that just read the keycodes for all keyboard types or allow y
15
17
16
18
### Platforms
17
19
18
-
Arduino AVR - tested on Uno and Mega 2560
19
-
Arduino SAM - tested on DUE
20
+
- Arduino AVR - tested on Uno and Mega 2560 (Users have tested on Teensy 2.0 and Teensy++ 2.0)
21
+
- Arduino SAM - tested on DUE
22
+
23
+
See later for porting to other platforms
20
24
21
25
### Test Environment
22
26
@@ -44,20 +48,21 @@ For other versions that just read the keycodes for all keyboard types or allow y
44
48
2. When using DUE or other boards with 3V3 I/O you MUST use a level translator FET or IC like Texas Instruments TXS0102 or similar as most keyboards not only operate at 5V but the two wire communications are pulled up by a resistor to 5V at the keyboard end.
45
49
46
50
### Introduction
47
-
48
51
After looking round for suitable libraries I found most were lacking in functionality and high in code and data footprint, so I created a series of PS2 Keyboard libraries. This is the second which fully supports the PS2 Keyboard Protocol, even allowing you control of keyboard LEDs (some have 4 LEDs) and changing settings..
49
52
50
53
The PS2 Keyboard interface is still needed for systems that have no USB and even if you have USB, you want it left for other uses.
51
54
52
55
The PS2 Keyboard interface is a Bi-directional two wire interface with a clock line and a data line which you connect to your Arduino (see above), the keyboard protocol has many nuances all of which are used in the other libraries of this series. this library allows you to access the keycodes sent from a keyboard into its small buffer and read out the codes with simple methods.
53
56
54
57
Returns any keypress as 16 bit integer, which includes a coded value for the key along with status for
58
+
55
59
- Make/Break
56
60
- CTRL, SHIFT, CAPS, ALT, GUI, ALT-GR Status
57
61
- Alphanumeric/keyboard Function
58
62
- 8 bit key code (defined in public header)
59
63
60
-
Fully featured PS2 keyboard library to provide
64
+
Fully featured PS2 keyboard library to provide
65
+
61
66
- All keys have a keycode (ESC, A-Z and 0-9 as ASCII equivalents)
62
67
- All function (F1 to F24), multimedia and movement keys supported
63
68
- Parity checking of data sent/received
@@ -74,20 +79,17 @@ Returns any keypress as 16 bit integer, which includes a coded value for the key
74
79
- Handles NUM/SCROLL internally
75
80
76
81
### Installation
77
-
78
82
Performed by standard zip file library inclusion into Arduino IDE
79
-
80
83
### Examples
81
-
82
84
This library has THREE examples, from simplest to most complec -
83
85
84
86
- SimpleTest that uses the serial port to output the converted codes received on every keystroke and auto-repeat.
85
87
- advcodetest that uses serial port and some of the keys pressed to send commands back to the keyboard to see the responses for things like Reset keyboard, Read ID, change Typematic rate (auto-repeat).
86
88
- KeyToLCD - Example that will allow you to display keyboard actions on LCD connected to Arduino and allow cursor movements to move the cursor on LCD, whilst also displaying strings for keys like ESC, TAB, F1 to F12
87
89
88
-
90
+
## Porting to different boards or architectures
91
+
See document Porting.md in extras folder for hints to assist in this process
# PS2KeyAdvanced - Porting to new boards or Architectures
2
+
This document assumes you have some low level understanding of your board, Arduino library structures and the compiler for your board.
3
+
4
+
The majority of assists you require are in PS2KeyAdvanced.h the main header file for the library which has some architecture specific defines.
5
+
6
+
- PS2_SUPPORTED
7
+
- PS2_REQUIRES_PROGMEM
8
+
- PS2_CLEAR_PENDING_IRQ
9
+
10
+
This are to cope with AVR Harvard architecture and AVR and SAM issue of not clearing past events on Interrupt pin before attachInterrupt enables interrupts
11
+
those causing false interrupt events.
12
+
## General Rules
13
+
To add another board type you need to make some changes
14
+
1. You need to determine what the define is for your architecture, as AVR uses ARDUINO_ARCH_AVR so from verbose compiling output you need to find the part in
15
+
compiling output for YOUR BOARD that should be **-DARDUINO_ARCH_xxxx**. Where the "xxxx" is the board architecture. You need this for making later changes.
16
+
2. In PS2KeyAdvanced.h you need to add a specific test for your board after the AVR and SAM checks (Note PS2_SUPPORTED **must** be included in your test otherwise a compilation error will occur.) like
17
+
~~~
18
+
#if defined( ARDUINO_ARCH_xxxx )
19
+
#define PS2_SUPPORTED 1
20
+
#define PS2_REQUIRES_PROGMEM 1
21
+
#endif
22
+
~~~
23
+
3. Change library.properties to add your architecture to the comma separated list for your architecture, normally this is the "xxxx" for ARCH_ARDUINO_xxxx
24
+
### PS2_SUPPORTED
25
+
This flag is set to indicate we have a supported board, this flag stops a compiler error being forced.
26
+
27
+
To enable for your architecture add a line in the '#if' for your architecture as follows
28
+
~~~
29
+
#define PS2_SUPPORTED 1
30
+
~~~
31
+
### PS2_REQUIRES_PROGMEM
32
+
This determines that to have constants in Flash memory not RAM on AVR boards the PROGMEM functions have to be used.
33
+
34
+
To enable for your architecture add a line in the '#if' for your architecture as follows
35
+
~~~
36
+
#define PS2_REQUIRES_PROGMEM 1
37
+
~~~
38
+
### PS2_CLEAR_PENDING_IRQ
39
+
When sending data to the keyboard, interrupts have to be turned off and back on again, on AVR and SAM architecture any changes on the clock pin cause extra interrupts
40
+
when attachInterrupt is used to start bit timing interrupts again, on other architectures this does not normally happen so we need to change how interrupt events
41
+
we see for a valid byte sending. This does not affect receiving data just the sending.
42
+
43
+
This defines adds an extra bit clock event interrupt step for AVR and SAM
44
+
45
+
To enable for your architecture add a line in the '#if' for your architecture as follows
46
+
~~~
47
+
#define PS2_CLEAR_PENDING_IRQ 1
48
+
~~~
49
+
## Support of changes
50
+
If you can test **ALL** functionality working, you are welcome to do a pull request from your github fork of this library. If meets our coding
51
+
guidelines and you can show it is has been working it will include in next release.
52
+
53
+
Please note whilst we can give assistance, we probably do not have your board or maybe not the time to incorporate full support for you.
sentence=PS2 keyboard FULL control and ALL keys processing, as well as LED control.
6
6
paragraph=Provides ability to convert long key stroke code sequences to a single integer, for all keys ANY Latin keyboard, even multimedia and 24 Function key keyboards.
0 commit comments