Hi there,
I´m interested in how working with libraries works using Arduino Uno.
Yesterday I tried to implement a library which encapsulates another one.
In Detail, i wanted to encapsulate an Object of the class LiquidCrystal_I2C as a member object in a class GUI_Display and add some functions to e.g. automatically Show a splashScreen on this LCD.
I wrote the following Header File for my library:
/***************************************************************************
* Library GUI_Display is used to serve an Interface to a I2C LCD Display
*
***************************************************************************/
#ifndef GUI_Display_H
#define GUI_Display_H
#include "Arduino.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
class GUI_Display
{
public:
GUI_Display(int addr, int columns, int li);
void InitDisplay();
void PrintWelcScreen();
private:
int _addr;
int _columns;
int _lines;
LiquidCrystal_I2C lcd;
};
#endif
The corresponding Cpp-File looks like this:
/**************************************************************************
* Library GUI_Display is used to serve an Interface to a I2C LCD Display
*
**************************************************************************/
#include "Arduino.h"
#include "GUI_Display.h"
GUI_Display::GUI_Display(int addr, int columns, int li) : lcd(addr, columns, li)
{
_addr = addr;
_columns = columns;
_lines = li;
//lcd=new LiquidCrystal_I2C();
}
void GUI_Display::InitDisplay()
{
this.lcd.init();
this.lcd.backlight();
}
void GUI_Display::PrintWelcScreen()
{
this.lcd.setCursor(3,0);
this.lcd.print("Hello World");
}
In my Arduino Sketch test_cls.ino i included my lib and tried to instanciate an object of the class GUI_Display and use it:
#include "GUI_Display.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
void setup() {
// put your setup code here, to run once:
GUI_Display disp(0x27,20,4);
disp.InitDisplay();
}
void loop() {
// put your main code here, to run repeatedly:
disp.PrintWelcScreen();
}
If i try to compile the Sketch, the following error is thrown:
'line' does not Name a type; did you mean 'sinf'?
Unfortunately, the error message does not give any hint, in which line for example the error is.
It would be fantastic, if someone could provide a hint where I have to look for the Problem. Possibly, there are some other fault in the Code, too, but never Mind, I am going through step by step trying to understand all mistakes i did.
Yours, Chris