I'm having a problem with pointers. I'm trying to create a custom Touch Keyboard library, using MCUFRIEND_kbv TFT library. When I try to pass the pointer of the TFT instance (found in main.cpp as tft variable) to the drawKeys function of the Keyboard library (call in loop() of main.cpp as kb.drawKeys(&tft)) i get an error
.pio\build\esp32doit-devkit-v1\src\main.cpp.o:(.literal._Z4loopv 0x4): undefined reference to `Keyboard::drawKeys(MCUFRIEND_kbv*)'
.pio\build\esp32doit-devkit-v1\src\main.cpp.o: In function `loop()':
Filepath/src/main.cpp:140: undefined reference to `Keyboard::drawKeys(MCUFRIEND_kbv*)'
"main.cpp" file
//INCLUDES
#include <SPI.h>
#include "Adafruit_GFX.h"
#include <MCUFRIEND_kbv.h>
#include <Wire.h>
#include "Fonts/FreeSerif24pt7b.h"
#include <SD.h>
#include "Keyboard.h"
//TFT
MCUFRIEND_kbv tft;
//KeyBoard & Buttons configuration
#define XELEMENTS 13
#define YELEMENTS 3
#define BUTTONMARGINS 1
#define SIDEPADDING 6
int _width = round(tft.width()/XELEMENTS)-(2*BUTTONMARGINS);
int _height = _width;
Keyboard kb(_height, _width, YELEMENTS, XELEMENTS, BUTTONMARGINS, SIDEPADDING);
bool sd_init = false;
void setup()
{
Serial.begin(250000);
Serial.println(F("TFT LCD test"));
pinMode(27, INPUT);
pinMode(22, OUTPUT);
Serial.print("TFT size is ");
Serial.print(tft.width());
Serial.print("x");
Serial.println(tft.height());
tft.reset();
Serial.print("ID: ");
Serial.println(tft.readID(), HEX);
uint16_t identifier = 0x9486;
tft.begin(identifier);
tft.fillScreen(TFT_BLACK);
tft.setRotation(3);
if (SD.begin(5))
{
sd_init = true;
}
tft.fillRect(0, 0, 480, 320, TFT_BLACK);
}
void loop(void)
{
while(1)
{
//tft.setFont(&FreeSerif24pt7b);
tft.fillRect(0,50,480,100, TFT_BLACK);
kb.drawKeys(&tft);
delay(2000);
}
}
"Keyboard.h" file
#ifndef _KEYBOARD_H
#define _KEYBOARD_H
#include "Adafruit_GFX.h"
#include <MCUFRIEND_kbv.h>
class Keyboard {
private:
public:
Keyboard(short _h, short _w, short _yel, short _xel, short _bmargins, short _sidepad);
void drawKeys(MCUFRIEND_kbv* _tft);
};
#endif
"Keyboard.cpp" file
#include "Keyboard.h"
#include "MCUFRIEND_kbv.h"
#include "Adafruit_GFX.h"
short xEl = 0, yEl = 0, bMargins = 0, sidePadding = 0, width = 0, height = 0;
unsigned short bBorder = 0, bBackground = 0, bTextColor = 0;
const char Mobile_KB[3][13] PROGMEM = {
{0, 13, 10, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'},
{2, 11, 9, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L'},
{2, 11, 7, 'Z', 'X', 'C', 'V', 'B', 'N', 'M'},
};
const char Mobile_NumKeys[3][13] PROGMEM = {
{0, 13, 10, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'},
{2, 11, 9, '-', '/', ':', ';', '(', ')', '&', '@', '"'},
{2, 11, 7, '.', ',', '?', '!', '\'', '`', '$'}
};
const char Mobile_SymKeys[3][13] PROGMEM = {
{0, 13, 10, '[', ']', '{', '}', '#', '%', '^', '*', ' ', '='},
{2, 11, 9, '_', '\\', '|', '~', '<', '>', '$', '"', '&'}, //4
{2, 11, 7, '.', ',', '?', '!', '\'', '`', '@'}
};
Keyboard::Keyboard(short _h, short _w, short _yel, short _xel, short _bmargins, short _sidepad)
{
height = _h;
width = _w;
yEl = _yel;
xEl = _xel;
bMargins = _bmargins;
sidePadding = _sidepad;
}
void drawKeys(MCUFRIEND_kbv &_tft)
{
int yoffset = height - (height * yEl);
for (int i = 0; i < yEl; i )
{
for (int x = 0; x < xEl; x )
{
_tft.fillRoundRect(((width*x) bMargins sidePadding),(((height*i) yoffset) bMargins), width-(2*bMargins), height-(2*bMargins), 8, TFT_DARKCYAN);
_tft.drawRoundRect(((width*x) bMargins sidePadding),(((height*i) yoffset) bMargins), width-(2*bMargins), height-(2*bMargins), 8, TFT_CYAN);
}
}
}
I'm unable to compile, and unable to find the problem