Shop OBEX P1 Docs P2 Docs Learn Events
Special effects — Parallax Forums

Special effects

NewzedNewzed Posts: 2,503
edited 2006-10-18 14:03 in Propeller 1
Mike, is there any way to "blink" a word - for instance the "Select" that follows the Menu display?

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?

Newzed@aol.com
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-17 22:36
    Sid,
    There's currently no nice neat way to do this. What you could do is assign a color number to the Menu text that's different from the default (say color #3) and make it the same colors as the default. Set up a cog that just sits in a REPEAT loop with a WAITCNT for a pause of maybe 1/2 second, then just swap the foreground and background colors for the blink color in the color table. That would invert the colors every 1/2 second of every character using that color number.

    I'm currently working on changes to the TV and lores VGA drivers to support cursors and will probably do it this way (but integrate it into the drivers). I haven't decided what to do with the hires VGA driver since it already has cursors, but not a blink mode.
    Mike
  • NewzedNewzed Posts: 2,503
    edited 2006-10-17 23:43
    Mike, I wrote:

    PUB blink
    · repeat 5
    ··· text.str(string(19,30,240,10,"Select"))
    ··· waitcnt(clkfreq/2 + cnt)
    ··· text.str(string(19,30,240,10," "))
    ··· waitcnt(clkfreq/2 + cnt)
    ··· text.str(string(19,30,62,10,"Select"))
    ··· waitcnt(clkfreq/2 + cnt)
    ··· text.str(string(19,30,240,10," "))
    ··· waitcnt(clkfreq/2 + cnt)··············

    Select changed colors every 1/2 second but it printed a new Select -· I would up with 10!· How can I make it display at the same X-Y position so I don't get duplicate words?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Don't have VGA?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-18 00:01
    Sid,
    I'm assuming that you're using the hires VGA text routines. Colors work a bit differently in the TV and lowres VGA text routines. For the hires ones, each line on the display has a foreground and background color associated with it. When you change a line's colors, the whole line changes regardless of the text on the line. You don't have to rewrite the text on the line to change the colors, just change the colors associated with the whole line. In addition, to make the text on a line disappear, just make the foreground and background colors the same. You don't have to replace the word "Select" with a blank (unless you have other text on the line that you want to display).

    There are display commands "MoveX", "MoveY", and "MoveXY" that you can use to reposition to a specific place on the screen. Look at the comments in the display routines for the numeric values. You can also use "text#MoveXY" or "text#SetColor" if you want to use the actual names (for clarity).
  • NewzedNewzed Posts: 2,503
    edited 2006-10-18 00:21
    OK, Mike - I've got Select changing colors but staying in the same place.· Now last question - I wrote repeat 5 and that's what is does.· However, I would like for it to jump to the getchoice method when I press a key.· I wrote:

    repeat until key.getkey

    but then it doesn't change color and it takes·a key stroke to get to getchoice.· Is there any way for it to keep changing colors until I press a key, and then go directly to the desired method?

    Sid



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Don't have VGA?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-18 02:07
    Try:
    repeat until code := key.key
      ' blink stuff
    case code
      "x": ...
      "y": ...
    
    
  • Tom WalkerTom Walker Posts: 509
    edited 2006-10-18 13:07
    Does key.key return, essentially, a FALSE value (don't have code in front of me) when nothing is available? If not, then == is probably called for instead of :=.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • NewzedNewzed Posts: 2,503
    edited 2006-10-18 13:35
    Mike, I tried your bit of code and I just couldn't get it to work right.· Then I moved the blink method into getchoice:

    PRI getChoice : selectedOption
    { Accept menu choice. Returns uppercase letter. }
    · 'key.clearkeys
    · repeat until code := key.key
    · 'blink stuff
    · repeat
    ··· selectedOption :=·key.getkey
    ··· if (selectedOption => "a") and (selectedOption =<"z")
    ······ selectedOption -= ("a" - "A")
    until (lookdown (selectedOption : "ABCDEFOQGTPRSMWX"))

    It worked but I had to hit the key I wanted twice.· So then I changed

    selectedOption :=·code

    and everything worked with only one key press!· There was an appreciable delay between the time I pressed the key and the action was performed, so in the blink section I changed:

    waitcnt(clkfreq/2+ cnt)

    to

    waitcnt(clkfreq/4 + cnt)

    and that helped things considerably.· Thanks a lot for the code bityeah.gif

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Don't have VGA?

    Newzed@aol.com
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-18 14:03
    Tom and Sid,
    "key.key" returns a zero if there's no keyboard key to return. It returns the character code if there is one. Sid's routine should look like
    PRI getChoice : selectedOption
    { Accept menu choice. Returns uppercase letter. }
      'key.clearkeys
      repeat
        repeat until selectedOption := key.key
          'blink stuff
        if (selectedOption => "a") and (selectedOption =<"z")     
           selectedOption -= ("a" - "A")                
      until (lookdown (selectedOption : "ABCDEFOQGTPRSMWX"))
    
    


    The "repeat until selectedOption := key.key" is correct. It gets the current key (or zero) and saves it as "selectedOption". The "repeat until", like ALL Boolean operations, treats a non-zero value as TRUE, so the repeat statement repeats (and blinks the menu item) as long as no key is pressed. Once a key is pressed, it exits the repeat loop (after the last blink is done), checks "selectedOption" for validity, and returns to the caller if the entered code is valid (otherwise goes back to wait for another keypress).

    I've left Sid's test for validity even though it's not complete. If the user were to enter control codes (using the control shift key), they could end up in the same range (0 to whatever) and falsely be accepted by the lookdown statement. In practice, this will work, but I wouldn't use it for some other project where the general public or children were going to use it.

    Post Edited (Mike Green) : 10/18/2006 2:08:22 PM GMT
Sign In or Register to comment.