Skip to content

Commit

Permalink
Adding posibility to plot mid line in double plot mode
Browse files Browse the repository at this point in the history
  • Loading branch information
elC0mpa committed Dec 30, 2020
1 parent b502fae commit 13f3043
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/OLED_SSD1306_Chart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ void OLED_SSD1306_Chart::drawChart()
drawFastVLine(temp, _y_lower_left_coordinate, 3, WHITE);
}
}
if (_mid_line_visible && _mode == DOUBLE_PLOT_MODE)
{
drawFastHLine(_x_lower_left_coordinate + _x_drawing_offset, _y_lower_left_coordinate - _chart_height / 2, _chart_width - _x_drawing_offset, WHITE);
for (i = 0; i <= _chart_width - _x_drawing_offset; i += _xinc_div)
{
drawFastVLine(i + _x_lower_left_coordinate + _x_drawing_offset, _y_lower_left_coordinate - _chart_height / 2, 3, WHITE);
}
}
}

void OLED_SSD1306_Chart::setPlotMode(char mode)
Expand Down Expand Up @@ -156,6 +164,11 @@ void OLED_SSD1306_Chart::setYLabelsVisible(bool yLabelsVisible)
_y_labels_visible = yLabelsVisible;
}

void OLED_SSD1306_Chart::setMidLineVisible(bool lineVisible)
{
_mid_line_visible = lineVisible;
}

void OLED_SSD1306_Chart::setPointGeometry(char pointGeometry, uint8_t chart)
{
if (chart == 0 || chart == 1)
Expand Down
6 changes: 6 additions & 0 deletions src/OLED_SSD1306_Chart.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class OLED_SSD1306_Chart : public Adafruit_SSD1306
char *_y_min_label[2]; //Labels of the lower y value
char *_y_max_label[2]; //Labels of the higher y value
double _x_drawing_offset; //Used to draw the char after the labels are applied
bool _mid_line_visible; //Determines if the mid line should be shown in Double plot mode

public:
//Ctors
Expand All @@ -34,6 +35,7 @@ class OLED_SSD1306_Chart : public Adafruit_SSD1306
_point_geometry[0] = POINT_GEOMETRY_NONE;
_point_geometry[1] = POINT_GEOMETRY_NONE;
_y_labels_visible = false;
_mid_line_visible = true;
_y_min_label[0] = "";
_y_min_label[1] = "";
_y_max_label[0] = "";
Expand All @@ -47,6 +49,7 @@ class OLED_SSD1306_Chart : public Adafruit_SSD1306
_point_geometry[0] = POINT_GEOMETRY_NONE;
_point_geometry[1] = POINT_GEOMETRY_NONE;
_y_labels_visible = false;
_mid_line_visible = true;
_y_min_label[0] = "";
_y_min_label[1] = "";
_y_max_label[0] = "";
Expand All @@ -60,6 +63,7 @@ class OLED_SSD1306_Chart : public Adafruit_SSD1306
_point_geometry[0] = POINT_GEOMETRY_NONE;
_point_geometry[1] = POINT_GEOMETRY_NONE;
_y_labels_visible = false;
_mid_line_visible = true;
_y_min_label[0] = "";
_y_min_label[1] = "";
_y_max_label[0] = "";
Expand All @@ -73,6 +77,7 @@ class OLED_SSD1306_Chart : public Adafruit_SSD1306
_point_geometry[0] = POINT_GEOMETRY_NONE;
_point_geometry[1] = POINT_GEOMETRY_NONE;
_y_labels_visible = false;
_mid_line_visible = true;
_y_min_label[0] = "";
_y_min_label[1] = "";
_y_max_label[0] = "";
Expand All @@ -88,6 +93,7 @@ class OLED_SSD1306_Chart : public Adafruit_SSD1306
void setPointGeometry(char pointGeometry, uint8_t chart = 0);
void setXIncrement(double xinc);
void setAxisDivisionsInc(double xinc, double yinc);
void setMidLineVisible(bool lineVisible);

void drawChart();
bool updateChart(double firstValue, double secondValue = 0);
Expand Down

0 comments on commit 13f3043

Please sign in to comment.