....and why are you wasting RAM, not using the F() macro for all those prints?

I found this comment "....and why are you wasting RAM, not using the F() macro for all those prints?"
in this thread I have a head scratcher. - Programming Questions - Arduino Forum

What is the "F() Macro"? and where is the best place to get information on this please?

Thanks
(I didn't ask in the original thread as I thought that would be classed as hijacking?)

first google result... Arduino Playground - Memory

Delta_G:
Google "Arduino F macro" and see what happens. That will work to at least get you started on most anything in the world that you want to know. It works especially well with programming and coding topics.

I did that and got thoroughly confused, i was hoping there may have been a tutorial or a "how to" guide that was regarded as being worth the looking at.

But thanks for your input, I will continue trolling through hundreds of hits searching for that "gem"

Kiwi_Bloke:
I did that and got thoroughly confused, i was hoping there may have been a tutorial or a "how to" guide that was regarded as being worth the looking at.

But thanks for your input, I will continue trolling through hundreds of hits searching for that "gem"

here is your how-to for saving RAM using F macro:

instead of this:

Serial.println("Some String Literal");

do this:

Serial.println(F("Some String Literal"));

"It's not rocket surgery."
:slight_smile:

BulldogLowell:
here is your how-to for saving RAM using F macro:

instead of this:

Serial.println("Some String Literal");

do this:

Serial.println(F("Some String Literal"));

Now that's a useful answer thank you Bulldog, I will try that with a display I am playing with that has a lot of lines printed for debug and test purposes.

Delta_G:
It's not rocket surgery. You put your string in parenthesis and put an F in front of it and magically the constant string in the print call doesn't take up RAM.

Actually to a non programmer learning a new language it looks exactly like rocket surgery, we are not all as clever or as experienced as you.

Delta_G:
As for how it works under the hood: well forget tutorials and forum threads, you've got the source code. Get in there and have a look.

Source code is a little like "White mans magic" to me, at the moment I am happy to read, study, test and ask for help.

Because the first article I found referenced PROGMEM and seemed to suggest I needed to do more than just add an "F" infront of my text to print.

Sadly I see more and more the clever ones seem to take delight in belittling those of us who need help understanding concepts, it not as if I asked you to solve my homework for me or write the code for my Discharge Tester.

So thank you Delta for you informed and helpful input, I am sure you found it most useful.....

Kiwi_Bloke:
Sadly I see more and more the clever ones seem to take delight in belittling...

hmmm...

Well, let's just say knowledgable; there is little in this realm that cannot be learned by most folks given time, patience and some guidance. It is sorta the point of it all.

Though, knowledge can be confused with intelligence (especially those with it).

Delta_G:
For some reason it seems like as soon as code gets involved people think they can just forget all the common sense stuff. Like how many thousands of threads are there because some n00b can't figure out Blink Without Delay. Look, you can use a clock in real life can't you? It's the exact same concept. But now there's code involved and suddenly they can't handle the difference between two numbers.

I have tried the Blink Without Delay and find the concept easy enough, but if one is new to coding the problem is not the concept of using a clock, its now to you translate that into a foreign language.

BulldogLowell:
hmmm...

Well, let's just say knowledgable; there is little in this realm that cannot be learned by most folks given time, patience and some guidance. It is sorta the point of it all.

Though, knowledge can be confused with intelligence (especially those with it).

That's kind of my point, I needed a little guidance, you provided it, I will test it in my program and learn from it.

Don’t forget to have fun.