Arduino Forum

Using Arduino => Interfacing w/ Software on the Computer => Topic started by: SierraGolfMike on Oct 08, 2018, 02:07 pm

Title: Conditional information displayed on serial monitor
Post by: SierraGolfMike on Oct 08, 2018, 02:07 pm
This might be a step too far, but wondered if it was possible to change the text colour displayed on the serial monitor depending on the value of the information coming from Arduino. For instance if a sensor measures a temperature, could the text colour be changed if it rises above a certain level?

Thanks in advance!

S
Title: Re: Conditional information displayed on serial monitor
Post by: pert on Oct 08, 2018, 02:43 pm
It's not possible with the Arduino IDE's Serial Monitor. However, if you use a terminal program that does VT100 emulation, you should be able to control color by sending the appropriate ANSI escape codes. I've never tried it but there was some discussion on the topic in the Arduino Developers mailing list.
Title: Re: Conditional information displayed on serial monitor
Post by: SierraGolfMike on Oct 08, 2018, 07:59 pm
Can anyone help me in terms of using ANSI escape codes with Arduino? There is a Library Ansiterm.h but not sure how to get that into Arduino? Any I have done before have been ZIP files.

I can't find any sample code on how to use ANSI with Arduino

Thanks in advance

S
Title: Re: Conditional information displayed on serial monitor
Post by: SierraGolfMike on Oct 08, 2018, 09:30 pm
I found the ansiterm library zip file, extracted and copied it into the libraries folder in Arduino and when opening up Arduino afterwards it says it's an invalid library. Any thoughts?

S
Title: Re: Conditional information displayed on serial monitor
Post by: pert on Oct 09, 2018, 02:30 am
Please post a link to where you downloaded the zip file from.
Title: Re: Conditional information displayed on serial monitor
Post by: SierraGolfMike on Oct 09, 2018, 09:30 am
Please post a link to where you downloaded the zip file from.
This is where I downloaded it from https://github.com/rklancer/ansiterm
Title: Re: Conditional information displayed on serial monitor
Post by: pert on Oct 09, 2018, 10:16 am
The library folder must be directly under the libraries folder, not in a subfolder. It's common for people to structure their repositories with the library is in the root so that it can be easily installed. Unfortunately that is not the case with this library. So to fix the error you just need to move the library folder up one folder level. The installed folder structure should look like this:

{sketchbook folder}
|_libraries
  |_ansiTest
     |_Ansiterm.h
     |_Ansiterm.cpp

I'm guessing yours currently looks like this:

{sketchbook folder}
|_libraries
  |_ansiterm-master
     |_ansiTest
        |_Ansiterm.h
        |_Ansiterm.cpp
Title: Re: Conditional information displayed on serial monitor
Post by: Robin2 on Oct 09, 2018, 11:09 am
Why would one need a library to send VT100 escape codes?

...R
Title: Re: Conditional information displayed on serial monitor
Post by: SierraGolfMike on Oct 10, 2018, 08:26 am
The library folder must be directly under the libraries folder, not in a subfolder. It's common for people to structure their repositories with the library is in the root so that it can be easily installed. Unfortunately that is not the case with this library. So to fix the error you just need to move the library folder up one folder level. The installed folder structure should look like this:

{sketchbook folder}
|_libraries
  |_ansiTest
     |_Ansiterm.h
     |_Ansiterm.cpp

I'm guessing yours currently looks like this:

{sketchbook folder}
|_libraries
  |_ansiterm-master
     |_ansiTest
        |_Ansiterm.h
        |_Ansiterm.cpp

Thanks for your reply, all sorted now!

S
Title: Re: Conditional information displayed on serial monitor
Post by: pert on Oct 10, 2018, 08:31 am
I'm glad to hear it. Are you able to get color output on puTTY now?
Title: Re: Conditional information displayed on serial monitor
Post by: SierraGolfMike on Oct 10, 2018, 09:06 am
I'm glad to hear it. Are you able to get color output on puTTY now?
Yes thanks, I can get the colours working fine now! Unfortunately the library does not have a blinking option but getting the colours are a big help. Much appreciated.

Thanks again

S
Title: Re: Conditional information displayed on serial monitor
Post by: SierraGolfMike on Oct 10, 2018, 09:16 am
I'm glad to hear it. Are you able to get color output on puTTY now?
Why would one need a library to send VT100 escape codes?

...R
Only because I couldn't find anywhere that showed me how to write the Arduino code for the escape codes! If you could point me to a post or source, that would be great.

Thanks

S
Title: Re: Conditional information displayed on serial monitor
Post by: Robin2 on Oct 10, 2018, 09:58 am
Only because I couldn't find anywhere that showed me how to write the Arduino code for the escape codes! If you could point me to a post or source, that would be great.
I suggested a Google search in your other Thread 2 days ago.

...R
Title: Re: Conditional information displayed on serial monitor
Post by: SierraGolfMike on Oct 10, 2018, 10:27 am
I have searched Google and can find sample code for Python Bash etc. but none for Arduino, except one line of code that did not work.
Title: Re: Conditional information displayed on serial monitor
Post by: Robin2 on Oct 10, 2018, 02:17 pm
I have searched Google and can find sample code for Python Bash etc. but none for Arduino, except one line of code that did not work.
Did you try the Google search that I suggested?

...R
Title: Re: Conditional information displayed on serial monitor
Post by: SierraGolfMike on Oct 10, 2018, 04:27 pm
Did you try the Google search that I suggested?

...R
Yes I did Google VT 100 escape codes and found a few pages but none of them showed how to adapt them to Arduino! I have found a sample sketch where they use a

#define BLINK "\033[5m"   Then:

Serial.print (BLINK);  I assume that switches BLINK on and anything printed after will blink?

Am I correct in thinking that if I define all the codes I need, I just invoke them by using a Serial.print statement? Also can I use these in conjunction with Ansiterm, using some of each code.

Thanks

S
Title: Re: Conditional information displayed on serial monitor
Post by: Robin2 on Oct 10, 2018, 06:29 pm
Am I correct in thinking that if I define all the codes I need, I just invoke them by using a Serial.print statement?
That is how I would go about it.

Quote
Also can I use these in conjunction with Ansiterm, using some of each code.
I don't know what Ansiterm is.


...R
Title: Re: Conditional information displayed on serial monitor
Post by: SierraGolfMike on Oct 10, 2018, 07:45 pm
I tried to run Rob Tillaart's VT100 sketch where he defines OFF. BOLD, LOWINTENS, UNDERLINE, BLINK and REVERSE using the relevant ANSI escape codes. I am using PuTTY but the BLINK and the LOWINTENS do not work, the rest do The BLINK just gives a background colour of grey. Does that mean that PuTTY does not support them?
Title: Re: Conditional information displayed on serial monitor
Post by: Robin2 on Oct 10, 2018, 10:01 pm
Does that mean that PuTTY does not support them?
You will have to read the PuTTY documentation for that.

...R