Browse Source

Implementation of new functions for creating horizontal, vertical and cartesian graphs.

master
parent
commit
31f6565257
1 changed files with 36 additions and 20 deletions
  1. +36
    -20
      DisplayESP32.ino

+ 36
- 20
DisplayESP32.ino View File

@ -190,7 +190,7 @@ class Graph{ //ContentTypeMenu false, it is not a menu
double xmaximum; //For: Horizontal Bar Cartesian
double yStepSize; //For: Vertical Bar Cartesian
double xStepSize; //For: Horizontal Bar Cartesian
double digit; //For: Vertical Bar
double digit; //For: Vertical Bar Horizontal Bar Cartesian
double x;
double yrange;
double xrange;
@ -217,6 +217,8 @@ class Graph{ //ContentTypeMenu false, it is not a menu
this->yStepSize = yStepSize;
this->xStepSize = xStepSize;
this->digit = digit;
this->xpos = xpos;
this->ypos = ypos;
switch(graphType){
case 'a':
this->yrange = ymaximum - yminimum;
@ -432,12 +434,24 @@ class Screen{
this->menu[menuIndex].createOption(content, destinationTypeMenu, destinationIndex);
}
void createGraph(String title, char graphType, double xpos, double ypos, double width, double height,
double yminimum, double ymaximum, double xminimum, double xmaximum, double yStepSize, double xStepSize, double digit){
this->graph[counterG].configure(title, graphType, xpos, ypos, width, height, yminimum, ymaximum, xminimum, xmaximum, yStepSize, xStepSize, digit);
void createVGraph(String title, double xpos, double ypos, double width, double height,
double yminimum, double ymaximum, double yStepSize, double digit){
this->graph[counterG].configure(title, 'a', xpos, ypos, width, height, yminimum, ymaximum, 0, 0, yStepSize, 0, digit);
counterG++;
}
void createHGraph(String title, double xpos, double ypos, double width, double height,
double xminimum, double xmaximum, double xStepSize, double digit){
this->graph[counterG].configure(title, 'b', xpos, ypos, width, height, 0, 0, xminimum, xmaximum, 0, xStepSize, digit);
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, double digit){
this->graph[counterG].configure(title, 'c', xpos, ypos, width, height, yminimum, ymaximum, xminimum, xmaximum, yStepSize, xStepSize, digit);
counterG++;
}
void redrawFlag(){
this->redraw = true;
}
@ -468,19 +482,21 @@ class Screen{
}
void goTo(){
int newScreen = this->menu[this->currentScreen].extractDestinationIndex();
bool newContentTypeMenu = this->menu[this->currentScreen].extractDestinationTypeMenu();
if (contentTypeMenu){
this->menu[newScreen].setPreviousScreen(this->currentScreen);
this->menu[newScreen].setPreviousContentTypeMenu(this->contentTypeMenu);
}
else{
this->graph[newScreen].setPreviousScreen(this->currentScreen);
this->graph[newScreen].setPreviousContentTypeMenu(this->contentTypeMenu);
if(this->contentTypeMenu){
int newScreen = this->menu[this->currentScreen].extractDestinationIndex();
bool newContentTypeMenu = this->menu[this->currentScreen].extractDestinationTypeMenu();
if (newContentTypeMenu){
this->menu[newScreen].setPreviousScreen(this->currentScreen);
this->menu[newScreen].setPreviousContentTypeMenu(this->contentTypeMenu);
}
else{
this->graph[newScreen].setPreviousScreen(this->currentScreen);
this->graph[newScreen].setPreviousContentTypeMenu(this->contentTypeMenu);
}
this->contentTypeMenu = newContentTypeMenu;
this->currentScreen = newScreen;
this->redraw = true;
}
this->contentTypeMenu = newContentTypeMenu;
this->currentScreen = newScreen;
this->redraw = true;
}
void goBack(){
@ -502,14 +518,14 @@ Screen screen;
void setup(){
setDisp(true);
screen.createMenu(128, 9);
screen.createMenu(128, 13);
/*String title, char graphType, double xpos, double ypos, double width, double height,
double yminimum, double ymaximum, double xminimum, double xmaximum, double yStepSize, double xStepSize, double digit*/
screen.createGraph("Grafica 1", 'a', 25, 60, 40, 40, 0, 100, 0, 0, 10, 0, 0);
screen.createGraph("Grafica 2", 'b', 10, 60, 100, 20, 0, 0, 0, 100, 0, 10, 0);
screen.createGraph("Grafica 3", 'c', 30, 50, 75, 30, 0, 1024, 0, 10, 100, 10, 0);
screen.createVGraph("Grafica 1", 25, 60, 40, 40, 0, 100, 10, 0);
screen.createHGraph("Grafica 2", 10, 60, 100, 20, 0, 100, 10, 0);
screen.createCGraph("Grafica 3", 30, 50, 75, 30, 0, 1024, 0, 10, 100, 10, 0);
screen.createOption(0, "Grafica vertical", false, 0);
screen.createOption(0, "Grafica horizontal", false, 1);


Loading…
Cancel
Save