Any way to use F macro with a passed variable? 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 &amp;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.
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 &amp; 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 (&amp;var) requires two bytes of data - just passing the content of a byte only requires one byte of data.