7 changed files with 142 additions and 4 deletions
Binary file not shown.
@ -0,0 +1,75 @@ |
|||
#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); |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
#include <Adafruit_SSD1306.h> |
|||
|
|||
#define DISPLAY_I2C_ADDRESS 0x3C |
|||
#define SCREEN_WIDTH 128 |
|||
#define SCREEN_HEIGHT 64 |
|||
|
|||
#define D1_I2C_SDA 21 |
|||
#define D1_I2C_SCL 5 |
|||
|
|||
#define D2_I2C_SDA 19 //19
|
|||
#define D2_I2C_SCL 18 //18
|
|||
|
|||
//Adafruit_SSD1306 display1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
|
|||
//Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, -1);
|
|||
|
|||
void initDisplay(); |
|||
void drawPoint(int displayId, int x, int y); |
|||
void display2Border(); |
|||
Loading…
Reference in new issue