 |
|
 |
| Parallax Forums > Public Forums > Propeller Chip > TriBladeProp PCB: Uses 3 Propeller ICs for a Single Board Computer (SBC) | Forum Quick Jump
|
|  Dr_Acula Registered Member

       Date Joined Dec 2008 Total Posts : 606 | Posted 10/6/2009 4:25 AM (GMT -8) |   | | | |
       |  Dr_Acula Registered Member

       Date Joined Dec 2008 Total Posts : 606 | Posted 10/8/2009 12:23 AM (GMT -8) |   | | | |
            |  Dr_Acula Registered Member

       Date Joined Dec 2008 Total Posts : 606 | Posted 10/15/2009 5:09 AM (GMT -8) |   | No, what I'm going to do is have it so the cursor positioning works wherever the current display window is, but maintain the scrollback.
That would work fine. Programs that move the cursor round (eg wordstar) would stay in the screen area automatically. Programs that scroll would scroll.
I've been using Teraterm and you have to remember to close it down when downloading a new propeller program as the ports conflict. I think there was a similar issue with BST, but it ought to be easy to shut down the terminal when downloading a new program. Or, if you don't want to lose the user's text, maybe keep the terminal open but close the serial port, download doing the reset etc, then reopen the serial port to the terminal. Or even just keep it open but redirect it?
Yes, there are only a few VT100 and Wyse codes. Though it helps to have a program outputting them so you can test it as you go. Either a spare triblade, or cluso's nifty new 1.3" ramblade...
Anyway, below is the code in vb.net, and for those that prefer reading spin, the code to do the same thing copied from Vince Briel's Pocketerm. We were building both at the same time, and just kept adding instructions till all the CP/M programs we could find were working ok.
Sub DisplayCharacter(ByRef CharacterChanged As String) ' receives a character from serial port and updates the display Dim x As Integer Dim y As Integer Dim a As Integer Dim i As Integer Dim DisplayString As String Dim asciichar As Integer Dim LineOfText As String If CursX > 79 Then CursX = 0 ' when listening to lots of ^ characters can error Static VT100 As String ' build vt100 string asciichar = Strings.Asc(CharacterChanged) Select Case asciichar Case 13 ' carriage return - back to the left side but don't scroll CursX = 0 Case 10 ' scroll up one line if on bottom line, otherwise just move down one If CursY < 24 Then CursY = CursY + 1 Else For x = 0 To 79 Display(x, 25) = " " ' clear hidden line Next For y = 1 To 25 For x = 0 To 79 Display(x, y - 1) = Display(x, y) Next Next CursY = 24 End If Case 8 ' backspace CursX = CursX - 1 If CursX < 0 Then CursX = 0 Display(CursX, CursY) = " " If CursX < 0 Then CursX = 0 Case 0, 28 To 31, 128 To 255 ' display binary values in curly braces DisplayString = "{" + Trim(Strings.Str(asciichar)) + "}" If CursX > 74 Then ' near end of line so new line Call Scroll() End If For i = 1 To Len(DisplayString) Display(CursX, CursY) = Strings.Mid(DisplayString, i, 1) CursX = CursX + 1 Next Case 1 To 7, 9, 11, 12, 14 To 26 ' display values 0 to 26 as ^ If CursX > 74 Then ' near end of line so new line Call Scroll() End If DisplayString = "^" + Strings.Chr(64 + asciichar) ' 1=^A 2=^B etc For i = 1 To Len(DisplayString) Display(CursX, CursY) = Strings.Mid(DisplayString, i, 1) CursX = CursX + 1 Next Case 27 ' escape sequence VT100 = "]" ' start building vt100 string End Select ' no need to print character if >128 or a control character as already printed above If asciichar >= 32 And VT100 = "" And asciichar < 128 Then ' ignore other characters under 32 Display(CursX, CursY) = CharacterChanged CursX = CursX + 1 ' add one to the cursor If CursX > 79 Then CursX = 0 CursY = CursY + 1 ' move to next line End If If CursY > 24 Then ' scroll up For x = 0 To 79 Display(x, 25) = " " ' clear hidden line Next For y = 1 To 25 For x = 0 To 79 Display(x, y - 1) = Display(x, y) Next Next CursY = 24 ' beginning of last line CursX = 0 End If End If ' vt100 escape codes - all start with ] which stands for escape (easier to match string) If VT100 <> "" And asciichar >= 32 Then VT100 = VT100 + CharacterChanged ' add new ones on End If If Strings.Len(VT100) > 40 Then ' some {instructions} can be at least 33 char VT100 = "" ' cancel it but this should never happen. Just gets it out of a potential hang End If If VT100 = "][H" Then ' home position CursX = 0 CursY = 0 Call RedrawDisplay() VT100 = "" ' reset it must do this for every command End If If VT100 = "][J" Then ' erase from current line to the bottom of the screen For y = CursY To 24 For x = 0 To 79 Display(x, y) = " " Next Next Call RedrawDisplay() VT100 = "" ' reset it must do this for every command End If If VT100 = "][0m" Then ' reset all attributes - ignore VT100 = "" ' reset it must do this for every command End If If Strings.Len(VT100) >= 6 And Strings.Len(VT100) <= 8 And Strings.Right(VT100, 1) = "H" Then ' a cursor move instruction can be ][03;04H or ][3;4H or ][03;4H i = Strings.InStr(VT100, ";") If i <> 0 Then LineOfText = Strings.Left(VT100, i - 1) LineOfText = Strings.Mid(LineOfText, 3) ' strip off escape and [ a = Val(LineOfText) ' row CursY = a - 1 ' I use origin of 0,0 and vt100 uses 1,1 LineOfText = Strings.Mid(VT100, i + 1) LineOfText = Strings.Left(LineOfText, Strings.Len(LineOfText) - 1) ' strip off H a = Val(LineOfText) ' column CursX = a - 1 Call RedrawDisplay() End If VT100 = "" ' reset it must do this for every command End If If VT100 = "][0;1m" Then ' highlight text ' highlight text but I'm not sure how to do this in a textbox (? a rich text box) ' plus need to store this attribute in the array ' so just ignore for the moment VT100 = "" End If If VT100 = "][K" Or VT100 = "][0K" Then ' delete to the end of the line For x = CursX To 79 Display(x, CursY) = " " Next Call RedrawDisplay() VT100 = "" ' reset it must do this for every command End If If VT100 = "][D" Then ' backspace ? a non documented vt100 code (escD is left arrow) 'Only happens when opening a file and changing the name. ' wordstar sends <esc>[D then a space then <esc>[D again CursX = CursX - 1 If CursX < 0 Then CursX = 0 Call RedrawDisplay() VT100 = "" ' reset it must do this for every command End If If VT100 = "][M" Then ' deletes the line with the cursor on it ' scrolls all lines below this up one For x = 0 To 79 Display(x, y) = " " Next y = 25 ' delete hidden line For x = 0 To 79 Display(x, y) = " " Next For y = CursY To 24 For x = 0 To 79 Display(x, y) = Display(x, y + 1) Next Next Call RedrawDisplay() VT100 = "" ' reset it must do this for every command End If If VT100 = "][L" Then ' everything moves down one line from the current cursor line ' and delete the cursor line For y = 23 To CursY Step -1 For x = 0 To 79 Display(x, y + 1) = Display(x, y) Next Next For x = 0 To 79 Display(x, CursY) = " " Next Call RedrawDisplay() VT100 = "" ' reset it must do this for every command End If If VT100 = "][2J" Then ' clear the whole display and move cursor to home For y = 0 To 25 For x = 0 To 79 Display(x, y) = " " Next Next CursX = 0 CursY = 0 Call RedrawDisplay() VT100 = "" 'reset it must do this for every command End If ' Televideo and Wyse commands for Pacman and tetris If VT100 = "];" Or VT100 = "]*" Then ' Televideo/Wyse60 command to clear screen ESC; or ESC* For y = 0 To 25 For x = 0 To 79 Display(x, y) = " " Next Next CursX = 0 CursY = 0 Call RedrawDisplay() VT100 = "" 'reset it must do this for every command End If ' move cursor If Strings.Len(VT100) = 4 And Strings.Left(VT100, 2) = "]=" Then ' a cursor move instruction is ESC=RC,4 bytes 32 offset CursY = Strings.Asc(Strings.Mid(VT100, 3, 1)) - 32 CursX = Strings.Asc(Strings.Mid(VT100, 4, 1)) - 32 Call RedrawDisplay() VT100 = "" ' reset it must do this for every command End If ' cursor off If Strings.Len(VT100) > 2 And Strings.Left(VT100, 1) = "]" And Strings.Mid(VT100, 3, 1) <> "[" Then ' not a VT100 message as second character is not [ If VT100 = "].0" Then ' cursor off VT100 = "" ' reset it must do this for every command End If If VT100 = "].1" Then ' cursor on VT100 = "" ' reset it must do this for every command End If End If ' don't forget to set vt100 to "" after every if vt100 statement End Sub
And in Spin
'Start of VT100 code if remote == 27 'vt100 ESC code is being sent vt100:=1 byte1:=0 byte2:=0 byte3:=0 byte4:=0 byte5:=0 byte6:=0 byte7:=0 remote:=0 temp2:=0 wyse:=0 w1:=0 w2:=0 w3:=0 ' removed the skip for esc= and put it further down 'if remote==61 ' vt100:=0 ' remote:=0 'Don't display the ESC code if remote == 99 and vt100 == 1 'ESC c remote:=0 vt100:=0 text.inv(0) text.cls(Baud,termcolor,pcport,ascii,CR) text.home
' wyse command to clear screen = Esc; if remote==59 and vt100==1 and wyse==0 vt100:=0 remote:=0 text.cls(Baud,termcolor,pcport,ascii,CR) text.home ' another wyse command to clear the screen is Esc* if remote==42 and vt100==1 and wyse==0 vt100:=0 remote:=0 text.cls(Baud,termcolor,pcport,ascii,CR) text.home
'put ESC D and ESC M here if remote == 77 and vt100 == 1 'AKA ESC M text.scrollM vt100 := 0 if remote == 68 and vt100 == 1 'AKA ESC D if byte2 <> 91 and byte3 <> 91 and byte4 <> 91 'not esc[D 'text.scrollD vt100 := 0 if remote == 76 and vt100 == 1 'AKA ESC L if remote == 91 and vt100 == 1 ' [ 'look for open bracket [ vt100:=2 ' begin wyse if remote==61 and vt100==1 and wyse==0 ' wyse command for Esc= wyse:=61 if remote==46 and vt100==1 and wyse==0 ' wyse command for Esc. wyse:=46 if wyse==61 or wyse==46 w3:=w2 ' wyse mini buffer , only needs a few characters as codes are short w2:=w1 w1:=remote remote:=0 ' so doesn't print character if w3==61 and wyse==61 ' an Esc=RC col:=w1-32 row:=w2-32 text.cursloc(col,row) vt100:=0 ' clear pointer wyse:=0 ' clear vt100 pointer too remote:=0 ' hide character from output if w2==46 and w1==49 and wyse==46 ' Esc.1 vt100:=0 ' do nothing but do need to trap these (cursor on and off) wyse:=0 remote:=0 ' hide character from output if w2==46 and w1==48 and wyse==46 ' Esc.0 vt100:=0 wyse:=0 remote:=0 ' hide character from output ' end wyse 'start recording code if remote == 62 and vt100 == 1 or remote == 60 and vt100 == 1 'look for < & > vt100:=0 ' not sure why this is coming up, can't find in spec. if vt100==2 ''Check checking for VT100 emulation codes if remote > 10 byte7:=byte6 byte6:=byte5 ' My VTCode Mini Buffer byte5:=byte4 byte4:=byte3 byte3:=byte2 'Record the last 7 bytes byte2:=byte1 byte1:=remote if remote == 109 'look for lowercase m if byte2 == 91 'if [m turn off to normal set text.inv(0) vt100:=0 if byte2 == 49 and vt100 > 0 'is it ESC[1m BOLD 'text.inv(1) vt100 := 0 if byte2 == 55 and vt100 > 0 'is it ESC[7m? text.inv(1) vt100 := 0 if byte2 == 48 and vt100 > 0 '0 is back to normal text.inv(0) vt100:=0 if byte2 == 52 and vt100 > 0 'is it ESC[4m underline? vt100:=0 'yes ignore if byte2 == 50 and vt100 >0 'is it ESC[2m dim text vt100:=0 'yes ignore if remote == 64 'look for ESC[value@ @=64 insert value spaces if byte4 == 91 'two digit value byte3:=byte3-48 'Grab 10's byte2:=byte2-48 'Grab 1's byte3:=byte3*10 'Multiply 10's byte3:=byte3+byte2 'Add 1's text.insertat(byte3) if byte3 == 91 'single digit value byte2:=byte2-48 text.insertat(byte2) vt100 :=0 if remote == 80 'look for ESC[valueP P=64 delete value spaces if byte4 == 91 'two digit value byte3:=byte3-48 'Grab 10's byte2:=byte2-48 'Grab 1's byte3:=byte3*10 'Multiply 10's byte3:=byte3+byte2 'Add 1's text.delp(byte3) if byte3 == 91 'single digit value byte2:=byte2-48 text.delp(byte2) vt100 :=0 if remote == 104 'look for lowercase h set CR/LF mode if byte2 == 48 'if character before h is 0 maybe command is 20h if byte3 == 50 'if byte3 then it is for sure 20h LNM := 0 vt100:=0
if remote == 61 'lool for = vt100:=0
if remote == 114 'look for lowercase r vt100:=0
if remote == 108 'look for lowercase l if byte2 == 48 'if character before l is 0 maybe command is 20l if byte3 == 50 'if byte3 then it is for sure 20l LNM := 1 '0 means CR/LF in CR mode only vt100:=0
if remote == 62 'look for > vt100:=0 if remote == 77 'ESC M look for obscure scroll window code text.scrollM vt100:=0 if remote == 68 or remote == 76 ' look for ESC D or ESC L text.scrollD vt100:=0 if remote == 72 or remote == 102 ' HOME CURSOR (uppercase H or lowercase f) if byte2==91 or byte2==59 'look for [H or [;f text.home vt100:=0 '' Check for X & Y with [H or ;f - Esc[Line;ColumnH
else 'here remote is either H or f if byte4 == 59 'is col is greater than 9 ; ALWAYS if byte4=59 byte3:=byte3-48 'Grab 10's byte2:=byte2-48 'Grab 1's byte3:=byte3*10 'Multiply 10's byte3:=byte3+byte2 'Add 1's col:=byte3 'Set cols if byte7 == 91 'Assume row number is greater than 9 if ; at byte 4 and [ at byte 7 greater than 9 byte6:=byte6-48 'Grab 10's byte5:=byte5-48 'Grab 1's byte6:=byte6*10 'Multiply 10's byte6:=byte6+byte5 'Add 1's row:=byte6
if byte6 == 91 'Assume row number is less than 10 byte5:=byte5 - 48 'Grab 1's row:=byte5
if byte3 == 59 ' Assume that col is less an 10 byte2:=byte2-48 'Grab 1's col:=byte2 'set cols
if byte6 == 91 'Assume row number is greater than 9 byte5:=byte5-48 'Grab 10's byte4:=byte4-48 'Grab 1's byte5:=byte5*10 'Multiply 10's byte5:=byte5+byte4 'Add 1's row:=byte5 if byte5 == 91 'Assume that col is greater than 10 byte4:=byte4-48 'Grab 1's row:=byte4
col:=col-1 if row == -459 row:=1 if col == -40 ' Patches a bug I havn't found. *yet* col := 58 ' A Microsoft approach to the problem. :) if row == -449 row := 2 ' Appears to be an issue with reading if row == -439 ' single digit rows. row := 3 if row == -429 ' This patch checks for the bug and replaces row := 4 ' the faulty calculation. if row == -419 row := 5 ' Add to list to find the source of bug later. if row == -409 row := 6 if row == -399 row := 7 if row == -389 row := 8 if row == -379 row := 9 row--
if row < 0 row:=0 if col < 0 col:=0 if row > 35 row :=35 if col > 79 col := 79 text.cursloc(col,row) vt100:=0 if remote == 114 'ESCr text.out(126) if remote == 74 '' CLEAR SCREEN if byte2==91 '' look for [J '' clear screen from cursor to 25 text.clsfromcursordown 'vt100:=0 if byte2==50 '' look for [2J '' clear screen text.cls(Baud,termcolor,pcport,ascii,CR) if byte2==49 'look for [1J text.clstocursor if byte2==48 'look for [0J text.clsfromcursordown vt100:=0 if remote == 66 '' CURSOR DOWN Esc[ValueB if byte4 == 91 '' Assume number over 10 byte3:=byte3-48 byte2:=byte2-48 byte3:=byte3*10 byte3:=byte3+byte2 var1:=byte3 if byte3 == 91 '' Assume number is less 10 byte2:=byte2-48 var1:=byte2 if byte2 == 91 ''ESC[B no numbers move down one 'text.out($C3) var1 := 1 loop:=0 repeat until loop == var1 loop++ text.out($C3)
vt100:=0
if remote == 65 '' CURSOR UP Esc[ValueA if byte4 == 91 '' Assume number over 10 byte3:=byte3-48 byte2:=byte2-48 byte3:=byte3*10 byte3:=byte3+byte2 var1:=byte3 if byte3 == 91 '' Assume number is less 10 byte2:=byte2-48 var1:=byte2 if byte2 == 91 ''ESC[A no numbers move down one var1 := 1 loop:=0 repeat until loop == var1 text.out($C2) loop++ vt100:=0
if remote == 67 '' CURSOR RIGHT Esc[ValueC if byte4 == 91 '' Assume number over 10 byte3:=byte3-48 byte2:=byte2-48 byte3:=byte3*10 byte3:=byte3+byte2 var1:=byte3 if byte3 == 91 '' Assume number is less 10 byte2:=byte2-48 var1:=byte2 if byte2 == 91 ''ESC[C no numbers move RIGHT one var1 := 1 loop:=0 repeat until loop == var1 text.out($C1) loop++ vt100:=0
if remote == 68 '' CURSOR LEFT Esc[ValueD OR ESC[D if byte4 == 91 '' Assume number over 10 byte3:=byte3-48 byte2:=byte2-48 byte3:=byte3*10 byte3:=byte3+byte2 var1:=byte3 if byte3 == 91 '' Assume number is less 10 byte2:=byte2-48 var1:=byte2 if byte2 == 91 ''ESC[D no numbers move LEFT one var1 := 1 loop:=0 repeat until loop == var1 text.out($C0) 'was $C0 loop++ vt100:=0 if remote == 75 '' Clear line Esc[K if byte2 == 91 '' Look for [ text.clearlinefromcursor vt100:=0 if byte2 == 48 ' look for [0K if byte3 == 91 text.clearlinefromcursor vt100:=0 if byte2 == 49 ' look for [1K if byte3 == 91 text.clearlinetocursor vt100 := 0 if byte2 == 50 ' look for [2K if byte3 == 91 text.clearline vt100 := 0
if remote == 99 ' look for [0c or [c ESC [ ? 1 ; Ps c Ps=0 for VT-100 no options if byte2 == 91 '' Look for [ ser2.str(string(27,"[?1;0c")) vt100 := 0 if byte2 == 48 if byte3 == 91 ser2.str(string(27,"[?1;0c")) vt100 := 0 remote:=0 '' hide all codes from the VGA output.
www.smarthome.viviti.com/build | | Back to Top | | |
  |  Yoda Registered Member

       Date Joined Mar 2009 Total Posts : 61 | Posted 10/15/2009 6:44 AM (GMT -8) |   | @Heater - I have had VT100 running on blade #1 since the very beginning. I modified that code that came on my PocketTerm that was a derivative of code I believe from OBC. Basically I just had it set to 115K baud and applied the cross jumpers that were a patch to the TriBlade that Cluso posted long ago. Works great. I have rewritten that code for the N8VEM to be a little easier to follow and I think I have removed the microsoft problems that OBC mentioned above. Have to finish up disk read and write for N8VEM and then I will dust of the TriBlade and get back in the game.
Dave | | Back to Top | | |
    | 849 posts in this thread. Viewing Page : | | Forum Information | Currently it is Friday, November 20, 2009 11:24 PM (GMT -8) There are a total of 393,738 posts in 55,521 threads. In the last 3 days there were 81 new threads and 700 reply posts. View Active Threads
| | Who's Online | This forum has 17687 registered members. Please welcome our newest member, mark09. 58 Guest(s), 4 Registered Member(s) are currently online. Details Dr_Acula, W9GFO, pharseid, micromang |
Forum powered by dotNetBB v2.42EC SP2.02 dotNetBB © 2000-2009 |
|
|