Greeting teachers,
I'm attempting to create a class that updates a 16x2 LCD across an i2c connection displaying
elapse time since Arduino starttup in hours and minutes (hh:mm).
I need to include the "Adafruit_LiquidCrystal" library in this class. I've done many hours
of research and have gotten the sketch down to three errors and haven't been able to make
any more progress.
I'm on the steep side of the C++ curve without a doubt. Your patience is greatly appreciated.
Setup and wire connection list:
Pro Mini to i2c/SPI character LCD backpack
(Adafruit ID:292)
Processor:
ATmega328P, Arduino Pro Mini, 5V, 16MHz
Pro Mini LCD backpack
pin pin Signal description
A4 SDA i2c Serial Data
A5 SCK i2c Serial Clock
Here's the sketch
#include<Adafruit_LiquidCrystal.h>
/* Connect via i2c, default address #0 (A0-A2 not jumpered) */
Adafruit_LiquidCrystal lcd(0);
class Display_update
{
// Class member variables that are initiated at startup.
int m; // minutes
int h; // hours
unsigned long currentMillis;
unsigned long previousMillis;
// Constructor - creates a Display_update instance, machine state can be passed
// to the subroutine in the constructor.
public:
Display_update(int mm, int hh, unsigned long current, unsigned long previous )
{
m = mm;
h = hh;
currentMillis = current;
previousMillis = previous;
};
void Update()
{
Serial.println("inside of the Update() method"); /// debug code ////
// Update HH:MM LCD display field
currentMillis = (millis()/500); ///////// clock speed is set here ////
delay(750); /////// delay for serial monitor debug purposes /////////////
Serial.println("Step 1"); //////////////// debug code ////
Serial.print(currentMillis, DEC); //////// debug code ////
Serial.print(" ");//////////////////// debug code ////
Serial.println(previousMillis, DEC);////// debug code ////
if((currentMillis - previousMillis) >= 1) {
Serial.println("Step 2"); ////////////// debug code ////
m=m+1;
Serial.println(m);
previousMillis = currentMillis;
Serial.println("Step 3"); ////////////// debug code ////
lcd.clear();
Serial.println("Step 4"); ////////////// debug code ////
if(h==0) {
Serial.println("Step 5"); //////////// debug code ////
lcd.setCursor(13,0);
goto Bailout;
}
if((h>0) && (h < 10)) {
Serial.println("Step 6"); //////////// debug code ////
lcd.setCursor(12,0);
lcd.print(h, DEC);
goto Bailout;
}
if(h > 9) {
lcd.setCursor(11,0);
lcd.print(h, DEC);
goto Bailout;
}
Bailout:
lcd.print(":");
if(m < 10) {
lcd.setCursor(14,0);
lcd.print("0");
}else{
lcd.setCursor(14,0);
}
lcd.print(m, DEC);
Serial.print(h, DEC);
Serial.print("0");
Serial.print(m, DEC);
if(m == 59) {
h=h+1;
m = 0;
}
} ///////////// end of if(currentMillis... ////
} /////////////// end of Update /////////////////
}; /////////////// end of class //////////////////
Display_update LCD(0, 0, 0, 0);
void setup()
{
Serial.begin(9600);
} ////////////////// end of Setup ///////////////////
void loop()
{
LCD.Update();
delay(1010);
} ////////////////// end of Loop ////////////////////
void Display_update::lcd.clear()
{
lcd.clear()=Adafruit_LiquidCrystal::lcd.clear();
}
void Display_update::lcd.setCursor()
{
lcd.setCursor()=Adafruit_LiquidCrystal::lcd.setCursor();
}
void Display_update::lcd.print()
{
lcd.print()=Adafruit_LiquidCrystal::lcd.print();
}
In the hours that I have poured into this project I haven't been able to execute any of the methods in the
Adafruit_LiquidCrystal library (lcd.clear, lcd.setCursor and lcd.print).
Here is the error report.
TimerDisplayDev_initial_e:138: error: expected initializer before '.' token
void Display_update::lcd.clear()
^
TimerDisplayDev_initial_e:143: error: expected initializer before '.' token
void Display_update::lcd.setCursor()
^
TimerDisplayDev_initial_e:148: error: expected initializer before '.' token
void Display_update::lcd.print()
^
exit status 1
expected initializer before '.' token
I don't have the words to tell how much I appreciate your help.
Many Thanks
Richard