![]() |
Forum Index : Microcontroller and PC projects : Sending control commands to console
Author | Message | ||||
mikeb![]() Senior Member ![]() Joined: 10/04/2016 Location: AustraliaPosts: 174 |
Hi all, Sorry for the total 'newbie' questions but I have only ever worked with 'integer' programming (PICbasicPro) and a completely different function set. How do I send control commands to the console ? (eg, CLS, HOME, LF, CR). I know to use the 'colon' character, at the end of the line to suppress the 'auto generation' of CR and LF, but this does not give me the results I require. I would like to send an output string and then have a CR so the next output string overwrites the previous one rather than have an ever expanding list in the console. Also, how best to 'truncate' a floating point number to a particular decimal place or pad a number to same. I see having varying lengths of data problematic when it comes to file storage and retrieval. I've been scouring the forum and example code, I like to try and sort things out myself first, but I'm becoming entirely confused. Thanks in advance. There are 10 kinds of people in the world. Those that understand binary and those that don't. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
Are you using a terminal program on a PC or a display attached to the mite? If its a VT1oo terminal program, you need to learn a few VT100 commands. For formatting numbers, look at the STR command Jim VK7JH MMedit |
||||
mikeb![]() Senior Member ![]() Joined: 10/04/2016 Location: AustraliaPosts: 174 |
Thanks for the reply Jim. At the moment I'm just looking at the console output in MMedit straight from the MMII or MM+. I know I should be using decimal 10(LF) and decimal 13(CR) for what I want to do but don't know how to format it to stop the decimal number from being printed. It will be easy on the display as I have (x), (y) co-ordinates to play with My code is simply this - DO PRINT "Temperature: " DS18B20(30) " C"; **********need CR command, with no LF here************* pause 1000 LOOP I would like to overwrite Temperature [value] C each second, hence the need for a CR. Purely for testing purposes. I'll have another look at the string command as you suggest. Reghards, Mike B. There are 10 kinds of people in the world. Those that understand binary and those that don't. |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9588 |
How about: DO PRINT "Temperature: " DS18B20(30) " C"; PRINT CHR$(13); pause 1000 LOOP "PRINT CHR$(13);" will print one single CR character/byte on the end of your temperature. Each time you run that loop, it SHOULD overwrite the last figure for you. Untested, but it should work. Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
MMEdit is a (very poor) VT100 terminal so if you want to locate text on the display, you will need to learn the VT100 commands. Google will give you a few lists to play with. You can also do colours etc, not just placement. Do not leave MMEdit running for a very long time in VT100 mode. If you weant to do that, it is much better to use TeraTerm. PRINT CHR$(27)+"[37;41;1m"
PRINT "Hello World" DO:LOOP UNTIL INKEY$<>"" PRINT CHR$(27)+"[0m" PRINT "Hello World" Most terminal programs let you set what happens when a single CR is received so I wouldn't rely on Grogster's method. Jim VK7JH MMedit |
||||
mikeb![]() Senior Member ![]() Joined: 10/04/2016 Location: AustraliaPosts: 174 |
A big thanks Jim, and Grogs, for pointing me in the right direction. Sometimes I can't see the wood for the trees. I just love 'learning curves' at 55. Also got my resolution sorted. I think I'll use a 'timer tick' once my program evolves. DO TEMPR START 22,3 PRINT "Temperature: " str$(TEMPR(22),0,1) " C"; PRINT CHR$(13); LOOP The "PRINT CHR$" works perfectly in Tera Term but not in the MMedit 'chat window'. Never mind. They both have their uses. Learn't something else today. Thanks Guy's. There are 10 kinds of people in the world. Those that understand binary and those that don't. |
||||
bigmik![]() Guru ![]() Joined: 20/06/2011 Location: AustraliaPosts: 2949 |
GDay Jim, Have you thought, well is it possible, to configure MMEdit to use TeraTerm as the terminal? I say that because as much as I love MMEdit, I hate its terminal window and invariably have auto run turned off, shut down the mini window and then load TT to do my ... whatever I do.. If you could automate that process it would be fantastic, even to the extent of shutting TT before it sends more code to the device. Does that make sense? Kind Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6269 |
I have tried a few times. There are a couple of issues that the TeraTerm authors don't want to address (due to security worries). Also, people keep asking for more 'features' that don't help the integration. Have you tried the macro methods - see the MMEdit help - Using the terminal/Teraterm I can try a method that copies your program (crunched etc if that's what you have set) to the clipboard with a small header to start the transfer process. All you have to do then is right click in TeraTerm and your program is pasted into TeraTerm and uploaded using autosave. This works well provided you have a suitable line delay set in TeraTerm. My preferred option is to get off my bum and put out a working version of MMEdit compiled with a decent compiler instead of the interpreted Basic I use now. It will still be my lousy programming but a lot faster. Jim VK7JH MMedit |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
I use something like this for debugging purposes, not the best choice but does the job. [Code] Dim string Esc=Chr$(27) .. .. Print Esc+"[f"; Print "Lounge Temp = ", Str$(TempLng1,2,1) Print "Bedroom Temp = ", Str$(TempBed1,2,1) Print "Ambient Temp = ", Str$(TempAmb1,2,1) Print "Roof Temp = ", Str$(TempRoof,2,1) Print "Maximum & Minimum Temps" Print "Lounge Max = ", Str$(TempLng1Max,2,1) Print "Lounge Min = ", Str$(TempLng1Min,2,1) Print "Roof Max = ", Str$(TempRoofMax,2,1) Print "Roof Min = ", Str$(TempRoofMin,2,1) Print "System Status:-" Print "Current Up Time is:- ", Time$ [/code] I create the Esc variable just for readability, and then ESC[2f takes the cursor back to the home position before each screen write. The Str$(ABCD,2,1) basically says turn the number into a string & display it with 2 digits left of the decimal, and 1 to the right. Cheers |
||||
paceman Guru ![]() Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
@Mikeb The TEMPR() function returns a floating point number with a 0.25o resolution and accuracy of 0.5o. The others have mentioned to use the STR$ function to format it for output. If you wish to report the result to just a whole number, then before you use the STR$ function you should use the CINT function to round the result, otherwise you can be reporting a number 0.75o out, i.e. it will be truncated, not rounded. Greg |
||||
redrok![]() Senior Member ![]() Joined: 15/09/2014 Location: United StatesPosts: 209 |
Hi All; This is my personal list of VT100 Escape codes. http://www.redrok.com/ESCape-Codes.txt
redrok ESCape codes and special characters for ANSII terminal and MicroMiteII PRINT CHR$(7); REM BELL PRINT CHR$(11); REM LF PRINT CHR$(13); REM CR PRINT CHR$(27); REM ESC PRINT CHR$(44); REM , Comma PRINT CHR$(46); REM . Full stop PRINT CHR$(124); REM | Pipe PRINT CHR$(126); REM ~ Tilde PRINT CHR$(27);"D"; REM Role Up 1 line PRINT CHR$(27);"E"; REM Move to Next line PRINT CHR$(27);"M"; REM Role Down 1 line PRINT CHR$(27);"[0K"; REM clear-EOL PRINT CHR$(27);"[0m"; REM Cursor Normal (Reset) PRINT CHR$(27);"[4m"; REM Underline Mode PRINT CHR$(27);"[5m"; REM Blinking Mode (Doesn't Work) PRINT CHR$(27);"[7m"; REM Reverse Video PRINT CHR$(27);"[8m"; REM Invisable Mode PRINT CHR$(27);"[1;1f"; REM Cursor to Home PRINT CHR$(27);"[1K"; REM clear-BOL PRINT CHR$(27);"[2J"; REM Erase Display, Pause 500mS PRINT CHR$(27);"[2K"; REM Erase Entire Line PRINT CHR$(27);"[3A"; REM ^ Curser Up 3 PRINT CHR$(27);"[4B"; REM v Curser Down 4 PRINT CHR$(27);"[5C"; REM -> Curser Forward 5 PRINT CHR$(27);"[6D"; REM <- Curser Backward 6 PRINT CHR$(27);"[f"; REM Curser to Upper Left Corner PRINT CHR$(27);"[;f"; REM Curser to Upper Left Corner PRINT CHR$(27);"[Line;Column f"; REM Curser to Screen Position PRINT CHR$(27);"[H"; REM Curser to Upper Left Corner PRINT CHR$(27);"[;H"; REM Curser to Upper Left Corner PRINT CHR$(27);"[Line;Column H"; REM Curser to Screen Position PRINT CHR$(27);"7"; REM Save Cursor Position & Attributes PRINT CHR$(27);"8"; REM Restore Cursor Position & Attributes PRINT CHR$(27);"[s"; REM Save Cursor Position PRINT CHR$(27);"[u"; REM Restore Cursor Position PRINT CHR$(27);"[1m"; REM Bold PRINT CHR$(27);"[0m"; REM Cursor Normal (Reset) PRINT CHR$(27);"[30m"; REM Black PRINT CHR$(27);"[1;30m"; REM Bold Black PRINT CHR$(27);"[31m"; REM Red PRINT CHR$(27);"[1;31m"; REM Bold Red PRINT CHR$(27);"[32m"; REM Green PRINT CHR$(27);"[1;32m"; REM Bold Green PRINT CHR$(27);"[33m"; REM Yellow PRINT CHR$(27);"[1;33m"; REM Bold Yellow PRINT CHR$(27);"[34m"; REM Blue PRINT CHR$(27);"[1;34m"; REM Bold Blue PRINT CHR$(27);"[35m"; REM Magenta PRINT CHR$(27);"[1;35m"; REM Bold Magenta PRINT CHR$(27);"[36m"; REM Cyan PRINT CHR$(27);"[1;36m"; REM Bold Cyan PRINT CHR$(27);"[37m"; REM White PRINT CHR$(27);"[1;37m"; REM Bold White I like to use this form for control with uMITE and TeraTerm UL1$=CHR$(27)+"[4m" :REM Underline Mode NM1$=CHR$(27)+"[0m" :REM Cursor Normal (Reset) BK0$=CHR$(27)+"[0;30m" :REM Bold Black actually White RD0$=CHR$(27)+"[0;31m" :REM Bold Red GR0$=CHR$(27)+"[0;32m" :REM Bold Green YE0$=CHR$(27)+"[0;33m" :REM Bold Yellow BU0$=CHR$(27)+"[0;34m" :REM Bold Blue MG0$=CHR$(27)+"[0;35m" :REM Bold Magenta CY0$=CHR$(27)+"[0;36m" :REM Bold Cyan WH0$=CHR$(27)+"[0;37m" :REM Bold White actually Gray BK1$=CHR$(27)+"[1;30m" :REM Bold Black Lighter Black RD1$=CHR$(27)+"[1;31m" :REM Bold Red GR1$=CHR$(27)+"[1;32m" :REM Bold Green YE1$=CHR$(27)+"[1;33m" :REM Bold Yellow BU1$=CHR$(27)+"[1;34m" :REM Bold Blue MG1$=CHR$(27)+"[1;35m" :REM Bold Magenta CY1$=CHR$(27)+"[1;36m" :REM Bold Cyan WH1$=CHR$(27)+"[1;37m" :REM Bold White actually heavy Black ER1$=Chr$(27)+"[2J" :REM ERACE DISPLAY HM1$=Chr$(27)+"[f" :REM Curser to Upper Left Corner UP1$=CHR$(27)+"[1A" :REM ^ 1 Line PRINT ER1$;HM1$; PRINT BK1$;"BK1$ ";BK0$;"BK0$ ";RD1$;"RD1$ ";RD0$;"RD0$ "; PRINT GR1$;"GR1$ ";GR0$;"GR0$ ";YE1$;"YE1$ ";YE0$;"YE0$ "; PRINT BU1$;"BU1$ ";BU0$;"BU0$ ";MG1$;"MG1$ ";MG0$;"MG0$ "; PRINT CY1$;"CY1$ ";CY0$;"CY0$ ";WH1$;"WH1$ ";WH0$;"WH0$ "; PRINT BU1$ Send the specified byte values to the display driver. The specific control codes, their parameters, and their meaning depend on the display driver. See the display driver documentation for descriptions. See: http://ascii-table.com/ascii.php http://ascii-table.com/ansi-escape-sequences.php http://ascii-table.com/ansi-escape-sequences-vt-100.php Everything including the QUOTES must be included in the statement. The QUOTES are not sent. |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
@redrok Thanks for this very useful summary list ![]() |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4036 |
LF should be 10 John |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |