I would like to make the functions in the adafruit library available to other libraries in a project. I would like for other libraries to be able to write to the LCD directly. In order to do this I am attempting to subclass the Adafruit libary.
I am following the example shown here
https://www.cs.bu.edu/teaching/cpp/inheritance/intro/
here is sample of what I am attempting
.h file
//#ifndef H_MINICON_
//#define H_MINICON_
#include <Arduino.h> //needed for Serial.println
#include <string.h> //needed for memcpy
#include <Adafruit_ILI9341.h> // Hardware-specific library
#include "Arduino.h"
#include "Print.h"
//#include "WProgram.h"
#include <Adafruit_GFX.h>
#include <avr/pgmspace.h>
//#define TFT_CS 53
//#define TFT_DC 77
class MiniConsole : public Adafruit_ILI9341 {
public:
MiniConsole(int8_t CS1);
void miniScreenConsole(char *miniConData);
private:
int _pin;
};
here is the .cpp file
#include <MiniConsole.h>
#include <Arduino.h>
#include <avr/pgmspace.h>
#include <TouchScreen.h>
#include <string.h>
//#include <Adafruit_GFX.h> // Core graphics library
//#include <Adafruit_ILI9341.h> // Hardware-specific library
//#include <Adafruit_STMPE610.h> // touch screen library
MiniConsole::MiniConsole(int8_t cs1) : Adafruit_ILI9341(53, 77){
_pin = cs1;
};
void MiniConsole::miniScreenConsole(char *miniConData) {
Serial.println("testetst");
Adafruit_ILI9341::drawRect(80, 140, 175, 90, ILI9341_BLUE);
Adafruit_ILI9341::fillRect(80, 140, 175, 90, ILI9341_WHITE);
Adafruit_ILI9341::setCursor(0, 142);
Adafruit_ILI9341::setTextColor(ILI9341_BLUE);
Adafruit_ILI9341::setTextSize(1);
Adafruit_ILI9341::print("TEST test");
}
Program complies however, once I call “miniScreenConsole” the program freezes after “Serial.println(“testetst”);” Not sure what is incorrect here.
Also if there is a more straight forward way to make the functions in the Adafruit library available/accessible to other libraries please let me know.
Thanks