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 yStepSize; //For: Vertical 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 yrange;
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.
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->graphType = graphType;
this->yminimum = yminimum;
@ -49,6 +50,7 @@ class Graph{ //ContentType (1)
this->digit = digit;
this->xpos = xpos;
this->ypos = ypos;
this->maximum = (int *) maximum;
switch(graphType){
case 'a':
this->yrange = ymaximum - yminimum;
@ -62,7 +64,6 @@ class Graph{ //ContentType (1)
case 'c':
this->yrange = ymaximum - yminimum;
this->xrange = xmaximum - xminimum;
break;
}
}
@ -149,6 +150,7 @@ class Graph{ //ContentType (1)
if (this->redraw == true) {
this->redraw = false;
this->xrange = *this->maximum - xminimum;
display.clearDisplay();
display.fillRect(0, 0, 127 , 16, SSD1306_WHITE);
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
@ -174,7 +176,7 @@ class Graph{ //ContentType (1)
display.println(i, this->digit);
}
// 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
display.setTextSize(1);
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,
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++;
}
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
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++;
}
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++;
}


Loading…
Cancel
Save