This is my first post so go easy on me.
I've made some modifications to the PS2Keyboard library I found on the Arduino website as it had some limitations for what I wanted.
Basically I've added: shift, alt, caps_lock and caps_lock light functionality and automatic recovery from hot plugging/unplugging a keyboard (when the byte sync goes wrong).
Is this stuff thats all been done before? (I couldn't find anything hence doing it myself) and is it worth making public? I have no idea how to do the latter. Thanks.
The PS2 Keyboard Library doesn't seem to have been utilized very much.
I have used it but would be interested to see the modifications that you have made. The library was created to not have thousands of characters/keys because the lookup would take too long. I had added F1 to F12 when I was using it (for shortcut keys) and I also removed some keys that I didn't need. I think that having a version with almost every key would be helpful to some people but a bit slow.
What did you find it to be like? Has is slowed down significantly?
How did you add the light functionality, this was something I wanted but never got round to working out...
Mowcius
The speed of the original version was one of the problems that I had and wanted to fix. I've changed the searching for a key routine to a switch statement, which is much quicker and doesn't slow down with adding more keys. I guess its bloated the code but I wasn't so bothered about absolute code size as long as it worked well.
When you say that the library hasn't been taken up much do you mean people don't want to use a keyboard with Arduino much or do you mean there is something else that people use?
Getting the lights to work was the trickiest bit to do, but having got caps_lock to work I found I just had to tackle the lights.
What's the best way of making the code available - pasting it into a post or putting it online somewhere?
I've put the code here:
I've put the code here:
Yep, that is a good place to put it...
The speed of the original version was one of the problems that I had and wanted to fix. I've changed the searching for a key routine to a switch statement, which is much quicker and doesn't slow down with adding more keys. I guess its bloated the code but I wasn't so bothered about absolute code size as long as it worked well.
Nice, I will take a look at it. I am also not too bothered about the size of my code.
When you say that the library hasn't been taken up much do you mean people don't want to use a keyboard with Arduino much or do you mean there is something else that people use?
I was rather surprised that it is not used more. I wouldn't say that people are using something else, everyone just owns a laptop... (I do but hey...)
I am wanting to use the code for writing lots of stuff including for writing text for a scrolling message board and other things... The rest's a secret
Mowcius
Personally, I would much rather have the Arduino EMULATE a PS2 keyboard versus having one attached to it. I have a hard time convincing myself why I would want to attach a keyboard to an Arduino...
I have a hard time convincing myself why I would want to attach a keyboard to an Arduino...
A PS2 keyboard can be a very simple way to get lots of switches connected to Arduino without using up a lot of pins. Gutting an old keyboard and connecting switch leads to the keyboard matrix contacts lets you use the matrix encoding built into the keyboard chip to get the signal into arduino in easily digestible form.
I suppose that's another use for it... I am personally using it for text input when I will not have a laptop/computer on hand...
Mowcius
The reason I wanted to attach a keyboard was because the project grew!
It started out as just a box to switch on a fan to extract hot air from my conservatory. Then I added a 2 line LCD to display the inside and outside temperatures. Then I fancied recording the temperatures to eeprom. Then I wanted to be able to change the sample period without carrying the computer down to the conservatory and reprogramming the Arduino, so I put the sample period and other parameters into eeprom too. I needed the keyboard so that I could change parameters and scroll through recorded temperatures. Having added the plug-in keyboard capability I wouldn't be with out it now.
I've got another project on the go now too and of course I'll be adding a PS2 keyboard socket just in case.
Thanks for posting the new code in the playground.
The PS/2 keyboard interface may be used more than people realize. I guess there's no really good way to measure how many people are using the playground functions, is there?
For me, it's a good way to supplant the serial read functions, and remove the need for having a PC attached to the Arduino.
I guess there's no really good way to measure how many people are using the playground functions, is there?
No, bu good idea by doing a search for topics containing it. Either the code is so easy to use that nobody has needed to ask many questions and not posted up their projects with it or it is not used much. I have heard hardly anything about it...
I also am going to use it for just numerical input using a PS2 numeric keypad. That then opens up a whole range of smaller projects that can be done simply and easily with a small number of arduino inputs.
The reason I wanted to attach a keyboard was because the project grew!
I saw the code and thought of a project for it because I thought that it would be cool
Mowcius
Personally, I would much rather have the Arduino EMULATE a PS2 keyboard versus having one attached to it. I have a hard time convincing myself why I would want to attach a keyboard to an Arduino...
Look at this thread
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1247772275