#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <stdio.h>
#include <math.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
float dat[100] = {
0.09, 0.21, 0.35, 0.53, 0.74, 1.00, 1.29, 1.63, 2.02, 2.46,
2.94, 3.46, 4.02, 4.61, 5.22, 5.84, 6.45, 7.05, 7.61, 8.12,
8.58, 8.95, 9.24, 9.44, 9.54, 9.54, 9.43, 9.24, 8.95, 8.59,
8.16, 7.69, 7.18, 6.65, 6.11, 5.58, 5.07, 4.58, 4.14, 3.73,
3.37, 3.06, 2.80, 2.58, 2.40, 2.26, 2.16, 2.08, 2.03, 2.01,
2.00, 2.00, 2.02, 2.04, 2.06, 2.09, 2.11, 2.13, 2.15, 2.17,
2.18, 2.18, 2.18, 2.18, 2.16, 2.14, 2.11, 2.08, 2.04, 2.00,
1.95, 1.89, 1.84, 1.77, 1.70, 1.63, 1.56, 1.49, 1.41, 1.33,
1.25, 1.17, 1.09, 1.01, 0.94, 0.86, 0.78, 0.71, 0.64, 0.57,
0.51, 0.44, 0.38, 0.33, 0.27, 0.22, 0.17, 0.13, 0.09, 0.05
};
int dat3x[25] = {
90, 88, 86, 84, 82, 81, 80, 81, 83, 84,
88, 91, 92, 94, 96, 97, 98, 100,
102, 106, 111, 112, 110, 102, 92
};
int dat3y[25] = {
44, 42, 40, 36, 30, 20, 8, 4, 8, 12,
26, 34, 38, 40, 43, 46, 47, 46,
46, 46, 44, 43, 42, 44, 46
};
int dat2y[25] = {
44, 46, 47, 50, 52, 53, 54, 55, 55, 55,
55, 55, 55, 55, 54, 54, 54, 53,
52, 50, 50, 47, 47, 47, 46
};
void setup() {
Serial.begin(9600);
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
}
void loop() {
display.clearDisplay();
display.drawRect(0, 0, 128, 64, WHITE);
display.drawLine(60,0,60,64,WHITE);
// significant p
// display.drawPixel(90,44,WHITE); // 0
// display.drawPixel(81,4,WHITE); // 7
// display.drawPixel(112,43,WHITE); // 23
// significant q
// display.drawPixel(81,50,WHITE); // left
// display.drawPixel(96,55,WHITE); // down
// display.drawPixel(112,50,WHITE); // right
for (int i=0; i<50; i++)
{
int a = i+5;
int b = 55 - dat[2*i] * 5;
display.drawPixel(a, b, WHITE);
display.display();
if ((i%2) == 0) {
int j = i / 2;
int c = dat3x[j];
int d = dat3y[j];
int e = dat2y[j] + 5;
display.drawPixel(c, d, WHITE);
// display.drawPixel(c, e, WHITE);
display.display();
}
delay(100);
}
delay(1000);
}