|
@ -104,9 +104,9 @@ class Menu{ //ContentType (0) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//The following method is used to created an option for the menu
|
|
|
//The following method is used to created an option for the menu
|
|
|
void createOption(String content, bool destinationTypeMenu, int destinationIndex){ |
|
|
|
|
|
|
|
|
void createOption(String content, int destinationType, int destinationIndex){ |
|
|
//The option takes the place in the array defined by the options number variable (options), which is later increased.
|
|
|
//The option takes the place in the array defined by the options number variable (options), which is later increased.
|
|
|
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++, destinationType, destinationIndex); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int extractDestinationType(){ |
|
|
int extractDestinationType(){ |
|
@ -426,7 +426,8 @@ class Modifier{ //ContentType (2) |
|
|
|
|
|
|
|
|
public: |
|
|
public: |
|
|
|
|
|
|
|
|
void configure(String title, int *value, int max, int min, int interval){ |
|
|
|
|
|
|
|
|
void configure(String title, int *value, int max, int min, int step){ |
|
|
|
|
|
this->title = title; |
|
|
this->value = value; |
|
|
this->value = value; |
|
|
this->max = max; |
|
|
this->max = max; |
|
|
this->min = min; |
|
|
this->min = min; |
|
@ -436,26 +437,30 @@ class Modifier{ //ContentType (2) |
|
|
void drawModifier(){ |
|
|
void drawModifier(){ |
|
|
display.clearDisplay(); |
|
|
display.clearDisplay(); |
|
|
display.fillRect(0, 0, 127 , 16, SSD1306_WHITE); |
|
|
display.fillRect(0, 0, 127 , 16, SSD1306_WHITE); |
|
|
display.setTextColor(SSD1306_BLACK); |
|
|
|
|
|
|
|
|
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); |
|
|
display.setTextSize(1); |
|
|
display.setTextSize(1); |
|
|
display.setCursor(2, 4); |
|
|
display.setCursor(2, 4); |
|
|
display.println(this->title); |
|
|
display.println(this->title); |
|
|
|
|
|
|
|
|
display.setTextColor(SSD1306_WHITE); |
|
|
display.setTextColor(SSD1306_WHITE); |
|
|
display.setTextSize(3); |
|
|
display.setTextSize(3); |
|
|
display.setCursor(2, ((DISP_HEIGHT - 16 - 20)/2) + 20); |
|
|
|
|
|
|
|
|
display.setCursor(2, ((DISP_HEIGHT - 16 - 15)/2) + 16); |
|
|
display.println(*this->value); |
|
|
display.println(*this->value); |
|
|
|
|
|
|
|
|
|
|
|
display.display(); |
|
|
|
|
|
|
|
|
|
|
|
display.setTextSize(1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void increaseValue(){ |
|
|
void increaseValue(){ |
|
|
if((*this->value + step) <= this->max){ |
|
|
|
|
|
*this->value += step; |
|
|
|
|
|
|
|
|
if((*this->value + this->step) <= this->max){ |
|
|
|
|
|
*this->value += this->step; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void decreaseValue(){ |
|
|
void decreaseValue(){ |
|
|
if((*this->value - step) >= this->min){ |
|
|
|
|
|
*this->value -= step; |
|
|
|
|
|
|
|
|
if((*this->value - this->step) >= this->min){ |
|
|
|
|
|
*this->value -= this->step; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -529,8 +534,8 @@ class Screen{ |
|
|
this->counterM++; |
|
|
this->counterM++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void createOption(int menuIndex, String content, bool destinationTypeMenu, int destinationIndex){ //this method should be used for creating an option in a menu
|
|
|
|
|
|
this->menu[menuIndex].createOption(content, destinationTypeMenu, destinationIndex); |
|
|
|
|
|
|
|
|
void createOption(int menuIndex, String content, int destinationType, int destinationIndex){ //this method should be used for creating an option in a menu
|
|
|
|
|
|
this->menu[menuIndex].createOption(content, destinationType, destinationIndex); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void createVGraph(String title, double xpos, double ypos, double width, double height, |
|
|
void createVGraph(String title, double xpos, double ypos, double width, double height, |
|
@ -551,8 +556,8 @@ class Screen{ |
|
|
counterG++; |
|
|
counterG++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void createModifier(String title, int *value, int max, int min, int interval){ //This method is used for the creation of a menu
|
|
|
|
|
|
this->modifier[counterMod].configure(title, value, max, min, interval); |
|
|
|
|
|
|
|
|
void createModifier(String title, int *value, int max, int min, int step){ //This method is used for the creation of a menu
|
|
|
|
|
|
this->modifier[counterMod].configure(title, value, max, min, step); |
|
|
this->counterMod++; |
|
|
this->counterMod++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -578,6 +583,9 @@ class Screen{ |
|
|
else if (contentType == 1){ |
|
|
else if (contentType == 1){ |
|
|
graph[currentScreen].drawGraph(); |
|
|
graph[currentScreen].drawGraph(); |
|
|
} |
|
|
} |
|
|
|
|
|
else if (contentType == 2){ |
|
|
|
|
|
modifier[currentScreen].drawModifier(); |
|
|
|
|
|
} |
|
|
this->redraw = false; |
|
|
this->redraw = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -609,7 +617,8 @@ class Screen{ |
|
|
this->graph[newScreen].redrawFlag(); |
|
|
this->graph[newScreen].redrawFlag(); |
|
|
} |
|
|
} |
|
|
else if(newContentType == 2){ |
|
|
else if(newContentType == 2){ |
|
|
|
|
|
|
|
|
|
|
|
this->modifier[newScreen].setPreviousScreen(this->currentScreen); |
|
|
|
|
|
this->modifier[newScreen].setPreviousContentType(this->contentType); |
|
|
} |
|
|
} |
|
|
this->contentType = newContentType; |
|
|
this->contentType = newContentType; |
|
|
this->currentScreen = newScreen; |
|
|
this->currentScreen = newScreen; |
|
@ -628,6 +637,10 @@ class Screen{ |
|
|
this->currentScreen = this->graph[this->currentScreen].getPreviousScreen(); |
|
|
this->currentScreen = this->graph[this->currentScreen].getPreviousScreen(); |
|
|
this->contentType = this->graph[this->currentScreen].getPreviousContentType(); |
|
|
this->contentType = this->graph[this->currentScreen].getPreviousContentType(); |
|
|
} |
|
|
} |
|
|
|
|
|
else if(contentType == 2){ |
|
|
|
|
|
this->currentScreen = this->modifier[this->currentScreen].getPreviousScreen(); |
|
|
|
|
|
this->contentType = this->modifier[this->currentScreen].getPreviousContentType(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//These methods control the plus and minus button actions
|
|
|
//These methods control the plus and minus button actions
|
|
@ -635,12 +648,18 @@ class Screen{ |
|
|
if(contentType == 0){ |
|
|
if(contentType == 0){ |
|
|
increasePos(); |
|
|
increasePos(); |
|
|
} |
|
|
} |
|
|
|
|
|
else if(contentType == 2){ |
|
|
|
|
|
this->modifier[currentScreen].increaseValue(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void minusAction(){ |
|
|
void minusAction(){ |
|
|
if(contentType == 0){ |
|
|
if(contentType == 0){ |
|
|
decreasePos(); |
|
|
decreasePos(); |
|
|
} |
|
|
} |
|
|
|
|
|
else if(contentType == 2){ |
|
|
|
|
|
this->modifier[currentScreen].decreaseValue(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
@ -729,6 +748,7 @@ class Keyboard{ |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
int i = 0; |
|
|
int i = 0; |
|
|
|
|
|
int multiplier = 1; |
|
|
|
|
|
|
|
|
Screen screen; |
|
|
Screen screen; |
|
|
Keyboard keyboard(13, 12, 14, 27, 30, &screen); |
|
|
Keyboard keyboard(13, 12, 14, 27, 30, &screen); |
|
@ -745,6 +765,8 @@ void setup(){ |
|
|
screen.createVGraph("Grafica 1", 25, 60, 40, 40, 0, 100, 10, 0); //Graph 0
|
|
|
screen.createVGraph("Grafica 1", 25, 60, 40, 40, 0, 100, 10, 0); //Graph 0
|
|
|
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, 1000, 25, 250, 0); //Graph 2
|
|
|
screen.createCGraph("Grafica 3", 30, 50, 75, 30, 0, 100, 0, 1000, 25, 250, 0); //Graph 2
|
|
|
|
|
|
|
|
|
|
|
|
screen.createModifier("Modify variable", &multiplier, 5, 1, 1); |
|
|
|
|
|
|
|
|
screen.createOption(0, "Vertical graph", 1, 0); |
|
|
screen.createOption(0, "Vertical graph", 1, 0); |
|
|
//Creates the first option in Menu 0, directing to a graph (contentType = 1 (Graph)), 0 (Graph 0)
|
|
|
//Creates the first option in Menu 0, directing to a graph (contentType = 1 (Graph)), 0 (Graph 0)
|
|
@ -753,7 +775,8 @@ void setup(){ |
|
|
screen.createOption(0, "Extra option", 0, 1); |
|
|
screen.createOption(0, "Extra option", 0, 1); |
|
|
|
|
|
|
|
|
screen.createOption(1, "Test", 1, 3); |
|
|
screen.createOption(1, "Test", 1, 3); |
|
|
screen.createOption(1, "Working?", 1, 4); |
|
|
|
|
|
|
|
|
screen.createOption(1, "Working?", 2, 2); |
|
|
|
|
|
screen.createOption(1, "Modify variable", 2, 0); |
|
|
|
|
|
|
|
|
// screen.increasePos();
|
|
|
// screen.increasePos();
|
|
|
// screen.increasePos();
|
|
|
// screen.increasePos();
|
|
@ -773,7 +796,7 @@ void loop(){ |
|
|
if(i <= 100){ |
|
|
if(i <= 100){ |
|
|
screen.graphAssignValue(1, i); //Assigning a demo value to Graph 1
|
|
|
screen.graphAssignValue(1, i); //Assigning a demo value to Graph 1
|
|
|
screen.graphAssignValue(2, i); //Assigning a demo value to Graph 2
|
|
|
screen.graphAssignValue(2, i); //Assigning a demo value to Graph 2
|
|
|
i++; |
|
|
|
|
|
|
|
|
i += multiplier; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
i = 0; |
|
|
i = 0; |
|
|