I want to put two animations on one OLED SSD1306 display, one on default frequency, another on 1Mhz via I2C bus. In order to do that, i called two constructors from Adafruit_SSD1306.h:
Adafruit_SSD1306 disp1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_SSD1306 disp2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET, **clkDuring**);
In order to use these object, I have to call .begin() function in void setup():
.
.
disp1.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
disp2.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
.
When I want to show disp1 animation everything is fine, but when I want to show disp2 it doesn't work. What could be the broblem? Here is the full code:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "myLib.h"
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define clkDuring 500000UL
#define clkAfter 100000UL
Adafruit_SSD1306 disp1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_SSD1306 disp2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET, clkDuring);
#define SCREEN_ADDRESS 0x3C
Animation Anim;
int logo_width = Anim.frame_w();
int logo_height = Anim.frame_h();
int xx = (SCREEN_WIDTH - logo_width) / 2;
int yy = (SCREEN_HEIGHT - logo_height) / 2;
void setup() {
Wire.begin();
disp1.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
disp2.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
delay(2);
}
void loop() {
for (int i = 0; i < A.num_of_frames(); i++) {
disp1.clearDisplay();
disp1.drawBitmap(xx, yy, A.frame(i), logo_width, logo_height, 1);
disp1.display();
}
}