Browse Source

Cartesian chart modified to support x axis modifications according to the value

of a variable, so now the number of samples can be modified.
master
parent
commit
355fc4ee74
2 changed files with 10 additions and 8 deletions
  1. +6
    -4
      resources/Graph.h
  2. +4
    -4
      resources/Screen.h

+ 6
- 4
resources/Graph.h View File

@ -17,7 +17,8 @@ class Graph{ //ContentType (1)
double xmaximum; //For: Horizontal Bar Cartesian double xmaximum; //For: Horizontal Bar Cartesian
double yStepSize; //For: Vertical Bar Cartesian double yStepSize; //For: Vertical Bar Cartesian
double xStepSize; //For: Horizontal Bar Cartesian double xStepSize; //For: Horizontal Bar Cartesian
int digit; //For: Vertical Bar Horizontal Bar Cartesian
int digit; //For: Vertical Bar Horizontal Bar Cartesian
int * maximum;
double x; double x;
double yrange; double yrange;
double xrange; double xrange;
@ -34,7 +35,7 @@ class Graph{ //ContentType (1)
//This method configures the graph created, defines its parameters according the type of graph selected. //This method configures the graph created, defines its parameters according the type of graph selected.
void configure(String title, char graphType, double xpos, double ypos, double width, double height, void configure(String title, char graphType, double xpos, double ypos, double width, double height,
double yminimum, double ymaximum, double xminimum, double xmaximum, double yStepSize, double xStepSize, int digit){
double yminimum, double ymaximum, double xminimum, double xmaximum, double yStepSize, double xStepSize, int digit, void *maximum){
this->title = title; this->title = title;
this->graphType = graphType; this->graphType = graphType;
this->yminimum = yminimum; this->yminimum = yminimum;
@ -49,6 +50,7 @@ class Graph{ //ContentType (1)
this->digit = digit; this->digit = digit;
this->xpos = xpos; this->xpos = xpos;
this->ypos = ypos; this->ypos = ypos;
this->maximum = (int *) maximum;
switch(graphType){ switch(graphType){
case 'a': case 'a':
this->yrange = ymaximum - yminimum; this->yrange = ymaximum - yminimum;
@ -62,7 +64,6 @@ class Graph{ //ContentType (1)
case 'c': case 'c':
this->yrange = ymaximum - yminimum; this->yrange = ymaximum - yminimum;
this->xrange = xmaximum - xminimum;
break; break;
} }
} }
@ -149,6 +150,7 @@ class Graph{ //ContentType (1)
if (this->redraw == true) { if (this->redraw == true) {
this->redraw = false; this->redraw = false;
this->xrange = *this->maximum - xminimum;
display.clearDisplay(); display.clearDisplay();
display.fillRect(0, 0, 127 , 16, SSD1306_WHITE); display.fillRect(0, 0, 127 , 16, SSD1306_WHITE);
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
@ -174,7 +176,7 @@ class Graph{ //ContentType (1)
display.println(i, this->digit); display.println(i, this->digit);
} }
// draw x scale // draw x scale
for (i = this->xminimum; i <= this->xmaximum; i += this->xStepSize) {
for (i = this->xminimum; i <= *this->maximum; i += this->xStepSize) {
// compute the transform // compute the transform
display.setTextSize(1); display.setTextSize(1);
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK); display.setTextColor(SSD1306_WHITE, SSD1306_BLACK);


+ 4
- 4
resources/Screen.h View File

@ -55,19 +55,19 @@ class Screen{
void createVGraph(String title, double xpos, double ypos, double width, double height, void createVGraph(String title, double xpos, double ypos, double width, double height,
double yminimum, double ymaximum, double yStepSize, int digit){ //this method calls the configure() of graph for a vertical graph double yminimum, double ymaximum, double yStepSize, int digit){ //this method calls the configure() of graph for a vertical graph
this->graph[counterG].configure(title, 'a', xpos, ypos, width, height, yminimum, ymaximum, 0, 0, yStepSize, 0, digit);
this->graph[counterG].configure(title, 'a', xpos, ypos, width, height, yminimum, ymaximum, 0, 0, yStepSize, 0, digit, 0);
this->counterG++; this->counterG++;
} }
void createHGraph(String title, double xpos, double ypos, double width, double height, void createHGraph(String title, double xpos, double ypos, double width, double height,
double xminimum, double xmaximum, double xStepSize, int digit){ //this method calls the configure() of graph for a horizontal graph double xminimum, double xmaximum, double xStepSize, int digit){ //this method calls the configure() of graph for a horizontal graph
this->graph[counterG].configure(title, 'b', xpos, ypos, width, height, 0, 0, xminimum, xmaximum, 0, xStepSize, digit);
this->graph[counterG].configure(title, 'b', xpos, ypos, width, height, 0, 0, xminimum, xmaximum, 0, xStepSize, digit, 0);
counterG++; counterG++;
} }
void createCGraph(String title, double xpos, double ypos, double width, double height, void createCGraph(String title, double xpos, double ypos, double width, double height,
double yminimum, double ymaximum, double xminimum, double xmaximum, double yStepSize, double xStepSize, int digit){ //this method calls the configure() of graph for a cartesian chart
this->graph[counterG].configure(title, 'c', xpos, ypos, width, height, yminimum, ymaximum, xminimum, xmaximum, yStepSize, xStepSize, digit);
double yminimum, double ymaximum, double xminimum, double yStepSize, double xStepSize, int digit, void * maximum){ //this method calls the configure() of graph for a cartesian chart
this->graph[counterG].configure(title, 'c', xpos, ypos, width, height, yminimum, ymaximum, xminimum, 0, yStepSize, xStepSize, digit, maximum);
counterG++; counterG++;
} }


Loading…
Cancel
Save