I am working on a touchscreen interface, my idea is a ScreenManager that manages the state of the touchscreen, IE: shows Menu / Interface / Submenus by using a list of screens, with that said, i am a C# guy so attempting to convert my c# ideas to c++ is a challenge, currently i am working on the base classes to set up what i want, and i am unable to pass my tft object to my class, i mean the code works, but the output to the touchscreen does not, i know my code my be horrid to you guys, and probably make your eyes bleed, and i am sure there are 100 different and better ways to do this, but i was hoping one of you might be able to point out whats wrong with this code .
In my main ino i create my tft with Elegoo hardware
Elegoo_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
Then i want to pass this to my screen class
Screen(uint8_t orientation, uint16_t backGroundColor, Elegoo_TFTLCD *tft);
i have tried &tft and just tft i cant assign it, so am forced to use a pointer, here is what my cpp looks like
#include "Screen.h"
Elegoo_TFTLCD *_tft;
Screen::Screen(uint8_t orientation, uint16_t backGroundColor, Elegoo_TFTLCD tft)
{
_orientation = orientation;
_backGroundColor = backGroundColor;
_tft = tft;
_mapper->SetOrientation(_orientation);
}
void Screen::addButton(Elegoo_GFX_Button button)
{
_screenButtons.add(button);
}
void Screen::addButton(int16_t x, int16_t y, uint8_t buttonWidth, uint8_t buttonHeight, uint16_t buttonBorderColor, uint16_t buttonColor, uint16_t textColor, char* label, uint8_t textSize)
{
// Check we are within bounds
// if (x > BUTTON_RIGHT | x < BUTTON_LEFT)
// return;
// if (y > BUTTON_BOTTOM | y < BUTTON_TOP)
// return;
Elegoo_GFX_Button *button;
button->initButton(_tft, x, y, buttonWidth, buttonHeight, buttonBorderColor, buttonColor, textColor, label, textSize);
_screenButtons.add(button);
}
void Screen::draw()
{
// clear screen
_tft->reset();
//if (_identifier != -1)
_tft->begin(_identifier);
_tft->setRotation(_orientation);
_tft->fillScreen(_backGroundColor);
// Go through our buttons and draw them
for(int i =0;i<_screenButtons.size();i++)
{
Elegoo_GFX_Button *button = _screenButtons.get(i);
button->drawButton();
}
}
void Screen::setHardwareIdentifier(uint16_t id = 0x9341)
{
_identifier = id;
}
Using a pointer i compile but no output hits the screen