Skip to content

Commit

Permalink
Examples updated
Browse files Browse the repository at this point in the history
  • Loading branch information
elC0mpa committed Dec 30, 2020
1 parent f34179c commit 134b7e9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
14 changes: 10 additions & 4 deletions examples/DoublePlotMode/DoublePlotMode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <Arduino.h>
#include <OLED_SSD1306_Chart.h>
#include <Adafruit_I2CDevice.h> //Include this to avoid compile errors in Platformio
#include <Adafruit_I2CDevice.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Expand All @@ -22,6 +22,8 @@

OLED_SSD1306_Chart display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

bool mid_line_visible = false;

void setup()
{
// put your setup code here, to run once:
Expand All @@ -42,9 +44,11 @@ void setup()
display.setYLimitLabels("0", "100", 1);
display.setAxisDivisionsInc(12, 6); //Each 12 px a division will be painted in X axis and each 6px in Y axis
display.setYLabelsVisible(true);
display.setPointGeometry(POINT_GEOMETRY_CIRCLE, 0);
display.setPlotMode(DOUBLE_PLOT_MODE); //Set double plot mode
display.drawChart(); //Update the buffer to draw the cartesian chart
display.setMidLineVisible(mid_line_visible);
display.setLineThickness(LIGHT_LINE);
display.setLineThickness(NORMAL_LINE, 1);
display.drawChart(); //Update the buffer to draw the cartesian chart
display.display();
}

Expand All @@ -56,7 +60,9 @@ void loop()
if (!display.updateChart(value0, value1)) //Value between Ymin and Ymax will be added to chart
{
display.clearDisplay(); //If chart is full, it is drawn again
mid_line_visible = !mid_line_visible;
display.setMidLineVisible(mid_line_visible);
display.drawChart();
}
delay(100);
}
}
21 changes: 17 additions & 4 deletions examples/SinglePlotMode/SinglePlotMode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

OLED_SSD1306_Chart display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

char actualThickness;

void setup()
{
// put your setup code here, to run once:
Expand All @@ -36,23 +38,34 @@ void setup()
display.setChartCoordinates(0, 60); //Chart lower left coordinates (X, Y)
display.setChartWidthAndHeight(123, 55); //Chart width = 123 and height = 60
display.setXIncrement(5); //Distance between Y points will be 5px
display.setYLimits(0, 100); //Ymin = 0 and Ymax = 100
display.setYLimitLabels("0", "100"); //Setting Y axis labels
display.setYLimits(50, 100); //Ymin = 0 and Ymax = 100
display.setYLimitLabels("50", "100"); //Setting Y axis labels
display.setYLabelsVisible(true);
display.setAxisDivisionsInc(12, 6); //Each 12 px a division will be painted in X axis and each 6px in Y axis
display.setPlotMode(SINGLE_PLOT_MODE); //Set single plot mode
display.setPointGeometry(POINT_GEOMETRY_CIRCLE);
// display.setPointGeometry(POINT_GEOMETRY_CIRCLE);
actualThickness = NORMAL_LINE;
display.setLineThickness(actualThickness);
display.drawChart(); //Update the buffer to draw the cartesian chart
display.display();
}

void loop()
{
// put your main code here, to run repeatedly:
auto value = random(100);
auto value = random(50) + 50;
if (!display.updateChart(value)) //Value between Ymin and Ymax will be added to chart
{
display.clearDisplay(); //If chart is full, it is drawn again
if (actualThickness == NORMAL_LINE)
{
actualThickness = LIGHT_LINE;
}
else if (actualThickness == LIGHT_LINE)
{
actualThickness = NORMAL_LINE;
}
display.setLineThickness(actualThickness);
display.drawChart();
}
delay(100);
Expand Down

0 comments on commit 134b7e9

Please sign in to comment.