After AlphaBeta's hint the compiler changed his errors. It had something to complain about
error: call of overloaded 'write(byte*&)' is ambiguous
After some fiddling i've changed write(byte *pData);
in the .h and .cpp files to write(byte pData);
and the errors disappeared. That went well i thought so i've made
void begin(long BaudRate);
boolean available(void);
int read(void);
in the .h and .cpp files. Still no error from the compiler but now the display won't initialize.
The files are now like this; .h
#include "WProgram.h"
#ifndef newoled_h
#define newoled_h
class uOLED
{
public:
uOLED (int pin, long baud, HardwareSerial *serialToUse);
//internal variables
int PinReset; //Pin that send Reset signal
long BRate; //serial Baud Rate
char res; //Result for every command
// Basic control for uOLED
void StartUp(void);
void Cls(void);
// Basic Graphics
void Line(char x1, char y1, char x2, char y2, unsigned int color);
private:
HardwareSerial *pSerial;
void write(byte pData);
void begin(long BaudRate);
boolean available(void);
int read(void);
char RBack(void);
};
#endif
.cpp
#include "newoled.h"
#include "WProgram.h"
//CONSTRUCTOR
uOLED::uOLED(int pin, long baud, HardwareSerial *serialToUse)
{
// save the port in the class.
pSerial = serialToUse;
PinReset=pin;
pinMode(PinReset, OUTPUT);
BRate = baud;
}
void uOLED::write(byte pData)
{
pSerial->write(pData);
}
void uOLED::begin(long BaudRate)
{
pSerial->begin(BaudRate);
}
boolean uOLED::available()
{
pSerial->available();
}
int uOLED::read()
{
pSerial->read();
}
//Make a Reset for uOLED and Clear Screen
void uOLED::StartUp()
{
//Reset display
digitalWrite(PinReset,LOW);
delay(20);
digitalWrite(PinReset,HIGH);
delay(7000); // If you want to see the startup animation change this to something well above 5000
begin(BRate);
//Send 0x55 to stablish baud rate for serial communication
write(0x55);
res=RBack();
Cls();
}
//Obtain result for every command that send Arduino to uOLED
char uOLED::RBack()
{
// Wait for serial data
while (!available())
{
// do nothing
}
return read();
}
//Erase Screen
void uOLED::Cls()
{
write(0x45);
res=RBack();
}
//Draw a line
void uOLED::Line(char x1, char y1, char x2, char y2, unsigned int color)
{
write(0x4C);
write(x1);
write(y1);
write(x2);
write(y2);
write(color >> 8);
write(color & 0xFF);
res=RBack();
}
and the sketch
#include "newoled.h"
uOLED uoled(8, 256000, &Serial1); // create an instance of the uOLED class with the reset line connected to pin 8 and a serial speed of 256000
void setup() {
uoled.StartUp(); // reset and initialize the display
uoled.Cls(); // clears the screen of everything on it. It uses the background color
uoled.Line(0, 0, 100, 100, 65000);
}
void loop() {
}
Jeroen