You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.1 KiB
75 lines
2.1 KiB
#include <Wire.h>
|
|
#include <Adafruit_GFX.h>
|
|
#include <Adafruit_SSD1306.h>
|
|
#include <display.h>
|
|
|
|
//Adafruit_SSD1306 display1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
|
|
Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, -1);
|
|
|
|
void initDisplay() {
|
|
/*Wire.begin(D1_I2C_SDA, D1_I2C_SCL);
|
|
if(!display1.begin(SSD1306_EXTERNALVCC, DISPLAY_I2C_ADDRESS)) {
|
|
Serial.println("SSD1306 #1 allocation failed");
|
|
for(;;);
|
|
}*/
|
|
|
|
Wire1.begin(D2_I2C_SDA, D2_I2C_SCL);
|
|
if(!display2.begin(SSD1306_SWITCHCAPVCC, DISPLAY_I2C_ADDRESS)) {
|
|
Serial.println("SSD1306 #2 allocation failed");
|
|
for(;;);
|
|
}
|
|
|
|
//display1.clearDisplay();
|
|
//Serial.println("start display 2");
|
|
display2.clearDisplay();
|
|
for (int x = 0; x < 128; x ++) {
|
|
for (int y = 0; y < 64; y++) {
|
|
display2.drawPixel(x, y, SSD1306_WHITE);
|
|
}
|
|
}
|
|
display2.display();
|
|
//Serial.println("start display 2 test success");
|
|
}
|
|
|
|
void drawPoint(int displayId, int x, int y) {
|
|
switch (displayId)
|
|
{
|
|
case 1:
|
|
|
|
//display1.clearDisplay();
|
|
//display1.drawPixel(x, y, SSD1306_WHITE);
|
|
break;
|
|
case 2:
|
|
display2.clearDisplay();
|
|
display2Border();
|
|
display2.drawPixel(x, y, SSD1306_WHITE);
|
|
display2.display();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
const int16_t borders[][2] = {
|
|
{20, 59},
|
|
{20, 30},
|
|
{29, 15},
|
|
{40, 3},
|
|
{45, 1},
|
|
{65, 0},
|
|
{80, 1},
|
|
{91, 3},
|
|
{103, 15},
|
|
{110, 30},
|
|
{110, 59}
|
|
};
|
|
const int borderSize = sizeof(borders) / sizeof(borders[0]);
|
|
|
|
void display2Border() {
|
|
int x = 0;
|
|
int y = 1;
|
|
for (int i = 1; i <borderSize; i++) {
|
|
display2.drawLine(borders[i-1][x], borders[i-1][y], borders[i][x], borders[i][y], WHITE);
|
|
}
|
|
display2.drawLine(borders[borderSize-1][x], borders[borderSize-1][y], borders[0][x], borders[0][y], WHITE);
|
|
}
|