All,

I have a neat graphing function that plots stuff like temperatures or voltages over time. The problem is a big ugly function and is hard to update to draw say 2 variables. I can re-code it for 2 variables, but maybe I want more. Ultimately I would like a library to make plotting data easier. I've made my function available (shown in a YouTube vid) and I'd like to make this lib publicly available as well. Maybe something such as:

create a MyGraph object (pass in display)
create Plot1 object (pass in graph object)
create Plot2 object (pass in graph object)

then in setup ()
MyGraph.draw() // draws graph, scale, title on the display

then in loop()
Getdata()
Plot1.draw(temperature)
Plot2.draw(humidity)


Here's the start of my class but complier errors out when I try to pass the graph object into the plot objects.

How do I pass the graph object to other objects? so the plot objects writes lines and such to the graph object?

.h
Code:
#ifndef GRAPH_H
#define GRAPH_H

#if ARDUINO >= 100
 #include "Arduino.h"
 #include "Print.h"
#else
 #include "WProgram.h"
#endif

#include <ILI9341_t3.h>   

class Graph {

 public:
	Graph(ILI9341_t3 *disp);		
	void init(float scaleLow = 100.0, float scaleHi = 100.0, float scale = 0.0, float snap = 0.0);		
	void draw();
     
private:
	ILI9341_t3 *_d;	
	float _sl;
	float _sh;
	float _sc;
	float _sn;
	uint16_t _sColor;		
	uint16_t _bColor;		
	uint16_t _hColor;			
  };




class Plot {

public:

///////////////////////////////////////////////////////////// 

// here's where it fails to compile but I don't know how to pass an object to an object
	Plot(Graph *g);		
	void draw(float x, float y);	
	
private:
	Graph *_g;	
	float _x;
	float _y;
};

#endif

.cpp
Code:
#include "Graph.h"
#include <ILI9341_t3.h>     // fast display driver lib

Graph::Graph(ILI9341_t3 *disp) {
		_d = disp;				
	}

void Graph::init(float scaleLow, float scaleHi, float scale, float snap) {
   	_sl = scaleLow;
	_sh = scaleHi;
	_sc = scale;
	_sn = snap;
	}

void Graph::draw() {
	_d->fillScreen(0x255);
	//draw grid, scales, etc.
}






void Plot::Plot(Graph *g) {
	_g = g;
}

void Plot::draw(float x, float y) {
	_x = x;
	_y = y;
	// _g->drawLine(_x, _y, x + 10, _y + 10);
}

possible .ino code implementation

Code:
#include <ILI9341_t3.h>   // fast display driver lib
#include "UTouch.h"       // touchscreen lib
#include <Graph.h>        // custom control define file

// create display and DS objects
ILI9341_t3 Display = ILI9341_t3(10, 9, 240, 320);

// create the touch screen object
UTouch  Touch( 6, 5, 4, 3, 2);

// create the graph object
Graph TheGraph(&Display);

// create plot objects to be drawn on TheGraph (need to be flexible so n plots can be drawn
Plot Temp(&TheGraph);
Plot Humidity(&TheGraph);
Plot Pressure(&TheGraph);

void setup() {

  Serial.begin(9600);

  Display.begin();

  // fire up the touch display
  Touch.InitTouch(PORTRAIT);
  Touch.setPrecision(PREC_EXTREME);
  
  TheGraph.init(); // function or functions to draw the cartesian coordinate system (omitted are arguments for the scales colors, etc)
 
}


void loop() {

// get temp
Temp.draw(TheTemperature);

// get Humidity
Temp.draw(TheHumidity);

// get pressure
Temp.draw(ThePressure);
 
}