Shop OBEX P1 Docs P2 Docs Learn Events
Using Windows HyperTerminal with Prop — Parallax Forums

Using Windows HyperTerminal with Prop

MikerocontrollerMikerocontroller Posts: 310
edited 2010-01-25 12:22 in Propeller 1
· Using the BS2 object I was able to DEBUG to the Windows Hypertext Terminal.· This is a very basic question: how do I clear the window of previously printed text?· I have no experience with Hypertext and could not find any info in the help menu.· I also am not able to advance the cursor to the next row.· The CR function places the cursor back in the HOME position.· Thank you.

Post Edited (Mikerocontroller) : 1/25/2010 7:42:30 AM GMT

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-01-25 06:09
    Do you mean Hyperterminal? This should respond to standard ANSI/VT100 commands so try a $0c to clear the screen and return the cursor to the top left. As an alternative TeraTerm is freely available and vastly superior.

    $0D or carriage return normally only ever returns to the left of the "carriage" or the same line. $0a is the line feed and so the correct new line sequence should always be $0d $0a.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • MikerocontrollerMikerocontroller Posts: 310
    edited 2010-01-25 07:12
    Thanks, Peter. I did mean to say Hyperterminal. Thank you for the tips. I'll give TeraTerm a try.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-01-25 10:52
    Re "The CR function places the cursor back in the HOME position"

    carriage return moves the cursor to the home position.
    line feed moves it down one line

    Anyway the standard way is you send both - carriage return then line feed.

    I use hyperterminal and teraterm. I just tested the following and it works on both:

    To clear the screen send ascii 27 then "[noparse][[/noparse]2J"

    To move the cursor to the top left, ascii 27 then "[noparse][[/noparse]H"

    These are standard VT100 codes. There are other codes to move the cursor round on the screen, delete lines etc.

    I wrote a tiny program in CP/M Sbasic on the Dracblade to test the above. It works on both hyperterminal and teraterm:
    print chr(27);"[noparse][[/noparse]H"; rem cursor to top left
    print chr(27);"[noparse][[/noparse]2J"; rem clear screen
    end
    
    



    You can write this in any language you like - but spin would be the simple choice. Some kind soul may be able to rewrite the above in Spin.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-01-25 12:22
    On the subject of ANSI commands here is a snippet of Spin code that you can integrate with your serial object's "tx" method. These are used to send out the ANSI sequences to ANSI terminal emulators to set attributes etc, even drawing commands. Shucks, you could even draw my avatar on the terminal if you want.


    '********************************* ANSI TERMINAL SUPPORT ******************
    
    con
      black = 0
      red = 1
      green = 2
      yellow = 3
      blue = 4
      magenta = 5
      cyan = 6
      white = 7
    
    pub vtx(ch)
      tx(ch)
    pub spaces(n)
      repeat n
        vtx(" ")
    pub tab
      vtx(9)
    pub atr(ch)
      escb(ch)
      vtx("m")
    pub plain  ' disable attributes
      atr($30)
    pub reverse  ' reverse text
      atr($37)
    pub bold
      atr($31)
    pub esc(ch)
      vtx($1b)
      vtx(ch)
    pub escb(ch)
      esc($5b)
      vtx(ch)
    pub curoff
      escb("?")
      dec(25)
      vtx("l")
    pub esch(ch)
      esc($23)
      vtx(ch)
    pub dht
      esch("3")
    pub dhb     ' double height bottom - forms the bottom half of a double height character
      esch("4")
    pub narrow
      esch("5")
    pub wide
      esch("6")
    pub cur(n,cmd)
      esc($5b)
      dec(n)
      vtx(cmd)
    pub xy(x,y)   ' position the cursor
      esc($5b)
      dec(y)
      vtx(";")
      dec(x)
      vtx("H")
    pub home
      escb($48)
    pub erscn   ' erase the screen from the point on
      escb("2")
      vtx("J")
    pub erline
      escb("2")
      vtx("K")
    pub cls   ' return home and clear the whole screen
      home
      erscn
    pub fg(col)  ' set foreground color
      escb($33)
      vtx(col+$30)
      vtx($6D)
    pub bg(col)  ' set background color
      escb($34)
      vtx(col+$30)
      vtx($6D)
    pub margins(top,bottom)
      esc($5b)
      dec(top)
      vtx(";")
      dec(bottom)
      vtx("r")
    pub horz(n)| i
      repeat i from 0 to n
        vtx($c4)
    pub hline(x,y,n)
      xy(x,y)
      horz(n)
    pub vert(n) | i
      repeat i from 1 to n
        str(string($b3,$0a,$08))
    pub vline(x,y,n)
      xy(x,y)
      vert(n)
    pub box (x,y,w,h)  ' you guessed it, draw a box or rectangle at x,y for width and height
    ' top line
      xy(x,y)      ' to top left
      vtx($da)     ' top left corner
      horz(w-2)    ' top line 
      vtx($bf)     ' top right corner
    ' bottom line
      xy(x,y+h)    ' to bottom left
      vtx($c0)     ' bottom left corner
      horz(w-2)    ' bottom line
    ' left side
      xy(x,y+1)    ' to left side below corner
      vert(h-1)    ' left side
    ' right side
      xy(x+w,y+1)
      vert(h-1)
      vtx($d9)     ' bottom right cornet
    
    
    


    P.S. just added some comments to the code

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*

    Post Edited (Peter Jakacki) : 1/25/2010 12:28:05 PM GMT
Sign In or Register to comment.