Hi,
I'm trying to write a class for a 16x2 serial LCD display. One of the functions I'm trying to inherit is the printf function from the Stream class, similar to the TextLCD or Textdisplay libs from Simon Ford.
For some reason, I cannot get the code to compile and get the following compiler output:
"Object of abstract class type "LCD16x2" is not allowed: (E322)" in file "/MyLCD/main.cpp"
"LCD16x2 LCD (p28); (E0)" in file "/MyLCD/main.cpp"
"^ (E0)" in file "/MyLCD/main.cpp"
I've already stripped down the code to the bare minimum but cannot pinpoint what the problem is. Can someone help me? Thanks in advance.
Here's my main.cpp
#include "mbed.h"
#include "LCD16x2.h"
LCD16x2 LCD (p28);
int main() {
int value=100;
while (1) {
LCD.printf("Testing : %i",value);
}
}
Here's the LCD16x2.h
#ifndef LCD16x2_H
#define LCD16x2_H
#include "mbed.h"
class LCD16x2:public Stream {
public:
LCD16x2(PinName rx);
int DoSomething(int number);
protected:
Serial _serial;
};
#endif
And the LCD16x2.cpp
#include "LCD16x2.h"
LCD16x2::LCD16x2(PinName rx):_serial(rx,NC) {
}
int LCD16x2::DoSomething(int number) {
number++;
return number;
}
Hi,
I'm trying to write a class for a 16x2 serial LCD display. One of the functions I'm trying to inherit is the printf function from the Stream class, similar to the TextLCD or Textdisplay libs from Simon Ford.
For some reason, I cannot get the code to compile and get the following compiler output:
"Object of abstract class type "LCD16x2" is not allowed: (E322)" in file "/MyLCD/main.cpp"
"LCD16x2 LCD (p28); (E0)" in file "/MyLCD/main.cpp"
"^ (E0)" in file "/MyLCD/main.cpp"
I've already stripped down the code to the bare minimum but cannot pinpoint what the problem is. Can someone help me? Thanks in advance.
Here's my main.cpp