PDA

View Full Version : Keyboard, Video, and Mouse Drivers!



Kye
01-04-2009, 01:58 AM
Happy New Year, everyone!

So, let me tell you a story. Ever since I got a hold of the propeller chip I have just been fascinated at it's awesome power and ability to do so much more that a BASIC Stamp. In fact, the propeller chip is more like a miniature computer than a micro controller. That being said, I plan to invest my time on it making device drivers for all sorts of wonderful applications for parallax community -· and here are some results.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 1/28/2009 4:37:23 AM GMT

Kye
01-04-2009, 01:58 AM
The Keyboard Driver
The download explains all.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 1/28/2009 4:36:20 AM GMT

Kye
01-04-2009, 01:58 AM
The Video Driver

The download explains all.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 1/28/2009 4:35:53 AM GMT

Kye
01-04-2009, 01:59 AM
The Mouse Driver

The download explains all.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 1/28/2009 4:35:19 AM GMT

Kye
01-04-2009, 02:00 AM
Demos are now included in each driver set.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 1/28/2009 4:32:18 AM GMT

Kye
01-04-2009, 04:00 AM
Notes about these drivers:

Programming these drivers is a learning experience for me. That's why I plan to rewrite almost every useful driver for a project I have in mind in ASM with Spin as a glue to meld them all together.
The drivers are really built to be made stream lined so I took all the self calculating code of Chip's drivers and then rebuilt his from the ground up (its a lot easier to trouble shoot when you have a working version to compare with).
Now, about the keyboard and mouse drivers. I have only tested them using the parallax keyboard and mouse. I do believe the mouse driver will work with any mouse but I'm not so sure about the keyboard driver. I really don't have that many PS2 keyboards lying around to test my code with honestly.
I did add in however a lot of different timeouts to fix the wait indefinitely problem I saw in Chip's driver so the mouse or keyboard can be reattached any time without locking up the driver. The drivers effectively poll the mouse or keyboard to make sure they are still attached, and if they are not the driver then resets the key states and waits for the mouse or keyboard to be reattached.
...But the video driver is the real deal here. I woke up one day saying to myself that I would make a video driver that would be capable of displaying a resolution of 640x480 on just one cog. And I managed to do that, but I had to create my own character set in order for everything to work properly.
I tried to use the built in character font, but I ran into a nasty problem. The central loop which displays video only has enough time to access the memory twice during run time and only execute two instructions before going to the next tile. The loop cannot be modified or the driver will fail. This is because during the central loop the cog has only enough time to access the video buffer which points to the characters, and then get the character's pixels. There is not enough time to get new color information. And because the character set is interleaved I would only be able to display even or odd characters per row since I would only be able to change colors every row. Not exactly acceptable.

But since the character set is in editable memory you can use any type of bit tiled graphics you want to display all sorts of different characters and such. The character set included with the driver can easily be extended to display anything on screen. Also the characters can be edited during run time for such things as cursor overlay.
Anyway, post any questions or concerns.

·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 1/28/2009 4:38:21 AM GMT

Kye
01-04-2009, 09:54 AM
Okay, the drivers up on the object exchange.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 1/7/2009 12:39:43 AM GMT

RossH
01-04-2009, 04:19 PM
Hi Kye,

This looks like a useful set of drivers. And your code is well structured and well commented- keep it up!

Ross.

Cluso99
01-04-2009, 06:43 PM
I have a friend who is playing with some old Motorola D2 Kits and he just asked about adding video to it (them).

I have suggested a Prop with Video and Keyboard to do the display via Serial, so your code may be a good solution. He can later play with 6800 emulation on the prop http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Prop Tools under Development or Completed (Index)
http://forums.parallax.com/showthread.php?p=753439

cruising (http://www.bluemagic.biz)]cruising[/url]

This is a bold test.

Dr_Acula
01-04-2009, 07:35 PM
The serial drivers look great. I'm glad you chose 256 bytes (and unmanaged). I've been trying to get radio comms working with xmodem and there are radio modules out there that only work with 32 bytes. xmodem sends in 132 byte packets. 32 bytes needs rewrites of software with delays. 256 bytes would work perfectly. These routines could be very useful on the VT100 terminal project. Keep up the good work!

Kye
01-05-2009, 05:25 AM
Actually the drivers will have·512 byte FIFO buffers, that's the limit however.

They won't be unmanaged though, it won't work correctly if I make them that way.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 1/7/2009 12:41:01 AM GMT

ren
01-05-2009, 01:49 PM
Kye, thanks for sharing.
I'm a complete noob about to get stuck into some OSD so the video drivers are most welcome.

Do you have plans for higher resolution?
I have been lurking since the end of last year and recall yours and other peoples earlier attempts at video output with some people outputing larger than 640x480.

My particular interest is in Head Up Displays so vector graphics -> video is somewhere down the line for me.
I'm not yet fully aware what is already available in the forums and on the Propeller Object Exchange but the ability to size, position and rotate/scale simple objects in 3D is something I want to look into.
Simple objects for me means line, disc/circle/triangle/square, box/sphere.

Post Edited (ren) : 1/5/2009 5:58:37 AM GMT

RossH
01-05-2009, 04:48 PM
Hi ren

There is a virtual VGA driver for the propeller that can do vector graphics at resolutions up to 1152x864 (2 colour) or 800x600 (4 color). You can find this driver as part of the VGA versions of SpaceWar or BattleZ0wned. It supports many of the standard Parallex graphics functions (e.g. text, arcs, lines, etc). But I have to warn you - running VGA at these resolutions currently requires 5 cogs!

The best way to see this driver in operation is to run one of the vector games that use it - for a version of SpaceWar that uses this driver, see the thread http://forums.parallax.com/forums/default.aspx?f=33&m=281452

Ross

Philldapill
01-06-2009, 02:26 AM
Kye, this is great!

You say you want to rework/make more drivers? Great! You've got a Mouse, Keyboard, and VGA driver working... Three things for a computer interface - How about wireless connections? Leon was nice enough to give us his C code for a wireless communication chip, but it would be great to have it ported to Spin/ASM. This would be a fantastic addition to the OBEX!

Here's the link to the thread:
http://forums.parallax.com/forums/default.aspx?f=25&m=317588

Keep it up!

Kye
01-06-2009, 06:54 AM
Hey guys,

The point of the video driver was to really allow flexible tile graphics on screen. If you notice the file is over 2000 lines of code (I wrote every single one -·3 days... on the character map) however, you can use the tile map and maybe one other spin processor to constantly change the memory allowing for interesting bit mapped tile displays. I encourage you to add whatever characters you need to the object so you can display circles or bar graphs or whatever - the driver is fully capable of that any type of graphics.

And the best part is that it all runs on one cog. I found the high resolution video drivers interesting but somewhat wasteful and harder to work with since there was so much going on in the spin interface. I believe the propeller chip will be a much better tool if everything is done is ASM rather than spin and spin·should only used to connect files together to solve the multiprocoessor headache problem.

In other news. I'm not sure if its possible to make it run at a higher resolution. The processor was barely making it even a 640x480.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Kye
01-10-2009, 12:28 PM
The drivers have been updated to be more user friendy and I have included status return statements on all the methods now.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Kye
01-28-2009, 12:24 PM
Version 2.0 is out now!!!

I've finalized the drivers now!

A full summary of operation is included, with electrical connections and such!

The pins can now be changed easily and the drivers now self calculate at run time!

All the methods are fully protected!

You can now get deltas from the mouse!

The character set is now improved!!!

AND!

COMBO KEYBOARD AND MOUSE DRIVERS FOR THE PROPELLER DEMO BOARD/PROPELLER·PROTBOARD·AND HYRDA SYSTEM.

100% PLUG n' Play and Rock Solid!

Enjoy!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 1/28/2009 4:42:35 AM GMT

kwinn
01-29-2009, 12:36 AM
Kye, beautifully formatted and clearly commented code. Very easy to follow also, but I am wondering if you actually ran them on a proto or demo board. When I tried the 2 pin version on my protoboard I get a horizontal frequency of 53 KHz and a vertical of 101 Hz.

Kye
01-29-2009, 11:55 AM
Yes, they are tested for the protobard. They should work correctly.

... the vga driver does not have a 2 pin version, if thats what your are talking about. The vga driver has not been tested on every monitor yet, however, it works on about half. Try adjusting the (frequencyState) number within the video driver asm data section which adjusts the pixle clock to fix monitor problems. However the number should produce the exact 25.175 MHz frequency for vga.

Now, if you were talking about the keyboard or mouse they don't have a vertical or horizontal frequency. I'm not sure what you are refering to. I have only tested the drivers with 80MHZ. There is a disclaimer about this, the drivers are flexibile in their calculations, however, to allow for different clock frequencies.

Please provide details as I would like to debug any of these problems.

Also, note that scan code set 3 is used for the keyboard.

So for the mouse and keyboard drivers, the mouse should always work (5 button are not supported). However, the keyboard may not work if it doesn't support set 3 (which all ps/2 keyboards should support since scan code set 3 is the ps/2 protocol).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 1/29/2009 3:02:25 PM GMT

kwinn
01-29-2009, 12:25 PM
Hi Kye, Thanks for the quick response. I am referring to the monitor frequency. I downloaded the PS2Engine.zip file and copied the 2pin and 4pin file folders out to have unzipped files available. In looking at the Demo.spin files in the two folders it was obvious that the files in the 2pin folder were for the demo and proto boards while the 4pin folder was for the Hydra (by the way you also have a zipped version of the files in there as well). I compiled the Demo.spin file in the 2pin folder and down loaded them to he prop which has an old NEC lcd monitor connected to it. That monitor will display the frequencies of any video sync signals that are out of range, and it displayed the video signals as being 53 KHz for the horizontal and 101 Hz for the vertical.
Had to run out before I could investigate further, and just got in half an hour ago (11:00pm local time) so I will not be checking it tonight.

Kye
01-29-2009, 11:07 PM
Mmm, well I havent done enough testing yet to see if my video driver works with all monitors. Its about 50 - 50 right now. But I can improve that number with help from other people. Soo...

Can you please verify that the ps2 keyoard and mouse work without the monitor. Basically try pressing the caps lock, scroll lock, or number lock key and see if the LED truns on. If so then the keyboard driver is working. As for the mouse driver there is really now way to tell without a monitor.

As for the monitor. There is one setting in the dat data section of the asm video driver which controls the pixel clock frequency. Its called frequencyState. Try playing arround with the number and see what happens. The driver updates the monitor and itself based on that number.

However, the current frequency state number should come out to produce a pixles clock of 25.175MHZ which is the vga frequency.

Also, you can try another monitor. That may fix the problem - or try reseting your monitor back to the factory default state.

Thanks, please give updates.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Hanno
08-19-2009, 08:22 AM
Hi Kye,
Great work on this- unlike the Parallax "Mouse" object and the KBM object, yours worked perfectly with my "Compaq" branded Logitech mouse. It recognized the 2 buttons and clickable scroll wheel. Minor bug-the VGA screen flashes around 1/second. Do you have any updates to this? How serious is the limitation of only supporting "scan code set three" keyboards? Has anyone had problems with this? I'm looking for a very robust keyboard/mouse single cog driver for use with 12Blocks- this seems to be the best so far... Great job Kye!
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

Hanno
08-19-2009, 08:32 AM
I've read the instructions and changed the frequencystate constant to multiple values between +/- 5%, but no luck. The change did have an effect- at the low end more pixel crawl, at the high end it wouldn't sync at all.
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

Cluso99
08-19-2009, 09:39 AM
Kye, you have done some great objects. Perhaps you might like to include a list of thread links in your signature to the various objects you have done?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBladeProp (http://forums.parallax.com/showthread.php?p=786418), RamBlade (http://forums.parallax.com/showthread.php?p=810753), TwinBlade (http://forums.parallax.com/showthread.php?p=806697),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index (http://forums.parallax.com/showthread.php?p=778427)) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)
· Search the Propeller forums (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)

Kye
08-19-2009, 12:17 PM
Wow, you guys are late to the party.

The video driver suffers from a sync glitch. I know how to fix the glitch but I do not sponsor these drivers anymore. I have also removed them from the obex.

I have a much better keyboard·and mouse driver interfaceEngine that really out shines these drivers... but its for a for profit system. I'm not to keen about releasing it for free since it will be my bread and butter.·PM me if you want to talk about it.


·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 8/19/2009 2:04:08 PM GMT

Cluso99
08-19-2009, 12:39 PM
Good luck Kye http://forums.parallax.com/images/smilies/smile.gif You deserve some rewards for your effort http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBladeProp (http://forums.parallax.com/showthread.php?p=786418), RamBlade (http://forums.parallax.com/showthread.php?p=810753), TwinBlade (http://forums.parallax.com/showthread.php?p=806697),·SixBlade (http://forums.parallax.com/showthread.php?p=780033), website (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index (http://forums.parallax.com/showthread.php?p=778427)) ZiCog (Z80) (http://forums.parallax.com/showthread.php?p=788511) , MoCog (6809) (http://forums.parallax.com/showthread.php?p=811043)
· Search the Propeller forums (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)