Notifications
Clear all

What happened with `printf` and its family?

39 Posts
6 Users
9 Likes
2,552 Views
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7012
 

@yurkshirelad Remember, the sprintf statement can also accept the same formatting, so once you have a string of formatted text you can 'output' it any way you want. If I have a text message field on say the arduino cloud, this can be used to fancy it up.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@yurkshirelad

I've used the bash shell to do the same in the past, as long as the escape sequences are supported.

For example:

#!/usr/bin/bash
echo -e '\033[0;33m'Hello


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 
Posted by: @zander

@yurkshirelad Remember, the sprintf statement can also accept the same formatting, so once you have a string of formatted text you can 'output' it any way you want. If I have a text message field on say the arduino cloud, this can be used to fancy it up.

I tend to agree that using a stylesheet as suggested by @yurkshirelad is the better way to approach it... it means less code for you to write in your main code, and allows the web server to automate it all for you.  The possibilities are endless with CSS these days, and you could even make use of fancy CSS stylesheet libraries if you don't want to write it yourself - just look at what BOOTSTRAP is doing 😉


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7012
 

@frogandtoad Yes, that's the thing I was thinking of. I got pulled away from solving that problem by another problem. I will find a 'cheat sheet' somewhere so I can add some colour to my text.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7012
 

@frogandtoad The problem is where I want to add some 'style' is in the arduino IoT cloud and it's just code, no CSS etc. a simple sprintf variant is all I need. The cloud system is very primitive at the moment, I assume they have a team working on it to bring it into the modern world. I can't even put proper labels on fields yet.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
 

Can you use escape codes to add colour to a web page?


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7012
 

@yurkshirelad I don't know, I assume so. I am not directly working with a web page, wouldn't have a clue. I am simply using the Arduino IoT cloud. It is very basic at the moment but I am hoping escape sequences will cause colour. Right now I am still analyzing and designing, when I write the code I will try some escape sequences and see what happens.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
 

My memory's hazy, I thought the intent was to write to a web page. Just getting confused in my middle age. 😀 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7012
 

@yurkshirelad No not confused, probably my poor assumption that everyone on herte was familiar with the Arduino IoT cloud that Bill made the video about.The end result is I suppose a web page on my phone but as the coder, I never see anything but regular C code and mostly not even that, it's click and move around little boxes.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 
Posted by: @yurkshirelad

Can you use escape codes to add colour to a web page?

www.w3.org


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @zander

@frogandtoad The problem is where I want to add some 'style' is in the arduino IoT cloud and it's just code, no CSS etc. a simple sprintf variant is all I need. The cloud system is very primitive at the moment, I assume they have a team working on it to bring it into the modern world. I can't even put proper labels on fields yet.

Well, you can still format CSS and embed it directly inline between some style tags or dedicated tags in the head section... preferably an external stylesheet however.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7012
 

@frogandtoad Thanks for the link, I will see if there is info in there to guide me how to build a C string with colour added. This is a nice to have, not something that will break the project.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 7012
 

@frogandtoad Here is a picture of the start of the sketch generated by the Arduino IoT cloud tool. NO web stuff visible, just C code.

Screen Shot 2022 04 09 at 07.41.10

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @zander

@frogandtoad Thanks for the link, I will see if there is info in there to guide me how to build a C string with colour added. This is a nice to have, not something that will break the project.

C and C++ can write to stdout for example, which may or may not be attached to a display device.  If however, you can send to some sort of display device, then any language scripting or otherwise can send escape sequences to that device, as long as it supports such standards, which many do and are POSIX compliant as well.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @zander

@frogandtoad Here is a picture of the start of the sketch generated by the Arduino IoT cloud tool. NO web stuff visible, just C code.

Screen Shot 2022 04 09 at 07.41.10

Hehe... "the thing"!

I have never used the cloud, and personally don't trust clouds, unless it's my own personal cloud that I have complete control over.  I can only imagine that you must have installed some kind of browser plugin to keep the session alive for communications?  Did you do something like that during installation or browser configuration?


   
ReplyQuote
Page 2 / 3