Browse Source

Code changed for future implementation of new screen type for changing system variables and parameters by user.

master
parent
commit
caae47348a
1 changed files with 61 additions and 49 deletions
  1. +61
    -49
      DisplayESP32.ino

+ 61
- 49
DisplayESP32.ino View File

@ -25,26 +25,26 @@ class Option{
int textSpacing; int textSpacing;
bool fill = false; bool fill = false;
bool disp = false; bool disp = false;
bool destinationTypeMenu;
int destinationType;
int destinationIndex; int destinationIndex;
public: public:
//Option(){} //Option(){}
void configure(String content, int sizex, int sizey, int pos, bool destinationTypeMenu, int destinationIndex){
void configure(String content, int sizex, int sizey, int pos, int destinationType, int destinationIndex){
this->sizex = sizex; this->sizex = sizex;
this->sizey = sizey; this->sizey = sizey;
this->content = content; this->content = content;
this->pos = pos; this->pos = pos;
this->destinationTypeMenu = destinationTypeMenu;
this->destinationType = destinationType;
this->destinationIndex = destinationIndex; this->destinationIndex = destinationIndex;
this->disp = true; this->disp = true;
this->textSpacing = ((sizey - 7)/2) + 7; this->textSpacing = ((sizey - 7)/2) + 7;
} }
bool getDestinationTypeMenu(){
bool destinationType = this->destinationTypeMenu;
int getDestinationType(){
int destinationType = this->destinationType;
return destinationType; return destinationType;
} }
@ -80,9 +80,10 @@ class Menu{ //ContentTypeMenu true, it is a menu
int pos = 0; //This indicates the position of the cursor int pos = 0; //This indicates the position of the cursor
int page = 0; //If the menu is too long, this indicates the page that is being displayed int page = 0; //If the menu is too long, this indicates the page that is being displayed
Option opt[MAX_OPTIONS]; Option opt[MAX_OPTIONS];
int previousScreen = 0;
int optPPage; int optPPage;
bool previousContentTypeMenu = true;
int previousScreen = 0;
int previousContentType = true;
public: public:
@ -96,9 +97,9 @@ class Menu{ //ContentTypeMenu true, it is a menu
this->opt[this->options].configure(content, this->sizex, this->sizey, this->options++, destinationTypeMenu, destinationIndex); this->opt[this->options].configure(content, this->sizex, this->sizey, this->options++, destinationTypeMenu, destinationIndex);
} }
bool extractDestinationTypeMenu(){
bool destinationTypeMenu = this->opt[this->pos].getDestinationTypeMenu();
return destinationTypeMenu;
int extractDestinationType(){
int destinationType = this->opt[this->pos].getDestinationType();
return destinationType;
} }
int extractDestinationIndex(){ int extractDestinationIndex(){
@ -127,8 +128,8 @@ class Menu{ //ContentTypeMenu true, it is a menu
this->previousScreen = prev; this->previousScreen = prev;
} }
void setPreviousContentTypeMenu(bool prev){
this->previousContentTypeMenu = prev;
void setPreviousContentType(int prev){
this->previousContentType = prev;
} }
int getPreviousScreen(){ int getPreviousScreen(){
@ -136,8 +137,8 @@ class Menu{ //ContentTypeMenu true, it is a menu
return prev; return prev;
} }
bool getPreviousContentTypeMenu(){
bool prev = this->previousContentTypeMenu;
int getPreviousContentType(){
int prev = this->previousContentType;
return prev; return prev;
} }
}; };
@ -172,7 +173,7 @@ class Graph{ //ContentTypeMenu false, it is not a menu
bool redraw = true; bool redraw = true;
int previousScreen = 0; int previousScreen = 0;
bool previousContentTypeMenu = true;
int previousContentType = 0;
public: public:
@ -362,8 +363,8 @@ class Graph{ //ContentTypeMenu false, it is not a menu
this->previousScreen = prev; this->previousScreen = prev;
} }
void setPreviousContentTypeMenu(bool prev){
this->previousContentTypeMenu = prev;
void setPreviousContentType(int prev){
this->previousContentType = prev;
} }
int getPreviousScreen(){ int getPreviousScreen(){
@ -371,8 +372,8 @@ class Graph{ //ContentTypeMenu false, it is not a menu
return prev; return prev;
} }
bool getPreviousContentTypeMenu(){
bool prev = this->previousContentTypeMenu;
int getPreviousContentType(){
int prev = this->previousContentType;
return prev; return prev;
} }
@ -394,9 +395,9 @@ class Screen{
Graph graph[MAX_GRAPH]; Graph graph[MAX_GRAPH];
int counterM = 0; int counterM = 0;
int counterG = 0; int counterG = 0;
int currentScreen = 0;
bool redraw = true; bool redraw = true;
bool contentTypeMenu = true;
int currentScreen = 0;
int contentType = 0;
public: public:
@ -469,10 +470,10 @@ class Screen{
void control(){ void control(){
if (redraw){ if (redraw){
if (contentTypeMenu){
if (contentType == 0){
menu[currentScreen].drawMenu(); menu[currentScreen].drawMenu();
} }
else{
else if (contentType == 1){
graph[currentScreen].drawGraph(); graph[currentScreen].drawGraph();
} }
this->redraw = false; this->redraw = false;
@ -488,37 +489,48 @@ class Screen{
} }
void goTo(){ void goTo(){
if(this->contentTypeMenu){
if(this->contentType == 0){
int newScreen = this->menu[this->currentScreen].extractDestinationIndex(); int newScreen = this->menu[this->currentScreen].extractDestinationIndex();
bool newContentTypeMenu = this->menu[this->currentScreen].extractDestinationTypeMenu();
if (newContentTypeMenu){
int newContentType = this->menu[this->currentScreen].extractDestinationType();
if (newContentType == 0){
this->menu[newScreen].setPreviousScreen(this->currentScreen); this->menu[newScreen].setPreviousScreen(this->currentScreen);
this->menu[newScreen].setPreviousContentTypeMenu(this->contentTypeMenu);
this->menu[newScreen].setPreviousContentType(this->contentType);
} }
else{
else if(newContentType == 1){
this->graph[newScreen].setPreviousScreen(this->currentScreen); this->graph[newScreen].setPreviousScreen(this->currentScreen);
this->graph[newScreen].setPreviousContentTypeMenu(this->contentTypeMenu);
this->graph[newScreen].setPreviousContentType(this->contentType);
this->graph[newScreen].reset(); this->graph[newScreen].reset();
this->graph[newScreen].redrawFlag(); this->graph[newScreen].redrawFlag();
} }
this->contentTypeMenu = newContentTypeMenu;
else if(newContentType == 2){
}
this->contentType = newContentType;
this->currentScreen = newScreen; this->currentScreen = newScreen;
this->redraw = true; this->redraw = true;
} }
} }
void goBack(){ void goBack(){
if (contentTypeMenu){
if(contentType == 0){
//Gets indexes from previous screen saved in actual screen if it is a menu, and sets them as the current indexes //Gets indexes from previous screen saved in actual screen if it is a menu, and sets them as the current indexes
this->currentScreen = this->menu[this->currentScreen].getPreviousScreen(); this->currentScreen = this->menu[this->currentScreen].getPreviousScreen();
this->contentTypeMenu = this->menu[this->currentScreen].getPreviousContentTypeMenu();
this->contentType = this->menu[this->currentScreen].getPreviousContentType();
} }
else{
else if(contentType == 1){
//Gets indexes from previous screen saved in actual screen if it is a graph, and sets them as the current indexes //Gets indexes from previous screen saved in actual screen if it is a graph, and sets them as the current indexes
this->currentScreen = this->graph[this->currentScreen].getPreviousScreen(); this->currentScreen = this->graph[this->currentScreen].getPreviousScreen();
this->contentTypeMenu = this->graph[this->currentScreen].getPreviousContentTypeMenu();
this->contentType = this->graph[this->currentScreen].getPreviousContentType();
} }
} }
void plusAction(){
}
void minusAction(){
}
}; };
@ -537,22 +549,22 @@ void setup(){
screen.createHGraph("Grafica 2", 10, 40, 100, 20, 0, 100, 10, 0); //Graph 1 screen.createHGraph("Grafica 2", 10, 40, 100, 20, 0, 100, 10, 0); //Graph 1
screen.createCGraph("Grafica 3", 30, 50, 75, 30, 0, 100, 0, 100, 25, 25, 0); //Graph 2 screen.createCGraph("Grafica 3", 30, 50, 75, 30, 0, 100, 0, 100, 25, 25, 0); //Graph 2
screen.createOption(0, "Vertical graph", false, 0);
//Creates the first option in Menu 0, directing to a graph (Menu Content = false), 0 (Graph 0)
screen.createOption(0, "Horizontal graph", false, 1);
screen.createOption(0, "Cartesian graph", false, 2);
screen.createOption(0, "Extra option", true, 1);
screen.createOption(1, "Test", false, 3);
screen.createOption(1, "Working?", false, 4);
// screen.increasePos();
// screen.increasePos();
// screen.goTo();
screen.createOption(0, "Vertical graph", 1, 0);
//Creates the first option in Menu 0, directing to a graph (contentType = 1 (Graph)), 0 (Graph 0)
screen.createOption(0, "Horizontal graph", 1, 1);
screen.createOption(0, "Cartesian graph", 1, 2);
screen.createOption(0, "Extra option", 0, 1);
screen.createOption(1, "Test", 1, 3);
screen.createOption(1, "Working?", 1, 4);
screen.increasePos();
screen.increasePos();
screen.goTo();
// screen.graphAssignValue(2, 50); // screen.graphAssignValue(2, 50);
// screen.goBack();
// screen.increasePos();
// screen.goTo();
screen.goBack();
screen.increasePos();
screen.goTo();
// screen.goBack(); // screen.goBack();
// screen.decreasePos(); // screen.decreasePos();
} }


Loading…
Cancel
Save