Browse Source

New class added for variable manipulation.

master
parent
commit
71779e2b43
1 changed files with 77 additions and 2 deletions
  1. +77
    -2
      DisplayESP32.ino

+ 77
- 2
DisplayESP32.ino View File

@ -14,6 +14,7 @@
#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_GRAPHS 3 #define MAX_GRAPHS 3
#define MAX_MODIFIERS 3
#define DISP_WIDTH 128 // OLED display width #define DISP_WIDTH 128 // OLED display width
#define DISP_HEIGHT 64 // OLED display height #define DISP_HEIGHT 64 // OLED display height
#define REFRESH 10 //Refresh time in ms #define REFRESH 10 //Refresh time in ms
@ -80,7 +81,7 @@ class Option{
} }
}; };
class Menu{ //ContentType (1)
class Menu{ //ContentType (0)
private: private:
int sizex; //X size for each option in the menu int sizex; //X size for each option in the menu
@ -166,7 +167,7 @@ class Menu{ //ContentType (1)
} }
}; };
class Graph{
class Graph{ //ContentType (1)
private: private:
String title; String title;
@ -411,14 +412,82 @@ class Graph{
}; };
class Modifier{ //ContentType (2)
private:
String title;
int *value;
int max;
int min;
int interval;
int previousScreen = 0;
int previousContentType = 0;
public:
void configure(String title, int *value, int max, int min, int interval){
this->value = value;
this->max = max;
this->min = min;
this->interval = interval;
}
void drawModifier(){
display.clearDisplay();
display.fillRect(0, 0, 127 , 16, SSD1306_WHITE);
display.setTextColor(SSD1306_BLACK);
display.setTextSize(1);
display.setCursor(2, 4);
display.println(this->title);
display.setTextColor(SSD1306_WHITE);
display.setTextSize(3);
display.setCursor(2, ((DISP_HEIGHT - 16 - 20)/2) + 20);
display.println(*this->value);
}
void increaseValue(){
if((*this->value + interval) <= this->max){
*this->value += interval;
}
}
void decreaseValue(){
if((*this->value - interval) >= this->min){
*this->value -= interval;
}
}
void setPreviousScreen(int prev){
this->previousScreen = prev;
}
void setPreviousContentType(int prev){
this->previousContentType = prev;
}
int getPreviousScreen(){
int prev = this->previousScreen;
return prev;
}
int getPreviousContentType(){
int prev = this->previousContentType;
return prev;
}
};
class Screen{ class Screen{
private: private:
Menu menu[MAX_MENUS]; //Array of menus to use Menu menu[MAX_MENUS]; //Array of menus to use
Graph graph[MAX_GRAPHS]; //Array of graphs to use Graph graph[MAX_GRAPHS]; //Array of graphs to use
Modifier modifier[MAX_MODIFIERS]; //Array of modifiers to use
int counterM = 0; //Number of menus created int counterM = 0; //Number of menus created
int counterG = 0; //Number of graphs created int counterG = 0; //Number of graphs created
int counterMod = 0;
bool redraw = true; //Redraw interface for when there is a change of screen bool redraw = true; //Redraw interface for when there is a change of screen
int currentScreen = 0; int currentScreen = 0;
int contentType = 0; int contentType = 0;
@ -482,6 +551,11 @@ 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);
this->counterMod++;
}
/* /*
void redrawFlag(){ void redrawFlag(){
this->redraw = true; this->redraw = true;
@ -489,6 +563,7 @@ class Screen{
*/ */
//The following method is used for assingning a value to a graph //The following method is used for assingning a value to a graph
//This can be avoided using pointers to the variable to plot in the graph
void graphAssignValue(int graphIndex, double value){ void graphAssignValue(int graphIndex, double value){
this->graph[graphIndex].assignValue(value); this->graph[graphIndex].assignValue(value);
this->redraw = true; this->redraw = true;


Loading…
Cancel
Save