wayne_weedon
New Member
This has probably been done before, but I have been playing around with sending terminal escape sequences via the programming lead to the excellent PuTTy terminal which supports VT100/ANSI controls. Even though I have not played with this archaic stuff since adapting old CP/M Z80 Assembler Sources for various terminals many years ago, I have managed to get something rough and ready working.
The program below is not at all structured, but a rather linear series of instructions to just test things out. I can select various colours and other controls and have control over the cursor position. The latter was what I wanted to do initially; i.e. Printing exactly where I wanted to on screen rather than the data scrolling off.
I have used the PICAXE T4 trainer as that's what I am using in my classroom. This works well although reading the DS18B20 temperature sensor does make the program quite laggy. I have also experienced this when using this sensor with *rduino's.
So not particularly pretty or efficient, but it works and demonstrates what can be done! I will end up just using a couple of colours and cursor positioning so the overhead will be light.
The program below is not at all structured, but a rather linear series of instructions to just test things out. I can select various colours and other controls and have control over the cursor position. The latter was what I wanted to do initially; i.e. Printing exactly where I wanted to on screen rather than the data scrolling off.
I have used the PICAXE T4 trainer as that's what I am using in my classroom. This works well although reading the DS18B20 temperature sensor does make the program quite laggy. I have also experienced this when using this sensor with *rduino's.
So not particularly pretty or efficient, but it works and demonstrates what can be done! I will end up just using a couple of colours and cursor positioning so the overhead will be light.
Code:
#no_data
symbol esc = 27
#rem
Test of communication to PuTTy Terminal using VT100/ANSI ESCape sequences
sertxd (esc,"[2J") 'cls
sertxd (esc,"[f") 'home
sertxd (esc,"[?25l") 'hide cursor
sertxd (esc,"[?25h") 'show cursor
sertxd (esc,"[<Y>;<X>H") 'Cursor positioning
sertxd (esc,"[1m") 'bold
sertxd (esc,"[2m") 'dim
sertxd (esc,"[4m") 'Underscore
sertxd (esc,"[5m") 'blink
sertxd (esc,"[7m") 'reverse
sertxd (esc,"#6") 'double_width
sertxd (esc,"[30m") 'black
sertxd (esc,"[31m") 'red
sertxd (esc,"[32m") 'green
sertxd (esc,"[33m") 'yellow
sertxd (esc,"[34m") 'blue
sertxd (esc,"[35m") 'magenta
sertxd (esc,"[36m") 'cyan
sertxd (esc,"[37m") 'white
sertxd (esc,"[0m") 'attributes off
#endrem
do
gosub init
sertxd (esc,"[2J") 'cls
sertxd (esc,"[f") 'home
sertxd (esc,"[?25l") 'hide cursor
sertxd (esc,"[1m","Bold ") 'bold
pause 1000
sertxd (esc,"[31m","Red ") 'Red
pause 1000
sertxd (esc,"[32m"," Green") 'green
pause 1000
sertxd (esc,"[33m"," Yellow") 'yellow
pause 1000
sertxd (esc,"[34m"," Blue") 'blue
pause 1000
sertxd (esc,"[35m"," Magenta") 'magenta
pause 1000
sertxd (esc,"[36m"," Cyan") 'cyan
pause 1000
sertxd (esc,"[37m"," White",cr,lf,lf) 'white
pause 1000
sertxd (esc,"#6","Double Width Text",cr,lf,lf) 'double_width
pause 1000
sertxd (esc,"[4m","Underscored Text",cr,lf,lf) 'Underscore
pause 1000
sertxd (esc,"[0m","Attributes Off!",cr,lf,lf) 'attributes off
pause 1000
sertxd (esc,"[1m",esc,"[10;25H","Bold Text at X=25 and Y=10",cr,lf,lf) 'Cursor positioning
pause 1000
sertxd (esc,"[12;10H","Analogue Value C.1 =")
sertxd (esc,"[?25l") 'hide cursor
sertxd (esc,"[14;11H","Switch C.6 Status =")
sertxd (esc,"[16;11H","Switch C.7 Status =")
sertxd (esc,"[14;37H","Temperature C.2 =")
sertxd (esc,"[16;37H","Light Level C.0 =")
do while pinc.5 = 1 'Reset Switch (active low)
readadc c.1,b0
sertxd (esc,"[36m",esc,"[12;31H") 'cyan value
select case b0
case 0 to 9
sertxd("00",#b0)
case 10 to 99
sertxd("0",#b0)
case >=100
sertxd(#b0)
endselect
b1 = pinc.6
sertxd (esc,"[14;31H") 'cyan value
select case b1
case 0
sertxd (esc,"[32m","LOW ") 'green
case 1
sertxd (esc,"[31m","HIGH") 'Red
endselect
b2 = pinc.7
sertxd (esc,"[16;31H") 'cyan value
select case b2
case 0
sertxd (esc,"[32m","LOW ") 'green
case 1
sertxd (esc,"[31m","HIGH") 'Red
endselect
readadc c.1,b0
sertxd (esc,"[36m",esc,"[12;31H") 'cyan value
gosub format_adc
readadc c.0,b0
sertxd (esc,"[36m",esc,"[16;55H") 'cyan value
gosub format_adc
readtemp c.2,b0
sertxd (esc,"[36m",esc,"[14;55H") 'cyan value
gosub format_temp
loop
sertxd (esc,"[2J") 'cls
loop
init:
sertxd(cr,lf,lf,"Clear Screen, Home Cursor and Hide cursor in 4 Seconds!")
pause 4000
return
format_adc:
select case b0
case 0 to 9
sertxd("00",#b0)
case 10 to 99
sertxd("0",#b0)
case >=100
sertxd(#b0)
endselect
return
format_temp:
select case b0
case 0 to 9
sertxd("0",#b0," Celcius")
case 10 to 99
sertxd(#b0," Celcius")
endselect
return
Last edited: