| 
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -4,6 +4,13 @@ | 
															
														
														
													
														
															
																 | 
																 | 
																#include <Adafruit_SSD1306.h>
 | 
																 | 
																 | 
																#include <Adafruit_SSD1306.h>
 | 
															
														
														
													
														
															
																 | 
																 | 
																#define __DEBUG__
 | 
																 | 
																 | 
																#define __DEBUG__
 | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																//The following constants are used to configure the behaviour of the interface
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																// MAX_OPTIONS defines the maximum number of options a menu can hold
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																// MAX_MENUS declares the maximum number of menu screens in the interface
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																// MAX_GRAPHS is the maximum number of graphs to create
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																// DISP_WIDTH and DISP_HEIGHT are hardware specific (SSD1306)
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																// REFRESH: is the time in miliseconds the interface will take in refreshing (this time affects the loop, keep that in mind)
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																#define MAX_OPTIONS 10      //Maximum number of options for each menu
 | 
																 | 
																 | 
																#define MAX_OPTIONS 10      //Maximum number of options for each menu
 | 
															
														
														
													
														
															
																 | 
																 | 
																#define MAX_MENUS 3
 | 
																 | 
																 | 
																#define MAX_MENUS 3
 | 
															
														
														
													
														
															
																 | 
																 | 
																#define MAX_GRAPH 3
 | 
																 | 
																 | 
																#define MAX_GRAPH 3
 | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																			
																		
																	
																 | 
																@ -17,20 +24,21 @@ int i = 0; | 
															
														
														
													
														
															
																 | 
																 | 
																class Option{ | 
																 | 
																 | 
																class Option{ | 
															
														
														
													
														
															
																 | 
																 | 
																  private: | 
																 | 
																 | 
																  private: | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																  int sizex; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  int sizey; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  String content; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  int pos; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  int textSpacing; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  bool fill = false; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  bool disp = false; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  int destinationType; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																  int destinationIndex; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  int sizex;    //Defines the size it will occupy in the x axis (width), this value is gotten from the menu
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  int sizey;    //Defines the height of the option (this value is gotten from the menu it belongs to)
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  String content;   //Text of the option
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  int pos;      //Defines the position it has in the menu
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  int textSpacing;   //According to the height, defines the space for the text, so that it's vertically centered
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  bool fill = false;  //In case an option is not selected this should be false
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  bool disp = false;   //In case an option is not configured, it should be false and, thus hidden
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  int destinationType;   //Defines what the option leads to (another menu, graph, something else)
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  int destinationIndex;  //Defines where the option leads to (index of the destination)
 | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																  public: | 
																 | 
																 | 
																  public: | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																  //Option(){}
 | 
																 | 
																 | 
																  //Option(){}
 | 
															
														
														
													
														
															
																 | 
																 | 
																   | 
																 | 
																 | 
																   | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  //Method to configure an option, all attributes are assigned, and disp is true, so the option can be displayed
 | 
															
														
														
													
														
															
																 | 
																 | 
																  void configure(String content, int sizex, int sizey, int pos, int destinationType, 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; | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																			
																		
																	
																 | 
																@ -52,16 +60,18 @@ class Option{ | 
															
														
														
													
														
															
																 | 
																 | 
																    return destinationIndex; | 
																 | 
																 | 
																    return destinationIndex; | 
															
														
														
													
														
															
																 | 
																 | 
																  } | 
																 | 
																 | 
																  } | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																//This method draws each option
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																  void drawopt(int page, int pos, int optPPage){ | 
																 | 
																 | 
																  void drawopt(int page, int pos, int optPPage){ | 
															
														
														
													
														
															
																 | 
																 | 
																    if(this->disp){ | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																      if(this->pos == pos){ | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    if(this->disp){    //Checks if the option was configured and, as a result, is displayable
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																      if(this->pos == pos){   //If the position of the option corresponds to the position passed to the function, then it should be selected
 | 
															
														
														
													
														
															
																 | 
																 | 
																        display.fillRect(0, (this->sizey)*(this->pos) + 1 - (page*optPPage*this->sizey), this->sizex, this->sizey, WHITE); | 
																 | 
																 | 
																        display.fillRect(0, (this->sizey)*(this->pos) + 1 - (page*optPPage*this->sizey), this->sizex, this->sizey, WHITE); | 
															
														
														
													
														
															
																 | 
																 | 
																        display.setTextColor(SSD1306_BLACK); | 
																 | 
																 | 
																        display.setTextColor(SSD1306_BLACK); | 
															
														
														
													
														
															
																 | 
																 | 
																        display.setCursor(5, (this->sizey)*(this->pos + 1) - (page*optPPage*this->sizey) - this->textSpacing); | 
																 | 
																 | 
																        display.setCursor(5, (this->sizey)*(this->pos + 1) - (page*optPPage*this->sizey) - this->textSpacing); | 
															
														
														
													
														
															
																 | 
																 | 
																        display.print(this->content); | 
																 | 
																 | 
																        display.print(this->content); | 
															
														
														
													
														
															
																 | 
																 | 
																        display.setTextColor(SSD1306_WHITE); | 
																 | 
																 | 
																        display.setTextColor(SSD1306_WHITE); | 
															
														
														
													
														
															
																 | 
																 | 
																      } | 
																 | 
																 | 
																      } | 
															
														
														
													
														
															
																 | 
																 | 
																      else{ | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																      else{                  //If the option is not selected, the rectangle containing it shouldn't be filled
 | 
															
														
														
													
														
															
																 | 
																 | 
																        display.drawRect(0, (this->sizey)*(this->pos) + 1 - (page*optPPage*this->sizey), this->sizex, this->sizey, WHITE); | 
																 | 
																 | 
																        display.drawRect(0, (this->sizey)*(this->pos) + 1 - (page*optPPage*this->sizey), this->sizex, this->sizey, WHITE); | 
															
														
														
													
														
															
																 | 
																 | 
																        display.setCursor(5, (this->sizey)*(this->pos + 1) - (page*optPPage*this->sizey) - this->textSpacing); | 
																 | 
																 | 
																        display.setCursor(5, (this->sizey)*(this->pos + 1) - (page*optPPage*this->sizey) - this->textSpacing); | 
															
														
														
													
														
															
																 | 
																 | 
																        display.print(this->content); | 
																 | 
																 | 
																        display.print(this->content); | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																			
																		
																	
																 | 
																@ -73,7 +83,7 @@ class Option{ | 
															
														
														
													
														
															
																 | 
																 | 
																class Menu{    //ContentTypeMenu true, it is a menu
 | 
																 | 
																 | 
																class Menu{    //ContentTypeMenu true, it is a menu
 | 
															
														
														
													
														
															
																 | 
																 | 
																  private: | 
																 | 
																 | 
																  private: | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																  int sizex; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  int sizex;                  //X size for each option in the menu
 | 
															
														
														
													
														
															
																 | 
																 | 
																  int sizey;                  //Y size of each option in the menu
 | 
																 | 
																 | 
																  int sizey;                  //Y size of each option in the menu
 | 
															
														
														
													
														
															
																 | 
																 | 
																  int options = 0;            //This indicates the number of options created
 | 
																 | 
																 | 
																  int options = 0;            //This indicates the number of options created
 | 
															
														
														
													
														
															
																 | 
																 | 
																  int pos = 0;                //This indicates the position of the cursor
 | 
																 | 
																 | 
																  int pos = 0;                //This indicates the position of the cursor
 | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																			
																		
																	
																 | 
																@ -86,13 +96,15 @@ class Menu{    //ContentTypeMenu true, it is a menu | 
															
														
														
													
														
															
																 | 
																 | 
																   | 
																 | 
																 | 
																   | 
															
														
														
													
														
															
																 | 
																 | 
																  public: | 
																 | 
																 | 
																  public: | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																  void configure(int sizex, int sizey){ | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  void configure(int sizex, int sizey){   //This method configures the menu created from Screen
 | 
															
														
														
													
														
															
																 | 
																 | 
																    this->sizex = sizex; | 
																 | 
																 | 
																    this->sizex = sizex; | 
															
														
														
													
														
															
																 | 
																 | 
																    this->sizey = sizey; | 
																 | 
																 | 
																    this->sizey = sizey; | 
															
														
														
													
														
															
																 | 
																 | 
																    this->optPPage = DISP_HEIGHT / this->sizey; | 
																 | 
																 | 
																    this->optPPage = DISP_HEIGHT / this->sizey; | 
															
														
														
													
														
															
																 | 
																 | 
																  } | 
																 | 
																 | 
																  } | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																  //The following method is used to created an option for the menu
 | 
															
														
														
													
														
															
																 | 
																 | 
																  void createOption(String content, bool destinationTypeMenu, int destinationIndex){ | 
																 | 
																 | 
																  void createOption(String content, bool destinationTypeMenu, int destinationIndex){ | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    //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++, destinationTypeMenu, destinationIndex); | 
															
														
														
													
														
															
																 | 
																 | 
																  } | 
																 | 
																 | 
																  } | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																			
																		
																	
																	
																	
																 | 
																
  |