Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Creating a Subclass (Read 2223 times)
Aerouta
Junior Member
**
Offline


Posts: 16
Location: USA
Joined: Feb 16th, 2013
Creating a Subclass
Apr 8th, 2016 at 1:37pm
Print Post  
I am attempting to create the following subclass. 
Here is the .h file
Code
Select All
//#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 <Adafruit_GFX.h>
#include <avr/pgmspace.h>


class MiniConsole : public Adafruit_ILI9341 {

	public:
		//MiniConsole();
		MiniConsole(int8_t CS1);
		void miniScreenConsole(char *miniConData);

	private:

		int _pin;
};

//#endif // H_MINICON_
 



and here is the .cpp file
Code
Select All
#include <MiniConsole.h>
#include <Arduino.h>
#include <avr/pgmspace.h>
#include <TouchScreen.h>
#include <string.h>

MiniConsole::MiniConsole(int8_t cs1) : Adafruit_ILI9341(53, 77){
	_pin = cs1;
}


void MiniConsole::miniScreenConsole(char *miniConData) {
	Serial.println("testetst");
	drawRect(80, 140, 175, 90, ILI9341_BLUE);
	fillRect(80, 140, 175, 90, ILI9341_WHITE);
	setCursor(0, 142);
	setTextColor(ILI9341_BLUE);
	setTextSize(1);
	print("TEST test");

}
 




However ever when I call the function with the following lines, the program freezes. 
Code
Select All
MiniConsole mini = MiniConsole(1);
mini.miniScreenConsole("testData_");
 



I have a question with the constructor in the in .cpp file. I noticed that most of the time VM notices the contructor line and changes the color of the class. However in this instance the class "MiniConsole" is not the teal color but black. Does this mean I am doing something incorrectly? Is there anything you notice that is being done wrong. I am new the subclasses.
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.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Creating a Subclass
Reply #1 - Apr 8th, 2016 at 2:26pm
Print Post  
Hi,

I would ignore Visual studio colors when it comes to inherited classes. It's not always valid.

Does this article help?

http://playground.arduino.cc/Code/Hierarchy

  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint