Shop OBEX P1 Docs P2 Docs Learn Events
Keyboard, Video, and Mouse Drivers! — Parallax Forums

Keyboard, Video, and Mouse Drivers!

KyeKye Posts: 2,200
edited 2009-08-19 04:39 in Propeller 1
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

Comments

  • KyeKye Posts: 2,200
    edited 2009-01-03 17:58
    The Keyboard Driver
    The download explains all.

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

    Post Edited (Kye) : 1/28/2009 4:36:20 AM GMT
  • KyeKye Posts: 2,200
    edited 2009-01-03 17:58
    The Video Driver

    The download explains all.


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

    Post Edited (Kye) : 1/28/2009 4:35:53 AM GMT
  • KyeKye Posts: 2,200
    edited 2009-01-03 17:59
    The Mouse Driver

    The download explains all.


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

    Post Edited (Kye) : 1/28/2009 4:35:19 AM GMT
  • KyeKye Posts: 2,200
    edited 2009-01-03 18:00
    Demos are now included in each driver set.


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

    Post Edited (Kye) : 1/28/2009 4:32:18 AM GMT
  • KyeKye Posts: 2,200
    edited 2009-01-03 20:00
    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
  • KyeKye Posts: 2,200
    edited 2009-01-04 01:54
    Okay, the drivers up on the object exchange.


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

    Post Edited (Kye) : 1/7/2009 12:39:43 AM GMT
  • RossHRossH Posts: 5,512
    edited 2009-01-04 08:19
    Hi Kye,

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

    Ross.
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-01-04 10:43
    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 smile.gif

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

    cruising][noparse][[/noparse]url=http://www.bluemagic.biz]cruising[noparse][[/noparse]/url][/url]

    This is a [noparse][[/noparse]b]bold[noparse][[/noparse]/b] test.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2009-01-04 11:35
    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!
  • KyeKye Posts: 2,200
    edited 2009-01-04 21:25
    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
  • renren Posts: 6
    edited 2009-01-05 05:49
    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
  • RossHRossH Posts: 5,512
    edited 2009-01-05 08:48
    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
  • PhilldapillPhilldapill Posts: 1,283
    edited 2009-01-05 18:26
    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!
  • KyeKye Posts: 2,200
    edited 2009-01-05 22:54
    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,
  • KyeKye Posts: 2,200
    edited 2009-01-10 04:28
    The drivers have been updated to be more user friendy and I have included status return statements on all the methods now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • KyeKye Posts: 2,200
    edited 2009-01-28 04:24
    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
  • kwinnkwinn Posts: 8,697
    edited 2009-01-28 16:36
    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.
  • KyeKye Posts: 2,200
    edited 2009-01-29 03:55
    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
  • kwinnkwinn Posts: 8,697
    edited 2009-01-29 04:25
    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.
  • KyeKye Posts: 2,200
    edited 2009-01-29 15:07
    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,
  • HannoHanno Posts: 1,130
    edited 2009-08-19 00:22
    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 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!
  • HannoHanno Posts: 1,130
    edited 2009-08-19 00:32
    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 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!
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-08-19 01:39
    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, RamBlade, TwinBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: Micros eg Altair, and Terminals eg VT100 (Index) ZiCog (Z80) , MoCog (6809)
    · Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • KyeKye Posts: 2,200
    edited 2009-08-19 04:17
    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
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-08-19 04:39
    Good luck Kye smile.gif You deserve some rewards for your effort smile.gif

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

    · Home of the MultiBladeProps: TriBladeProp, RamBlade, TwinBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: Micros eg Altair, and Terminals eg VT100 (Index) ZiCog (Z80) , MoCog (6809)
    · Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
Sign In or Register to comment.