Skip to content

Problem function use an object before object declaration #111

Description

@thierry7100

Hi
In some cases with functions, I have a problem because the functions will refer to an object before the object declaration.
Here is an example of the generated code: The function "AfficheHeure" will use the object lcd before its declaration, this will lead to compiler error within tthe Arduino IDE.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

int Heure;
int Minute;
int Seconde;
int Jour;
int Mois;
int Annee;
unsigned long MemSeconde;

// Décrire cette fonction
void AfficheHeure() {
if (Heure < 10) {
lcd.setCursor(3,0);
lcd.print("0");
lcd.setCursor(4,0);
lcd.print(Heure);

} else {
lcd.setCursor(3,0);
lcd.print(Heure);

}
lcd.setCursor(5,0);
lcd.print(":");
if (Minute < 10) {
lcd.setCursor(6,0);
lcd.print("0");
lcd.setCursor(7,0);
lcd.print(Minute);

} else {
lcd.setCursor(6,0);
lcd.print(Minute);

}
lcd.setCursor(8,0);
lcd.print(":");
if (Seconde < 10) {
lcd.setCursor(9,0);
lcd.print("0");
lcd.setCursor(10,0);
lcd.print(Seconde);

} else {
lcd.setCursor(9,0);
lcd.print(Seconde);

}
if (Jour < 10) {
lcd.setCursor(2,1);
lcd.print("0");
lcd.setCursor(3,1);
lcd.print(Jour);

} else {
lcd.setCursor(2,1);
lcd.print(Jour);

}
lcd.setCursor(4,1);
lcd.print("/");
if (Mois < 10) {
lcd.setCursor(5,1);
lcd.print("0");
lcd.setCursor(6,1);
lcd.print(Mois);

} else {
lcd.setCursor(5,1);
lcd.print(Mois);

}
lcd.setCursor(7,1);
lcd.print("/");
lcd.setCursor(8,1);
lcd.print(Annee);
}

LiquidCrystal_I2C lcd(0x3F, 16, 2);
// Décrire cette fonction
void MiseAJourHeure() {_

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions