Problem with coding functions using LiquidCrystal (LCD 16x2 screen)

I'm coding the interface part of a robotics projet using a LCD 16x2 screen. I tested the device with the LiquidCrystal library for some basic display tests and got it to work fine. I'm now trying to set up a more clear and re-usable code with a main code file, a functions file and a .h file where I define all my constants, etc which will allow me to add functionality / options to my interface when required.

The error seems to come from how LiquidCrystal works to define a LiquidCrystal object, it's not clear to me.
LiquidCrystal is at the same time the type of the screen object, yet also used to directly initialize the screen? For example, LiquidCrystal lcd(pin_rs,pin_enable,pin_d0,pin_d1,pin_d2,pin_d3); is valid code?

I would really appreciate some help, whenever I try to compile my code I get this error :
functions.c:5:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘lcd’
functions.c: In function ‘affiche’:
functions.c:12:3: error: ‘lcd’ undeclared (first use in this function)

It happens when I try to put a LiquidCrystal as an object in a parameter of another function.
Is this not possible? I've encluded my code in a .rar. It's commented in french but I can explain parts if it's not clear.

If it matters I'm using an arduino Uno but have several Megas available as well.

Thanks for any help I'm totally stuck! I can't get a clear idea of how this library works

ecran.rar (2.71 KB)

LiquidCrystal lcd(pin_rs,pin_enable,pin_d0,pin_d1,pin_d2,pin_d3); is valid code?

It's called the "Constructor" or "Descriptor" for the lcd. It's a form of declaration describing the exact
pin assignment for that specific lcd. Bill, Paul, and Don can tell you everything you need to know
about that. They are the display experts.

The error seems to come from how LiquidCrystal works to define a LiquidCrystal object, it's not clear to me.
LiquidCrystal is at the same time the type of the screen object, yet also used to directly initialize the screen?

Bill (bperrybap) is the one to ask about C programming although I can answer one or two of your questions.

LiquidCrystal does not initialize the screen, that is done by the lcd.begin(...) statement.

For example, LiquidCrystal lcd(pin_rs,pin_enable,pin_d0,pin_d1,pin_d2,pin_d3); is valid code?

This looks perfectly valid to me.

If you would like to try running the LCD without a library then take a look at some of the fully commented (in English) programming examples at http://web.alfredstate.edu/weimandn for some ideas.

Don

Well, that one really threw me for a loop.
The error is actually down in new.h but it is one of those strange types of "errors" that really isn't an error
or at least not an error related to reported error.

The problem is that the functions.c is a C module but the code is using C++ constructs.
It is attempting to define a C++ constructor and then using the C++ lcd object.
Rename the module to functions.cpp

--- bill

In this section of the code:

  int HIGH = 1;
  etat_courant_up = HIGH;
  etat_courant_down = HIGH;
  etat_courant_left = HIGH;
  etat_courant_right = HIGH;
  etat_previous_up = HIGH;
  etat_previous_down = HIGH;
  etat_previous_left = HIGH;
  etat_previous_right = HIGH;

Do you want an integer "HIGH" or are you defining "HIGH" as "1"? I don't know enough C to know why my compiler complains about this but I suspect that one of the header files has previously defined "HIGH".

The problem was it not being a .cpp file, things seem to be working fine now. Working on adding features and a proper easily customizable menu interface.
For the "HIGH" issue I removed the definition of it and just included Arduino.h, seems to be alright.

Thanks for all the help!

On to the user interfaCe, check out a few existing libraries, dont reinvent the wheel. Click phi_prompt on my signature for one of such library.