Shop OBEX P1 Docs P2 Docs Learn Events
tv_wtext question — Parallax Forums

tv_wtext question

PVJohnPVJohn Posts: 60
edited 2006-07-14 23:21 in Propeller 1
Hi
I was trying out this code, and from some reason I cant get 40 chrs/col.
One row is always missing on the screen.
http://forums.parallax.com/showthread.php?p=590631

Here's my code:

'start
CON
· _clkmode····· = xtal1 + pll16x
· _xinfreq······· = 5_000_000
· basepin······· = 12
· CLS·········· · = $00· 'clear screen
· HOME········ · = $01· 'home
· CRSRXY······· = $02· 'set X, Y position (X, Y follow)
· CRSRLF······· ·= $03· 'cursor left
· CRSRRT······· = $04· 'cursor right
· CRSRUP······· = $05· 'cursor up
· CRSRDN······· = $06· 'cursor dn
· USECLR········ = $07· 'use color C (C follows)
· BS·············· ·= $08· 'backspace
· TAB············ ·= $09· 'tab (8 spaces per)
· LF·············· ·= $0A· 'linefeed
· CLREOL······ · = $0B· 'clear to end of line
· CLRDN········ · = $0C· 'clear down (to end of window)
· CR··············· = $0D· 'return
· CRSRX······· ·· = $0E· 'set X position (X follows)
· CRSRY······· ·· = $0F· 'set Y position (Y follows)
· DEFWIN····· ·· = $10· 'define window· W (W, Left, Top, nCols, nRows follow)
· USEWIN······ · = $11· 'use window W (W follows)
· DEFCLR······ ·· = $12· 'define color C (C, FG, BG follow)
· SCRLLF······ ·· = $13· 'scroll window left
· SCRLRT····· · · = $14· 'scroll window right
· SCRLUP······ ·· = $15· 'scroll window up
· SCRLDN····· ··· = $16· 'scroll window down
· CHGCLR······ ·· = $17· 'change all colors in window to C (C follows)
· CLRW········· ·· = $1E· 'same as CLR, but can be used in strings.
· ESC············ · = $1F· 'escape next character C (i.e. print as-is) (C follows)
· ZERO··········· · = $FF· 'can be used for 0, which is not allowed in strings, for command 'arguments


OBJ
· pr : "tv_wtext"

PUB start
··pr.start(basepin)
· pause(1)
· pr.out (CLS)
· pr.str(string(CHGCLR ,6))
· pr.str(string(CRSRXY, ZERO,ZERO,"1234567890123456789012345678901234567890"))···
· pr.str(string(CRSRXY, ZERO,1,"1234567890123456789012345678901234567890"))··
· pr.str(string(CRSRXY, ZERO,2,"1234567890123456789012345678901234567890"))
· pr.str(string(CRSRXY, ZERO,3,"1234567890123456789012345678901234567890"))
· pr.str(string(CRSRXY, ZERO,4,"1234567890123456789012345678901234567890"))···
· pr.str(string(CRSRXY, ZERO,5,"1234567890123456789012345678901234567890"))··
· pr.str(string(CRSRXY, ZERO,6,"1234567890123456789012345678901234567890"))
· pr.str(string(CRSRXY, ZERO,7,"1234567890123456789012345678901234567890"))
· pr.str(string(CRSRXY, ZERO,8,"1234567890123456789012345678901234567890"))···
· pr.str(string(CRSRXY, ZERO,9,"1234567890123456789012345678901234567890"))··
· pr.str(string(CRSRXY, ZERO,10,"1234567890123456789012345678901234567890"))
· pr.str(string(CRSRXY, ZERO,11,"1234567890123456789012345678901234567890"))··

' end



My second question is how to add keyboard function to this code to get fully functional
text editor?

Thanks,

PVJohn

·

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-07-13 04:11
    PVJohn,

    Yup, you're right. tv_wtext uses a delayed linefeed mechanism, so you can fill lines without causing an immediate scroll. Where tv_text might do a newline, tv_wtext just sets the eol flag, relying on a subsequent character to trigger the newline. But I failed to consider that CRSRXY should reset the eol flag. So you were getting an extra linefeed.

    Attached is a new version to try. I've patched some other eol errors, too. Hopefully, I haven't created more in the process...

    -Phil
  • PVJohnPVJohn Posts: 60
    edited 2006-07-13 04:23
    pHIL,
    This looks fine now! Thanks. Can you halp me to add a keybord function to your code to make text editor? Sincerely,
    PVJohn

    ·
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-07-13 04:46
    PVJohn,

    'Glad it worked out! Please let me know if anything else crops up.

    I'm pretty pressed for time these days (busy getting the PropCAM finished and kitting up more PropSTICKs). Plus I haven't done a thing with the keyboard yet. So I'm afraid I'll have to decline your editor invitation for now. Sorry...


    -Phil
  • PVJohnPVJohn Posts: 60
    edited 2006-07-14 06:42
    Hi Phil,
    I'm not sure what's happening, but when I run this code one character always goes to the next (6th) row, and then comes back to the 5th row, but then it it skip one column. Here's what I do:




    CON
    · _clkmode····· = xtal1 + pll16x
    · _xinfreq····· = 5_000_000
    · basepin······ = 12
    · CLS·········· = $00· 'clear screen
    · HOME········· = $01· 'home
    · CRSRXY······· = $02· 'set X, Y position (X, Y follow)
    · CRSRLF······· = $03· 'cursor left
    · CRSRRT······· = $04· 'cursor right
    · CRSRUP······· = $05· 'cursor up
    · CRSRDN······· = $06· 'cursor dn
    · USECLR······· = $07· 'use color C (C follows)
    · BS··········· = $08· 'backspace
    · TAB·········· = $09· 'tab (8 spaces per)
    · LF··········· = $0A· 'linefeed
    · CLREOL······· = $0B· 'clear to end of line
    · CLRDN········ = $0C· 'clear down (to end of window)
    · CR··········· = $0D· 'return
    · CRSRX········ = $0E· 'set X position (X follows)
    · CRSRY········ = $0F· 'set Y position (Y follows)
    · DEFWIN······· = $10· 'define window· W (W, Left, Top, nCols, nRows follow)
    · USEWIN······· = $11· 'use window W (W follows)
    · DEFCLR······· = $12· 'define color C (C, FG, BG follow)
    · SCRLLF······· = $13· 'scroll window left
    · SCRLRT······· = $14· 'scroll window right
    · SCRLUP······· = $15· 'scroll window up
    · SCRLDN······· = $16· 'scroll window down
    · CHGCLR······· = $17· 'change all colors in window to C (C follows)
    · CLRW········· = $1E· 'same as CLR, but can be used in strings.
    · ESC·········· = $1F· 'escape next character C (i.e. print as-is) (C follows)
    · ZERO········· = $FF· 'can be used for 0, which is not allowed in strings, for command arguments

    · dpin· = 26·····················································
    · cpin· = 27
    · NewLine = 13
    '· KeyLocks_Setup = %0_000_010··· 'CapsLock ON··········
    · KeyLocks_Setup = %0_000_000··· 'CapsLock OFF
    · AutoRepeat_Setup = %01_01000·· 'See number(3) at the bottom.

    OBJ
    · pr : "tv_wtext"
    · KB : "Keyboard"
    ··
    PUB start· | col, row, taster
    ·col := 1
    ·row := 1

    · pr.start(basepin)
    · pause(1)
    · pr.out (CLS)
    · pr.str(string(CHGCLR ,6))

    ·· 'start keyboard
    · KB.Startx(dpin, cpin, KeyLocks_Setup, AutoRepeat_Setup) 'IS· - Edited by Beau Schwabe (May 18, 2006)
    · WaitCnt(50_000_000 + Cnt)

    ··
    ·· Repeat
    ····· taster := KB.GetKey
    ······ pr.str(string(CRSRY,5))
    ······ pr.out(taster)


    BTW, CRSRx works fine.


    My second question is how can I replace numbers and use variables for CRSRY, CRSRX and CRSRXY?
    For example:

    ·· Repeat
    ····· taster := KB.GetKey
    ······ pr.str(string(CRSRXY,col,row))
    ······ pr.out(taster)
    ······ col=col+1


    Thanks for your replay.
    Sincerely,
    PVJohn

    ·
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-07-14 09:05
    PVJohn,

    Can you post an example of this behavior that doesn't use the keyboard?

    To answer your second question, string does not allow embedded variables. You will have to use pr.out for col and again for row.

    Thanks,
    Phil
  • PVJohnPVJohn Posts: 60
    edited 2006-07-14 13:33
    Hi Phil, Thanks for your replay. Here's an example w/o keyboard.

    Regards,

    PVJohn





    CON

    · _clkmode····· = xtal1 + pll16x
    · _xinfreq····· = 5_000_000
    · basepin······ = 12

    · CLS·········· = $00· 'clear screen
    · HOME········· = $01· 'home
    · CRSRXY······· = $02· 'set X, Y position (X, Y follow)
    · CRSRLF······· = $03· 'cursor left
    · CRSRRT······· = $04· 'cursor right
    · CRSRUP······· = $05· 'cursor up
    · CRSRDN······· = $06· 'cursor dn
    · USECLR······· = $07· 'use color C (C follows)
    · BS··········· = $08· 'backspace
    · TAB·········· = $09· 'tab (8 spaces per)
    · LF··········· = $0A· 'linefeed
    · CLREOL······· = $0B· 'clear to end of line
    · CLRDN········ = $0C· 'clear down (to end of window)
    · CR··········· = $0D· 'return
    · CRSRX········ = $0E· 'set X position (X follows)
    · CRSRY········ = $0F· 'set Y position (Y follows)
    · DEFWIN······· = $10· 'define window· W (W, Left, Top, nCols, nRows follow)
    · USEWIN······· = $11· 'use window W (W follows)
    · DEFCLR······· = $12· 'define color C (C, FG, BG follow)
    · SCRLLF······· = $13· 'scroll window left
    · SCRLRT······· = $14· 'scroll window right
    · SCRLUP······· = $15· 'scroll window up
    · SCRLDN······· = $16· 'scroll window down
    · CHGCLR······· = $17· 'change all colors in window to C (C follows)
    · CLRW········· = $1E· 'same as CLR, but can be used in strings.
    · ESC·········· = $1F· 'escape next character C (i.e. print as-is) (C follows)
    · ZERO········· = $FF· 'can be used for 0, which is not allowed in strings, for command arguments

    · NewLine = 13



    OBJ

    · pr : "tv_wtext"


    ··
    PUB start·


    · pr.start(basepin)
    · 'pause (1)

    · pr.out (CLS)
    · pr.str(string(CHGCLR ,6))
    · pr.str(string(CRSRXY, ZERO,ZERO,"1234567890123456789012345678901234567890"))···

    · pause (2)·········
    ·· Repeat 45
    ······ pr.str(string(CRSRY,ZERO))
    ······ pr.out("A")

    ··
    PRI pause(t)

    · if t < 0
    ··· t := clkfreq / ||t
    · else
    ··· t *= clkfreq
    · waitcnt(t + cnt)
    ···
  • PVJohnPVJohn Posts: 60
    edited 2006-07-14 14:10
    Phil, Could you please edit a code from my previous post to use variables with CRSRX and CRSRXY.

    Regards,

    John
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-07-14 17:41
    John,

    I tried your code, and it's doing what it's supposed to do. CRSRY just changes the Y position and leaves X where it was. If X was at the end-of-line, a newline is executed before the next character is printed. But this is probably not what most people want or expect. So I changed the code to check for the end-of-line condition upon a CRSRY. If the condition existed, then X is simply changed to 0 and the end-of-line condition reset. This prevents the newline from happening. (The revised tv_wtext object is attached.)

    As to your other question, I won't edit your program for you, but I'll show you how to do it:

      pr.out(CRSRXY)
      pr.out(col)
      pr.out(row)
    
    
    


    where col and row are variables.

    -Phil
  • PVJohnPVJohn Posts: 60
    edited 2006-07-14 23:21
    Phil,

    Thanks very much for your time and help.

    PVJohn
Sign In or Register to comment.