Code Monkey home page Code Monkey logo

ps2keymap's Introduction

PS2KeyMap

Arduino PS2 keyboard International Keyboard mapping from PS2KeyAdvanced and return as UTF-8

This library requires PS2KeyAdvanced as well to work

V1.0.6 April 2020 Correct _KeyMaps definition error in V1.0.5

V1.0.5 March 2020 Add Italian and Spanish keyboard layouts

V1.0.4 January 2020 Work better with new library manager spec and better additional platform possibilities

V1.0.3 July 2018 Improved keywords file

First Public Release Version V1.0.2

Smaller footprint than any others found and more functionality.

Platforms

Arduino AVR - tested on Uno and Mega 2560
Arduino SAM - tested on DUE
SAMD1 - tested by user on Seeeduino Xiao M0+

Test Environment

All platforms versions of test R3 Hardware
Arduino V1.6.7
DUE Board Manager package V1.6.6

Important Hardware Notes

  1. Make sure you have data and clock wires connected correctly. Clock wire MUST be connected to an interrupt pin.
  • Do NOT use Pin 13 for either clock or data wires
  • PS2KeyRaw requires both pins specified for begin() as in keyboard.begin( data_pin, irq_pin );
  • Valid irq pins:
    • Arduino Uno: 2, 3
    • Arduino Due: All pins, except 13 (LED)
    • Arduino Mega: 2, 3, 18, 19, 20, 21
    • Teensy 2.0: All pins, except 13 (LED)
    • Teensy 2.0: 5, 6, 7, 8
    • Teensy 1.0: 0, 1, 2, 3, 4, 6, 7, 16
    • Teensy++ 2.0: 0, 1, 2, 3, 18, 19, 36, 37
    • Teensy++ 1.0: 0, 1, 2, 3, 18, 19, 36, 37
    • Sanguino: 2, 10, 11
  1. 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.

Introduction

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 third which extends the second one PS2KeyAdvanced to support different Country keyboard mapping. More countries and special mappings can be added.

The size of the keyboard mappings is smaller than other libraries as some countries can be not used, and existing mappings are only the keys that are different from US layout, so only change data is stored (in Flash).

The library takes the 16 bit integer from PS2KeyAdvanced and converts to UTF-8/ASCII honouring SHIFT, CAPS and as long as NOT a functional key like F1 to F24 or Page Up, will convert to UTF-8 equivalent, otherwise same code is returned.

Current Country mappings included (other contributions welcomed)

  • US
  • UK/GB
  • DE - German
  • FR - French

You can select which map to use from your programme.

Installation

Performed by standard zip file library inclusion into Arduino IDE

Examples

This library has TWO examples, from simplest to most complec -

  • Internationl that uses the serial port to output the converted codes received and allow changing of keyboard mapping on the fly.
  • KeyToLCD - Example that will allow you to display converted keyboard characters 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

Note on LCDs and some terminal emulators not all characters may be supported.

Euro Currency Symbol

As the Euro came about AFTER the standardisation of UTF-8, the Euro Symbol is a supported keycode but NOT a conversion to UTF-8. This is just not possible.

Contributor and Author Details

Author Paul Carpenter, PC Services

Web Site http://www.pcserviceselectronics.co.uk

ps2keymap's People

Contributors

per1234 avatar programmingelectronics avatar techpaul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ps2keymap's Issues

Examples not working

I have successfully connected my PS2 keyboard to an Arduino Nano. I get the correct keycodes in the serial monitor. However setting a keymap never works. In both of the provided examples, everything looks ok, except for changing the keymap.

In https://github.com/techpaul/PS2KeyMap/blob/master/examples/International/International.ino I have added the following code at line 146 :

Serial.println("Trying to switch to french");
found = keymap.selectMap( (char *)"FR" );
if (found) {
    Serial.println("Success");
}
else {
    Serial.println("Failed");
}

But the only things I get in the serial monitor are as follows :

PS2KeyMap plus PS2KeyAdvanced Libraries
International Keyboard Test:
Default is US layout, type a key to change layout
 U for US     G for GB/UK
 D for DE     F for FR
 I for IT     E for ES
 All keys on keyboard echoed here
Value 44 mapped 64 - Status Bits 0  Code 64  ( d )
Value 46 mapped 66 - Status Bits 0  Code 66  ( f )
Trying to switch to french
Failed
Value 44 mapped 64 - Status Bits 0  Code 64  ( d )
Value 46 mapped 66 - Status Bits 0  Code 66  ( f )
Trying to switch to french
Failed

Would you have a hint as to what I might be doing wrong ?
thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.