Shop OBEX P1 Docs P2 Docs Learn Events
Problem with VGA and keyboard usage — Parallax Forums

Problem with VGA and keyboard usage

djh82ukdjh82uk Posts: 193
edited 2008-08-12 03:29 in Propeller 1
Hi All

Im trying to make a modular relay control system. Basically I want a prop with a vga display and keyboard entry, the user will type in a 3 digit number and press enter, this toggles the state of that relay and displays what the state is now.

My idea was to use one prop for the display and keyboard, which then sends out a broadcast message to the relay control boards (SX48's) either via I2C or via serial, the corresponding sx48 boards toggles the relay.

My question is how can i do the vga and keyboard entry easily? i thought it would be best for the prop to maintain the registry of what relays are in which state so there is only 1 way traffic over the i2c bus/serial

Ive got no idea where to start

any help would be great

DJH

Comments

  • Graham StablerGraham Stabler Posts: 2,510
    edited 2008-07-11 22:32
    Use the VGA and keyboard objects, take a look at and run the example programs.

    Graham
  • djh82ukdjh82uk Posts: 193
    edited 2008-08-11 14:58
    Hiya

    I have done just that, I have got the keyboard test object to use VGA, but I cannot figure out how to tell it where to right the text, but worse than that is the fact that it does not display the keystroke (just garbage), like if I press key 3 it displays an arrow :S

    I want to be able to type in 3 numbers, press enter and have that stored as a variable.

    PUB start | i

    'start the tv terminal
    text.start(16)
    text.str(string("Keyboard Demo..."))

    'start the keyboard
    kb.start(26, 27)

    'echo keystrokes in hex
    repeat
    'text.hex(kb.getkey,3)
    keypressed := kb.getkey
    text.str(keypressed)






    Anyone help?
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-08-11 15:14
    You may/may not find this code helpful, (depending on what you are doing with the input)
    but it's come in handy on many occasions.

    
    PUB input(data, size) | keystroke,len
       keystroke:=0
       len:=0
       text.out(02)
       repeat' until keystroke == 13 'Exit when Carriage Return is pressed
         keystroke := key.key
             
          if keystroke == $C8       ' Check for Backspace Key
            if len > 0
             byte[noparse][[/noparse]data--] := 0
             size++
             len--
             text.out(8)
             text.out(32) 'These lines erase the cursor on backspace
             text.out(8)
             
             text.out(8)
             text.out(32)
             text.out(8)
             text.out(02)
             keystroke := 0
    
          if keystroke == $C8        'Clean up backspace if all is cleared
             keystroke:= 0
    
          if keystroke == 13
             text.out(8)
             text.out(32)
             text.out(8)
             text.out(13)
             quit
             
          if keystroke > 10 
            if size > 1
              text.out(8)
              text.out(keystroke)
              text.out(02)
              
              ''text.dec(keystroke) 'for troubleshooting
              if keystroke <> 13 
                byte[noparse][[/noparse]data++] := keystroke
                size--
                len++
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • djh82ukdjh82uk Posts: 193
    edited 2008-08-11 15:22
    hiya

    I had an error on that code on the key.key part, im guessing I need to add some stuff in var etc.


    Anyway it kicked me into fixing part out it. I was using text.str( instead of text.out(


    now it diplays whatever key is pressed [noparse]:)[/noparse]

    now I need to figure out how to capture 3 keys into one variable,

    basically there is going to be loads of outputs each with a 3 digit number, I want to be able to type the number press enter and toggle the respective output. ive been away from prop and programming in general so am struggling to slip back into it (not that I was ever that good at it anyway [noparse]:)[/noparse]

    Thanks

    DJH
  • MovieMakerMovieMaker Posts: 502
    edited 2008-08-11 15:56
    My keyboard and mouse and vga seems not to work with the VGA,Ky,MS accessories.When I run the mouse drivers, I can use the mice and keyboard from the pc to the terminal window but not direct hooked up to board.

    ???
  • djh82ukdjh82uk Posts: 193
    edited 2008-08-12 02:37
    hmm, how can I clear the screen using vga_text obj?
  • djh82ukdjh82uk Posts: 193
    edited 2008-08-12 03:29
    no worries, figured it out.

    I now have it so that you type in 3 numbers, press enter, it displays the 3 numbers and then resets.

    I now need to add some sort of error control so that it only accepts numbers, any ideas?

    is there a way to check if a string is numeric?

    Need to sort out how to send serial comms then.

    On the other end will be a load of SX48 boards that all sit waiting for serial input. If the number is in the range of the board it will activate that relay, otherwise it ignores it.
Sign In or Register to comment.