I'm struggling to learn Arduino's C++ right now. I'm trying to write a simple wrapper so I can use multiple OLED's on my project. Here is what I've got so far :
class Screen
{
private:
Adafruit_SSD1306 display;
unsigned long startTime = 0;
public :
Screen(){
Adafruit_SSD1306 this->display(128, 64, &Wire, -1);
}
void init(){
//Initialize the screen
this->display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
this->display.setTextSize(1);
this->display.setTextColor(SSD1306_WHITE);
this->display.clearDisplay();
this->output(60,30,":)");
this->display.display();
}
void output(int x, int y, String S){
this->display.setCursor(x, y);
this->display.print(S);
Display.display();
}
};
Screen screen();
void setup(){
screen.init();
}
void loop(){}
Errors are :
In file included from D:\project\escape\puzzle box\source\puzzle_box_v6\Puzzle_box_v6.ino:12:0:
sketch\Screen.h: In constructor 'Screen::Screen()':
Screen.h:12:25: error: expected unqualified-id before 'this'
Adafruit_SSD1306 this->display(128, 64, &Wire, -1);
^~~~
sketch\Screen.h: In member function 'void Screen::output(int, int, String)':
Screen.h:27:7: error: 'Display' was not declared in this scope
Display.display();
^~~~~~~
sketch\Screen.h:27:7: note: suggested alternative: 'display'
Display.display();
^~~~~~~
display
D:\project\escape\puzzle box\source\puzzle_box_v6\Puzzle_box_v6.ino: In function 'void setup()':
Puzzle_box_v6:40:9: error: expected unqualified-id before '.' token
Screen.init();
^
exit status 1
expected unqualified-id before 'this'
I would appreciate any and all advice. Perhaps my entire approach is wrong. If not, specifically could I get an explanation on how to generate an object and assign it to a property of another class.
Lastly, if anyone is still reading...I don't what parameter data type I need to declare to pass in the memory location value for init(). Currently it is "0x36" hardcoded, I want to pass it in via parameter. If anyone could advise on this matter I would appreciate it as well.