Shop OBEX P1 Docs P2 Docs Learn Events
Keyboard Input — Parallax Forums

Keyboard Input

[Deleted User][Deleted User] Posts: 0
edited 2006-12-11 05:59 in Propeller 1
Hi,
·Do I have to do this for all key's , or is there a easier way !!

·If ASCII_Key == $CB·········· 'Looks for Esc Key ($CB)
····· Start···················· 'Restarts program·
· Case ASCII_Key
···· "0" : LCD.Str(string("0"))
···········store := 0
···· "1" : LCD.Str(string("1"))
···········store := 1
···· "2" : LCD.Str(string("2"))
···········store := 2
···· "3" : LCD.Str(string("3"))
···········store := 3
···· "4" : LCD.Str(string("4"))
·········· store:= 4
···· "5" : LCD.Str(string("5"))
···········store := 5
···· "6" : LCD.Str(string("6"))
···········store := 6
···· "7" : LCD.Str(string("7"))
···········store := 7
···· "8" : LCD.Str(string("8"))
···········store := 8
···· "A" : LCD...................
Thanks,Brian···································


·
«1

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-09 02:10
    You could do:
    case ASCII_Key
      "0".."8"
        LCD.Str(ASCII_Key)
        store := ASCII_Key - "0"
      "A"
        LCD.Str(ASCII_Key)
    
    
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-09 02:47
    Mike,
    I'm trying to , 1)Enter a number(display while entering),·2) Store a Number 3), Display the stored number


    PRI Input_Info

    repeat
    Num1 := kb.getkey
    tv.out(Num1)
    Num2 := Num1
    until Num1 == $0D

    Waitcnt (clkfreq/2 +cnt)

    tv.out(Num2)

    Thanks,Brian

    Post Edited (truckwiz) : 12/9/2006 3:09:36 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-09 03:15
    Attached is a routine to scan a number (in decimal, hex, or binary) from a keyboard echoing the characters to the display. It stops at the first character that doesn't belong there and returns that (or the negative of the address of an error string) as its value. The number is placed in a long variable whose address is supplied to the routine. With simple modifications, this can accept input from any source. I took this from the Propeller OS source and modified it to take its input from the keyboard. I haven't tested the changes, but it should work.

    To output decimal numbers, you just have to use the dsp.dec() call.

    Mike
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-09 03:34
    AWSOME !!
    That just freed up my whole weekend !!

    Thanks, Brian
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-09 04:53
    Mike ,

    ·Works awsome !! Have two little proplems ,1) first key you hit on enter numbers doesn't show

    ·2) all the operators work except add wants to subtract.

    Thanks,Brian

    Post Edited (truckwiz) : 12/9/2006 6:11:29 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-09 04:54
    I'm sure you'll find something to do with it (the weekend that is). Enjoy ...
    Mike
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-09 05:06
    Hi,
    ·Everything working great now,except first digit fails to appear when entering numbers.

    Thanks,Brian

    Post Edited (truckwiz) : 12/9/2006 6:33:34 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-09 06:37
    Sorry, forgot a dsp.out(c) around line 50. Here's the corrected version.
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-09 06:44
    Looking Good,
    ·I Better go to bed , my wife is getting mad

    Thanks,Brian
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-09 16:58
    Hi,
    ·Oh how things look differnt in the light of day . Working on cleaning this up a little . Made Mikes code into it's own object . making object for operators . How far back can you call up objects , the dsp.() is giving me a error now. Don't have time too check into it now, 50 deg. in MN on the 9th of December don't happen very often.


    Brian
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-09 21:25
    Hi,

    ·Throwing away version[noparse][[/noparse]0].6 , picking back up where I left off on version [noparse][[/noparse]1].5

    Brian
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-09 22:37
    Hi,

    ·Back to code from last night with some minor inprovements, Starting to work on shifts , rotates , boolean operators . Tried them a little bit , looks like I'm doing some more reading.

    Brian


    ( I uploaded the wrong one , this is the right one)

    Post Edited (truckwiz) : 12/9/2006 11:41:57 PM GMT
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-10 03:03
    Hi,
    Is there away to shorten this ?

    dsp.out($0A,0)
    dsp.out(0)
    dsp.out($0b)
    dsp.out(6)
    dsp.dec(total)
    dsp.out($0A)
    dsp.out(0)
    dsp.out($0B)
    dsp.out(7)
    dsp.hex(total,8)
    dsp.out($0A)
    dsp.out(0)
    dsp.out($0b)
    dsp.out(8)
    dsp.bin(total,32)

    I know this don't work , but somthing like this.
    dsp.out ($0a,0,$0b,0,)

    Thanks,Brian
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-12-10 03:12
    PRI gotoxy(x,y)
      dsp.out($0A)
      dsp.out(x)
      dsp.out($0B)
      dsp.out(y)
     
    ...
     
    gotoxy(0,6)
    dsp.dec(total)
    gotoxy(0,7)
    dsp.hex(total,8)
    gotoxy(0,8)
    dsp.bin(total,32)
    
    


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 12/10/2006 3:17:25 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-10 03:27
    You can also define a series of outx methods like:
    PRI out2(a,b)
      dsp.out(a)
      dsp.out(b)
    
    PRI out3(a,b,c)
      dsp.out(a)
      dsp.out(b)
      dsp.out(c)
    
    


    In the Propeller OS, I've got these routines in the display interface up to 6 arguments to account for the longest display command.
    Mike
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-10 03:37
    Hi,
    Looks much cleaner

    Thanks,Brian

    Post Edited (truckwiz) : 12/10/2006 4:22:40 AM GMT
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-10 20:20
    Hi,
    Anybody have any vga & mouse demo programs that I could take a peek at ?

    Thanks,Brian
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-10 20:31
    Take a look at Chip's 1024 x 768 VGA driver and demo program at the end of this thread <http://forums.parallax.com/forums/default.aspx?f=25&m=154758&p=1&ord=d>. It uses both text and graphics and has an optional cursor used with the mouse driver.

    Chip has made similar higher resolution drivers that use more cogs to handle the higher speed necessary. I think there's a 1200 x 1024 driver that uses 4 cogs and a 1600 x 1200 driver that uses 6 cogs (just for the video). A cursor requires an additional cog and the main program itself requires one.

    Post Edited (Mike Green) : 12/10/2006 8:36:08 PM GMT
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-10 20:34
    Mike,
    Tried running it. I get a error message " missing Lincoln. txt in propeller library ".

    Thanks,Brian
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-10 20:41
    There's nothing in his program (or the support files for graphics, keyboard, and mouse) that references a "Lincoln.txt". I've attached a fresh copy of the archive to this message. Try it again and consider reinstalling your Propeller Tool if it still doesn't work.
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-10 20:57
    I take it that the only thing that the monitor program is doing here is suppling the text ? (the program I had was tring to start up that lincoln2.txt & this one is using the monitor object).

    Brian
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-10 21:09
    Yes, the text is provided by the source file for monitor.spin. You could substitute anything else by changing the file name (near the end of the demo code) or by including the text in string form.
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-10 21:23
    I was tring to run chip's new tile driver (no cog's left for mouse) ,which was using a differnt text file for filler .

    Brian


    (if I would have read your first message all the threw ,there would have been no need for any further messages )smilewinkgrin.gif

    Post Edited (truckwiz) : 12/10/2006 9:43:25 PM GMT
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-11 02:40
    Mike,
    The more I think about the features that should be added to this trainer, the more I’m thinking GUI. Been playing around with Chips demo and beleive that a object could be written to control all the aspects of each button. Any thoughts on this??

    Brian
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-11 03:45
    Brian,
    Now that there's a nice VGA driver with reasonable memory and cog requirements and a cursor (and some graphics capability memory permitting), a GUI would be nice. I would suggest initially doing it without a mouse, maybe moving from object to object with the keyboard tab key (and shift tab for backwards). This makes it possible to not use a mouse (and free up a cog) for now, but add a mouse later. The display interface routines for the Propeller OS use an extended version of the windowed text display routines posted long ago to this forum. They allow up to 15 windows with scrolling and other control functions limited to the current window. The number of windows could be expanded easily enough to 31 with each containing a field or button (window 0 is the whole screen). A routine could be easily added to identify the window being clicked in by the mouse. A list of windows containing GUI objects could be maintained separately along with the behavior of each type of object. Just thinking ...
    Mike
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-11 04:05
    Is this the one ???




    ·Also ,If anybody else is working on this, be carefull not to draw a box outside the screen.The propeller·will get really mad !!

    Post Edited (truckwiz) : 12/11/2006 4:40:21 AM GMT
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-11 05:26
    Hi,
    ·This question has been bugging me for a long time. If you look at the diagrams of the propeller it shows a rotating cog. I know that things have really come along way in silicon fabrication, but do we really have rotating cog or is that to make us gear heads feel better. “Yah I have 500 hp in my cog, what about yours”
    ·
    Brian



    when my text look's like this , I used spell check !!

    Post Edited (truckwiz) : 12/11/2006 6:38:52 AM GMT
  • Harrison.Harrison. Posts: 484
    edited 2006-12-11 05:43
    Theres no rotating cog.

    Here is a picture of the propeller silicon (taken from http://www.circuitcellar.com/library/print/0806/Cantrell193/4.htm ).
    attachment.php?attachmentid=44577

    Post Edited (Harrison.) : 12/11/2006 5:47:21 AM GMT
    336 x 280 - 42K
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-11 05:50
    Brian,
    I don't remember the "guihires" item. A lot has gone on since that point in terms of display drivers. I'm really excited about the VGA Tiled Drivers in that they allow small areas of high resolution graphics to be embedded within a mostly text screen. The VGA 1024x768 Tiled Driver has very modest memory and cog needs, yet provides a 64x24 character screen with very crisp characters, lots of different colors, and the ability to embed small areas of high resolution bitmapped graphics (small areas to save on memory needs). Look at Chip's example of the use of the driver. He's got a couple of buttons that look very nice using some special features of the built-in character set.
    Mike
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-11 05:59
    Mike,
    I had 32 buttons up at one time,you have to be very careful how you place them. It took me a long time to get my propeller to take any code after I miss loaded with buttons that where off the screen.(trust me ,you don't want to see the code!!)

    Brian





    Thank you for the info Harrison !!·· smile.gif

    Post Edited (truckwiz) : 12/11/2006 6:14:17 AM GMT
Sign In or Register to comment.