Hi All!
I'm relatively new to Arduino and C++. I'm working on creating a library for my LCD to perform some of the basic LCD functions. My plan was to use NewSoftSerial.h to do the actual communication on the back end. After some reading, I found that I can't directly include the NewSoftSerial.h file in my library, but I should instead include it in the sketch. Well, I tried that, and I still can't get the library to work. I get the following error
(path to libraries)\libraries\LCDSoftSerial\/LCDSoftSerial.h:17: error: 'NewSoftSerial' does not name a type
Any idea what's going on? I'm at the bare minimum of code right now
Sketch
#include <NewSoftSerial.h>
#include <LCDSoftSerial.h>
LCDSoftSerial.h
#ifndef LCD_H
#define LCD_H
class LCDSoftSerial{
public:
LCDSoftSerial(int, int);
void selectLineOne();
void selectLineTwo();
void goTo(int);
void clearLCD();
void backlightOn();
void backlightOff();
void serCommand();
void init(int txPin, int baud);
private:
NewSoftSerial test; // Errors here
};
#endif
LCDSoftSerial.cpp
#include "LCDSoftSerial.h"
void LCDSoftSerial::selectLineOne(){ //puts the cursor at line 0 char 0.
lcd.print(0xFE, BYTE); //command flag
lcd.print(128, BYTE); //position
}
void LCDSoftSerial::selectLineTwo(){ //puts the cursor at line 0 char 0.
lcd.print(0xFE, BYTE); //command flag
lcd.print(192, BYTE); //position
}
void LCDSoftSerial::goTo(int position) { //position = line 1: 0-15, line 2: 16-31, 31+ defaults back to 0
if (position<16){ lcd.print(0xFE, BYTE); //command flag
lcd.print((position+128), BYTE); //position
}else if (position<32){lcd.print(0xFE, BYTE); //command flag
lcd.print((position+48+128), BYTE); //position
} else { goTo(0); }
}
void LCDSoftSerial::clearLCD(){
lcd.print(0xFE, BYTE); //command flag
lcd.print(0x01, BYTE); //clear command.
}
void LCDSoftSerial::backlightOn(){ //turns on the backlight
lcd.print(0x7C, BYTE); //command flag for backlight stuff
lcd.print(157, BYTE); //light level.
}
void LCDSoftSerial::backlightOff(){ //turns off the backlight
lcd.print(0x7C, BYTE); //command flag for backlight stuff
lcd.print(128, BYTE); //light level for off.
}
void LCDSoftSerial::serCommand(){ //a general function to call the command flag for issuing all other commands
lcd.print(0xFE, BYTE);
}
/*
LCDSoftSerial::LCDSoftSerial(int txPin, int baud){
lcd = NewSoftSerial(0, txPin);
lcd.begin(baud);
}
*/