I have an arduino and an LCD display attached on it.I use lcd.print function to write things on the LCD.I need to write a function that enables or disables all writes on the LCD replacing the lcd.print depending on a "condition".

jzuidema

Not familiar with the LCD screen, but as far as my (limited) knowledge of Arduino programming goes, its rather impossible to define an argument for a method that can take multiple or all forms. I would suggest to either store the to-be-printed material in global variables, and handle the different formats with different methods, or use an identifier in the argument to tell the method what kind of data is being printed. Perhaps with a switch case or something.

I have no clue exactly what the extend of the expected data formats is, but this is a general solution which should be easily implementable

EDIT: perhaps you can set up 'condition' as to take care of selecting the correct method to handle the data. Some actual code would be useful, primarily the part which fills/selects the data for the final printing. How do you decide which variables are printed? The casting question I cannot answer, but would be useful if the method would simply print what you feed it...

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.Do not send technical questions via personal messaging - they will be ignored.I speak for myself, not Arduino.

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.Do not send technical questions via personal messaging - they will be ignored.I speak for myself, not Arduino.

For a compiled, type-safe method, do as Nick suggests and use templates.

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.Do not send technical questions via personal messaging - they will be ignored.I speak for myself, not Arduino.

A macro is simply a text-replacement mechanism, so yes, it can take any type as argument.

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.Do not send technical questions via personal messaging - they will be ignored.I speak for myself, not Arduino.