user11174: I want to know if it's possible to use the F() macro on text that is being passed to a function.
This is an example function:
void displayMenu(const char * txt, byte &var) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(txt);
  lcd.setCursor(0, 1);
  lcd.print(var);
}

This is how I'm calling the function:
displayMenu("Backlight:", backlight);

If I didn't separate the repeating code into a separate function, I would've been able to write it out like this:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("Backlight: "));
lcd.setCursor(0, 1);
lcd.print(var);

If I try to do:
displayMenu(F("Backlight"), backlight);

it doesn't work. Also if I try to do this in the function:
lcd.print(F(txt));

that also doesn't work.
I'm just wondering if such a thing is possible.

user4143: There is a special type for just this occasion - the __FlashStringHelper type.
void displayMenu(const __FlashStringHelper *txt, byte var) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(txt);
  lcd.setCursor(0, 1);
  lcd.print(var);
}

Note I removed the & from var - you don't want that unless you are passing a complex class or are wanting to modify the contents of var in the function and have it reflected back outside the function.  Passing a reference to a byte (&var) requires two bytes of data - just passing the content of a byte only requires one byte of data.

11174: <p>I want to know if it's possible to use the F() macro on text that is being passed to a function.</p>

<p>This is an example function:</p>

<pre><code>void displayMenu(const char * txt, byte &amp;var) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(txt);
  lcd.setCursor(0, 1);
  lcd.print(var);
}
</code></pre>

<p>This is how I'm calling the function:</p>

<pre><code>displayMenu("Backlight:", backlight);
</code></pre>

<p>If I didn't separate the repeating code into a separate function, I would've been able to write it out like this:</p>

<pre><code>lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F("Backlight: "));
lcd.setCursor(0, 1);
lcd.print(var);
</code></pre>

<p>If I try to do:</p>

<pre><code>displayMenu(F("Backlight"), backlight);
</code></pre>

<p>it doesn't work. Also if I try to do this in the function:</p>

<pre><code>lcd.print(F(txt));
</code></pre>

<p>that also doesn't work.</p>

<p>I'm just wondering if such a thing is possible.</p>
 4143: <p>There is a special type for just this occasion - the <code>__FlashStringHelper</code> type.</p>

<pre><code>void displayMenu(const __FlashStringHelper *txt, byte var) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(txt);
  lcd.setCursor(0, 1);
  lcd.print(var);
}
</code></pre>

<p>Note I removed the <code>&amp;</code> from <code>var</code> - you don't want that unless you are passing a complex class or are wanting to modify the contents of <code>var</code> in the function and have it reflected back outside the function.  Passing a reference to a byte (<code>&amp;var</code>) requires two bytes of data - just passing the content of a byte only requires one byte of data.</p>
