Get the Instance of the object

03 May 2011

Hello

I have a question !

When you program in Java for exemple :

you can write this to create & use a object

TFT_4DGL name = new TFT_4DGL(p13,p14,P15);
 
name.baudrate(128000);
oneObject instance= new oneObject(name);

...

With Mbed we write that :

TFT_4DGL name(p13,p14,p15);

name.baudrate(128000);
oneObject instance= new oneObject(name);

But how get the instance of this object to manipulate into a other object ? When I write that :

TFT_4DGL _name;
..
Constructor(TFT_4DGL name){
_name = name;
_name.baudrate(128000);
}

The error is " TFT_4DGL " have no default constructor

When i write that :

TFT_4DGL * _name;
..
Constructor(TFT_4DGL * name){
_name = name;
_name.baudrate(128000);
}

The error is : "Expression must have class type (E153) "

You understand ???

Thanks

03 May 2011

example 1

// Create object
TFT_4DGL name(p13,p14,P15);

int main() {
    // Create pointer p to point to name
    TFT_4DGL *p = &name;
    // Use -> rather than . when using pointers.
    p->baudrate(128000);
}

example 2

// Pointer to object
TFT_4DGL *name;

int main() {
    name = new TFT_4DGL(p13,p14,p15);
    name->baudrate(128000);
}
03 May 2011

Ok thanks !

I have a second problem :

I have in my object a intance of TFT_4DGL name "ecran". When i call this method :

void Screens :: background_color(int couleur){
    ecran->background_color(couleur);
    }

They have no effect .

But if i call in the constructor the background got white .. Do you have an idea ?

PS : its the main :

#include "mbed.h"
// #include "TFT_4DGL.h"
// #include "Rectangle.h"
#include "Screens.h"

Screens *  ecran;
 
 int main() {
     ecran = new Screens(p13,p14,p15); // serial tx, serial rx, reset pin;
     char s[500];
     int x = 0, y = 0, status, xc = 0, yc = 0;
 
     ecran->background_color(0xFFFFFF); // No effect !!     ...
03 May 2011

Really need to see the bigger picture. Can you publish the program and provide a link here?

03 May 2011
03 May 2011

Is it wired up properly? Can you get it to do anything at all?